Changes for page Simulation (KiSim)
Last modified by Richard Kreissig on 2023/09/14 11:07
Summary
-
Page properties (1 modified, 0 added, 0 removed)
-
Objects (1 modified, 0 added, 0 removed)
Details
- Page properties
-
- Content
-
... ... @@ -171,7 +171,7 @@ 171 171 String, the shell command that is used to start the process 172 172 )))|(% colspan="1" %)(% colspan="1" %) 173 173 ((( 174 -python "${executable_path}" 174 +python -i "${executable_path}" 175 175 )))|(% colspan="1" %)(% colspan="1" %) 176 176 ((( 177 177 The shell command to start the executable ... ... @@ -592,6 +592,7 @@ 592 592 593 593 There are also additional fields for variables than their value. However these only need to be communicated once after the initialization of the model and are explained in the table below. 594 594 595 +(% class="wrapped" %) 595 595 |=((( 596 596 Field Name 597 597 )))|=((( ... ... @@ -638,6 +638,7 @@ 638 638 Bitmask, that determines how the variable is used in the source model's interface (e.g. input, output, internal, other). 639 639 A bitmask has been choosen because a mixture of a variables interface types is possible (e.g. input, output, input output) 640 640 642 +(% class="wrapped" %) 641 641 |=((( 642 642 Interface Type 643 643 )))|=((( ... ... @@ -693,10 +693,36 @@ 693 693 6 694 694 ))) 695 695 696 -Not that internal is intended for variables that are neither input nor output but still part of the source model, in contrast to variables that are created in the compilation (e.g. register flags). 698 +Note that internal is intended for variables that are neither input nor output but still part of the source model, in contrast to variables that are created in the compilation (e.g. register flags). 697 697 Anyway an input and output is also a internal variable normally. 698 698 ))) 699 699 700 700 === Python Example === 701 701 702 -\\ 704 +The following shows a tiny python script, that will write a Data Pool containing an output variable x to stdout. 705 + 706 +{{code title="prog.py"}} 707 +import sys 708 + 709 +x = 0 710 +while True: 711 + json = """{"x":{"value":""" + str(x) + ""","interface":2}}""" 712 + print(json) # Send output to simulation 713 + raw_input("") # Wait for input from simulation 714 + x = x + 1 715 + 716 + 717 +{{/code}} 718 + 719 +This script can be executed from within KIELER to start a simulation because it uses the JSON communication on stdin and stdout. Note however that the input coming from the simulation is not handled in the script. An example kisim configuration to start such a scipt is given below. 720 + 721 +{{code}} 722 +configure sim A { 723 + executable: prog.py 724 + command: "python -i ${executable_path}" 725 +} 726 + 727 +execution { 728 + write sim A 729 +} 730 +{{/code}}
- Confluence.Code.ConfluencePageClass[0]
-
- Id
-
... ... @@ -1,1 +1,1 @@ 1 -3326006 31 +33260106 - URL
-
... ... @@ -1,1 +1,1 @@ 1 -https://rtsys.informatik.uni-kiel.de/confluence//wiki/spaces/KIELER/pages/3326006 3/V2 Simulation1 +https://rtsys.informatik.uni-kiel.de/confluence//wiki/spaces/KIELER/pages/33260106/V2 Simulation