@@ -353,7 +353,6 class ABSConfiguration(Configuration): | |||||
353 |
|
353 | |||
354 |
|
354 | |||
355 | def stop_device(self): |
|
355 | def stop_device(self): | |
356 | print("estoy en ABS models") |
|
|||
357 | self.device.status = 2 |
|
356 | self.device.status = 2 | |
358 | self.device.save() |
|
357 | self.device.save() | |
359 | self.message = 'ABS has been stopped.' |
|
358 | self.message = 'ABS has been stopped.' |
@@ -17,70 +17,55 class Command(BaseCommand): | |||||
17 | manage.py restart_experiment |
|
17 | manage.py restart_experiment | |
18 | """ |
|
18 | """ | |
19 | def handle(self, *args, **options): |
|
19 | def handle(self, *args, **options): | |
20 | print("") |
|
20 | print("\n\n") | |
|
21 | all_campaigns=Campaign.objects.all() | |||
21 | campaigns = Campaign.objects.filter(start_date__lte=datetime.now(), |
|
22 | campaigns = Campaign.objects.filter(start_date__lte=datetime.now(), | |
22 | end_date__gte=datetime.now()).order_by('-start_date') |
|
23 | end_date__gte=datetime.now()).order_by('-start_date') | |
23 |
|
24 | |||
24 |
|
|
25 | for campaign in all_campaigns: | |
25 |
|
26 | if campaign.start_date<datetime.now() and campaign.end_date > datetime.now(): | ||
26 | for campaign in campaigns: |
|
|||
27 | print(campaign.name) |
|
|||
28 | print(campaign.start_date) |
|
|||
29 | print(campaign.end_date) |
|
|||
30 | print(campaign.experiments.all()[0].id) |
|
|||
31 | print("STATUS: ",campaign.experiments.all()[0].status) |
|
|||
32 |
|
27 | |||
33 | radar=campaign.get_experiments_by_radar(radar=None) |
|
28 | radar=campaign.get_experiments_by_radar(radar=None) | |
34 | radar_id=radar[0]["id"] |
|
29 | for rad in radar: | |
35 |
print(ra |
|
30 | # print("RADR", rad) | |
36 |
|
31 | radar_id=rad["id"] | ||
37 | now = datetime.now() |
|
32 | # print("RADR_",radar_id) | |
38 | if now<campaign.end_date and now >campaign.start_date: |
|
|||
39 | print("La campaña",campaign.name ,"se ejecuta!",flush=True) |
|
|||
40 | radar_start_scheduler(campaign.id,radar_id) |
|
33 | radar_start_scheduler(campaign.id,radar_id) | |
|
34 | print(campaign.name, "\t\t Campaign already running") | |||
41 |
|
35 | |||
42 | else: |
|
36 | else: | |
43 | copy_campaigns=Campaign.objects.all() |
|
|||
44 | print("-------------Deteniendo procesos-------------") |
|
|||
45 | for campaign in copy_campaigns: |
|
|||
46 | print(campaign.name) |
|
|||
47 | print(campaign.start_date) |
|
|||
48 | print(campaign.end_date) |
|
|||
49 | print("ID: ",campaign.experiments.all()[0].id) |
|
|||
50 | print("STATUS: ",campaign.experiments.all()[0].status) |
|
|||
51 | print("----,,,---") |
|
|||
52 | radar=campaign.get_experiments_by_radar(radar=None) |
|
37 | radar=campaign.get_experiments_by_radar(radar=None) | |
53 | radar_id=radar[0]["id"] |
|
38 | radar_id=radar[0]["id"] | |
54 |
|
||||
55 | if campaign.experiments.all()[0].status !=1: |
|
39 | if campaign.experiments.all()[0].status !=1: | |
56 | print("Estoy en :",campaign.experiments.all()[0].status) |
|
40 | print(campaign.name, "\t\t Stopping Campaign...") | |
57 | print("Con ID: ",campaign.experiments.all()[0].id) |
|
|||
58 | print("\n\n") |
|
|||
59 | a=radar_stop_scheduler(campaign.id,radar_id,campaign.experiments.all()[0].id) |
|
41 | a=radar_stop_scheduler(campaign.id,radar_id,campaign.experiments.all()[0].id) | |
60 |
print(" |
|
42 | print("New Status: ", a) | |
61 |
|
43 | else: | ||
|
44 | print(campaign.name,"\t\t\t Campaign already stooped") | |||
62 |
|
45 | |||
63 | def radar_start_scheduler(id_camp,id_radar): |
|
46 | def radar_start_scheduler(id_camp,id_radar): | |
64 | print("-------------------") |
|
|||
65 | campaign = get_object_or_404(Campaign, pk=id_camp) |
|
47 | campaign = get_object_or_404(Campaign, pk=id_camp) | |
66 | experiments = campaign.get_experiments_by_radar(id_radar)[0]['experiments'] |
|
48 | experiments = campaign.get_experiments_by_radar(id_radar)[0]['experiments'] | |
67 | now = datetime.now() |
|
49 | now = datetime.now() | |
68 |
|
50 | # print(campaign) | ||
|
51 | # print(experiments) | |||
69 | for exp in experiments: |
|
52 | for exp in experiments: | |
70 | exp = get_object_or_404(Experiment, pk=exp.id) |
|
53 | exp = get_object_or_404(Experiment, pk=exp.id) | |
71 |
|
54 | # print("---------DEBUGG-------------") | ||
|
55 | # print(exp) | |||
72 | if exp.status == 2: |
|
56 | if exp.status == 2: | |
73 |
print('Experiment |
|
57 | print('\t\t\t {} \t\t Experiment already runnnig'.format(exp)) | |
74 | else: |
|
58 | else: | |
75 | exp.status = exp.start() |
|
59 | exp.status = exp.start() | |
76 | if exp.status == 0: |
|
60 | if exp.status == 0: | |
77 |
print('Experiment |
|
61 | print('\t\t\t {} \t\tExperiment not start'.format(exp)) | |
78 | if exp.status == 2: |
|
62 | if exp.status == 2: | |
79 |
print('Experiment |
|
63 | print('\t\t\t {} \t\tExperiment started'.format(exp)) | |
|
64 | if exp.status == 4: | |||
|
65 | print('\t\t\t {} \t\tExperiment with state uknown, please reset'.format(exp)) | |||
80 | exp.save() |
|
66 | exp.save() | |
81 |
|
67 | |||
82 | def radar_stop_scheduler(id_camp,id_radar,id_experiment): |
|
68 | def radar_stop_scheduler(id_camp,id_radar,id_experiment): | |
83 | print("-------------------") |
|
|||
84 | ''' |
|
69 | ''' | |
85 | Stop experiments's devices |
|
70 | Stop experiments's devices | |
86 | DDS-JARS-RC-CGS-ABS |
|
71 | DDS-JARS-RC-CGS-ABS | |
@@ -92,8 +77,7 def radar_stop_scheduler(id_camp,id_radar,id_experiment): | |||||
92 | confs = confs.exclude(device__device_type__name='cgs') |
|
77 | confs = confs.exclude(device__device_type__name='cgs') | |
93 | try: |
|
78 | try: | |
94 | for conf in confs: |
|
79 | for conf in confs: | |
95 |
print( |
|
80 | # print(conf) | |
96 | print(conf) |
|
|||
97 | conf.stop_device() |
|
81 | conf.stop_device() | |
98 | exp.status= 1 |
|
82 | exp.status= 1 | |
99 | except: |
|
83 | except: |
General Comments 0
You need to be logged in to leave comments.
Login now