Simulate a Function or Logical Component Containing a Dymola Behavior Using EKL Scripting
You can simulate behavior in a function or logical component using Enterprise Knowledge Language (EKL) scripts. You use the global function SimulateBehaviorModel .
In this task you create an action to simulate a logical component with a Dymola behavior, and you test that the simulation was performed. Note:
To be able to use an object that is located in the same PLM object as the action, we use an RFLVPMLogicalReference input in this scenario.
- From the Compass, click 3D Modeling Apps , and select Engineering Rules Capture.
- From the action bar, click Action .
For full information about actions, see Engineering Rules Capture Users Guide: Working with Actions: Creating an Action. - In the Knowledge Engineering Specification Logical dialog box that appears, click OK.
In the tree, a Knowledge Engineering Specification Logical node appears. - In the Action Editor that appears, do the following:
- To create the input variable to use, In the Argument list, the Name column, double-click <Add new argument> and type myLogicalInput.
- Click the Type box and select, from the list, RFLVPMLogicalReference.
- Click the text pane to enter it.
- Press Enter to go to a new line.
- Type
myLogicalInput->SimulateBehaviorModel(0,6) You have now selected start time 0 and stop time 6 for the simulation. Note:
You can select to use the start time and stop time defined for the model in the simulation setup in Dymola Behavior Modeling. See General Tab.
The full text for this task is now: myLogicalInput->SimulateBehaviorModel(0,6) - Click OK.
The result is: - The action is created.
- In the tree, under the Relations.1 node, the action is displayed with an icon .
- In the tree, under the Relations.1 node, right-click Action.1 and select .
- In the Insert Object dialog box:
- To select reference for the selected myLogicalInput, from the Compass, click the Logical Reference node.
- Click OK.
The result is: - The action is executed, MyModelTest is simulated with start time 0 and stop time 6.
- The Signal Monitor appears to display the result of the simulation.
- To check the result, in the Signal Monitor, right-click a signal and select .
- From the Compass, click 3D Modeling Apps , and select Functional & Logical Design.
Note:
You can now edit and run the action directly without changing app. You can edit the action by double-clicking the action in the tree.
Retrieving the Simulation Results for Further Scripting
You can retrieve the simulation results for further scripting.
In this task, you retrieve the simulation results from the previous simulation, and check that the results were retrieved. You retrieve the simulation results by enhancing the action from previous task.
Before you begin: Do the previous talk.
- To open the action to enhance it, double-click it in the tree.
- In the Action Editor, do the following:
- Press Enter to go to a new line.
- To define a EKL variable result of type List where the retrieved simulation results are stored, enter the line
let result(List) - On a new line, type
myLogicalInput->GetSimulationResult("MainModel.myModelTest.x",result) The first parameter is the path to the variable to retrieve the simulation result for, the second parameter is the variable holding the retrieved result.
- To see all values in the result as a message on the screen, add the line
Message("AllValues",result) The full text for this scenario is now: myLogicalInput->SimulateBehaviorModel(0,6)
let result(List)
myLogicalInput->GetSimulationResult("MainModel.myModelTest.x",result)
Message("AllValues",result)
- Click OK.
The action is enhanced. - In the tree, under the Relations.1 node, right-click Action.1 and select .
- In the Insert Object dialog box:
- To select reference for the selected myLogicalInput, from the Compass, click the Logical Reference node.
- Click OK.
The result is: - The model is again simulated according to the task above.
- The simulation result of the variable x is retrieved and stored in result for further scripting.
- A message appears displaying the content in result.
|