Commit 86dd6e43d3fbd08ebfb26b00074b667e956af938
1 parent
d5611ba1
Exists in
master
and in
1 other branch
Simulator script finished
Showing
25 changed files
with
836 additions
and
85 deletions
Show diff stats
... | ... | @@ -0,0 +1,13 @@ |
1 | +{ | |
2 | + "SCIENTIFIC_PROGRAMS" : {"quantity" : -1, "content" : [{"id" : 5, "name" : "Sim1", "desc" : "Sim1", "quota": 20, "priority" : 3}, {"id" : 6, "name" : "Sim2", "quota" : 20, priority : 4}]}, | |
3 | + "USER_LEVELS" : {"quantity" : 5, "content" : []}, | |
4 | + "PYROS_USERS" : {"quantity": 5, "content" : []}, | |
5 | + "AUTH_USERS" : {"quantity": 5, "content" : []}, | |
6 | + "REQUESTS" : {"quantity" : 10, "content" : []}, | |
7 | + "SEQUENCES" : {"quantity" : [1, 2, 3], "content" : []}, | |
8 | + "ALBUMS" : {"quantity" : [1, 2], "content" : [{"sequence" : 1}]}, | |
9 | + "PLANS" : {"quantity" : [1, 2, 3, 4], "content" : []}, | |
10 | + "DETECTORS" : {"quantity" : -1, "existing" : true, "id" : [1, 2], "content" : []}, | |
11 | + "TELESCOPES" : {"quantity" : -1, "existing" : true, "id" : [1], "content" : []}, | |
12 | + "DEVICES" : {"quantity" : 0, "existing" : false, "content" : []} | |
13 | +} | ... | ... |
... | ... | @@ -0,0 +1,543 @@ |
1 | +[ | |
2 | +{ | |
3 | + "model": "common.country", | |
4 | + "pk": 1, | |
5 | + "fields": { | |
6 | + "name": "France", | |
7 | + "desc": "", | |
8 | + "quota": null | |
9 | + } | |
10 | +}, | |
11 | +{ | |
12 | + "model": "common.detector", | |
13 | + "pk": 1, | |
14 | + "fields": { | |
15 | + "device": 1, | |
16 | + "telescope": 1, | |
17 | + "status": "", | |
18 | + "nb_photo_x": null, | |
19 | + "nb_photo_y": null, | |
20 | + "photo_size_x": null, | |
21 | + "photo_size_y": null, | |
22 | + "has_shutter": false, | |
23 | + "equivalent_foc_len": "", | |
24 | + "acq_start": null, | |
25 | + "acq_stop": null, | |
26 | + "check_temp": null, | |
27 | + "gain": null, | |
28 | + "readout_noise": null, | |
29 | + "readout_time": null, | |
30 | + "idcam_readout_mode": null | |
31 | + } | |
32 | +}, | |
33 | +{ | |
34 | + "model": "common.detector", | |
35 | + "pk": 2, | |
36 | + "fields": { | |
37 | + "device": 7, | |
38 | + "telescope": 1, | |
39 | + "status": "", | |
40 | + "nb_photo_x": null, | |
41 | + "nb_photo_y": null, | |
42 | + "photo_size_x": null, | |
43 | + "photo_size_y": null, | |
44 | + "has_shutter": false, | |
45 | + "equivalent_foc_len": "", | |
46 | + "acq_start": null, | |
47 | + "acq_stop": null, | |
48 | + "check_temp": null, | |
49 | + "gain": null, | |
50 | + "readout_noise": null, | |
51 | + "readout_time": null, | |
52 | + "idcam_readout_mode": null | |
53 | + } | |
54 | +}, | |
55 | +{ | |
56 | + "model": "common.device", | |
57 | + "pk": 1, | |
58 | + "fields": { | |
59 | + "name": "Cagire", | |
60 | + "desc": "", | |
61 | + "created": "2016-05-13T11:49:49Z", | |
62 | + "updated": "2016-05-13T11:49:49Z", | |
63 | + "is_online": false, | |
64 | + "status": "", | |
65 | + "maintenance_date": null | |
66 | + } | |
67 | +}, | |
68 | +{ | |
69 | + "model": "common.device", | |
70 | + "pk": 2, | |
71 | + "fields": { | |
72 | + "name": "First infrared filter", | |
73 | + "desc": "", | |
74 | + "created": "2016-05-13T11:49:56Z", | |
75 | + "updated": "2016-05-13T11:49:56Z", | |
76 | + "is_online": false, | |
77 | + "status": "", | |
78 | + "maintenance_date": null | |
79 | + } | |
80 | +}, | |
81 | +{ | |
82 | + "model": "common.device", | |
83 | + "pk": 3, | |
84 | + "fields": { | |
85 | + "name": "First visible filter", | |
86 | + "desc": "", | |
87 | + "created": "2016-05-13T11:50:02Z", | |
88 | + "updated": "2016-05-13T11:50:02Z", | |
89 | + "is_online": false, | |
90 | + "status": "", | |
91 | + "maintenance_date": null | |
92 | + } | |
93 | +}, | |
94 | +{ | |
95 | + "model": "common.device", | |
96 | + "pk": 4, | |
97 | + "fields": { | |
98 | + "name": "Second infrared filter", | |
99 | + "desc": "", | |
100 | + "created": "2016-05-13T11:50:07Z", | |
101 | + "updated": "2016-05-13T11:50:07Z", | |
102 | + "is_online": false, | |
103 | + "status": "", | |
104 | + "maintenance_date": null | |
105 | + } | |
106 | +}, | |
107 | +{ | |
108 | + "model": "common.device", | |
109 | + "pk": 5, | |
110 | + "fields": { | |
111 | + "name": "Second visible filter", | |
112 | + "desc": "", | |
113 | + "created": "2016-05-13T11:50:11Z", | |
114 | + "updated": "2016-05-13T11:50:11Z", | |
115 | + "is_online": false, | |
116 | + "status": "", | |
117 | + "maintenance_date": null | |
118 | + } | |
119 | +}, | |
120 | +{ | |
121 | + "model": "common.device", | |
122 | + "pk": 6, | |
123 | + "fields": { | |
124 | + "name": "Telescope", | |
125 | + "desc": "", | |
126 | + "created": "2016-05-13T11:50:14Z", | |
127 | + "updated": "2016-05-13T11:50:14Z", | |
128 | + "is_online": false, | |
129 | + "status": "", | |
130 | + "maintenance_date": null | |
131 | + } | |
132 | +}, | |
133 | +{ | |
134 | + "model": "common.device", | |
135 | + "pk": 7, | |
136 | + "fields": { | |
137 | + "name": "Visible camera", | |
138 | + "desc": "", | |
139 | + "created": "2016-05-13T11:50:17Z", | |
140 | + "updated": "2016-05-13T11:50:17Z", | |
141 | + "is_online": false, | |
142 | + "status": "", | |
143 | + "maintenance_date": null | |
144 | + } | |
145 | +}, | |
146 | +{ | |
147 | + "model": "common.device", | |
148 | + "pk": 8, | |
149 | + "fields": { | |
150 | + "name": "Cagire FW", | |
151 | + "desc": "", | |
152 | + "created": "2016-06-28T13:28:28Z", | |
153 | + "updated": "2016-06-28T13:28:28Z", | |
154 | + "is_online": false, | |
155 | + "status": "", | |
156 | + "maintenance_date": null | |
157 | + } | |
158 | +}, | |
159 | +{ | |
160 | + "model": "common.device", | |
161 | + "pk": 9, | |
162 | + "fields": { | |
163 | + "name": "Visible Camera FW", | |
164 | + "desc": "", | |
165 | + "created": "2016-06-28T13:28:46Z", | |
166 | + "updated": "2016-06-28T13:28:46Z", | |
167 | + "is_online": false, | |
168 | + "status": "", | |
169 | + "maintenance_date": null | |
170 | + } | |
171 | +}, | |
172 | +{ | |
173 | + "model": "common.filter", | |
174 | + "pk": 1, | |
175 | + "fields": { | |
176 | + "device": 2, | |
177 | + "filter_wheel": 2, | |
178 | + "category": "", | |
179 | + "transmission_curve_doc": "" | |
180 | + } | |
181 | +}, | |
182 | +{ | |
183 | + "model": "common.filter", | |
184 | + "pk": 2, | |
185 | + "fields": { | |
186 | + "device": 4, | |
187 | + "filter_wheel": 2, | |
188 | + "category": "", | |
189 | + "transmission_curve_doc": "" | |
190 | + } | |
191 | +}, | |
192 | +{ | |
193 | + "model": "common.filter", | |
194 | + "pk": 3, | |
195 | + "fields": { | |
196 | + "device": 3, | |
197 | + "filter_wheel": 2, | |
198 | + "category": "", | |
199 | + "transmission_curve_doc": "" | |
200 | + } | |
201 | +}, | |
202 | +{ | |
203 | + "model": "common.filter", | |
204 | + "pk": 4, | |
205 | + "fields": { | |
206 | + "device": 5, | |
207 | + "filter_wheel": 2, | |
208 | + "category": "", | |
209 | + "transmission_curve_doc": "" | |
210 | + } | |
211 | +}, | |
212 | +{ | |
213 | + "model": "common.filterwheel", | |
214 | + "pk": 1, | |
215 | + "fields": { | |
216 | + "device": 8, | |
217 | + "detector": 1 | |
218 | + } | |
219 | +}, | |
220 | +{ | |
221 | + "model": "common.filterwheel", | |
222 | + "pk": 2, | |
223 | + "fields": { | |
224 | + "device": 9, | |
225 | + "detector": 2 | |
226 | + } | |
227 | +}, | |
228 | +{ | |
229 | + "model": "common.scientificprogram", | |
230 | + "pk": 1, | |
231 | + "fields": { | |
232 | + "name": "GRB", | |
233 | + "desc": "", | |
234 | + "quota": 9999.0, | |
235 | + "priority": 0, | |
236 | + "pyros_users": [ | |
237 | + 5 | |
238 | + ] | |
239 | + } | |
240 | +}, | |
241 | +{ | |
242 | + "model": "common.strategyobs", | |
243 | + "pk": 1, | |
244 | + "fields": { | |
245 | + "name": "strat1", | |
246 | + "desc": "", | |
247 | + "xml_file": "strat1.xml", | |
248 | + "is_default": false | |
249 | + } | |
250 | +}, | |
251 | +{ | |
252 | + "model": "common.strategyobs", | |
253 | + "pk": 2, | |
254 | + "fields": { | |
255 | + "name": "strat2", | |
256 | + "desc": "", | |
257 | + "xml_file": "strat2.xml", | |
258 | + "is_default": false | |
259 | + } | |
260 | +}, | |
261 | +{ | |
262 | + "model": "common.strategyobs", | |
263 | + "pk": 3, | |
264 | + "fields": { | |
265 | + "name": "strat_unittest", | |
266 | + "desc": "", | |
267 | + "xml_file": "strat_unittest.xml", | |
268 | + "is_default": true | |
269 | + } | |
270 | +}, | |
271 | +{ | |
272 | + "model": "common.telescope", | |
273 | + "pk": 1, | |
274 | + "fields": { | |
275 | + "device": 6, | |
276 | + "mount_type": "", | |
277 | + "diameter": null, | |
278 | + "status": "", | |
279 | + "latitude": null, | |
280 | + "longitude": null, | |
281 | + "sens": "", | |
282 | + "altitude": null, | |
283 | + "readout_time": null, | |
284 | + "slew_time": null, | |
285 | + "slew_dead": null, | |
286 | + "slew_rate_max": null, | |
287 | + "horizon_type": "", | |
288 | + "horizon_def": null, | |
289 | + "lim_dec_max": null, | |
290 | + "lim_dec_min": null, | |
291 | + "lim_ha_rise": null, | |
292 | + "lim_ha_set": null, | |
293 | + "address": "", | |
294 | + "night_elev_sun": null, | |
295 | + "mpc_code": "" | |
296 | + } | |
297 | +}, | |
298 | +{ | |
299 | + "model": "common.userlevel", | |
300 | + "pk": 1, | |
301 | + "fields": { | |
302 | + "name": "Developer", | |
303 | + "desc": "", | |
304 | + "priority": 0, | |
305 | + "quota": 9999.0 | |
306 | + } | |
307 | +}, | |
308 | +{ | |
309 | + "model": "common.version", | |
310 | + "pk": 1, | |
311 | + "fields": { | |
312 | + "module_name": "Scheduler", | |
313 | + "version": "0.1", | |
314 | + "created": "2016-06-23T14:04:48Z", | |
315 | + "updated": "2016-06-23T14:04:48Z" | |
316 | + } | |
317 | +}, | |
318 | +{ | |
319 | + "model": "common.version", | |
320 | + "pk": 2, | |
321 | + "fields": { | |
322 | + "module_name": "Dashboard", | |
323 | + "version": "0.1", | |
324 | + "created": "2016-06-23T14:04:48Z", | |
325 | + "updated": "2016-06-23T14:04:48Z" | |
326 | + } | |
327 | +}, | |
328 | +{ | |
329 | + "model": "common.version", | |
330 | + "pk": 3, | |
331 | + "fields": { | |
332 | + "module_name": "Observation Manager", | |
333 | + "version": "0.1", | |
334 | + "created": "2016-06-23T14:04:48Z", | |
335 | + "updated": "2016-06-23T14:04:48Z" | |
336 | + } | |
337 | +}, | |
338 | +{ | |
339 | + "model": "common.version", | |
340 | + "pk": 4, | |
341 | + "fields": { | |
342 | + "module_name": "Routine Manager", | |
343 | + "version": "0.1", | |
344 | + "created": "2016-06-23T14:04:48Z", | |
345 | + "updated": "2016-06-23T14:04:48Z" | |
346 | + } | |
347 | +}, | |
348 | +{ | |
349 | + "model": "common.version", | |
350 | + "pk": 5, | |
351 | + "fields": { | |
352 | + "module_name": "Alert Manager", | |
353 | + "version": "0.1", | |
354 | + "created": "2016-06-23T14:04:48Z", | |
355 | + "updated": "2016-06-23T14:04:48Z" | |
356 | + } | |
357 | +}, | |
358 | +{ | |
359 | + "model": "common.version", | |
360 | + "pk": 6, | |
361 | + "fields": { | |
362 | + "module_name": "Monitoring", | |
363 | + "version": "0.1", | |
364 | + "created": "2016-06-23T14:04:48Z", | |
365 | + "updated": "2016-06-23T14:04:48Z" | |
366 | + } | |
367 | +}, | |
368 | +{ | |
369 | + "model": "common.version", | |
370 | + "pk": 7, | |
371 | + "fields": { | |
372 | + "module_name": "User Manager", | |
373 | + "version": "0.1", | |
374 | + "created": "2016-06-23T14:04:48Z", | |
375 | + "updated": "2016-06-23T14:04:48Z" | |
376 | + } | |
377 | +}, | |
378 | +{ | |
379 | + "model": "common.version", | |
380 | + "pk": 8, | |
381 | + "fields": { | |
382 | + "module_name": "Analyzer", | |
383 | + "version": "0.1", | |
384 | + "created": "2016-06-23T14:04:48Z", | |
385 | + "updated": "2016-06-23T14:04:48Z" | |
386 | + } | |
387 | +}, | |
388 | +{ | |
389 | + "model": "common.version", | |
390 | + "pk": 9, | |
391 | + "fields": { | |
392 | + "module_name": "Majordome", | |
393 | + "version": "0.1", | |
394 | + "created": "2016-06-23T14:04:48Z", | |
395 | + "updated": "2016-06-23T14:04:48Z" | |
396 | + } | |
397 | +}, | |
398 | +{ | |
399 | + "model": "common.version", | |
400 | + "pk": 10, | |
401 | + "fields": { | |
402 | + "module_name": "Majordome", | |
403 | + "version": "0.2", | |
404 | + "created": "2016-06-28T10:50:32Z", | |
405 | + "updated": "2016-06-28T10:50:32Z" | |
406 | + } | |
407 | +}, | |
408 | +{ | |
409 | + "model": "common.version", | |
410 | + "pk": 11, | |
411 | + "fields": { | |
412 | + "module_name": "Majordome", | |
413 | + "version": "0.1.4", | |
414 | + "created": "2016-07-20T13:44:29Z", | |
415 | + "updated": "2016-07-20T13:44:29Z" | |
416 | + } | |
417 | +}, | |
418 | +{ | |
419 | + "model": "common.version", | |
420 | + "pk": 12, | |
421 | + "fields": { | |
422 | + "module_name": "Alert Manager", | |
423 | + "version": "0.2.3", | |
424 | + "created": "2016-07-20T13:44:29Z", | |
425 | + "updated": "2016-07-20T13:44:29Z" | |
426 | + } | |
427 | +}, | |
428 | +{ | |
429 | + "model": "common.version", | |
430 | + "pk": 13, | |
431 | + "fields": { | |
432 | + "module_name": "Dashboard", | |
433 | + "version": "0.1.1", | |
434 | + "created": "2016-07-20T13:44:29Z", | |
435 | + "updated": "2016-07-20T13:44:29Z" | |
436 | + } | |
437 | +}, | |
438 | +{ | |
439 | + "model": "common.version", | |
440 | + "pk": 14, | |
441 | + "fields": { | |
442 | + "module_name": "Observation Manager", | |
443 | + "version": "0.1.3", | |
444 | + "created": "2016-07-20T13:44:29Z", | |
445 | + "updated": "2016-07-20T13:44:29Z" | |
446 | + } | |
447 | +}, | |
448 | +{ | |
449 | + "model": "common.version", | |
450 | + "pk": 15, | |
451 | + "fields": { | |
452 | + "module_name": "Routine Manager", | |
453 | + "version": "0.1.2", | |
454 | + "created": "2016-07-20T13:44:29Z", | |
455 | + "updated": "2016-07-20T13:44:29Z" | |
456 | + } | |
457 | +}, | |
458 | +{ | |
459 | + "model": "common.version", | |
460 | + "pk": 16, | |
461 | + "fields": { | |
462 | + "module_name": "Monitoring", | |
463 | + "version": "0.1.3", | |
464 | + "created": "2016-07-20T13:44:29Z", | |
465 | + "updated": "2016-07-20T13:44:29Z" | |
466 | + } | |
467 | +}, | |
468 | +{ | |
469 | + "model": "common.version", | |
470 | + "pk": 17, | |
471 | + "fields": { | |
472 | + "module_name": "Scheduler", | |
473 | + "version": "0.1.2", | |
474 | + "created": "2016-07-20T13:44:29Z", | |
475 | + "updated": "2016-07-20T13:44:29Z" | |
476 | + } | |
477 | +}, | |
478 | +{ | |
479 | + "model": "common.version", | |
480 | + "pk": 18, | |
481 | + "fields": { | |
482 | + "module_name": "User Manager", | |
483 | + "version": "0.1.1", | |
484 | + "created": "2016-07-20T13:44:29Z", | |
485 | + "updated": "2016-07-20T13:44:29Z" | |
486 | + } | |
487 | +}, | |
488 | +{ | |
489 | + "model": "common.version", | |
490 | + "pk": 19, | |
491 | + "fields": { | |
492 | + "module_name": "Analyzer", | |
493 | + "version": "0.1.2", | |
494 | + "created": "2016-07-20T13:44:29Z", | |
495 | + "updated": "2016-07-20T13:44:29Z" | |
496 | + } | |
497 | +}, | |
498 | +{ | |
499 | + "model": "auth.user", | |
500 | + "pk": 9, | |
501 | + "fields": { | |
502 | + "password": "pbkdf2_sha256$24000$HRial3QUfrlz$bVuEzQaXthOd9GZVXd2449LDEF8EMQure69nA/Hu7qQ=", | |
503 | + "last_login": "2016-08-10T15:16:42.327Z", | |
504 | + "is_superuser": true, | |
505 | + "username": "pyros", | |
506 | + "first_name": "", | |
507 | + "last_name": "", | |
508 | + "email": "admin@example.com", | |
509 | + "is_staff": true, | |
510 | + "is_active": true, | |
511 | + "date_joined": "2016-08-10T15:15:58.481Z", | |
512 | + "groups": [], | |
513 | + "user_permissions": [] | |
514 | + } | |
515 | +}, | |
516 | +{ | |
517 | + "model": "common.pyrosuser", | |
518 | + "pk": 5, | |
519 | + "fields": { | |
520 | + "user": 9, | |
521 | + "country": 1, | |
522 | + "user_level": 1, | |
523 | + "desc": "", | |
524 | + "created": "2016-08-11T07:54:05.627Z", | |
525 | + "updated": "2016-08-11T07:54:05.627Z", | |
526 | + "tel": "", | |
527 | + "address": "", | |
528 | + "laboratory": "IRAP", | |
529 | + "last_connect": null, | |
530 | + "cur_connect": null, | |
531 | + "putvalid_beg": null, | |
532 | + "putvalid_end": null, | |
533 | + "acqvalid_beg": "", | |
534 | + "acqvalid_end": "", | |
535 | + "quota": 1000.0, | |
536 | + "quota_rea": null, | |
537 | + "u_priority": 1, | |
538 | + "p_priority": 1, | |
539 | + "dir_level": null, | |
540 | + "can_del_void_req": false | |
541 | + } | |
542 | +} | |
543 | +] | ... | ... |
src/pyros/__init__.py
... | ... | @@ -9,11 +9,11 @@ from django.conf import settings |
9 | 9 | @worker_ready.connect |
10 | 10 | def start_permanent_tasks(signal, sender): |
11 | 11 | import monitoring.tasks |
12 | - import simulator.tasks | |
12 | + import simulator.userSimulator.tasks | |
13 | 13 | |
14 | 14 | print(sender.hostname) |
15 | 15 | if sender.hostname == "pyros@simulator": |
16 | - simulator.tasks.simulator.delay() | |
16 | + simulator.userSimulator.tasks.simulator.delay() | |
17 | 17 | |
18 | 18 | if sender.hostname == "pyros@monitoring": |
19 | 19 | monitoring.tasks.monitoring.delay() | ... | ... |
src/pyros/settings.py
... | ... | @@ -242,7 +242,7 @@ CELERY_IMPORTS = ( |
242 | 242 | "monitoring.tasks", |
243 | 243 | "observation_manager.tasks", |
244 | 244 | "scheduler.tasks", |
245 | - "simulator.tasks", | |
245 | + "simulator.userSimulator.tasks", | |
246 | 246 | ) |
247 | 247 | |
248 | 248 | # This config allows only 1 process / queue. We replace it by the -c option at celery workers creation. |
... | ... | @@ -278,7 +278,7 @@ CELERY_ROUTES = { |
278 | 278 | "observation_manager.tasks.execute_plan_nir": {"queue": "execute_plan_nir_q"}, |
279 | 279 | "observation_manager.tasks.create_calibrations": {"queue": "create_calibrations_q"}, |
280 | 280 | "scheduler.tasks.scheduling": {"queue": "scheduling_q"}, |
281 | - "simulator.tasks.simulator": {"queue": "simulator_q"}, | |
281 | + "simulator.userSimulator.tasks.simulator": {"queue": "simulator_q"}, | |
282 | 282 | } |
283 | 283 | |
284 | 284 | ''' Removes pickle warning ''' | ... | ... |
src/scripts/kill_simulation.sh
src/scripts/simulator_launch.sh
... | ... | @@ -4,27 +4,73 @@ SCRIPT_PATH=${SCRIPT_PATH%/*} |
4 | 4 | |
5 | 5 | cd $SCRIPT_PATH/.. |
6 | 6 | |
7 | +echo -n "Existing simulations : " | |
8 | +ls misc/fixtures/simulation/ | |
9 | +echo -n "Enter which simulation you want to launch : " | |
10 | +read -r line | |
11 | + | |
12 | +if [ ! -f misc/fixtures/simulation/"$line" ]; then | |
13 | + echo "This simulation doesn't exist" | |
14 | + exit | |
15 | +fi | |
16 | + | |
17 | +sed -i -e "s/SIMULATOR_VALUE = None/SIMULATOR_VALUE = '$line'/g" simulator/userSimulator/tasks.py | |
7 | 18 | sed -i -e "s/CELERY_TEST = False/CELERY_TEST = True/g" pyros/settings.py |
8 | 19 | |
20 | +trap ctrl_c INT | |
21 | + | |
22 | +function ctrl_c() { | |
23 | + ./../pyrosrun.sh kill_simulation | |
24 | + killall ALERTsimulator.py | |
25 | + killall PLCsimulator.py | |
26 | + echo "Ctrl-c catched, all process launched have been killed" | |
27 | + exit | |
28 | +} | |
29 | + | |
30 | + | |
9 | 31 | rm -f testdb.sqlite3 |
10 | 32 | python manage.py migrate |
11 | 33 | python manage.py loaddata misc/fixtures/initial_fixture.json |
12 | 34 | |
13 | -echo "----------------WEB SERVER----------------" | |
35 | +python manage.py loaddata misc/fixtures/simulation/"$line" | |
36 | + | |
37 | +echo "----------------LAUNCHING WEB SERVER----------------" | |
14 | 38 | python manage.py runserver & |
15 | 39 | |
16 | 40 | sleep 2 |
17 | -echo "----------------WEB SERVER----------------" | |
41 | +echo "----------------WEB SERVER LAUNCHED-----------------" | |
18 | 42 | |
19 | -#launch simulator workers | |
20 | -./scripts/start_simulator_worker.sh 2>&1 /dev/null | |
21 | - | |
22 | -echo "----------------------------SUMMARY-------------------------------------" | |
23 | -echo "The simulator has been successfully launched" | |
43 | +echo "----------------------------------------SUMMARY---------------------------------------------" | |
44 | +echo "The simulator has been successfully initialised" | |
24 | 45 | echo "The simulator run on a temp database : src/testdb.sqlite3" |
25 | 46 | echo "The simulation will be ended by the task 'simulator herself'" |
26 | 47 | echo "If you want to shutdown the simulation, please run :" |
27 | -echo "./pyrosrun.sh kill_simulation" | |
48 | +echo "CTRL-C or ./pyrosrun.sh kill_simulation" | |
28 | 49 | echo "If the simulation isn't correctly killed, please switch the variable" |
29 | 50 | echo "CELERY_TEST in src/pyros/settings.py to false" |
30 | -echo "----------------------------SUMMARY-------------------------------------" | |
51 | +echo "" | |
52 | +echo "----------------------------------------SUMMARY---------------------------------------------" | |
53 | +echo "" | |
54 | +read -n1 -r -p "Press any key to continue..." key | |
55 | + | |
56 | +#launch simulator workers | |
57 | +./scripts/start_simulator_worker.sh 2>&1 /dev/null | |
58 | + | |
59 | +#launch simulators binaries | |
60 | +python simulator/alertSimulator/ALERTsimulator.py "$line" & | |
61 | +ALERTPID=$! | |
62 | +python simulator/plcSimulator/PLCsimulator.py "$line" & | |
63 | +PLCPID=$! | |
64 | + | |
65 | +echo "" | |
66 | +echo "Waiting for ALERTsimulator to finish" | |
67 | +wait "$ALERTPID" | |
68 | +echo "Alersimulator finished" | |
69 | +echo "" | |
70 | +echo "Waiting for PLCsimulator to finish" | |
71 | +wait "$PLCPID" | |
72 | +echo "PLCsimulator finished" | |
73 | +echo "" | |
74 | +echo "Killing all processes" | |
75 | + | |
76 | +./../pyrosrun.sh kill_simulation | ... | ... |
src/scripts/start_simulator_worker.sh
... | ... | @@ -9,7 +9,6 @@ source ../private/venv_py3_pyros/bin/activate |
9 | 9 | |
10 | 10 | ./scripts/kill_celery_workers.sh |
11 | 11 | |
12 | - | |
13 | 12 | celery worker -A pyros -Q monitoring_q -n pyros@monitoring -c 1 & |
14 | 13 | celery worker -A pyros -Q alert_listener_q -n pyros@alert_listener -c 1 & |
15 | 14 | celery worker -A pyros -Q simulator_q -n pyros@simulator -c 1 & | ... | ... |
src/simulator/__init__.py
... | ... | @@ -0,0 +1,17 @@ |
1 | +import sys | |
2 | +import time | |
3 | + | |
4 | +class AlertSimulator(): | |
5 | + def __init__(self, argv): | |
6 | + if (len(argv) > 1): | |
7 | + self.path = argv[1] | |
8 | + pass | |
9 | + | |
10 | + def run(self): | |
11 | + print("Alert Simulator %s"%self.path) | |
12 | + time.sleep(2) | |
13 | + pass | |
14 | + | |
15 | +if __name__ == "__main__": | |
16 | + sim = AlertSimulator(sys.argv) | |
17 | + sim.run() | ... | ... |
src/simulator/migrations/__init__.py renamed to src/simulator/alertSimulator/__init__.py
... | ... | @@ -0,0 +1,15 @@ |
1 | +import sys | |
2 | +import time | |
3 | + | |
4 | +class PLCSimulator(): | |
5 | + def __init__(self, argv): | |
6 | + pass | |
7 | + | |
8 | + def run(self): | |
9 | + print("PLC simulator running") | |
10 | + time.sleep(4) | |
11 | + pass | |
12 | + | |
13 | +if __name__ == "__main__": | |
14 | + sim = PLCSimulator(sys.argv) | |
15 | + sim.run() | ... | ... |
src/simulator/tasks.py deleted
... | ... | @@ -1,69 +0,0 @@ |
1 | -from __future__ import absolute_import | |
2 | -from django.conf import settings | |
3 | -from common.models import * | |
4 | -from celery.task import Task | |
5 | - | |
6 | -import logger.config as l | |
7 | -import sys | |
8 | -import os | |
9 | -import time | |
10 | - | |
11 | -log = l.setupLogger("simulator", "simulator") | |
12 | - | |
13 | -class SimulatorRoutines(): | |
14 | - def __init__(self, quantity, dtime): | |
15 | - self.quantity = quantity | |
16 | - self.dtime = dtime | |
17 | - log.info("SimulatorRoutines class instantiated with %d routines to be executed with an interval of time %d"%(quantity,dtime)) | |
18 | - | |
19 | - # First create some scientific programs | |
20 | - def createScientificPrograms(self): | |
21 | - pass | |
22 | - | |
23 | - # create some user levels with diferent priorities | |
24 | - def createUserLevels(self): | |
25 | - pass | |
26 | - | |
27 | - # create some pyros users | |
28 | - def createPyrosUsers(self, country, user_id, user_level_id): | |
29 | - pass | |
30 | - | |
31 | - # create auth users | |
32 | - def createAuthUsers(self): | |
33 | - | |
34 | - # You can now create Requests | |
35 | - def createRequest(self, pyros_user_id, scientific_program_id): | |
36 | - pass | |
37 | - | |
38 | - # requests must have sequences | |
39 | - def createSequences(self, request): | |
40 | - pass | |
41 | - | |
42 | - # Sequences must have albums | |
43 | - def createAlbums(self, sequence): | |
44 | - pass | |
45 | - | |
46 | - # albums must have plans | |
47 | - def createPlans(self, album): | |
48 | - pass | |
49 | - | |
50 | - def process(self): | |
51 | - pass | |
52 | - | |
53 | - | |
54 | -class simulator(Task): | |
55 | - shouldClean = False | |
56 | - | |
57 | - def run(self): | |
58 | - simu = SimulatorRoutines(100, 2) | |
59 | - # for schedule in py_schedules: | |
60 | - | |
61 | - | |
62 | - # END OF EXECTUION (KILLING WEB SERVER AN PROCESS) | |
63 | - if (self.shouldClean == True): | |
64 | - os.system("%s/../pyrosrun.sh kill_simulation"%settings.BASE_DIR) | |
65 | - | |
66 | -if __name__ == "__main__": | |
67 | - sim = simulator(Task) | |
68 | - sim.shouldClean = False | |
69 | - sim.run() |
src/simulator/admin.py renamed to src/simulator/userSimulator/admin.py
src/simulator/apps.py renamed to src/simulator/userSimulator/apps.py
src/simulator/models.py renamed to src/simulator/userSimulator/models.py
... | ... | @@ -0,0 +1,174 @@ |
1 | +from __future__ import absolute_import | |
2 | +from django.conf import settings | |
3 | +from common.models import * | |
4 | +from celery.task import Task | |
5 | + | |
6 | +import logger.config as l | |
7 | +import sys | |
8 | +import os | |
9 | +import time | |
10 | +import json | |
11 | + | |
12 | +log = l.setupLogger("simulator", "simulator") | |
13 | + | |
14 | +SIMULATOR_VALUE = None | |
15 | + | |
16 | +class simulator(Task): | |
17 | + shouldClean = False | |
18 | + | |
19 | + def loadJson(self, path): | |
20 | + json_data = open(path, 'r') | |
21 | + # if (not json_data.is_open()): | |
22 | + | |
23 | + def run(self): | |
24 | + print('-------------------------------') | |
25 | + print(SIMULATOR_VALUE) | |
26 | + | |
27 | + # END OF EXECTUION (KILLING WEB SERVER AN PROCESS) | |
28 | + if (self.shouldClean == True): | |
29 | + os.system("%s/../pyrosrun.sh kill_simulation"%settings.BASE_DIR) | |
30 | + | |
31 | +if __name__ == "__main__": | |
32 | + sim = simulator(Task) | |
33 | + sim.shouldClean = False | |
34 | + sim.run() | |
35 | + | |
36 | + | |
37 | +""" | |
38 | +class SimulatorRoutines(): | |
39 | + def __init__(self, dtime): | |
40 | + self.dtime = dtime | |
41 | + self.dicto = { | |
42 | + "SCIENTIFIC_PROGRAMS" : self.createScientificPrograms, | |
43 | + "USER_LEVELS" : self.createUserLevels, | |
44 | + "PYROS_USERS" : self.createPyrosUsers, | |
45 | + "AUTH_USERS" : self.createAuthUsers, | |
46 | + "REQUESTS" : self.createRequest, | |
47 | + "ALBUMS" : self.createAlbums, | |
48 | + "PLANS" : self.createPlans, | |
49 | + "DETECTORS" : self.createDetector, | |
50 | + "TELESCOPES" : self.createTelescope, | |
51 | + "DEVICES" : self.createDev | |
52 | + } | |
53 | + | |
54 | + USER PART | |
55 | + # First create some scientific programs | |
56 | + def createScientificPrograms(self, params, default=False): | |
57 | + sc = [] | |
58 | + i = 0 | |
59 | + # for (value in self.data["SCIENTIFIC_PROGRAMS"]): | |
60 | + | |
61 | + if (quantity == -1): | |
62 | + return (sc) | |
63 | + while (quantity > i): | |
64 | + sc[i] = ScientificProgram(name="Sc_test-%d"%quantity, desc="Simulation", quota=(100 / quantity), priority=i) | |
65 | + sc[i].save | |
66 | + i += 1 | |
67 | + return (sc) | |
68 | + | |
69 | + # create some user levels with diferent priorities | |
70 | + def createUserLevels(self, params, default=False): | |
71 | + pass | |
72 | + | |
73 | + # create some pyros users -> country, user_id, user_level_id | |
74 | + def createPyrosUsers(self, params, default=False): | |
75 | + pass | |
76 | + | |
77 | + # create auth users | |
78 | + def createAuthUsers(self, params, default=False): | |
79 | + pass | |
80 | + | |
81 | + | |
82 | + | |
83 | + | |
84 | + DEVICE PART | |
85 | + # if you want to create an album you must have a detector | |
86 | + # device, telescope | |
87 | + def createDetector(self, params, default=False): | |
88 | + pass | |
89 | + | |
90 | + # detector must have a telescope | |
91 | + # device | |
92 | + def createTelescope(self, params, default=False): | |
93 | + pass | |
94 | + | |
95 | + # detector AND telescope must have a device | |
96 | + def createDevice(self, params, default=False): | |
97 | + dc = [] | |
98 | + i = 0 | |
99 | + | |
100 | + if (quantity == -1): | |
101 | + # TODO create from class array loaded by loadJson | |
102 | + return (dc) | |
103 | + while (quantity > i): | |
104 | + dc[i] = Device(name="testdevice-%d"%i, desc="Simulator", | |
105 | + create=datetime.datetime.now(), updated=datetime.datetime.now(), | |
106 | + is_online="1", status="Online") | |
107 | + i += 1 | |
108 | + return (dc) | |
109 | + | |
110 | + | |
111 | + | |
112 | + ROUTINE PART | |
113 | + # You can now create Requests | |
114 | + # pyros_user_id, scientific_program_id | |
115 | + def createRequest(self, params, default=False): | |
116 | + pass | |
117 | + | |
118 | + # requests must have sequences | |
119 | + # Request | |
120 | + def createSequences(self, params, default=False): | |
121 | + pass | |
122 | + | |
123 | + # Sequences must have albums and albums must have a detector | |
124 | + # sequence, detector | |
125 | + def createAlbums(self, params, default=False): | |
126 | + pass | |
127 | + | |
128 | + # albums must have plans | |
129 | + # album id, plan id | |
130 | + def createPlans(self, params, default=False): | |
131 | + pass | |
132 | + | |
133 | + SIMULATOR PART | |
134 | + def prepareDatabase(self): | |
135 | + for (key, value in self.data): | |
136 | + for (name, func in self.dicto): | |
137 | + if (name == key): | |
138 | + ret = func(value) | |
139 | + if (not ret): | |
140 | + return (False) | |
141 | + return (True) | |
142 | + | |
143 | + def loadJson(self, path): | |
144 | + json_data = open(path, 'r') | |
145 | + if (not json_data.is_open()): | |
146 | + return (False) | |
147 | + self.init = True | |
148 | + data1 = json.load(json_data) | |
149 | + self.data = data1 | |
150 | + json_data.close() | |
151 | + return (True) | |
152 | + | |
153 | + def process(self): | |
154 | + | |
155 | + for (key, value in dicto): | |
156 | + array_object = value() | |
157 | + for (value in array_object): | |
158 | + value.save() | |
159 | + pass | |
160 | +class simulator(Task): | |
161 | + shouldClean = False | |
162 | + | |
163 | + def run(self): | |
164 | + simu = SimulatorRoutines(100, 2) | |
165 | + simu.loadJson("%s/../public/simulation/data.json"%settings.BASE_DIR) | |
166 | + simu.prepareDatabase() | |
167 | + simu.create | |
168 | + simu.process() | |
169 | + | |
170 | + # END OF EXECTUION (KILLING WEB SERVER AN PROCESS) | |
171 | + if (self.shouldClean == True): | |
172 | + os.system("%s/../pyrosrun.sh kill_simulation"%settings.BASE_DIR) | |
173 | + | |
174 | +""" | ... | ... |
src/simulator/tests.py renamed to src/simulator/userSimulator/tests.py
src/simulator/urls.py renamed to src/simulator/userSimulator/urls.py
src/simulator/views.py renamed to src/simulator/userSimulator/views.py