@@ -71,7 +71,7 class CGSConfiguration(Configuration): | |||||
71 |
|
71 | |||
72 | route = "http://" + str(ip) + ":" + str(port) + "/status/ad9548" |
|
72 | route = "http://" + str(ip) + ":" + str(port) + "/status/ad9548" | |
73 | try: |
|
73 | try: | |
74 |
r = requests.get(route,timeout= |
|
74 | r = requests.get(route,timeout=0.5) | |
75 | except: |
|
75 | except: | |
76 | self.device.status = 0 |
|
76 | self.device.status = 0 | |
77 | self.device.save() |
|
77 | self.device.save() | |
@@ -110,7 +110,7 class CGSConfiguration(Configuration): | |||||
110 |
|
110 | |||
111 | route = "http://" + str(ip) + ":" + str(port) + "/frequencies/" |
|
111 | route = "http://" + str(ip) + ":" + str(port) + "/frequencies/" | |
112 | try: |
|
112 | try: | |
113 |
frequencies = requests.get(route,timeout= |
|
113 | frequencies = requests.get(route,timeout=0.5) | |
114 |
|
114 | |||
115 | except: |
|
115 | except: | |
116 | self.message = "Could not read CGS parameters from this device" |
|
116 | self.message = "Could not read CGS parameters from this device" | |
@@ -148,7 +148,7 class CGSConfiguration(Configuration): | |||||
148 | route = "http://" + str(ip) + ":" + str(port) + "/frequencies/" |
|
148 | route = "http://" + str(ip) + ":" + str(port) + "/frequencies/" | |
149 |
|
149 | |||
150 | try: |
|
150 | try: | |
151 |
r = requests.post(route, post_data, timeout= |
|
151 | r = requests.post(route, post_data, timeout=0.5) | |
152 | except: |
|
152 | except: | |
153 | self.message = "Could not write CGS parameters" |
|
153 | self.message = "Could not write CGS parameters" | |
154 | return None |
|
154 | return None |
@@ -963,15 +963,49 def operation_search(request, id_camp=None): | |||||
963 | def radar_play(request, id_camp, id_radar): |
|
963 | def radar_play(request, id_camp, id_radar): | |
964 | campaign = get_object_or_404(Campaign, pk = id_camp) |
|
964 | campaign = get_object_or_404(Campaign, pk = id_camp) | |
965 | radar = get_object_or_404(Location, pk = id_radar) |
|
965 | radar = get_object_or_404(Location, pk = id_radar) | |
966 | experiments = Experiment.objects.filter(campaign=campaign).filter(location=radar) |
|
966 | today = datetime.today() | |
967 | current_time = datetime.today() |
|
967 | now = today.time() | |
968 | #exp = RunningExperiment( |
|
968 | ||
969 | # radar = purchase_request.user_id, |
|
969 | #--If campaign datetime is ok: | |
970 | # running_experiment = purchase_request, |
|
970 | if today >= campaign.start_date and today <= campaign.end_date: | |
971 | # status = , |
|
971 | experiments = Experiment.objects.filter(campaign=campaign).filter(location=radar) | |
972 | # ) |
|
972 | for exp in experiments: | |
973 | #new_pos.append(exp) |
|
973 | #--If experiment time is ok: | |
974 | #exp.save() |
|
974 | if now >= exp.start_time and now <= exp.end_time: | |
|
975 | configurations = Configuration.objects.filter(experiment = exp) | |||
|
976 | for conf in configurations: | |||
|
977 | if 'cgs' in conf.device.device_type.name: | |||
|
978 | conf.status_device() | |||
|
979 | else: | |||
|
980 | answer = conf.start_device() | |||
|
981 | conf.status_device() | |||
|
982 | #--Running Experiment | |||
|
983 | r_e = RunningExperiment.objects.filter(radar=radar) | |||
|
984 | #--If RunningExperiment element exists | |||
|
985 | if r_e: | |||
|
986 | r_e = r_e[0] | |||
|
987 | r_e.running_experiment = exp | |||
|
988 | r_e.status = 3 | |||
|
989 | r_e.save() | |||
|
990 | else: | |||
|
991 | running_experiment = RunningExperiment( | |||
|
992 | radar = radar, | |||
|
993 | running_experiment = exp, | |||
|
994 | status = 3, | |||
|
995 | ) | |||
|
996 | running_experiment.save() | |||
|
997 | ||||
|
998 | if answer: | |||
|
999 | messages.success(request, conf.message) | |||
|
1000 | exp.status=2 | |||
|
1001 | exp.save() | |||
|
1002 | else: | |||
|
1003 | messages.error(request, conf.message) | |||
|
1004 | else: | |||
|
1005 | if exp.status == 1 or exp.status == 3: | |||
|
1006 | exp.status=3 | |||
|
1007 | exp.save() | |||
|
1008 | ||||
975 |
|
1009 | |||
976 | route = request.META['HTTP_REFERER'] |
|
1010 | route = request.META['HTTP_REFERER'] | |
977 | route = str(route) |
|
1011 | route = str(route) |
General Comments 0
You need to be logged in to leave comments.
Login now