From e40954e05ac0cb470d289a468c43b378d53b2540 2023-03-22 23:16:42 From: Renato Huallpa Date: 2023-03-22 23:16:42 Subject: [PATCH] ATRAD actualizando títulos --- diff --git a/.env b/.env old mode 100644 new mode 100755 index 696b718..d7346f7 --- a/.env +++ b/.env @@ -26,6 +26,7 @@ MQTT_KEEPALIVE = 3660 MQTT_USER_ATRAD='' MQTT_PASSWORD_ATRAD = '' MQTT_TOPIC_ATRAD_RECIEVE = "atrad/test4" +MQTT_TOPIC_ATRAD_CONTROL = "atrad/test2" MQTT_USER = abs MQTT_PASSWORD = abs diff --git a/apps/abs/models.py b/apps/abs/models.py index 7064e14..4dd516b 100644 --- a/apps/abs/models.py +++ b/apps/abs/models.py @@ -339,7 +339,6 @@ class ABSConfiguration(Configuration): try: #self.write_device() send_task('task_change_beam', [self.id],) - # print("*************************RUNNING ABS**************************",flush=True) self.message = 'ABS running' except Exception as e: @@ -430,7 +429,6 @@ class ABSConfiguration(Configuration): message += ''.join([fromBinary2Char(beam.module_6bits(i)) for beam in beams]) status = ['0'] * 64 n = 0 - print("Estoy en write_device normal",flush=True) sock = self.send_multicast(message) while True: @@ -679,7 +677,7 @@ class ABSConfiguration(Configuration): return False sock = self.send_multicast('MNTR') - print("Estoy en status_deice",flush=True) + # print("Estoy en status_deice",flush=True) n = 0 status = ['0'] * 64 @@ -883,29 +881,6 @@ class ABSConfiguration(Configuration): else: beam_pos = 0 - #El indice del apunte debe ser menor que el numero total de apuntes - #El servidor tcp en el embebido comienza a contar desde 0 - # status = ['0'] * 64 - # message = 'CHGB{}'.format(beam_pos) - # sock = self.send_multicast(message) - # while True: - # #for i in range(32): - # try: - # data, address = sock.recvfrom(1024) - # print (address, data) - # data = data.decode() - # if data == '1': - # status[int(address[0][10:])-1] = '3' - # elif data == '0': - # status[int(address[0][10:])-1] = '1' - # except socket.timeout: - # print('Timeout') - # break - # except Exception as e: - # print ('Error {}'.format(e)) - # pass - - # sock.close() mqtt_client.publish('abs/change_beam',str(beam_pos)) @@ -913,7 +888,6 @@ class ABSConfiguration(Configuration): if confdds: confdds.start_device() if confrc: - #print confrc confrc.start_device() if confjars: confjars.start_device() diff --git a/apps/abs/views.py b/apps/abs/views.py index 71f3553..1dbfbba 100644 --- a/apps/abs/views.py +++ b/apps/abs/views.py @@ -174,7 +174,7 @@ def abs_conf(request, id_conf): return render(request, 'abs_conf.html', kwargs) def abs_conf_mqtt(request, id_conf): - print("Estoy en abs_conf_mqtt",flush=True) + # print("Estoy en abs_conf_mqtt",flush=True) conf = get_object_or_404(ABSConfiguration, pk=id_conf) beams = ABSBeam.objects.filter(abs_conf=conf) #------------Colors for Active Beam:------------- @@ -342,10 +342,10 @@ def send_beam(request, id_conf, id_beam): def change_beam_mqtt(request, id_conf, id_beam): conf = get_object_or_404(ABSConfiguration, pk=id_conf) - print("conf: {}".format(conf),flush=True) + # print("conf: {}".format(conf),flush=True) abs = Configuration.objects.filter(pk=conf.device.conf_active).first() - print("abs: {}".format(abs),flush=True) + # print("abs: {}".format(abs),flush=True) if abs!=conf: url = '#' if abs is None else abs.get_absolute_url() label = 'None' if abs is None else abs.label diff --git a/apps/atrad/models.py b/apps/atrad/models.py index 67b65c5..48370a1 100644 --- a/apps/atrad/models.py +++ b/apps/atrad/models.py @@ -115,6 +115,11 @@ class ATRADData(models.Model): potinc6_4 = models.SmallIntegerField() potret6_4 = models.SmallIntegerField() + combiner1 = models.SmallIntegerField() + combiner2 = models.SmallIntegerField() + combiner3 = models.SmallIntegerField() + combiner4 = models.SmallIntegerField() + class Meta: db_table = 'atrad_datas' diff --git a/apps/atrad/mqtt.py b/apps/atrad/mqtt.py index ec95c96..c0cd814 100644 --- a/apps/atrad/mqtt.py +++ b/apps/atrad/mqtt.py @@ -18,7 +18,8 @@ def insert(time,data): temp4_3,potinc4_3,potret4_3,temp5_3,potinc5_3,potret5_3,temp6_3,potinc6_3,potret6_3, status_4,temp_cll_4,nboards_4,tempdvr_4,potincdvr_4,potretdvr_4, temp1_4,potinc1_4,potret1_4,temp2_4,potinc2_4,potret2_4,temp3_4,potinc3_4,potret3_4, - temp4_4,potinc4_4,potret4_4,temp5_4,potinc5_4,potret5_4,temp6_4,potinc6_4,potret6_4) + temp4_4,potinc4_4,potret4_4,temp5_4,potinc5_4,potret5_4,temp6_4,potinc6_4,potret6_4, + combiner1,combiner2,combiner3,combiner4) VALUES(%s,%s,%s,%s,%s,%s,%s,%s, %s,%s,%s,%s,%s,%s,%s,%s,%s, %s,%s,%s,%s,%s,%s,%s,%s,%s, @@ -30,7 +31,8 @@ def insert(time,data): %s,%s,%s,%s,%s,%s,%s,%s,%s, %s,%s,%s,%s,%s,%s, %s,%s,%s,%s,%s,%s,%s,%s,%s, - %s,%s,%s,%s,%s,%s,%s,%s,%s);""" + %s,%s,%s,%s,%s,%s,%s,%s,%s, + %s,%s,%s,%s);""" try: # connect to the PostgreSQL database conn = psycopg2.connect(database="radarsys", user='docker', password='docker', host='radarsys-postgres', port= '5432') @@ -38,7 +40,7 @@ def insert(time,data): cur = conn.cursor() # execute the INSERT statement #data_tuple = [tuple(i[:]) for i in a] - values = (time,) + tuple(data[0][:25])+tuple(data[1][1:25])+tuple(data[2][1:25])+tuple(data[3][1:25]) + values = (time,) + tuple(data[0][:25])+tuple(data[1][1:25])+tuple(data[2][1:25])+tuple(data[3][1:25]) + tuple(data[0][29:31]) +tuple(data[2][27:29]) cur.execute(sql, values) # get the generated id back @@ -103,9 +105,9 @@ def GetTemperatures(data): def on_connect(mqtt_client, userdata, flags, rc): if rc == 0: - print('Connected successfullyasdss') - mqtt_client.subscribe("atrad/test4") - print("Exito") + # print('Connected successfullyasdss') + mqtt_client.subscribe(os.environ.get('MQTT_TOPIC_ATRAD_RECIEVE', 'atrad/test4')) + # print("Exito") else: print('Bad connection. Code:', rc) diff --git a/apps/atrad/templates/atrad_conf.html b/apps/atrad/templates/atrad_conf.html index 40f89d9..6a7c7ee 100644 --- a/apps/atrad/templates/atrad_conf.html +++ b/apps/atrad/templates/atrad_conf.html @@ -56,7 +56,7 @@
-
+

Status

@@ -191,10 +191,10 @@