Opened 15 years ago
Last modified 7 years ago
#1163 closed defect (fixed)
parameter(fixed = true) should be treated as a constant during runtime — at Version 2
Reported by: | Henning Kiel | Owned by: | Henning Kiel |
---|---|---|---|
Priority: | high | Milestone: | |
Component: | *unknown* | Version: | |
Keywords: | Cc: | Henning Kiel, Martin Sjölund |
Description (last modified by )
I would like to have a parameter which I can pass to a constructor for an ExternalObject.
I use the below code, but only get a NULL pointer passed to the constructor.
package demo model test class MyData extends ExternalObject ; function constructor input String fileName ; output MyData table ; external "C" table = constructor(fileName) annotation(Library = "test.o", Include = "#include \"test.h\""); end constructor ; function destructor input MyData table ; external "C" destructor(table) annotation(Library = "test.o", Include = "#include \"test.h\""); end destructor ; end MyData ; parameter String DataFile = "sampledata.xml"; MyData table = MyData(DataFile ) ; ... algorithm if HallSignal <> pre(HallSignal) then sig = func(omega, HallPos, table); end if; end test ; end demo;
!!Comment from Martin Sjoelund:
The simulation generates the following result:
$ ./test -v construct: (null) read start = 0 from init file. read stop = 1 from init file. read stepSize = 0.002 from init file. read tolerance = 1e-06 from init file. read method = dassl from init file. read $dummy = 0 from init file. read der($dummy) = 0 from init file. read DataFile = "sampledata.xml" from init file.
The way OpenModelica does this is it first initializes the whole structure. Then calls the external object constructors. Then reads the input.
I think this is wrong. It should move calling external objects to a new function in the simulation code. And do that after the input has been read. Obviosuly your code should work since it's a parameter(fixed = true), which [should be] treated as a constant during runtime.
Change History (2)
comment:1 by , 15 years ago
comment:2 by , 7 years ago
Component: | → *unknown* |
---|---|
Description: | modified (diff) |
Took me a while to get around to fixing this... Right in time for 1.5.0 release though.