Opened 7 years ago

Closed 7 years ago

#4529 closed defect (fixed)

[c runtime] FMI setReal/getReal doesn't work

Reported by: Lennart Ochel Owned by: Lennart Ochel
Priority: critical Milestone: 1.12.0
Component: FMI Version:
Keywords: Cc: Rüdiger Franke, Adeel Asghar

Description

Updating an input value using the FMI interface setReal doesn't affect the connected output values using the FMI interface getReal. This can be tested using the following example:

model A
  input Real p;
  input Real u;
  output Real y;
equation
  y = u * p;
end A;

Generate FMUs with both, c and cpp runtime:

setCommandLineOptions("--simCodeTarget=C"); getErrorString();
buildModelFMU(A, version="2.0", fmuType="me", fileNamePrefix="me_A_c", platforms={"static"}); getErrorString();
setCommandLineOptions("--simCodeTarget=Cpp"); getErrorString();
buildModelFMU(A, version="2.0", fmuType="me", fileNamePrefix="me_A_cpp", platforms={"static"}); getErrorString();

// workaround
system("mv A.fmu me_A_cpp.fmu"); getErrorString();

Run the test using OMFMISimulator:

function printAllValues(model)
  print("A.p: " .. getReal(model, "A.p"))
  print("A.u: " .. getReal(model, "A.u"))
  print("A.y: " .. getReal(model, "A.y") .. "\n")
end

tests = {"me_A_c.fmu", "me_A_cpp.fmu"}
for _,test in ipairs(tests) do
  print("Testing " .. test)

  model = newModel()
  instantiateFMU(model, test, "A")

  initialize(model)

  printAllValues(model)

  setReal(model, "A.p", 1.0)
  setReal(model, "A.u", 2.0)
  printAllValues(model)

  setReal(model, "A.p", 1.5)
  printAllValues(model)

  terminate(model)
  unload(model)
end

This will result in the following output:

Testing me_A_c.fmu
A.p: 0.0
A.u: 0.0
A.y: 0.0

A.p: 1.0
A.u: 2.0
A.y: 0.0

A.p: 1.5
A.u: 2.0
A.y: 0.0

Testing me_A_cpp.fmu
A.p: 0.0
A.u: 0.0
A.y: 0.0

A.p: 1.0
A.u: 2.0
A.y: 2.0

A.p: 1.5
A.u: 2.0
A.y: 3.0

The issue is that A.y is not updated if the c runtime is used.

Change History (5)

comment:1 by Lennart Ochel, 7 years ago

This is fixed now with OMCompiler#1832. However, all the other types have also to be reviewed.

comment:2 by Lennart Ochel, 7 years ago

Priority: highcritical
Status: newaccepted

comment:3 by Adeel Asghar, 7 years ago

We just need to do the same for all other types.

comment:4 by Lennart Ochel, 7 years ago

Yes, I will push that change today.

in reply to:  1 comment:5 by Lennart Ochel, 7 years ago

Resolution: fixed
Status: acceptedclosed

Done; see OMCompiler#1835.

Note: See TracTickets for help on using tickets.