Opened 11 years ago

Closed 9 years ago

Last modified 9 years ago

#2588 closed defect (fixed)

+modelicaOutput does not work properly.

Reported by: Lennart Ochel Owned by: Federico Bergero
Priority: high Milestone: 1.9.4
Component: Frontend Version: trunk
Keywords: Cc:

Description (last modified by Lennart Ochel)

The configuration flag + modelicaOutput does not work properly as the following script illustrates:

loadString("
package foo
  connector bInput = input Boolean \"'input Boolean' as connector\";
  connector bOutput = output Boolean \"'output Boolean' as connector\";

  model M1
    bOutput signal(start=true, fixed=false);
  equation
    signal = time > 0.5;
  end M1;

  model M2
    bInput signal;
    Real x(start=1, fixed=true);
    discrete Real t0(start=0, fixed=true);
  equation
    when edge(signal) then
      t0 =  time;
    end when;
    der(x) = if signal then 1 else 0;
  end M2;

  model M1_M2
    M1 control;
    M2 machine;
  equation
    connect(control.signal, machine.signal);
  end M1_M2;
end foo;
"); getErrorString();

setCommandLineOptions("+modelicaOutput"); getErrorString();
instantiateModel(foo.M1_M2); getErrorString();

The generated output is the following:

class foo.M1_M2
  output Boolean control__signal(start = true, fixed = false);
  input Boolean machine__signal;
  Real machine__x(start = 1.0, fixed = true);
  discrete Real machine__t0(start = 0.0, fixed = true);
equation
  control.signal = time > 0.5;
  when edge(machine.signal) then
  machine.t0 = time;
  end when;
  der(machine.x) = if machine.signal then 1.0 else 0.0;
  control__signal = machine__signal;
end foo.M1_M2;

Change History (9)

comment:1 by Lennart Ochel, 11 years ago

Description: modified (diff)

comment:2 by Martin Sjölund, 10 years ago

Milestone: 1.9.11.9.2

This ticket was not closed for 1.9.1, which has now been released. It was batch modified for milestone 1.9.2 (but maybe an empty milestone was more appropriate; feel free to change it).

comment:3 by Martin Sjölund, 10 years ago

Milestone: 1.9.21.9.3

Milestone changed to 1.9.3 since 1.9.2 was released.

comment:4 by Martin Sjölund, 9 years ago

Milestone: 1.9.31.9.4

Moved to new milestone 1.9.4

comment:5 by Federico Bergero, 9 years ago

Owner: changed from somebody to Federico Bergero
Status: newaccepted

comment:6 by Federico Bergero, 9 years ago

I have a fix for this bug and for generating valid modelica output when dumping the DAE in general. I checked the dot operator in variable names, expressions and funcion names. Also the names of (multi-dimensional) arrays variables were fixed since before an array

Real a[10];

would generate

Real a[1];
Real a[2];
...
Real a[10];

Can anybody think of any other language structure that would generate invalid Modelica when dumped?

comment:7 by Federico Bergero, 9 years ago

Resolution: fixed
Status: acceptedclosed

This is fixed with changes introduced in pull request
https://github.com/OpenModelica/OMCompiler/pull/303

comment:8 by Martin Sjölund, 9 years ago

Milestone: 1.9.41.9.4-1.9.x

Milestone renamed

comment:9 by Martin Sjölund, 9 years ago

Milestone: 1.9.4-1.9.x1.9.4

Milestone renamed

Note: See TracTickets for help on using tickets.