Archived OpenModelica forums. Posting is disabled.

Alternative forums include GitHub discussions or StackOverflow (make sure to read the Stack Overflow rules; you need to have well-formed questions)


Forgot password? | Forgot username? | Register

ModelicaML - State Machine Diagrams - Execution

ModelicaML - State Machine Diagrams - Execution

Hi again!

I am starting using step by step the different functionalities of ModelicaML. So far, I suceeded in generating code, simulating and plotting it. Currently, I'd like to use state machine diagram in order to generate Modelica Code from it. However, whenever I put a state Machine Diagram in my model, I got error messages from the OpenModelicaShell.

Here is my model architecture and my steps:

1)  In Eclipse:
- New element > Simulation Model(s) > 'Essai'
- (in my model) New element > Variables (Primitive) > x (Type: ModelicaReal)
-  New Element > Equation Section > 'Mon_equation' >x=sin(time); (Equations)
- New Diagram >  State Machine Diagram > [and I build then the diagram]

http://image.noelshack.com/fichiers/2015/36/1441367638-temp-3.png

- I generate the modelica code

2) In a text editor, I open my modelica code and delete the line 'within ModelicaMLModel;' (because, I don't know how to simulate if I keep this line)

3) In the OpenModelicaShell, I enter:

>> loadFile("c:/Essai.mo")
true
>> simulate(Essai)
[error messages]

 Spoiler Show Spoiler Hide Spoiler
 
record SimulationResult
    resultFile = "",
    simulationOptions = "startTime = 0.0, stopTime = 10.0, numberOfIntervals = 500, tolerance = 1e-006, method = 'dassl', fileNamePrefix = 'Essai', options = '', outputFormat = 'mat', variableFilter = '.*', cflags = '', simflags = ''",
    messages = "Simulation execution failed for model: Essai
assert            | debug   | No system for the symbolic initialization was generated.
assert            | info    | simulation terminated by an assertion at initialization
",
    timeFrontend = 0.06678928467165519,
    timeBackend = 0.01026345527154988,
    timeSimCode = 0.02004940572055946,
    timeTemplates = 0.1281593750043651,
    timeCompile = 5.100906749321492
end SimulationResult;
"[c:/dev/OpenModelica/Compiler/SimCode/SimCodeUtil.mo:6364:9-6364:54:writable] Error: Internal error Inverse Algorithm needs to be solved for {StateMachine0.Region0.negatif.timeAtActivation,StateMachine0.Region0.le_debut.active,StateMachine0.Region0.positif.active,$whenCondition4,$whenCondition5,StateMachine0.Region0.positif.timeAtActivation,$whenCondition1,$whenCondition10,$whenCondition9,StateMachine0.active,StateMachine0.Region0.nul.timeAtActivation,$whenCondition6,$whenCondition7,StateMachine0.timeAtActivation,$whenCondition2,StateMachine0.startBehaviour,StateMachine0.Region0.le_debut.timeAtActivation,StateMachine0.Region0.nul.active,StateMachine0.Region0.negatif.active,$whenCondition8,$whenCondition3,StateMachine0.Region0.numberOfActiveStates} in
algorithm
  StateMachine0.startBehaviour := true;
  if StateMachine0.startBehaviour then
    StateMachine0.active := true;
    StateMachine0.Region0.le_debut.active := true;
  end if;
  $whenCondition1 := StateMachine0.active;
  $whenCondition2 := StateMachine0.selfTransitionActivated;
  if StateMachine0.active then
    StateMachine0.stime := time - StateMachine0.timeAtActivation;
  end if;
  if not StateMachine0.active then
    StateMachine0.stime := 0.0;
  end if;
  $whenCondition3 := StateMachine0.Region0.le_debut.active;
  $whenCondition4 := StateMachine0.Region0.le_debut.selfTransitionActivated;
  if StateMachine0.Region0.le_debut.active then
    StateMachine0.Region0.le_debut.stime := time - StateMachine0.Region0.le_debut.timeAtActivation;
  end if;
  if not StateMachine0.Region0.le_debut.active then
    StateMachine0.Region0.le_debut.stime := 0.0;
  end if;
  $whenCondition5 := StateMachine0.Region0.nul.active;
  $whenCondition6 := StateMachine0.Region0.nul.selfTransitionActivated;
  $whenCondition7 := StateMachine0.Region0.positif.active;
  $whenCondition8 := StateMachine0.Region0.positif.selfTransitionActivated;
  $whenCondition9 := StateMachine0.Region0.negatif.active;
  $whenCondition10 := StateMachine0.Region0.negatif.selfTransitionActivated;
  if StateMachine0.Region0.nul.active then
    StateMachine0.Region0.nul.stime := time - StateMachine0.Region0.nul.timeAtActivation;
  end if;
  if not StateMachine0.Region0.nul.active then
    StateMachine0.Region0.nul.stime := 0.0;
  end if;
  if StateMachine0.Region0.positif.active then
    StateMachine0.Region0.positif.stime := time - StateMachine0.Region0.positif.timeAtActivation;
  end if;
  if not StateMachine0.Region0.positif.active then
    StateMachine0.Region0.positif.stime := 0.0;
  end if;
  if StateMachine0.Region0.negatif.active then
    StateMachine0.Region0.negatif.stime := time - StateMachine0.Region0.negatif.timeAtActivation;
  end if;
  if not StateMachine0.Region0.negatif.active then
    StateMachine0.Region0.negatif.stime := 0.0;
  end if;
  if StateMachine0.Region0.le_debut.active then
    StateMachine0.Region0.le_debut.active := false;
    StateMachine0.Region0.nul.active := true;
  end if;
  if StateMachine0.active then
    if $PRE.StateMachine0.Region0.nul.active then
      if x > 0.0 then
        StateMachine0.Region0.nul.active := false;
        StateMachine0.Region0.positif.active := true;
      end if;
    elseif $PRE.StateMachine0.Region0.positif.active then
      if x < 0.0 then
        StateMachine0.Region0.positif.active := false;
        StateMachine0.Region0.negatif.active := true;
      end if;
    elseif $PRE.StateMachine0.Region0.negatif.active then
      if x > 0.0 then
        StateMachine0.Region0.negatif.active := false;
        StateMachine0.Region0.positif.active := true;
      end if;
    end if;
  end if;
  if not StateMachine0.active then
    StateMachine0.Region0.le_debut.active := false;
    StateMachine0.Region0.nul.active := false;
    StateMachine0.Region0.positif.active := false;
    StateMachine0.Region0.negatif.active := false;
  end if;
  StateMachine0.Region0.numberOfActiveStates := 0;
  if StateMachine0.Region0.nul.active then
    StateMachine0.Region0.numberOfActiveStates := 1 + StateMachine0.Region0.numberOfActiveStates;
  end if;
  if StateMachine0.Region0.positif.active then
    StateMachine0.Region0.numberOfActiveStates := 1 + StateMachine0.Region0.numberOfActiveStates;
  end if;
  if StateMachine0.Region0.negatif.active then
    StateMachine0.Region0.numberOfActiveStates := 1 + StateMachine0.Region0.numberOfActiveStates;
  end if;
  if StateMachine0.Region0.le_debut.active then
    StateMachine0.Region0.numberOfActiveStates := 1 + StateMachine0.Region0.numberOfActiveStates;
  end if;
  if StateMachine0.active then
    assert(not StateMachine0.Region0.numberOfActiveStates < 1, "StateMachine0.Region0 has no active states although the parent state is active!");
    assert(not StateMachine0.Region0.numberOfActiveStates > 1, "StateMachine0.Region0 has multiple active states which are mutually exclusive!");
  end if;
  if not StateMachine0.active then
    assert(StateMachine0.Region0.numberOfActiveStates == 0, "StateMachine0.Region0 has active states although the parent state is not active!");
  end if;
This has not been implemented yet.
[c:/dev/OpenModelica/Compiler/SimCode/SimCodeUtil.mo:6369:7-6369:88:writable] Error: Internal error function createSingleAlgorithmCode failed
[c:/dev/OpenModelica/Compiler/SimCode/SimCodeUtil.mo:3915:9-3915:50:writable] Error: Internal error function createOdeSystem failed for component Algorithm 14 {11, 7, 20, 44, 41, 18, 45, 38, 37, 35, 25, 42, 39, 33, 46, 29, 5, 27, 13, 40, 43, 1}
[c:/dev/OpenModelica/Compiler/SimCode/SimCodeUtil.mo:2600:9-2600:54:writable] Error: Internal error function createEquationsForSystem1 failed for component Algorithm 14 {11, 7, 20, 44, 41, 18, 45, 38, 37, 35, 25, 42, 39, 33, 46, 29, 5, 27, 13, 40, 43, 1}
Error: No system for the symbolic initialization was generated.
"
I managed to simulate and plot my model without the state diagram but my objective is to use state diagram.
Does anyone know a solution to this problem?

Thank you,
Pierre

Edited by: pierreD - Sep-04-15 12:42:20

Re: ModelicaML - State Machine Diagrams - Execution

Hi,

I tried to look up the error messages origins. I identified the following errors:
- "Error: Internal error Inverse Algorithm needs to be solved for"
- "Error: No system for the symbolic initialization was generated."

However, I did not succeed in correcting them modifing the modelica code through a text editor.
Then, I decided to run the generated file in Dymola and everything worked fine.

As the message 'This has not been implemented yet.' may suggest, could these problems be related to the OpenModelica version?  I am using OMShell 1.1 connected to OpenModelica 1.9.2.

Thank you in advance for your help
Pierre

There are 0 guests and 0 other users also viewing this topic
You are here: