modelica - OMShell returns String but doesn't recognize it -


for 1 of models, required read final value of variables , set them initial value next simulation. real problem due types defined in omshell. can seen in the scripting commands of openmodelica, there string type , "variablename", "typename" types. elaborate difference:

// following loads standard modelica library >> loadmodel(modelica) true  // following throws error >> loadmodel("modelica") 

the reason loadmodel function doesn't expect string variable. expects name of model. returning problem, tried use val function in following, can give value initial value of next simulation.

>> final_time := 200; >> myvarvalue := val(myvar, final_time); 

this can done each variable using for-loop, thought have several variables , realized problem @ point.

// list of variables >> myvarlist := readsimulationresultvars(currentsimulationresult); >> size(myvarlist) {724}  // problem list contains strings >> myvarlist[1] "mysubsystem.mycomponent.mypin.v"  // following throws error doesn't expect string >> val(myvarlist[1], final_time) 

how can remove "" string omshell returns me? need convert "myvar" myvar can use input functions of omshell.

you can use stringvariablename function.

>>> vars:=openmodelica.scripting.readsimulationresultvars(currentsimulationresult) {"r","time"} >>> val(stringvariablename(vars[1]), 0.0) 1.0 

Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -