1.work flow:
2.Steps:
Initialize the model by default function or customize function
Set the termination conditions including end_time conditions or end_state conditions
Simulate the model until termination conditions satisfied
Terminate the experiment
Reset time or reset time and initialization
1.Functions added in Simulator:
2.Changes in Model:
3.Changes in DEVS:
in class CoupledDEVS,Function connectPorts is extended by adding "func".In Experiment.py:
Here the model which will be simulated is "trafficSystem". The submodel trafficLight will start in "green" state at time 0.5 and submodel policeman will start by default.
In the first round,the experiment will stop at time 500.Before that there will be two input events coming at time 60 and time 150.
In the second round, which is started by reset, with policeman will be "working" at time 6. Stop at time 650 or when state become "green"
the definations of all the termCondition functions.
1.Results:
Result2.Analysis:
At time 60, the first input event arrived. As we have connect the input port of trafficSystem to the input port of policeman and the Z-function of them is to opposite the coming signal, so policeman got the signal "towork" and was going to change at time 160
At time 150, the other input event arrived, so policeman model discarded the former schedule at time 160, implement input event 150, and going to chage state to idle at time 350
So at time 350, policeman state changed and then trafficLight got the interrupt signal from policeman.At last, the first round stop at end-time 500.
the second round started at time 6 and stopped at state "green" as we expected.
1.Background:
PyDEVS2.source code:
3. test case:TrafficSystem
Model.py Experiment.py