FMPy icon indicating copy to clipboard operation
FMPy copied to clipboard

Can't update value of getString

Open K3ik3i opened this issue 1 year ago • 1 comments

Hello. I execute code which load the FMU and get variables as below.

fmu = FMU2Slave(guid=md.guid,
                unzipDirectory=unzipdir,
                modelIdentifier=md.coSimulation.modelIdentifier,
                instanceName='instance1')
fmu.instantiate(visible=True, loggingOn=True)

time.sleep(3)

fmu.setupExperiment(startTime=0)
fmu.enterInitializationMode()
fmu.exitInitializationMode()

simTime = 0
stopTime =0.5
step_size = 0.01

vrs={}
for v in md.modelVariables:
    vrs[v.name] = v.valueReference

vr_output = vrs['can1_out_buf']


fmuResults = fmu.getString([vr_output])
print(fmuResults)

fmuResults = fmu.getString([vr_output])
print(fmuResults)

when i get the string value at first time, it works well, but at sencond time, getString API provide empty value as below what is wrong with my code?

b'04P0N0D000d0001h@0010000000200000000000000000000000000000040000500000Ebf004000050000000000000000000004P0N0D000d0001h@0010000000200000000000000000000000000000000002Pe;L0c=:k01EL]P000000000000000000000004P0N0D000d0001h@0010000000200000000000000000000000000000000002Pe;L0c=:k01EL]P2=^kD0000000000000000004P0<04000X00008Z0T00000000000000000ool02@000000000000000?oo000900000000000000000000000000000000000004P0<04000X00015@0X00000000000000000ool02@000000000000000?oo000900000000000000000000000000000000000004P0<04000X0001Qj0\\00000000000000000ool02@000000000000000?oo000900000000000000000000000000000000000004P0<04000X0003nP0`00000000000000000ool02@000000000000000?oo000900000000000000000000000000000000000004P0N0D000d0001h@0010000000200000000000000000000000000000000002Pe;L0c=:k01EL]P2=^kD0000000000000000004P0<04000X0003J:0d00000000000000000ool02@000000000000000?oo000900000000000000000000000000000000000004P0<04000X0002G`0h00000000000000000ool02@000000000000000?oo000900000000000000000000000000000000000004P0<04000X0002cJ0l00000000000000000ool02@000000000000000?oo000900000000000000000000000000000000000004P0<04000X0002S<Q000000000000000000ool02@000000000000000?oo000900000000000000000000000000000000000004P0<04000X00027VQ400000000000000000ool02@000000000000000?oo000900000000000000000000000000000000000004P0<04000X0003:LQ800000000000000000ool02@000000000000000?oo000900000000000000000000000000000000000004P0<04000X0003^fQ<00000000000000000ool02@000000000000000?oo000900000000000000000000000000000000000004P0<04000X0001a\\Q@00000000000000000ool02@000000000000000?oo0009000000000000000000000000000000000000']

[b'']

K3ik3i avatar Jan 22 '24 11:01 K3ik3i

Can you share the FMU?

t-sommer avatar Jan 22 '24 13:01 t-sommer