@@ -39,6 +39,18 def pedestal_start(self, id_exp): | |||
|
39 | 39 | exp.pedestal.start_device(name_experiment=name) |
|
40 | 40 | self.stdout.write(f'"{exp.name}" experiment: Pedestal acquisition was restarted') |
|
41 | 41 | |
|
42 | def pedestal_reset(self, id_exp): | |
|
43 | all_status = Experiment.objects.filter(status=2) | |
|
44 | check_id = False | |
|
45 | ||
|
46 | if len(all_status) > 0: | |
|
47 | check_id = all_status[0].pk | |
|
48 | ||
|
49 | if check_id and check_id == id_exp: | |
|
50 | exp = get_object_or_404(Experiment, pk=id_exp) | |
|
51 | exp.pedestal.reset_device() | |
|
52 | self.stdout.write(f'"{exp.name}" experiment: Pedestal acquisition is resetting') | |
|
53 | ||
|
42 | 54 | def pedestal_stop(self, id_exp): |
|
43 | 55 | all_status = Experiment.objects.filter(status=2) |
|
44 | 56 | check_id = False |
@@ -49,7 +61,7 def pedestal_stop(self, id_exp): | |||
|
49 | 61 | if check_id and check_id == id_exp: |
|
50 | 62 | exp = get_object_or_404(Experiment, pk=id_exp) |
|
51 | 63 | exp.pedestal.stop_device() |
|
52 |
self.stdout.write(f'"{exp.name}" experiment: Pedestal acquisition |
|
|
64 | self.stdout.write(f'"{exp.name}" experiment: Pedestal acquisition was stopped') | |
|
53 | 65 | |
|
54 | 66 | def hdf5_list_content(get_file): |
|
55 | 67 | table_records = np.array(get_file).tolist() |
@@ -180,8 +192,6 def restart_pedestal(self): | |||
|
180 | 192 | |
|
181 | 193 | pedestal_stop(self, id_exp) |
|
182 | 194 | time.sleep(14) |
|
183 | #pedestal_reset(self, id_exp) | |
|
184 | #time.sleep(2) | |
|
185 | 195 | pedestal_start(self, id_exp) |
|
186 | 196 | |
|
187 | 197 | else: |
@@ -190,10 +200,10 def restart_pedestal(self): | |||
|
190 | 200 | else: |
|
191 | 201 | self.stdout.write(f'No file increment, retry') |
|
192 | 202 | |
|
203 | pedestal_reset(self, id_exp) | |
|
204 | time.sleep(14) | |
|
193 | 205 | pedestal_stop(self, id_exp) |
|
194 | 206 | time.sleep(14) |
|
195 | #pedestal_reset(self, id_exp) | |
|
196 | #time.sleep(2) | |
|
197 | 207 | pedestal_start(self, id_exp) |
|
198 | 208 | |
|
199 | 209 | else: |
@@ -37,11 +37,15 def acquisition_start(self, id_exp): | |||
|
37 | 37 | name = '{}-R@{}'.format(exp.name, datetime.now().strftime('%Y-%m-%dT%H-%M-%S')) |
|
38 | 38 | exp.reception_rx.start_device(name_experiment = name, restart = True) |
|
39 | 39 | self.stdout.write(f'"{exp.name}" experiment: Data acquisition was restarted') |
|
40 | ||
|
40 | 41 | self.stdout.write(f'Restarting schain...') |
|
42 | datadir_exp = exp.reception_rx.datadir | |
|
43 | datadir_exp = datadir_exp.replace(os.environ.get('EXPOSE_NAS', '/DATA_RM/DATA') + '/', '') | |
|
44 | datadir_exp = datadir_exp.replace('/rawdata', '') | |
|
41 | 45 | |
|
42 | 46 | r = requests.get('http://'+os.environ.get('SCHAIN_SITE', 'sophy-schain')+'/stop') |
|
43 | 47 | time.sleep(1) |
|
44 |
r = requests.post('http://'+os.environ.get('SCHAIN_SITE', 'sophy-schain')+'/start', json={'name': exp |
|
|
48 | r = requests.post('http://'+os.environ.get('SCHAIN_SITE', 'sophy-schain')+'/start', json={'name': datadir_exp}) | |
|
45 | 49 | |
|
46 | 50 | def acquisition_stop(self, id_exp): |
|
47 | 51 | all_status = Experiment.objects.filter(status=2) |
@@ -342,6 +342,8 class Experiment(PolymorphicModel): | |||
|
342 | 342 | time.sleep(0.1) |
|
343 | 343 | self.reception_rx.stop_device() |
|
344 | 344 | time.sleep(0.1) |
|
345 | self.pedestal.reset_device() | |
|
346 | time.sleep(14) | |
|
345 | 347 | self.pedestal.stop_device() |
|
346 | 348 | time.sleep(0.1) |
|
347 | 349 | proc_url = 'http://'+os.environ['PROC_SITE']+'/stop' |
@@ -118,7 +118,25 class PedestalConfiguration(Configuration): | |||
|
118 | 118 | self.device.save() |
|
119 | 119 | return True |
|
120 | 120 | |
|
121 |
def reset_device(self |
|
|
121 | def reset_device(self): | |
|
122 | ||
|
123 | try: | |
|
124 | r = requests.get(self.device.url() + 'reset') | |
|
125 | ||
|
126 | if r: | |
|
127 | #self.device.status = 3 | |
|
128 | #self.device.save() | |
|
129 | self.message = 'Pedestal restarted' | |
|
130 | else: | |
|
131 | return False | |
|
132 | ||
|
133 | except Exception as e: | |
|
134 | self.message = "Pedestal can't restarted: {}".format(str(e)) | |
|
135 | return False | |
|
136 | ||
|
137 | return True | |
|
138 | ||
|
139 | def initial_device(self, axi, angle): | |
|
122 | 140 | |
|
123 | 141 | try: |
|
124 | 142 | url = self.device.url() + "position?params=" |
@@ -153,12 +171,12 class PedestalConfiguration(Configuration): | |||
|
153 | 171 | if r: |
|
154 | 172 | self.device.status = 3 |
|
155 | 173 | self.device.save() |
|
156 |
self.message = 'Pedestal |
|
|
174 | self.message = 'Pedestal - initial position' | |
|
157 | 175 | else: |
|
158 | 176 | return False |
|
159 | 177 | |
|
160 | 178 | except Exception as e: |
|
161 |
self.message = 'Pedestal |
|
|
179 | self.message = 'Pedestal - initial position: {}'.format(str(e)) | |
|
162 | 180 | return False |
|
163 | 181 | |
|
164 | 182 | return True |
@@ -173,7 +191,7 class PedestalConfiguration(Configuration): | |||
|
173 | 191 | AX = {'az':'azimuth', 'el':'elevation'} |
|
174 | 192 | axis = [AX[x.lower().strip()] for x in self.axis.split(',')] |
|
175 | 193 | list_of_floats = [float(x.strip()) for x in self.angle.split(",")] |
|
176 |
self. |
|
|
194 | self.initial_device(axis[0], list_of_floats[0]) | |
|
177 | 195 | |
|
178 | 196 | if r: |
|
179 | 197 | self.device.status = 4 |
@@ -293,4 +311,7 class PedestalConfiguration(Configuration): | |||
|
293 | 311 | return payload |
|
294 | 312 | |
|
295 | 313 | def get_absolute_url_import(self): |
|
296 | return reverse('url_import_pedestal_conf', args=[str(self.id)]) No newline at end of file | |
|
314 | return reverse('url_import_pedestal_conf', args=[str(self.id)]) | |
|
315 | ||
|
316 | def get_absolute_url_reset(self): | |
|
317 | return reverse('url_reset_pedestal_conf', args=[str(self.id)]) No newline at end of file |
@@ -3,6 +3,10 | |||
|
3 | 3 | {% load bootstrap4 %} |
|
4 | 4 | {% load main_tags %} |
|
5 | 5 | |
|
6 | {% block extra-menu-actions %} | |
|
7 | <li><a href="{{ dev_conf.get_absolute_url_reset }}"><span class="fas fa-spinner" aria-hidden="true"></span> Reset </a></li> | |
|
8 | {% endblock %} | |
|
9 | ||
|
6 | 10 | {% block content-detail %} |
|
7 | 11 | |
|
8 | 12 | <h2>Pedestal</h2> |
@@ -6,6 +6,7 urlpatterns = ( | |||
|
6 | 6 | path('<int:conf_id>/', views.conf, name='url_pedestal_conf'), |
|
7 | 7 | path('<int:conf_id>/import/', views.import_file, name='url_import_pedestal_conf'), |
|
8 | 8 | path('<int:conf_id>/edit/', views.conf_edit, name='url_edit_pedestal_conf'), |
|
9 | path('<int:conf_id>/reset/', views.conf_reset, name='url_reset_pedestal_conf'), | |
|
9 | 10 | #url(r'^(?P<id_conf>-?\d+)/write/$', 'apps.main.views.dev_conf_write', name='url_write_pedestal_conf'), |
|
10 | 11 | #url(r'^(?P<id_conf>-?\d+)/read/$', 'apps.main.views.dev_conf_read', name='url_read_pedestal_conf'), |
|
11 | 12 | ) |
@@ -114,6 +114,18 def import_file(request, conf_id): | |||
|
114 | 114 | |
|
115 | 115 | return render(request, 'pedestal_import.html', kwargs) |
|
116 | 116 | |
|
117 | @login_required | |
|
118 | def conf_reset(request, conf_id): | |
|
119 | ||
|
120 | conf = get_object_or_404(PedestalConfiguration, pk=conf_id) | |
|
121 | ||
|
122 | if conf.reset_device(): | |
|
123 | messages.success(request, conf.message) | |
|
124 | else: | |
|
125 | messages.error(request, conf.message) | |
|
126 | ||
|
127 | return redirect(conf.get_absolute_url()) | |
|
128 | ||
|
117 | 129 | def conf_raw(request, conf_id): |
|
118 | 130 | conf = get_object_or_404(PedestalConfiguration, pk=conf_id) |
|
119 | 131 | raw = conf.write_device(raw=True) |
General Comments 0
You need to be logged in to leave comments.
Login now