Changeset e3518437 in OpenModelica


Ignore:
Timestamp:
2022-05-19T15:04:25+02:00 (2 years ago)
Author:
Per Östlund <perost86@…>
Parents:
d0dfb07d
git-author:
Per Östlund <perost86@…> (05/19/22 13:45:27)
git-committer:
Per Östlund <perost86@…> (05/19/22 15:04:25)
Message:

Implement dumping of Vector visualizers

  • Add support for dumping the Vector visualizer in VisualXML.
  • Clean up VisualXML.
  • Fix indentation of visualization XML format.
  • Add test case for visualization XML format.
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • OMCompiler/Compiler/BackEnd/VisualXML.mo

    r68cae5a re3518437  
    3333" file:        VisualXML
    3434  package:     VisualXML
    35   description: This package gathers alle information about visualization objects from the MultiBody lib and outputs them as an XML file.
    36                This can be used additionally to the result file to visualize the system.
     35  description: This package gathers all information about visualization objects from the MultiBody lib and outputs them as an XML file.
     36               This can be used together with the result file to visualize the system.
    3737
    3838
     
    6565//----------------------------
    6666
    67 public uniontype Visualization
     67public
     68uniontype Visualization
    6869  record SHAPE
    6970    DAE.ComponentRef ident;
     
    8182    DAE.Exp specularCoeff;
    8283  end SHAPE;
     84
     85  record VECTOR
     86    DAE.ComponentRef ident;
     87    array<list<DAE.Exp>> T;
     88    array<DAE.Exp> r;
     89    array<DAE.Exp> coordinates;
     90    array<DAE.Exp> color;
     91    DAE.Exp specularCoeff;
     92    DAE.Exp quantity;
     93    DAE.Exp headAtOrigin;
     94    DAE.Exp twoHeadedArrow;
     95  end VECTOR;
    8396end Visualization;
    8497
     
    87100//-------------------------
    88101
    89 public function visualizationInfoXML"dumps an xml containing information about visualization objects.
     102public
     103function visualizationInfoXML"dumps an xml containing information about visualization objects.
    90104author:Waurich TUD 2015-04"
    91105  input BackendDAE.BackendDAE daeIn;
     
    99113  list<BackendDAE.Var> globalKnownVarLst, allVarLst, aliasVarLst;
    100114  list<Visualization> visuals;
    101   list<DAE.ComponentRef> allVisuals;
     115  list<tuple<DAE.ComponentRef, String>> allVisuals;
    102116algorithm
    103117  BackendDAE.DAE(eqs=eqs0, shared=shared) := daeIn;
     
    120134  //fill theses visualization objects with information
    121135  allVarLst := listAppend(globalKnownVarLst,listAppend(allVarLst,aliasVarLst));
    122   (visuals,_,_) := List.mapFold2(allVisuals, fillVisualizationObjects,allVarLst, program);
     136  visuals := List.mapFold2(allVisuals, fillVisualizationObjects,allVarLst, program);
    123137  //some expressions refer to other known parameters, get them
    124138  visuals := List.map2(visuals,replaceVisualBinding,globalKnownVars,program);
     
    129143
    130144  //update the variabels
    131   (globalKnownVars,_) := BackendVariable.traverseBackendDAEVarsWithUpdate(globalKnownVars, setVisVarsPublic,"");
    132   (aliasVars,_) := BackendVariable.traverseBackendDAEVarsWithUpdate(aliasVars, setVisVarsPublic,"");
     145  globalKnownVars := BackendVariable.traverseBackendDAEVarsWithUpdate(globalKnownVars, setVisVarsPublic,"");
     146  aliasVars := BackendVariable.traverseBackendDAEVarsWithUpdate(aliasVars, setVisVarsPublic,"");
    133147  daeOut := BackendDAE.DAE(eqs=eqs, shared=shared);
    134148end visualizationInfoXML;
    135149
    136 protected function replaceVisualBinding"Replace the cref binding for the given visualization shapeType with the constant expression of its alias.
    137 author: vwaurich 2016-10"
    138   input Visualization visIn;
     150protected
     151function replaceVisualBinding
     152  "Replace the cref binding for the given visualization shapeType with the constant expression of its alias.
     153   author: vwaurich 2016-10"
     154  input output Visualization vis;
    139155  input BackendDAE.Variables varArray;
    140156  input Absyn.Program program;
    141   output Visualization visOut;
    142 algorithm
    143   visOut := matchcontinue(visIn,varArray,program)
    144     local
    145       DAE.ComponentRef cr, ident;
    146       DAE.Exp exp, length, width, height, extra, specularCoeff, shapeType;
    147       Real rvalue;
     157algorithm
     158  () := matchcontinue vis
     159    local
     160      DAE.ComponentRef cr;
    148161      String s;
    149       array<DAE.Exp> color, r, lengthDir, widthDir, r_shape ;
    150       array<list<DAE.Exp>> T;
    151   case(SHAPE(ident=ident, shapeType=DAE.CREF(componentRef = cr), T=T, r=r, r_shape=r_shape, lengthDir=lengthDir, widthDir=widthDir,
    152      length=length, width=width, height=height, extra=extra, color=color, specularCoeff=specularCoeff),_,_)
    153      equation
    154        DAE.SCONST(string=s) = getConstCrefBinding(cr,varArray);
    155        s = getFullCADFilePath(s,program);
    156     then (SHAPE(ident, DAE.SCONST(s), T, r, r_shape, lengthDir, widthDir, length, width, height, extra, color, specularCoeff));
    157   case(SHAPE(ident=ident, shapeType=DAE.SCONST(string=s), T=T, r=r, r_shape=r_shape, lengthDir=lengthDir, widthDir=widthDir,
    158      length=length, width=width, height=height, extra=extra, color=color, specularCoeff=specularCoeff),_,_)
    159      equation
    160        s = getFullCADFilePath(s,program);
    161     then (SHAPE(ident, DAE.SCONST(s), T, r, r_shape, lengthDir, widthDir, length, width, height, extra, color, specularCoeff));
    162   else
    163     then visIn;
     162
     163    case SHAPE(shapeType = DAE.CREF(componentRef = cr))
     164      algorithm
     165        vis.shapeType := getConstCrefBinding(cr, varArray);
     166      then
     167        ();
     168
     169    case SHAPE(shapeType = DAE.SCONST(string=s))
     170      algorithm
     171        vis.shapeType := DAE.SCONST(getFullCADFilePath(s, program));
     172      then
     173        ();
     174
     175    else ();
    164176  end matchcontinue;
    165177end replaceVisualBinding;
    166178
    167 protected function getConstCrefBinding"Get the const binding for the cref. It has to be somewhere in the vars.
    168 author: vwaurich 2016-10"
     179function getConstCrefBinding
     180  "Get the const binding for the cref. It has to be somewhere in the vars.
     181   author: vwaurich 2016-10"
    169182  input DAE.ComponentRef cr;
    170183  input BackendDAE.Variables vars;
     
    178191    ({var},_) := BackendVariable.getVar(cr,vars);
    179192    e := BackendVariable.varBindExp(var);
    180     eOut := matchcontinue(e)
    181       case(_)
    182         equation
    183           true = Expression.isConst(e);
    184         then e;
    185       case(DAE.CREF(_))
    186         equation
    187         then  getConstCrefBinding(Expression.expCref(e),vars);
     193    eOut := matchcontinue e
     194      case _  guard Expression.isConst(e) then e;
     195      case DAE.CREF(_) then getConstCrefBinding(Expression.expCref(e),vars);
    188196          /*
    189197      case(DAE.CALL(Absyn.FULLYQUALIFIED(Absyn.QUALIFIED("Modelica",Absyn.QUALIFIED("Utilities",Absyn.QUALIFIED("Files",Absyn.IDENT("fullPathName"))))),{DAE.SCONST(s)},_))
     
    201209end getConstCrefBinding;
    202210
    203 public function setVisVarsPublic "Sets the VariableAttributes of protected visualization vars to public.
    204 author: waurich TUD 08-2016"
     211function setVisVarsPublic
     212  "Sets the VariableAttributes of protected visualization vars to public.
     213   author: waurich TUD 08-2016"
    205214  input BackendDAE.Var inVar;
    206215  input String dummyArgIn;
     
    213222end setVisVarsPublic;
    214223
    215 protected function makeVarPublicHideResultFalse "Sets the VariableAttributes to public and hideResult to false
    216 author: waurich TUD 08-2016"
     224function makeVarPublicHideResultFalse
     225  "Sets the VariableAttributes to public and hideResult to false
     226   author: waurich TUD 08-2016"
    217227  input BackendDAE.Var inVar;
    218228  output BackendDAE.Var outVar;
    219229protected
    220     Option<DAE.VariableAttributes> vals;
     230  Option<DAE.VariableAttributes> vals;
    221231algorithm
    222232  vals := inVar.values;
     
    226236end makeVarPublicHideResultFalse;
    227237
    228 protected function setBindingForProtectedVars "searches for protected vars and sets the binding exp with their equation.
    229 This is needed since protected, time-dependent variables are not stored in result files (in OMC and Dymola)"
     238function setBindingForProtectedVars
     239  "searches for protected vars and sets the binding exp with their equation.
     240   This is needed since protected, time-dependent variables are not stored in result files (in OMC and Dymola)"
    230241  input BackendDAE.EqSystem eqSysIn;
    231242  output BackendDAE.EqSystem eqSysOut;
     
    236247algorithm
    237248  try
    238   BackendDAE.EQSYSTEM(orderedEqs=eqs, orderedVars=vars, matching=BackendDAE.MATCHING(ass1=ass1)) := eqSysIn;
    239   BackendVariable.traverseBackendDAEVarsWithUpdate(vars, setBindingForProtectedVars1, (1, ass1, eqs));
     249    BackendDAE.EQSYSTEM(orderedEqs=eqs, orderedVars=vars, matching=BackendDAE.MATCHING(ass1=ass1)) := eqSysIn;
     250    BackendVariable.traverseBackendDAEVarsWithUpdate(vars, setBindingForProtectedVars1, (1, ass1, eqs));
    240251  else
    241252  end try;
     253
    242254  eqSysOut := eqSysIn;
    243255end setBindingForProtectedVars;
    244256
    245 protected function setBindingForProtectedVars1 "checks if the var is protected and sets the binding (i.e. the solved equation)"
     257function setBindingForProtectedVars1
     258  "checks if the var is protected and sets the binding (i.e. the solved equation)"
    246259  input BackendDAE.Var varIn;
    247260  input tuple<Integer,array<Integer>,BackendDAE.EquationArray> tplIn;
     
    249262  output tuple<Integer,array<Integer>,BackendDAE.EquationArray> tplOut;
    250263algorithm
    251   (varOut,tplOut) := matchcontinue(varIn,tplIn)
     264  (varOut, tplOut) := matchcontinue (varIn, tplIn)
    252265    local
    253266      Integer idx, eqIdx;
     
    257270      BackendDAE.Var var;
    258271      DAE.Exp exp1, exp2;
    259   case(BackendDAE.VAR(bindExp=NONE(), values=SOME(_)),(idx,ass1,eqs))
    260     equation
    261       true = (BackendVariable.isProtectedVar(varIn) and isVisualizationVar(varIn));
    262       eq = BackendEquation.get(eqs,arrayGet(ass1,idx));
    263       BackendDAE.EQUATION(exp=exp1, scalar=exp2) = eq;
    264       (exp1,_) =  ExpressionSolve.solve(exp1,exp2,BackendVariable.varExp(varIn));
    265       var = BackendVariable.setBindExp(varIn,SOME(exp1));
    266       var = makeVarPublicHideResultFalse(var);
    267     then (var,(idx+1,ass1,eqs));
    268   case(_,(idx,ass1,eqs))
     272
     273  case (BackendDAE.VAR(bindExp=NONE(), values=SOME(_)) , (idx, ass1, eqs))
     274      guard BackendVariable.isProtectedVar(varIn) and isVisualizationVar(varIn)
     275    algorithm
     276      eq := BackendEquation.get(eqs, arrayGet(ass1, idx));
     277      BackendDAE.EQUATION(exp=exp1, scalar=exp2) := eq;
     278      (exp1,_) := ExpressionSolve.solve(exp1, exp2, BackendVariable.varExp(varIn));
     279      var := BackendVariable.setBindExp(varIn, SOME(exp1));
     280      var := makeVarPublicHideResultFalse(var);
     281    then
     282      (var, (idx+1, ass1, eqs));
     283
     284  case (_, (idx, ass1, eqs))
    269285    equation
    270286      if (BackendVariable.isProtectedVar(varIn) and isVisualizationVar(varIn)) then
     
    273289        var = varIn;
    274290      end if;
    275     then (var,(idx+1,ass1,eqs));
     291    then (var, (idx+1, ass1, eqs));
    276292  end matchcontinue;
    277293end setBindingForProtectedVars1;
    278294
    279 protected function fillVisualizationObjects"gets the identifier of a visualization object as an input and collects all information from allVars.
    280 author:Waurich TUD 2015-04"
    281   input DAE.ComponentRef crefIn;
     295function fillVisualizationObjects
     296  "gets the identifier of a visualization object as an input and collects all information from allVars.
     297   author:Waurich TUD 2015-04"
     298  input tuple<DAE.ComponentRef, String> visVar;
    282299  input list<BackendDAE.Var> allVarsIn;
    283300  input Absyn.Program programIn;
    284301  output Visualization visOut;
    285   output list<BackendDAE.Var> allVarsOut;
    286   output Absyn.Program programOut;
    287 algorithm
    288   (visOut,allVarsOut,programOut) := matchcontinue(crefIn,allVarsIn,programIn)
    289     local
    290       String name;
    291       list<String> nameChars,prefix;
    292       Visualization vis;
    293       list<BackendDAE.Var> allVars;
    294   case(_,_,_)
    295     algorithm
    296       //nameChars := stringListStringChar(nameIn);
    297       //(prefix,nameChars) := List.split(nameChars,6);
    298       //name := stringCharListString(nameChars);
    299       //name := Util.stringReplaceChar(name,"$",".");
    300       //true := stringEqual(stringCharListString(prefix),"Shape$");
    301       //name := ComponentReference.printComponentRefStr(crefIn);
    302       vis := SHAPE(crefIn,DAE.SCONST("DUMMY"),arrayCreate(3,{DAE.RCONST(-1),DAE.RCONST(-1),DAE.RCONST(-1)}),
    303                            arrayCreate(3,DAE.RCONST(-1)), arrayCreate(3,DAE.RCONST(-1)), arrayCreate(3,DAE.RCONST(-1)),arrayCreate(3,DAE.RCONST(-1)),
    304                            DAE.RCONST(-1),DAE.RCONST(-1),DAE.RCONST(-1),DAE.RCONST(-1), arrayCreate(3,DAE.RCONST(-1)), DAE.RCONST(-1));
    305       (_,vis) := List.fold2(allVarsIn,fillVisualizationObjects1,true,programIn,({},vis));
    306     then (vis,allVarsIn,programIn);
     302  output list<BackendDAE.Var> allVarsOut = allVarsIn;
     303  output Absyn.Program programOut = programIn;
     304protected
     305  DAE.ComponentRef cref;
     306  String name, vis_name;
     307  list<String> nameChars,prefix;
     308  Visualization vis;
     309  list<BackendDAE.Var> allVars;
     310algorithm
     311  try
     312    //nameChars := stringListStringChar(nameIn);
     313    //(prefix,nameChars) := List.split(nameChars,6);
     314    //name := stringCharListString(nameChars);
     315    //name := Util.stringReplaceChar(name,"$",".");
     316    //true := stringEqual(stringCharListString(prefix),"Shape$");
     317    //name := ComponentReference.printComponentRefStr(crefIn);
     318    (cref, vis_name) := visVar;
     319    vis := newVisualizer(cref, vis_name);
     320    (_, visOut) := List.fold2(allVarsIn,fillVisualizationObjects1,true,programIn,({},vis));
    307321  else
    308     algorithm
    309322    print("fillVisualizationObjects failed! - not yet supported type");
    310    then fail();
    311   end matchcontinue;
     323    fail();
     324  end try;
    312325end fillVisualizationObjects;
    313326
    314 protected function makeCrefQualFromString"generates a qualified cref from the '.' separated string.
    315 author: Waurich TUD 2015-04"
     327function newVisualizer
     328  input DAE.ComponentRef cref;
     329  input String visualizerName;
     330  output Visualization vis;
     331algorithm
     332  vis := match visualizerName
     333    case "Shape"
     334      then SHAPE(cref,
     335             DAE.SCONST("DUMMY"),
     336             arrayCreate(3, {DAE.RCONST(-1),DAE.RCONST(-1),DAE.RCONST(-1)}),
     337             arrayCreate(3, DAE.RCONST(-1)),
     338             arrayCreate(3, DAE.RCONST(-1)),
     339             arrayCreate(3, DAE.RCONST(-1)),
     340             arrayCreate(3, DAE.RCONST(-1)),
     341             DAE.RCONST(-1),
     342             DAE.RCONST(-1),
     343             DAE.RCONST(-1),
     344             DAE.RCONST(-1),
     345             arrayCreate(3, DAE.RCONST(-1)),
     346             DAE.RCONST(-1));
     347
     348    case "Vector"
     349      then VECTOR(cref,
     350             arrayCreate(3, {DAE.RCONST(-1), DAE.RCONST(-1), DAE.RCONST(-1)}),
     351             arrayCreate(3, DAE.RCONST(-1)),
     352             arrayCreate(3, DAE.RCONST(-1)),
     353             arrayCreate(3, DAE.RCONST(-1)),
     354             DAE.RCONST(-1),
     355             DAE.RCONST(-1),
     356             DAE.BCONST(false),
     357             DAE.BCONST(false));
     358
     359    else
     360      algorithm
     361        Error.addInternalError(getInstanceName() + " failed on " +
     362          visualizerName + "\n", sourceInfo());
     363      then
     364        fail();
     365  end match;
     366end newVisualizer;
     367
     368function makeCrefQualFromString
     369  "generates a qualified cref from the '.' separated string.
     370   author: Waurich TUD 2015-04"
    316371  input String s;
    317372  output DAE.ComponentRef crefOut;
     
    327382end makeCrefQualFromString;
    328383
    329 protected function splitCrefAfter"checks if crefCut exists in the crefIn and outputs the appending crefs
    330 author:Waurich TUD 2015-04"
     384function splitCrefAfter
     385  "checks if crefCut exists in the crefIn and outputs the appending crefs
     386   author:Waurich TUD 2015-04"
    331387  input DAE.ComponentRef crefIn;
    332388  input DAE.ComponentRef crefCut;
     
    334390  output Boolean wasCut;
    335391algorithm
    336   (crefOut,wasCut) := matchcontinue(crefIn,crefCut)
     392  (crefOut, wasCut) := matchcontinue(crefIn, crefCut)
    337393    local
    338394      DAE.ComponentRef crefCut1, crefIn1;
    339   case(DAE.CREF_QUAL(componentRef=crefIn1),DAE.CREF_QUAL())
    340     equation
    341       // the crefs are not equal, check the next cref in crefIn
    342       true = not ComponentReference.crefFirstCrefEqual(crefIn,crefCut);
    343     then splitCrefAfter(crefIn1,crefCut);
    344   case(DAE.CREF_QUAL(componentRef=crefIn1),DAE.CREF_QUAL(componentRef=crefCut1))
    345     equation
    346       // the crefs are equal, continue checking
    347       true = ComponentReference.crefFirstCrefEqual(crefIn,crefCut);
    348     then splitCrefAfter(crefIn1,crefCut1);
    349   case(DAE.CREF_QUAL(componentRef=crefIn1),DAE.CREF_IDENT(_))
    350     equation
    351       // the cref has to be cut after this step
    352       true = ComponentReference.crefFirstCrefEqual(crefIn,crefCut);
    353     then (crefIn1,true);
    354   case(DAE.CREF_QUAL(componentRef=crefIn1),DAE.CREF_IDENT(_))
    355     equation
    356       // there is no identical cref
    357       true = not ComponentReference.crefFirstCrefEqual(crefIn,crefCut);
    358     then (crefIn1,false);
    359    else
    360      then (crefCut,false);
     395
     396    case(DAE.CREF_QUAL(componentRef=crefIn1),DAE.CREF_QUAL())
     397      algorithm
     398        // the crefs are not equal, check the next cref in crefIn
     399        true := not ComponentReference.crefFirstCrefEqual(crefIn,crefCut);
     400      then
     401        splitCrefAfter(crefIn1,crefCut);
     402
     403    case(DAE.CREF_QUAL(componentRef=crefIn1),DAE.CREF_QUAL(componentRef=crefCut1))
     404      algorithm
     405        // the crefs are equal, continue checking
     406        true := ComponentReference.crefFirstCrefEqual(crefIn,crefCut);
     407      then
     408        splitCrefAfter(crefIn1,crefCut1);
     409
     410    case(DAE.CREF_QUAL(componentRef=crefIn1),DAE.CREF_IDENT(_))
     411      algorithm
     412        // the cref has to be cut after this step
     413        true := ComponentReference.crefFirstCrefEqual(crefIn,crefCut);
     414      then
     415        (crefIn1, true);
     416
     417    case(DAE.CREF_QUAL(componentRef=crefIn1),DAE.CREF_IDENT(_))
     418      algorithm
     419        // there is no identical cref
     420        true := not ComponentReference.crefFirstCrefEqual(crefIn,crefCut);
     421      then
     422        (crefIn1, false);
     423
     424    else (crefCut, false);
    361425  end matchcontinue;
    362426end splitCrefAfter;
    363427
    364 protected function fillVisualizationObjects1"checks if a variable belongs to a certain visualization var. if true, add information to the visualization object
    365 author:Waurich TUD 2015-04"
     428function fillVisualizationObjects1
     429  "checks if a variable belongs to a certain visualization var. if true, add information to the visualization object
     430   author:Waurich TUD 2015-04"
    366431  input BackendDAE.Var varIn; //check this var
    367432  input Boolean storeProtectedCrefs; // if you want to store the protected crefs instead of the bidning expression
     
    370435  output tuple<list<BackendDAE.Var>,Visualization> tplOut;
    371436algorithm
    372    tplOut := matchcontinue(varIn,storeProtectedCrefs,tplIn)
     437   tplOut := matchcontinue(varIn, tplIn)
    373438    local
    374439      String compIdent;
    375440      list<BackendDAE.Var> vars;
    376441      DAE.ComponentRef cref,crefIdent,cref1,ident;
    377       Visualization vis;
    378   case(BackendDAE.VAR(varName=cref),_,(vars, vis as SHAPE(ident=ident)))
    379     algorithm
    380       //this var belongs to the visualization object
    381       //crefIdent := makeCrefQualFromString(ident); // make a qualified cref out of the shape ident
    382       (cref1,true) := splitCrefAfter(cref,ident); // check if this occures in the qualified var cref
    383       vis := fillShapeObject(cref1,varIn,storeProtectedCrefs,program,vis);
    384     then (vars, vis);
    385   else
    386     algorithm
    387       (vars,vis) := tplIn;
    388     then (varIn::vars, vis);
     442      Visualization vis, filled_vis;
     443
     444    case (BackendDAE.VAR(varName=cref), (vars, vis as SHAPE(ident=ident)))
     445      algorithm
     446        //this var belongs to the visualization object
     447        //crefIdent := makeCrefQualFromString(ident); // make a qualified cref out of the shape ident
     448        (cref1,true) := splitCrefAfter(cref,ident); // check if this occures in the qualified var cref
     449        filled_vis := fillShapeObject(cref1,varIn,storeProtectedCrefs,program,vis);
     450      then
     451        (vars, filled_vis);
     452
     453    case (BackendDAE.VAR(varName=cref), (vars, vis as VECTOR(ident=ident)))
     454      algorithm
     455        //this var belongs to the visualization object
     456        //crefIdent := makeCrefQualFromString(ident); // make a qualified cref out of the shape ident
     457        (cref1,true) := splitCrefAfter(cref,ident); // check if this occures in the qualified var cref
     458        filled_vis := fillVectorObject(cref1,varIn,storeProtectedCrefs,program,vis);
     459      then
     460        (vars, filled_vis);
     461
     462    else
     463      algorithm
     464        (vars, vis) := tplIn;
     465      then
     466        (varIn::vars, vis);
     467
    389468  end matchcontinue;
    390469end fillVisualizationObjects1;
    391470
    392 protected function getFullCADFilePath "Get the absolute path for the given modelica uri.
    393 author: vwaurich TUD 2016-10"
     471function getFullCADFilePath
     472  "Get the absolute path for the given modelica uri.
     473   author: vwaurich TUD 2016-10"
    394474  input String sIn;
    395475  input Absyn.Program program;
     
    405485end getFullCADFilePath;
    406486
    407 protected function fillShapeObject"sets the visualization info in the visualization object
    408 author:Waurich TUD 2015-04"
     487function fillShapeObject
     488  "sets the visualization info in the visualization object
     489   author:Waurich TUD 2015-04"
    409490  input DAE.ComponentRef cref;
    410491  input BackendDAE.Var var;
    411492  input Boolean storeProtectedCrefs;
    412493  input Absyn.Program program;
    413   input Visualization visIn;
    414   output Visualization visOut;
    415 algorithm
    416   visOut := matchcontinue(cref,var,storeProtectedCrefs,program,visIn)
     494  input output Visualization vis;
     495algorithm
     496  () := matchcontinue (cref, vis)
    417497    local
    418498      Option<DAE.Exp> bind;
    419       DAE.ComponentRef ident;
    420       DAE.Exp exp, length, width, height, extra, specularCoeff, shapeType;
    421       Integer ivalue, pos, pos1;
    422       Real rvalue;
    423       array<DAE.Exp> color, r, lengthDir, widthDir, r_shape ;
     499      DAE.Exp exp;
     500      Integer pos, pos1;
    424501      list<DAE.Exp> T0;
    425       array<list<DAE.Exp>> T;
    426 
    427   case(DAE.CREF_IDENT(ident="shapeType"),BackendDAE.VAR(bindExp=SOME(exp)),_ ,_ , SHAPE(ident=ident, shapeType=shapeType, T=T, r=r, r_shape=r_shape, lengthDir=lengthDir, widthDir=widthDir, length=length, width=width, height=height, extra=extra, color=color, specularCoeff=specularCoeff))
    428     algorithm
    429     then (SHAPE(ident, exp, T, r, r_shape, lengthDir, widthDir, length, width, height, extra, color, specularCoeff));
    430 
    431   case(DAE.CREF_QUAL(ident="R",componentRef=DAE.CREF_IDENT(ident="T", subscriptLst = {DAE.INDEX(DAE.ICONST(pos)),DAE.INDEX(DAE.ICONST(pos1))})),BackendDAE.VAR(bindExp=bind),_ ,_ , SHAPE(ident=ident, shapeType=shapeType, T=T, r=r, r_shape=r_shape, lengthDir=lengthDir, widthDir=widthDir, length=length, width=width, height=height, extra=extra, color=color, specularCoeff=specularCoeff))
    432     algorithm
    433       if isSome(bind) then
    434         exp := if not Expression.isConstValue(Util.getOption(bind)) and storeProtectedCrefs then BackendVariable.varExp(var) else Util.getOption(bind);
    435       else exp := BackendVariable.varExp(var);
    436       end if;
    437       T0 := arrayGet(T,pos);
    438       T0 := List.replaceAt(exp,pos1,T0);
    439       T := arrayUpdate(T,pos,T0);
    440     then (SHAPE(ident, shapeType, T, r, r_shape, lengthDir, widthDir, length, width, height, extra, color, specularCoeff));
    441 
    442   case(DAE.CREF_IDENT(ident="r", subscriptLst = {DAE.INDEX(DAE.ICONST(pos))}),BackendDAE.VAR(bindExp=bind), _ ,_ , SHAPE(ident=ident, shapeType=shapeType, T=T, r=r, r_shape=r_shape, lengthDir=lengthDir, widthDir=widthDir, length=length, width=width, height=height, extra=extra, color=color, specularCoeff=specularCoeff))
    443     algorithm
    444       if isSome(bind) then
    445         exp := if not Expression.isConstValue(Util.getOption(bind)) and storeProtectedCrefs then BackendVariable.varExp(var) else Util.getOption(bind);
    446       else exp := BackendVariable.varExp(var);
    447       end if;
    448       r := arrayUpdate(r,pos,exp);
    449     then (SHAPE(ident, shapeType, T, r, r_shape, lengthDir, widthDir, length, width, height, extra, color, specularCoeff));
    450 
    451   case(DAE.CREF_IDENT(ident="r_shape", subscriptLst = {DAE.INDEX(DAE.ICONST(pos))}),BackendDAE.VAR(bindExp=bind), _ ,_ , SHAPE(ident=ident, shapeType=shapeType, T=T, r=r, r_shape=r_shape, lengthDir=lengthDir, widthDir=widthDir, length=length, width=width, height=height, extra=extra, color=color, specularCoeff=specularCoeff))
    452     algorithm
    453       if isSome(bind) then
    454         exp := if not Expression.isConstValue(Util.getOption(bind)) and storeProtectedCrefs then BackendVariable.varExp(var) else Util.getOption(bind);
    455       else exp := BackendVariable.varExp(var);
    456       end if;
    457       r_shape := arrayUpdate(r_shape,pos,exp);
    458     then (SHAPE(ident, shapeType, T, r, r_shape, lengthDir, widthDir, length, width, height, extra, color, specularCoeff));
    459 
    460   case(DAE.CREF_IDENT(ident="lengthDirection", subscriptLst = {DAE.INDEX(DAE.ICONST(pos))}),BackendDAE.VAR(bindExp=bind), _ ,_ , SHAPE(ident=ident, shapeType=shapeType, T=T, r=r, r_shape=r_shape, lengthDir=lengthDir, widthDir=widthDir, length=length, width=width, height=height, extra=extra, color=color, specularCoeff=specularCoeff))
    461     algorithm
    462       if isSome(bind) then
    463         exp := if not Expression.isConstValue(Util.getOption(bind)) and storeProtectedCrefs then BackendVariable.varExp(var) else Util.getOption(bind);
    464       else exp := BackendVariable.varExp(var);
    465       end if;
    466       lengthDir := arrayUpdate(lengthDir,pos,exp);
    467     then (SHAPE(ident, shapeType, T, r, r_shape, lengthDir, widthDir, length, width, height, extra, color, specularCoeff));
    468 
    469   case(DAE.CREF_IDENT(ident="widthDirection", subscriptLst = {DAE.INDEX(DAE.ICONST(pos))}),BackendDAE.VAR(bindExp=bind), _ ,_ , SHAPE(ident=ident, shapeType=shapeType, T=T, r=r, r_shape=r_shape, lengthDir=lengthDir, widthDir=widthDir, length=length, width=width, height=height, extra=extra, color=color, specularCoeff=specularCoeff))
    470     algorithm
    471       if isSome(bind) then
    472         exp := if not Expression.isConstValue(Util.getOption(bind)) and storeProtectedCrefs then BackendVariable.varExp(var) else Util.getOption(bind);
    473       else exp := BackendVariable.varExp(var);
    474       end if;
    475       widthDir := arrayUpdate(widthDir,pos,exp);
    476     then (SHAPE(ident, shapeType, T, r, r_shape, lengthDir, widthDir, length, width, height, extra, color, specularCoeff));
    477 
    478   case(DAE.CREF_IDENT(ident="length"),BackendDAE.VAR(bindExp=bind), _ ,_ , SHAPE(ident=ident, shapeType=shapeType, T=T, r=r, r_shape=r_shape, lengthDir=lengthDir, widthDir=widthDir, length=length, width=width, height=height, extra=extra, color=color, specularCoeff=specularCoeff))
    479     algorithm
    480       if isSome(bind) then
    481         exp := if not Expression.isConstValue(Util.getOption(bind)) and storeProtectedCrefs then BackendVariable.varExp(var) else Util.getOption(bind);
    482       else exp := BackendVariable.varExp(var);
    483       end if;
    484     then (SHAPE(ident, shapeType, T, r, r_shape, lengthDir, widthDir, exp, width, height, extra, color, specularCoeff));
    485 
    486   case(DAE.CREF_IDENT(ident="width"),BackendDAE.VAR(bindExp=bind), _ ,_ , SHAPE(ident=ident, shapeType=shapeType, T=T, r=r, r_shape=r_shape, lengthDir=lengthDir, widthDir=widthDir, length=length, width=width, height=height, extra=extra, color=color, specularCoeff=specularCoeff))
    487     algorithm
    488       if isSome(bind) then
    489         exp := if not Expression.isConstValue(Util.getOption(bind)) and storeProtectedCrefs then BackendVariable.varExp(var) else Util.getOption(bind);
    490       else exp := BackendVariable.varExp(var);
    491       end if;
    492     then (SHAPE(ident, shapeType, T, r, r_shape, lengthDir, widthDir, length, exp, height, extra, color, specularCoeff));
    493 
    494   case(DAE.CREF_IDENT(ident="height"),BackendDAE.VAR(bindExp=bind), _ ,_ , SHAPE(ident=ident, shapeType=shapeType, T=T, r=r, r_shape=r_shape, lengthDir=lengthDir, widthDir=widthDir, length=length, width=width, height=height, extra=extra, color=color, specularCoeff=specularCoeff))
    495     algorithm
    496       if isSome(bind) then
    497         exp := if not Expression.isConstValue(Util.getOption(bind)) and storeProtectedCrefs then BackendVariable.varExp(var) else Util.getOption(bind);
    498       else exp := BackendVariable.varExp(var);
    499       end if;
    500     then (SHAPE(ident, shapeType, T, r, r_shape, lengthDir, widthDir, length, width, exp, extra, color, specularCoeff));
    501 
    502    case(DAE.CREF_IDENT(ident="extra"),BackendDAE.VAR(bindExp=bind), _ ,_ , SHAPE(ident=ident, shapeType=shapeType, T=T, r=r, r_shape=r_shape, lengthDir=lengthDir, widthDir=widthDir, length=length, width=width, height=height, extra=extra, color=color, specularCoeff=specularCoeff))
    503     algorithm
    504       if isSome(bind) then
    505         exp := if not Expression.isConstValue(Util.getOption(bind)) and storeProtectedCrefs then BackendVariable.varExp(var) else Util.getOption(bind);
    506       else exp := BackendVariable.varExp(var);
    507       end if;
    508     then (SHAPE(ident, shapeType, T, r, r_shape, lengthDir, widthDir, length, width, height, exp, color, specularCoeff));
    509 
    510   case(DAE.CREF_IDENT(ident="color", subscriptLst = {DAE.INDEX(DAE.ICONST(pos))}),BackendDAE.VAR(bindExp=bind), _ ,_ , SHAPE(ident=ident, shapeType=shapeType, T=T, r=r, r_shape=r_shape, lengthDir=lengthDir, widthDir=widthDir, length=length, width=width, height=height, extra=extra, color=color, specularCoeff=specularCoeff))
    511     algorithm
    512       if isSome(bind) then
    513         exp := if not Expression.isConstValue(Util.getOption(bind)) and storeProtectedCrefs then BackendVariable.varExp(var) else Util.getOption(bind);
    514       else exp := BackendVariable.varExp(var);
    515       end if;
    516       color := arrayUpdate(color,pos,exp);
    517     then (SHAPE(ident, shapeType, T, r, r_shape, lengthDir, widthDir, length, width, height, extra, color, specularCoeff));
    518 
    519    case(DAE.CREF_IDENT(ident="specularCoefficient"),BackendDAE.VAR(bindExp=bind), _ ,_ , SHAPE(ident=ident, shapeType=shapeType, T=T, r=r, r_shape=r_shape, lengthDir=lengthDir, widthDir=widthDir, length=length, width=width, height=height, extra=extra, color=color))
    520     algorithm
    521       if isSome(bind) then
    522         exp := if not Expression.isConstValue(Util.getOption(bind)) and storeProtectedCrefs then BackendVariable.varExp(var) else Util.getOption(bind);
    523       else exp := BackendVariable.varExp(var);
    524       end if;
    525     then (SHAPE(ident, shapeType, T, r, r_shape, lengthDir, widthDir, length, width, height, extra, color, exp));
    526 
    527   else visIn;
     502
     503    case (DAE.CREF_IDENT(ident="shapeType"), SHAPE())
     504      algorithm
     505        BackendDAE.VAR(bindExp = bind) := var;
     506
     507        if isSome(bind) then
     508          vis.shapeType := Util.getOption(bind);
     509        end if;
     510      then
     511        ();
     512
     513    case (DAE.CREF_QUAL(ident="R", componentRef=DAE.CREF_IDENT(ident="T",
     514            subscriptLst = {DAE.INDEX(DAE.ICONST(pos)), DAE.INDEX(DAE.ICONST(pos1))})), SHAPE())
     515      algorithm
     516        exp := getVariableBinding(var, storeProtectedCrefs);
     517        T0 := arrayGet(vis.T, pos);
     518        T0 := List.replaceAt(exp, pos1, T0);
     519        arrayUpdate(vis.T, pos, T0);
     520      then
     521        ();
     522
     523    case (DAE.CREF_IDENT(ident="r", subscriptLst = {DAE.INDEX(DAE.ICONST(pos))}), SHAPE())
     524      algorithm
     525        exp := getVariableBinding(var, storeProtectedCrefs);
     526        arrayUpdate(vis.r, pos, exp);
     527      then
     528        ();
     529
     530    case (DAE.CREF_IDENT(ident="r_shape", subscriptLst = {DAE.INDEX(DAE.ICONST(pos))}), SHAPE())
     531      algorithm
     532        exp := getVariableBinding(var, storeProtectedCrefs);
     533        arrayUpdate(vis.r_shape, pos, exp);
     534      then
     535        ();
     536
     537    case (DAE.CREF_IDENT(ident="lengthDirection", subscriptLst = {DAE.INDEX(DAE.ICONST(pos))}), SHAPE())
     538      algorithm
     539        exp := getVariableBinding(var, storeProtectedCrefs);
     540        arrayUpdate(vis.lengthDir, pos, exp);
     541      then
     542        ();
     543
     544    case (DAE.CREF_IDENT(ident="widthDirection", subscriptLst = {DAE.INDEX(DAE.ICONST(pos))}), SHAPE())
     545      algorithm
     546        exp := getVariableBinding(var, storeProtectedCrefs);
     547        arrayUpdate(vis.widthDir, pos, exp);
     548      then
     549        ();
     550
     551    case (DAE.CREF_IDENT(ident="length"), SHAPE())
     552      algorithm
     553        vis.length := getVariableBinding(var, storeProtectedCrefs);
     554      then
     555        ();
     556
     557    case (DAE.CREF_IDENT(ident="width"), SHAPE())
     558      algorithm
     559        vis.width := getVariableBinding(var, storeProtectedCrefs);
     560      then
     561        ();
     562
     563    case (DAE.CREF_IDENT(ident="height"), SHAPE())
     564      algorithm
     565        vis.height := getVariableBinding(var, storeProtectedCrefs);
     566      then
     567        ();
     568
     569     case (DAE.CREF_IDENT(ident="extra"), SHAPE())
     570      algorithm
     571        vis.extra := getVariableBinding(var, storeProtectedCrefs);
     572      then
     573        ();
     574
     575    case (DAE.CREF_IDENT(ident="color", subscriptLst = {DAE.INDEX(DAE.ICONST(pos))}), SHAPE())
     576      algorithm
     577        exp := getVariableBinding(var, storeProtectedCrefs);
     578        arrayUpdate(vis.color, pos, exp);
     579      then
     580        ();
     581
     582    case (DAE.CREF_IDENT(ident="specularCoefficient"), SHAPE())
     583      algorithm
     584        vis.specularCoeff := getVariableBinding(var, storeProtectedCrefs);
     585      then
     586        ();
     587
     588    else ();
    528589  end matchcontinue;
    529590end fillShapeObject;
    530591
    531 protected function printVisualization"printing function for debugging.
    532 author:Waurich TUD 2015-04"
     592function fillVectorObject
     593  "sets the visualization info in the visualization object
     594   author:Waurich TUD 2015-04"
     595  input DAE.ComponentRef cref;
     596  input BackendDAE.Var var;
     597  input Boolean storeProtectedCrefs;
     598  input Absyn.Program program;
     599  input output Visualization vis;
     600algorithm
     601  () := matchcontinue (cref, vis)
     602    local
     603      Option<DAE.Exp> bind;
     604      DAE.Exp exp;
     605      Integer pos, pos1;
     606      list<DAE.Exp> T0;
     607
     608    case (DAE.CREF_QUAL(ident="R", componentRef=DAE.CREF_IDENT(ident="T",
     609            subscriptLst = {DAE.INDEX(DAE.ICONST(pos)), DAE.INDEX(DAE.ICONST(pos1))})), VECTOR())
     610      algorithm
     611        exp := getVariableBinding(var, storeProtectedCrefs);
     612        T0 := arrayGet(vis.T, pos);
     613        T0 := List.replaceAt(exp, pos1, T0);
     614        arrayUpdate(vis.T, pos, T0);
     615      then
     616        ();
     617
     618    case (DAE.CREF_IDENT(ident="r", subscriptLst = {DAE.INDEX(DAE.ICONST(pos))}), VECTOR())
     619      algorithm
     620        exp := getVariableBinding(var, storeProtectedCrefs);
     621        arrayUpdate(vis.r, pos, exp);
     622      then
     623        ();
     624
     625    case (DAE.CREF_IDENT(ident="coordinates", subscriptLst = {DAE.INDEX(DAE.ICONST(pos))}), VECTOR())
     626      algorithm
     627        exp := getVariableBinding(var, storeProtectedCrefs);
     628        arrayUpdate(vis.coordinates, pos, exp);
     629      then
     630        ();
     631
     632    case (DAE.CREF_IDENT(ident="color", subscriptLst = {DAE.INDEX(DAE.ICONST(pos))}), VECTOR())
     633      algorithm
     634        exp := getVariableBinding(var, storeProtectedCrefs);
     635        arrayUpdate(vis.color, pos, exp);
     636      then
     637        ();
     638
     639    case (DAE.CREF_IDENT(ident="specularCoefficient"), VECTOR())
     640      algorithm
     641        vis.specularCoeff := getVariableBinding(var, storeProtectedCrefs);
     642      then
     643        ();
     644
     645    case (DAE.CREF_IDENT(ident="quantity"), VECTOR())
     646      algorithm
     647        vis.quantity := getVariableBinding(var, storeProtectedCrefs);
     648      then
     649        ();
     650
     651    case (DAE.CREF_IDENT(ident="headAtOrigin"), VECTOR())
     652      algorithm
     653        vis.headAtOrigin := getVariableBinding(var, storeProtectedCrefs);
     654      then
     655        ();
     656
     657    case (DAE.CREF_IDENT(ident="twoHeadedArrow"), VECTOR())
     658      algorithm
     659        vis.twoHeadedArrow := getVariableBinding(var, storeProtectedCrefs);
     660      then
     661        ();
     662
     663    else ();
     664  end matchcontinue;
     665end fillVectorObject;
     666
     667function getVariableBinding
     668  input BackendDAE.Var var;
     669  input Boolean storeProtectedCrefs;
     670  output DAE.Exp exp;
     671protected
     672  Option<DAE.Exp> binding;
     673algorithm
     674  BackendDAE.VAR(bindExp = binding) := var;
     675
     676  if isSome(binding) then
     677    SOME(exp) := binding;
     678
     679    if not Expression.isConstValue(exp) and storeProtectedCrefs then
     680      exp := BackendVariable.varExp(var);
     681    end if;
     682  else
     683    exp := BackendVariable.varExp(var);
     684  end if;
     685end getVariableBinding;
     686
     687function printVisualization
     688  "printing function for debugging.
     689   author:Waurich TUD 2015-04"
    533690  input Visualization vis;
    534691  output String s;
     
    550707end printVisualization;
    551708
    552 protected function isVisualizationVar"the var inherits from an visualization object. Therefore, the paths are checked.
    553 author:Waurich TUD 2015-04"
     709function isVisualizationVar
     710  "the var inherits from an visualization object. Therefore, the paths are checked.
     711   author:Waurich TUD 2015-04"
    554712  input BackendDAE.Var var;
    555713  output Boolean isVisVar;
    556714algorithm
    557   isVisVar := matchcontinue(var)
    558   local
    559     Boolean b;
    560     DAE.ElementSource source;
    561     String obj;
    562     list<Absyn.Path> paths;
    563     list<String> paths_lst;
    564     case(BackendDAE.VAR(source=source))
    565       algorithm
    566        paths := ElementSource.getElementSourceTypes(source);
    567        //_ := list(AbsynUtil.pathString(p) for p in paths);
    568        //print("paths_lst "+stringDelimitList(paths_lst, "; ")+"\n");
    569        (obj,_) := hasVisPath(paths,1);
    570     then Util.stringNotEqual(obj,"");
    571     else
    572       then false;
     715  isVisVar := matchcontinue var
     716    local
     717      Boolean b;
     718      DAE.ElementSource source;
     719      String obj;
     720      list<Absyn.Path> paths;
     721      list<String> paths_lst;
     722
     723    case BackendDAE.VAR(source=source)
     724      algorithm
     725        paths := ElementSource.getElementSourceTypes(source);
     726        //_ := list(AbsynUtil.pathString(p) for p in paths);
     727        //print("paths_lst "+stringDelimitList(paths_lst, "; ")+"\n");
     728        obj := hasVisPath(paths, 1);
     729      then
     730        Util.stringNotEqual(obj, "");
     731
     732    else false;
    573733  end matchcontinue;
    574734end isVisualizationVar;
    575735
    576 
    577 protected function isVisualizationVarFold"the var inherits from an visualization object. Therefore, the paths are checked.
    578 author:Waurich TUD 2015-04"
     736function isVisualizationVarFold
     737  "the var inherits from an visualization object. Therefore, the paths are checked.
     738   author:Waurich TUD 2015-04"
    579739  input BackendDAE.Var var;
    580   input tuple<list<BackendDAE.Var>,list<DAE.ComponentRef>> tplIn;//visualizationVars, visualization Identifiers
    581   output tuple<list<BackendDAE.Var>,list<DAE.ComponentRef>> tplOut;
     740  input tuple<list<BackendDAE.Var>,list<tuple<DAE.ComponentRef, String>>> tplIn;//visualizationVars, visualization Identifiers
     741  output tuple<list<BackendDAE.Var>,list<tuple<DAE.ComponentRef, String>>> tplOut;
    582742algorithm
    583743  tplOut := matchcontinue(var,tplIn)
     
    585745      Integer idx;
    586746      DAE.ComponentRef varName, cref;
    587       list<DAE.ComponentRef> crefs;
     747      list<tuple<DAE.ComponentRef, String>> crefs;
    588748      DAE.ElementSource source;
    589749      list<BackendDAE.Var> varLst;
     
    591751      list<Absyn.Path> paths;
    592752
    593     case (BackendDAE.VAR(varName=varName,  source=source), (varLst,crefs))
     753    case (BackendDAE.VAR(varName=varName, source=source), (varLst,crefs))
    594754      algorithm
    595755        paths := ElementSource.getElementSourceTypes(source);
    596756        //print("Component " + ComponentReference.printComponentRefStr(varName) + ":\n");
    597757        //print(List.toString(paths, AbsynUtil.pathStringDefault, "", "  ", "\n  ", "", false) + "\n");
    598         (obj,idx) := hasVisPath(paths,1);
    599         true := Util.stringNotEqual(obj,"");
     758        (obj, idx) := hasVisPath(paths, 1);
     759        true := Util.stringNotEqual(obj, "");
    600760        //print("ComponentRef "+ComponentReference.printComponentRefStr(varName)+" path: "+obj+ " idx: "+intString(idx)+"\n");
    601         cref := ComponentReference.firstNCrefs(varName,idx-1);
    602         crefs := List.unique(cref::crefs);
     761        cref := ComponentReference.firstNCrefs(varName, idx-1);
     762        crefs := List.unique((cref, obj)::crefs);
    603763      then
    604764        (var::varLst, crefs);
     
    608768end isVisualizationVarFold;
    609769
    610 protected function hasVisPath"checks if the path is Modelica.Mechanics.MultiBody.Visualizers.Advanced.* and outputs * if true. outputs which path is the vis path
    611 author:Waurich TUD 2015-04"
     770function hasVisPath
     771  "checks if the path is Modelica.Mechanics.MultiBody.Visualizers.Advanced.* and
     772   outputs * if true. outputs which path is the vis path
     773   author:Waurich TUD 2015-04"
    612774  input  list<Absyn.Path> pathsIn;
    613775  input Integer numIn;
     
    615777  output Integer numOut;
    616778algorithm
    617   (visPath,numOut) := matchcontinue(pathsIn,numIn)
     779  (visPath, numOut) := matchcontinue pathsIn
    618780    local
    619781      String name, shapeIdent;
     
    622784      Absyn.Path path;
    623785      list<Absyn.Path> rest;
    624   case({},_)
    625     then ("",-1);
    626   case(Absyn.FULLYQUALIFIED(path=path)::rest,_)
    627     algorithm
    628     (name,num) := hasVisPath(path::rest,numIn);
    629     then (name,num);
    630   case(Absyn.QUALIFIED(name="Modelica",path=Absyn.QUALIFIED(name="Mechanics",path=Absyn.QUALIFIED(name="MultiBody",path=Absyn.QUALIFIED(name="Visualizers",path=Absyn.QUALIFIED(name="Advanced",path=Absyn.IDENT(name=name))))))::_,_)
    631     algorithm
    632       shapeIdent := substring(name, 1, 5);
    633       true := stringEqual(shapeIdent,"Shape");
    634     then (name,numIn);
    635   case(_::rest,_)
    636     algorithm
    637       (name,num) := hasVisPath(rest,numIn+1);
    638     then (name,num);
     786
     787    case {} then ("", -1);
     788    case Absyn.FULLYQUALIFIED(path=path)::rest then hasVisPath(path::rest, numIn);
     789
     790    case Absyn.QUALIFIED(name="Modelica",
     791        path=Absyn.QUALIFIED(name="Mechanics",
     792          path=Absyn.QUALIFIED(name="MultiBody",
     793            path=Absyn.QUALIFIED(name="Visualizers",
     794              path=Absyn.QUALIFIED(name="Advanced",
     795                path=Absyn.IDENT(name=name))))))::_
     796      algorithm
     797        true := listMember(name, {"Shape", "Vector"});
     798      then
     799        (name, numIn);
     800
     801    case _::rest then hasVisPath(rest,numIn+1);
    639802  end matchcontinue;
    640803end hasVisPath;
    641804
    642 
    643 public function dumpVis "author: waurich TUD
    644   Dumps the graph into a *.xml-file."
     805function dumpVis
     806  "author: waurich TUD
     807   Dumps the graph into a *.xml-file."
    645808  input array<Visualization> visIn;
    646809  input String iFileName;
  • OMCompiler/Compiler/Template/VisualXMLTpl.tpl

    r83be5f2b re3518437  
    4747                  <ident><%ComponentReference.printComponentRefStr(ident)%></ident>
    4848                  <type><%svalue%></type>
    49                   <T><%TDump%></T>
    50                   <r><%rDump%></r>
    51                   <r_shape><%r_shapeDump%></r_shape>
    52                   <lengthDir><%lDirDump%></lengthDir>
    53                   <widthDir><%wDirDump%></widthDir>
     49                  <T>
     50                      <%TDump%>
     51                  </T>
     52                  <r>
     53                      <%rDump%>
     54                  </r>
     55                  <r_shape>
     56                      <%r_shapeDump%>
     57                  </r_shape>
     58                  <lengthDir>
     59                      <%lDirDump%>
     60                  </lengthDir>
     61                  <widthDir>
     62                      <%wDirDump%>
     63                  </widthDir>
    5464                  <length><%dumpExp(length)%></length>
    5565                  <width><%dumpExp(width)%></width>
    5666                  <height><%dumpExp(height)%></height>
    5767                  <extra><%dumpExp(extra)%></extra>
    58                   <color><%colorDump%></color>
     68                  <color>
     69                      <%colorDump%>
     70                  </color>
    5971                  <specCoeff><%dumpExp(specularCoeff)%></specCoeff>
    6072              </shape>
    6173            >>
     74
     75        case vis as VECTOR() then
     76          let TDump = arrayList(T) |> T0 => <<
     77          <%dumpVecExp(T0)%>
     78          >> ; separator="\n"
     79          let rDump = dumpVecExp(arrayList(r))
     80          let coordDump = dumpVecExp(arrayList(coordinates))
     81          let colorDump = dumpVecExp(arrayList(color))
     82            <<
     83              <vector>
     84                  <ident><%ComponentReference.printComponentRefStr(ident)%></ident>
     85                  <T>
     86                      <%TDump%>
     87                  </T>
     88                  <r>
     89                      <%rDump%>
     90                  </r>
     91                  <coordinates>
     92                      <%coordDump%>
     93                  </coordinates>
     94                  <color>
     95                      <%colorDump%>
     96                  </color>
     97                  <specCoeff><%dumpExp(specularCoeff)%></specCoeff>
     98                  <quantity><%dumpExp(quantity)%></quantity>
     99                  <headAtOrigin><%dumpExp(headAtOrigin)%></headAtOrigin>
     100                  <twoHeadedArrow><%dumpExp(twoHeadedArrow)%></twoHeadedArrow>
     101              </vector>
     102            >>
     103
    62104    end match
    63105end dumpVisualization;
     
    75117        case expIn as BCONST(__) then
    76118            <<
    77                 <bexp><%ExpressionDump.printExpStr(expIn)%></bexp>
     119            <bexp><%ExpressionDump.printExpStr(expIn)%></bexp>
    78120            >>
    79121        case expIn as CREF(__) then
    80122            <<
    81                 <cref><%ExpressionDump.printExpStr(expIn)%></cref>
     123            <cref><%ExpressionDump.printExpStr(expIn)%></cref>
    82124            >>
    83125        case expIn as BINARY(__) then
     
    130172        else
    131173            <<
    132                 <exp><%ExpressionDump.printExpStr(expIn)%></exp>
     174            <exp><%ExpressionDump.printExpStr(expIn)%></exp>
    133175            >>
    134176    end match
  • OMCompiler/Compiler/Template/VisualXMLTplTV.mo

    r9405381f re3518437  
    160160        DAE.Exp specularCoeff;
    161161      end SHAPE;
     162
     163      record VECTOR
     164        DAE.ComponentRef ident;
     165        array<list<DAE.Exp>> T;
     166        array<DAE.Exp> r;
     167        array<DAE.Exp> coordinates;
     168        array<DAE.Exp> color;
     169        DAE.Exp specularCoeff;
     170        DAE.Exp quantity;
     171        DAE.Exp headAtOrigin;
     172        DAE.Exp twoHeadedArrow;
     173      end VECTOR;
    162174    end Visualization;
    163175  end VisualXML;
  • testsuite/Makefile

    r4cb8721 re3518437  
    4343device.log \
    4444ffi.log \
    45 conversion.log
     45conversion.log \
     46visualization.log \
    4647
    4748SIMULATIONLOGS = \
     
    645646  $(MAKE) -C openmodelica/conversion -f Makefile test > $@
    646647  @echo $@ done
     648visualization.log: omc-diff
     649  $(MAKE) -C openmodelica/visualization -f Makefile test > $@
     650  @echo $@ done
    647651
    648652failingtest: omc-diff
Note: See TracChangeset for help on using the changeset viewer.