Add tutorial models
This commit is contained in:
parent
a3050e5f1d
commit
070993ac35
17 changed files with 533 additions and 0 deletions
25
examples/tutorial_parallel/policeman.py
Normal file
25
examples/tutorial_parallel/policeman.py
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
from pypdevs.DEVS import *
|
||||
|
||||
class Policeman(AtomicDEVS):
|
||||
def __init__(self):
|
||||
AtomicDEVS.__init__(self, "policeman")
|
||||
self.out = self.addOutPort("output")
|
||||
self.state = "idle"
|
||||
|
||||
def intTransition(self):
|
||||
if self.state == "idle":
|
||||
return "working"
|
||||
elif self.state == "working":
|
||||
return "idle"
|
||||
|
||||
def timeAdvance(self):
|
||||
if self.state == "idle":
|
||||
return 20
|
||||
elif self.state == "working":
|
||||
return 360
|
||||
|
||||
def outputFnc(self):
|
||||
if self.state == "idle":
|
||||
return {self.out: ["manual"]}
|
||||
elif self.state == "working":
|
||||
return {self.out: ["auto"]}
|
||||
Loading…
Add table
Add a link
Reference in a new issue