List of commits:
Subject Hash Author Date (UTC)
Added all waiting waypoints for 1xx. bbba002738e0a26b085673400c76329d3055d8ba Jan Allersma 2017-11-29 12:00:37
Simulation now working correctly for ID's 101, 102 and 103. 1bc2fb65bb75b3a1f63cf7690472152fe1f32564 Jan Allersma 2017-11-28 16:22:53
Autos kunnen gespawned worden en rijden dan de goede richting op. b36ef1cafeda20d5753b72c6f8e6ac8423c42d95 Jan Allersma 2017-11-26 21:44:39
Last changes before test case 5. 258ba4735dfd2078f8e4f034fffed2bbbb086f2a Jan Allersma 2017-11-22 14:08:37
hallo dit is kapot maar het werkt woehoe 4475c2633e962688c71634d633ac8789524f16cf XCBouke 2017-11-22 13:58:54
It's actually working now! With a gameloop and new icons :D 0b65d450fea6d9f679029f2d6765c7e2d1126cdd Jan Allersma 2017-11-20 22:02:23
Something... Works?? 9a6afe028642b571483fccd6d6bdab10dee68e9c Jan Allersma 2017-11-20 15:14:07
User input for sending msg. cdd1c17cfe8cc73985945aad5878e4891e92eab1 Jan Allersma 2017-11-14 23:05:53
prutsen veel prusten f37cf730ff7a0ad2e08cd769da5f488051ac6dd4 XCBouke 2017-11-09 21:32:15
uglyJsonCode created online with Bitbucket ed6c9c541947ec64827b6e80ed959feb1b0f9b85 XCBouke 2017-11-09 14:29:36
Connectie created online with Bitbucket (send en recieve in 1) b484aff52014ff8d1dbaf8387cf1479cf236f33a XCBouke 2017-11-09 14:28:29
Ready for test case 3. Also BIG cleanup. bda906e19e3b82fb91df53eb2208e8def822c6b5 Jan Allersma 2017-11-05 21:38:16
test case 2 fix(?) dd86d637d166707a31b644dad711c7a9e39dbc8d Jan Allersma 2017-11-04 10:55:03
Test case 2 9ea6eadbd85dde0e9522068718092b1f0e9b49f0 Jan Allersma 2017-10-29 22:37:57
Added threading. 4540fe1669c9e145e613edf2459031e7bec500ea Jan Allersma 2017-10-29 20:47:49
Code for testing 16/10/17. Use simulatie/rabbit/combination.py mainly. c5e87d7fe5abbcd3316b1538a0d647fd23faa59f Jan Allersma 2017-10-15 19:13:23
Added more paths. Some of them are WIP. 03ad1039e22bd1ebd301bda99e78f38239a15077 Jan Allersma 2017-09-21 14:40:44
Added paths... 5561d21918f048a40ca9686112638a48805917e3 Jan Allersma 2017-09-21 13:06:43
Added first paths of crossroad. Also added reference of crossroad. 43a5ddf291e38b47bad02a92af58839d86f9d449 Jan Allersma 2017-09-21 12:21:53
Added first paths of crossroad. Also added reference of crossroad. bb687a8152231d0c89fed827baefcfbf067be90c Jan Allersma 2017-09-21 12:21:11
Commit bbba002738e0a26b085673400c76329d3055d8ba - Added all waiting waypoints for 1xx.
Author: Jan Allersma
Author date (UTC): 2017-11-29 12:00
Committer name: Jan Allersma
Committer date (UTC): 2017-11-29 12:00
Parent(s): 1bc2fb65bb75b3a1f63cf7690472152fe1f32564
Signer:
Signing key:
Signing status: N
Tree: adb57684b2fa2480b5801f47fbee99caef4c06e8
File Lines added Lines deleted
simulatie/connection.py 54 3
simulatie/pyg.py 6 4
simulatie/reciever.py 0 34
simulatie/sender.py 0 48
simulatie/traffic.py 2 48
simulatie/trafficModel.py 38 10
File simulatie/connection.py changed (mode: 100644) (index eda78d6..e3018ee)
1 1 import pika import pika
2 2 import threading import threading
3 import json
3 4
4 5 import model import model
5 6 import pyg import pyg
6 7
8 import time
9
10 # lights = [[id, amountOfVehicles, DirRequests]]
11 lights = [
12 [101, 0, None],
13 [102, 0, None],
14 [103, 0, None],
15 [104, 0, None],
16 [105, 0, None],
17 [106, 0, None],
18 [107, 0, None],
19 [108, 0, None],
20 [109, 0, None],
21 [110, 0, None],
22 [201, 0, None],
23 [301, 0, None],
24 [302, 0, None],
25 [303, 0, None],
26 [304, 0, None],
27 [305, 0, None],
28 [401, 0, None],
29 [402, 0, None],
30 [403, 0, None],
31 [404, 0, None],
32 [405, 0, None],
33 [406, 0, None],
34 [501, 0, None],
35 [601, 0, None]
36 ]
37
38 msg = ''
39
7 40 creds = pika.PlainCredentials(model.uname, model.passwd) creds = pika.PlainCredentials(model.uname, model.passwd)
8 41 SendConnection = pika.BlockingConnection(pika.ConnectionParameters(host=model.host, virtual_host=model.vhost, credentials=creds)) SendConnection = pika.BlockingConnection(pika.ConnectionParameters(host=model.host, virtual_host=model.vhost, credentials=creds))
9 42 RecieveConnection = pika.BlockingConnection(pika.ConnectionParameters(host=model.host, virtual_host=model.vhost, credentials=creds)) RecieveConnection = pika.BlockingConnection(pika.ConnectionParameters(host=model.host, virtual_host=model.vhost, credentials=creds))
 
... ... def callback(ch, method, prop, body):
20 53 print(model.sendQueue + ': status recieved!') print(model.sendQueue + ': status recieved!')
21 54 pyg.update(body.decode('utf-8', 'ignore')) pyg.update(body.decode('utf-8', 'ignore'))
22 55
23 def sendMsg(msg):
56 def sendMsg(msg, index, amount):
24 57 channel.basic_publish ( channel.basic_publish (
25 58 exchange='', exchange='',
26 59 routing_key=model.sendQueue, routing_key=model.sendQueue,
27 60 body=msg body=msg
28 61 ) )
29 pyg.spawnVehicle(0)
62
30 63 print('Msg sent.') print('Msg sent.')
31
64
65 for i in range(0, amount):
66 pyg.spawnVehicle(index)
67 time.sleep(2)
68
69 def update(index, amountOfCars, dirRequests):
70 lights[index][1] = amountOfCars
71 lights[index][2] = dirRequests
72
73 msg = json.dumps({
74 "TrafficUpdate": {
75 "LightId": lights[index][0],
76 "Count": lights[index][1],
77 "DirectionRequests": lights[index][2]
78 }
79 }, sort_keys=True, indent=4, separators=(',',': '))
80
81 sendMsg(msg, index, amountOfCars)
82
32 83 def listen(): def listen():
33 84 print('Waiting for a sign..') print('Waiting for a sign..')
34 85 recieve.basic_consume ( recieve.basic_consume (
File simulatie/pyg.py changed (mode: 100644) (index 0f9270e..4dbb9e0)
... ... import time
6 6 import json import json
7 7
8 8 import trafficModel as tm import trafficModel as tm
9 import connection
9 10
10 11 vehicles = list() vehicles = list()
11 12
 
... ... class Vehicle(object):
74 75 self.wp += 1 self.wp += 1
75 76 print("W: " + str(self.wp) + " / " + str(len(tm.queues[self.trafficId]))) print("W: " + str(self.wp) + " / " + str(len(tm.queues[self.trafficId])))
76 77
77 elif self.wp < len(tm.waypoints[self.trafficId]):
78 elif not self.waiting and self.wp < len(tm.waypoints[self.trafficId]):
78 79 self.goto(tm.waypoints[self.trafficId][self.wp][0], tm.waypoints[self.trafficId][self.wp][1]) self.goto(tm.waypoints[self.trafficId][self.wp][0], tm.waypoints[self.trafficId][self.wp][1])
79 80 self.wp += 1 self.wp += 1
80 81 print("NW: " + str(self.wp) + " / " + str(len(tm.waypoints[self.trafficId]))) print("NW: " + str(self.wp) + " / " + str(len(tm.waypoints[self.trafficId])))
 
... ... class Vehicle(object):
85 86 if tm.lights[self.trafficId]["Status"] != 0 and self.waiting and self.wp <= len(tm.queues[self.trafficId]): if tm.lights[self.trafficId]["Status"] != 0 and self.waiting and self.wp <= len(tm.queues[self.trafficId]):
86 87 self.waiting = False self.waiting = False
87 88 self.wp = 0 self.wp = 0
89 connection.update(self.trafficId, 0, None)
88 90 self.update() self.update()
89 91
90 92 clock = pygame.time.Clock() clock = pygame.time.Clock()
 
... ... def spawnVehicle(index):
118 120
119 121 # Mainloop # Mainloop
120 122 def gameloop(): def gameloop():
121 #id = 0
122 #car = Vehicle(tm.queues[id][0][0],tm.queues[id][0][1],id)
123 id = 5
124 car = Vehicle(tm.queues[id][0][0],tm.queues[id][0][1],id)
123 125 while True: while True:
124 126 clock.tick(60) clock.tick(60)
125 127 for event in pygame.event.get(): for event in pygame.event.get():
 
... ... def gameloop():
129 131 screen.blit(bg, bg.get_rect()) screen.blit(bg, bg.get_rect())
130 132 for vehicle in vehicles: for vehicle in vehicles:
131 133 vehicle.trafficCheck() vehicle.trafficCheck()
132 #car.trafficCheck()
134 car.trafficCheck()
133 135 #screen.blit(car.auto, car.rect) #screen.blit(car.auto, car.rect)
134 136 pygame.display.flip() pygame.display.flip()
File simulatie/reciever.py deleted (index dcd4cde..0000000)
1 #!/usr/bin/env python
2
3 import pika
4 import model
5
6 creds = pika.PlainCredentials(model.uname, model.passwd)
7 connection = pika.BlockingConnection(pika.ConnectionParameters(host=model.host, virtual_host=model.vhost, credentials=creds))
8 channel = connection.channel()
9
10 channel.exchange_declare(
11 exchange='1234',
12 exchange_type='direct'
13 )
14
15 result = channel.queue_declare(exclusive=True)
16 queuename = result.method.queue
17
18 channel.queue_bind(
19 exchange='1234',
20 queue=queuename,
21 routing_key=model.vhost
22 )
23
24 def callback(ch, method, prop, body):
25 print('%r ontvangen' % body)
26
27 channel.basic_consume (
28 callback,
29 queue=queuename,
30 no_ack=True
31 )
32
33 print('Waiting for a sign..')
34 channel.start_consuming()
File simulatie/sender.py deleted (index 0b2e6e4..0000000)
1 #!/usr/bin/env python
2
3 import pika
4 #import threading
5 import model
6
7 creds = pika.PlainCredentials(model.uname, model.passwd)
8 connection = pika.BlockingConnection(pika.ConnectionParameters(host=model.host, virtual_host=model.vhost, credentials=creds))
9 channel = connection.channel()
10
11 channel.queue_declare(
12 queue=model.c,
13 auto_delete=True
14 )
15
16 def start():
17 channel.basic_consume(
18 consumer_callback=cons_callb,
19 queue=model.c
20 );
21
22 channel.start_consuming()
23
24 def cons_callb(self, channel, method, properties, body):
25 content = body.decode('utf-8', 'ignore')
26 print(content)
27
28 #channel.exchange_declare(
29 # exchange='1234',
30 # exchange_type='direct'
31 #)
32
33 channel.basic_publish (
34 exchange='',
35 routing_key=model.vhost,
36 properties=pika.BasicProperties(correlation_id=properties.correlation_id),
37 body='Simulator ' + model.vhost
38 )
39
40 cannel.basic_ack(delivery_tag=method.delivery_tag)
41
42 print('Ack sent.')
43
44 #connection.close()
45 start()
46 #thread = threading.Thread(target=start)
47 #thread.start()
48 #thread.join(0)
File simulatie/traffic.py changed (mode: 100644) (index af2c9a5..ab50a6d)
1 import json
2 import time
3 1 import sys import sys
4 2
5 3 import connection import connection
6 4
7 # lights = [[id, amountOfVehicles, DirRequests]]
8 lights = [
9 [101, 0, None],
10 [102, 0, None],
11 [103, 0, None],
12 [104, 0, None],
13 [105, 0, None],
14 [106, 0, None],
15 [107, 0, None],
16 [108, 0, None],
17 [109, 0, None],
18 [110, 0, None],
19 [201, 0, None],
20 [301, 0, None],
21 [302, 0, None],
22 [303, 0, None],
23 [304, 0, None],
24 [305, 0, None],
25 [401, 0, None],
26 [402, 0, None],
27 [403, 0, None],
28 [404, 0, None],
29 [405, 0, None],
30 [406, 0, None],
31 [501, 0, None],
32 [601, 0, None]
33 ]
34
35 msg = ''
36
37 def update(index, amountOfCars, dirRequests):
38 lights[index][1] = amountOfCars
39 lights[index][2] = dirRequests
40
41 msg = json.dumps({
42 "TrafficUpdate": {
43 "LightId": lights[index][0],
44 "Count": lights[index][1],
45 "DirectionRequests": lights[index][2]
46 }
47 }, sort_keys=True, indent=4, separators=(',',': '))
48
49 connection.sendMsg(msg)
50
51 5 while True: while True:
52 6 ui = raw_input() ui = raw_input()
53 7 ui = list(ui) ui = list(ui)
54 print([lights[int(ui[0])], int(ui[1]), None])
55 update(int(ui[0]), int(ui[1]), None)
8 print([connection.lights[int(ui[0])], int(ui[1]), None])
9 connection.update(int(ui[0]), int(ui[1]), None)
56 10
57 11 sys.exit() sys.exit()
File simulatie/trafficModel.py changed (mode: 100644) (index 118f34e..dc21a1d)
... ... lights = [
150 150 ] ]
151 151
152 152 queues = [ queues = [
153 [ #101
153 [ # 101
154 154 [300, -50], [300, -50],
155 155 [300, 0], [300, 0],
156 156 [300, 140] [300, 140]
157 157 ], ],
158 [ #102
158 [ # 102
159 159 [350, -50], [350, -50],
160 160 [350, 0], [350, 0],
161 161 [350, 140] [350, 140]
162 162 ], ],
163 [ #103
163 [ # 103
164 164 [400, -50], [400, -50],
165 165 [400, 0], [400, 0],
166 166 [400, 140] [400, 140]
167 ],
168 [ # 104
169 [850, 350],
170 [650, 350]
171 ],
172 [ # 105
173 [850, 400],
174 [650, 400]
175 ],
176 [ # 106A
177 [470, 850],
178 [470, 690]
179 ],
180 [ # 107
181 [430, 850],
182 [470, 690]
183 ],
184 [ #108
185 [-50, 450],
186 [150, 450]
187 ],
188 [ # 109
189 [-50, 400],
190 [150, 400]
191 ],
192 [ # 110
193 [-50, 350],
194 [150, 350]
167 195 ] ]
168 196 ] ]
169 197
 
... ... waypoints = [
189 217 [850, 450] [850, 450]
190 218 ], ],
191 219 [ #104 [ #104
192 [850, 350],
220 #[850, 350],
193 221 [500, 350], [500, 350],
194 222 [490, -50] [490, -50]
195 223 ], ],
196 224 [ #105 [ #105
197 [850, 400],
225 #[850, 400],
198 226 [500, 400], [500, 400],
199 227 [300, 300], [300, 300],
200 228 [-50, 300] [-50, 300]
201 229 ], ],
202 230 [ # 106A [ # 106A
203 [470, 850],
231 #[470, 850],
204 232 [470, 500], [470, 500],
205 233 [490, -50] [490, -50]
206 234 ], ],
207 235 [ # 107 [ # 107
208 [430, 850],
236 #[430, 850],
209 237 [420, 400], [420, 400],
210 238 [300, 300], [300, 300],
211 239 [-50, 300] [-50, 300]
212 240 ], ],
213 241 [ # 108 [ # 108
214 [-50, 450],
242 #[-50, 450],
215 243 [310, 450], [310, 450],
216 244 [310, 850] [310, 850]
217 245 ], ],
218 246 [ # 109 [ # 109
219 [-50, 400],
247 #[-50, 400],
220 248 [310, 400], [310, 400],
221 249 [500, 450], [500, 450],
222 250 [850, 450] [850, 450]
223 251 ], ],
224 252 [ # 110 [ # 110
225 [-50, 350],
253 #[-50, 350],
226 254 [450, 350], [450, 350],
227 255 [490, -50] [490, -50]
228 256 ] ]
Hints:
Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://rocketgit.com/user/kapstok/NHL-SoftDev

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@ssh.rocketgit.com/user/kapstok/NHL-SoftDev

Clone this repository using git:
git clone git://git.rocketgit.com/user/kapstok/NHL-SoftDev

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a merge request:
... clone the repository ...
... make some changes and some commits ...
git push origin main