-
Notifications
You must be signed in to change notification settings - Fork 0
/
test2.py
60 lines (46 loc) · 1.23 KB
/
test2.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
__author__ = 'mohammadreza'
from main import *
class xa (Agent):
def behavior(self,signal,args=None):
signal.attributes["yes ?"] = "yes"
return signal
class ya (Agent):
def behavior(self,signal,args=None):
signal.attributes["yes ?"] = "no"
return signal
class za (Agent):
def behavior(self,signal,args=None):
return signal
x = xa("ali")
y = ya("jj")
z = za("pp")
creator = Emitter()
recorder = Receiver()
class en1 (Environment):
def setEnvironment(self):
creator.sendTo(x)
x.sendTo(y)
y.sendTo(z)
z.sendTo(recorder)
creator.busyTime=0
x.setBusyTime(4)
y.setBusyTime(1)
z.setBusyTime(3)
def getStat(self):
print("terminal signals")
for i in self.receivers :
print(len(i.receivedSingals))
for j in i.receivedSingals :
print(j.attributes["yes ?"])
print("agents process delays")
for j in self.agents :
print(j.processDelay)
print("emitter process delays")
for j in self.emitters :
print(j.processDelay)
en = en1()
en.agents = [x,y,z]
en.emitters = [creator]
en.receivers = [recorder]
en.start()
en.getStat()