##// END OF EJS Templates
ATRAD actualizando títulos
Renato Huallpa -
r397:e40954e05ac0
parent child
Show More
@@ -26,6 +26,7 MQTT_KEEPALIVE = 3660
26 26 MQTT_USER_ATRAD=''
27 27 MQTT_PASSWORD_ATRAD = ''
28 28 MQTT_TOPIC_ATRAD_RECIEVE = "atrad/test4"
29 MQTT_TOPIC_ATRAD_CONTROL = "atrad/test2"
29 30
30 31 MQTT_USER = abs
31 32 MQTT_PASSWORD = abs
@@ -339,7 +339,6 class ABSConfiguration(Configuration):
339 339 try:
340 340 #self.write_device()
341 341 send_task('task_change_beam', [self.id],)
342 # print("*************************RUNNING ABS**************************",flush=True)
343 342 self.message = 'ABS running'
344 343
345 344 except Exception as e:
@@ -430,7 +429,6 class ABSConfiguration(Configuration):
430 429 message += ''.join([fromBinary2Char(beam.module_6bits(i)) for beam in beams])
431 430 status = ['0'] * 64
432 431 n = 0
433 print("Estoy en write_device normal",flush=True)
434 432 sock = self.send_multicast(message)
435 433
436 434 while True:
@@ -679,7 +677,7 class ABSConfiguration(Configuration):
679 677 return False
680 678
681 679 sock = self.send_multicast('MNTR')
682 print("Estoy en status_deice",flush=True)
680 # print("Estoy en status_deice",flush=True)
683 681
684 682 n = 0
685 683 status = ['0'] * 64
@@ -883,29 +881,6 class ABSConfiguration(Configuration):
883 881 else:
884 882 beam_pos = 0
885 883
886 #El indice del apunte debe ser menor que el numero total de apuntes
887 #El servidor tcp en el embebido comienza a contar desde 0
888 # status = ['0'] * 64
889 # message = 'CHGB{}'.format(beam_pos)
890 # sock = self.send_multicast(message)
891 # while True:
892 # #for i in range(32):
893 # try:
894 # data, address = sock.recvfrom(1024)
895 # print (address, data)
896 # data = data.decode()
897 # if data == '1':
898 # status[int(address[0][10:])-1] = '3'
899 # elif data == '0':
900 # status[int(address[0][10:])-1] = '1'
901 # except socket.timeout:
902 # print('Timeout')
903 # break
904 # except Exception as e:
905 # print ('Error {}'.format(e))
906 # pass
907
908 # sock.close()
909 884 mqtt_client.publish('abs/change_beam',str(beam_pos))
910 885
911 886
@@ -913,7 +888,6 class ABSConfiguration(Configuration):
913 888 if confdds:
914 889 confdds.start_device()
915 890 if confrc:
916 #print confrc
917 891 confrc.start_device()
918 892 if confjars:
919 893 confjars.start_device()
@@ -174,7 +174,7 def abs_conf(request, id_conf):
174 174 return render(request, 'abs_conf.html', kwargs)
175 175
176 176 def abs_conf_mqtt(request, id_conf):
177 print("Estoy en abs_conf_mqtt",flush=True)
177 # print("Estoy en abs_conf_mqtt",flush=True)
178 178 conf = get_object_or_404(ABSConfiguration, pk=id_conf)
179 179 beams = ABSBeam.objects.filter(abs_conf=conf)
180 180 #------------Colors for Active Beam:-------------
@@ -342,10 +342,10 def send_beam(request, id_conf, id_beam):
342 342 def change_beam_mqtt(request, id_conf, id_beam):
343 343
344 344 conf = get_object_or_404(ABSConfiguration, pk=id_conf)
345 print("conf: {}".format(conf),flush=True)
345 # print("conf: {}".format(conf),flush=True)
346 346
347 347 abs = Configuration.objects.filter(pk=conf.device.conf_active).first()
348 print("abs: {}".format(abs),flush=True)
348 # print("abs: {}".format(abs),flush=True)
349 349 if abs!=conf:
350 350 url = '#' if abs is None else abs.get_absolute_url()
351 351 label = 'None' if abs is None else abs.label
@@ -115,6 +115,11 class ATRADData(models.Model):
115 115 potinc6_4 = models.SmallIntegerField()
116 116 potret6_4 = models.SmallIntegerField()
117 117
118 combiner1 = models.SmallIntegerField()
119 combiner2 = models.SmallIntegerField()
120 combiner3 = models.SmallIntegerField()
121 combiner4 = models.SmallIntegerField()
122
118 123 class Meta:
119 124 db_table = 'atrad_datas'
120 125
@@ -18,7 +18,8 def insert(time,data):
18 18 temp4_3,potinc4_3,potret4_3,temp5_3,potinc5_3,potret5_3,temp6_3,potinc6_3,potret6_3,
19 19 status_4,temp_cll_4,nboards_4,tempdvr_4,potincdvr_4,potretdvr_4,
20 20 temp1_4,potinc1_4,potret1_4,temp2_4,potinc2_4,potret2_4,temp3_4,potinc3_4,potret3_4,
21 temp4_4,potinc4_4,potret4_4,temp5_4,potinc5_4,potret5_4,temp6_4,potinc6_4,potret6_4)
21 temp4_4,potinc4_4,potret4_4,temp5_4,potinc5_4,potret5_4,temp6_4,potinc6_4,potret6_4,
22 combiner1,combiner2,combiner3,combiner4)
22 23 VALUES(%s,%s,%s,%s,%s,%s,%s,%s,
23 24 %s,%s,%s,%s,%s,%s,%s,%s,%s,
24 25 %s,%s,%s,%s,%s,%s,%s,%s,%s,
@@ -30,7 +31,8 def insert(time,data):
30 31 %s,%s,%s,%s,%s,%s,%s,%s,%s,
31 32 %s,%s,%s,%s,%s,%s,
32 33 %s,%s,%s,%s,%s,%s,%s,%s,%s,
33 %s,%s,%s,%s,%s,%s,%s,%s,%s);"""
34 %s,%s,%s,%s,%s,%s,%s,%s,%s,
35 %s,%s,%s,%s);"""
34 36 try:
35 37 # connect to the PostgreSQL database
36 38 conn = psycopg2.connect(database="radarsys", user='docker', password='docker', host='radarsys-postgres', port= '5432')
@@ -38,7 +40,7 def insert(time,data):
38 40 cur = conn.cursor()
39 41 # execute the INSERT statement
40 42 #data_tuple = [tuple(i[:]) for i in a]
41 values = (time,) + tuple(data[0][:25])+tuple(data[1][1:25])+tuple(data[2][1:25])+tuple(data[3][1:25])
43 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])
42 44 cur.execute(sql, values)
43 45
44 46 # get the generated id back
@@ -103,9 +105,9 def GetTemperatures(data):
103 105
104 106 def on_connect(mqtt_client, userdata, flags, rc):
105 107 if rc == 0:
106 print('Connected successfullyasdss')
107 mqtt_client.subscribe("atrad/test4")
108 print("Exito")
108 # print('Connected successfullyasdss')
109 mqtt_client.subscribe(os.environ.get('MQTT_TOPIC_ATRAD_RECIEVE', 'atrad/test4'))
110 # print("Exito")
109 111 else:
110 112 print('Bad connection. Code:', rc)
111 113
@@ -56,7 +56,7
56 56
57 57 <!-- Second row : Status and alerts -->
58 58 <div class="row">
59 <div class="card-deck" style="width: 90%;">
59 <div class="card-deck" style="width: 100%;">
60 60 <div class="card border-light">
61 61 <div class="card-body">
62 62 <h4 class="card-title">Status</h4>
@@ -191,10 +191,10
191 191
192 192 <!--Modales-->
193 193 <div class="modal fade" id="Pot-1" role="dialog">
194 <div class="modal-dialog modal-lg" style="max-width:50%;min-width:750px">
194 <div class="modal-dialog modal-lg" style="max-width:50%;min-width:928px">
195 195 <div class="modal-content">
196 196 <div class="modal-header">
197 <h4 class="modal-title">Potencia incidente - Transmisor 1</h4>
197 <h4 class="modal-title">Incident Power - Transmitter 1 </h4>
198 198 <button type="button" class="close" data-dismiss="modal">&times;</button>
199 199 </div>
200 200 <div class="modal-body">
@@ -207,7 +207,7
207 207 <tbody>
208 208 <tr>
209 209 <th scope="col"># Amp</th>
210 <th scope="col">Potencia (kW)</th>
210 <th scope="col">Power (kW)</th>
211 211 </tr>
212 212 <tr>
213 213 <th scope="row">P1</th>
@@ -235,10 +235,10
235 235 </div>
236 236
237 237 <div class="modal fade" id="Pot-2" role="dialog">
238 <div class="modal-dialog modal-lg" style="max-width:50%;min-width:750px">
238 <div class="modal-dialog modal-lg" style="max-width:50%;min-width:928px">
239 239 <div class="modal-content">
240 240 <div class="modal-header">
241 <h4 class="modal-title">Potencia incidente - Transmisor 2</h4>
241 <h4 class="modal-title">Incident Power - Transmitter 2</h4>
242 242 <button type="button" class="close" data-dismiss="modal">&times;</button>
243 243 </div>
244 244 <div class="modal-body">
@@ -251,7 +251,7
251 251 <tbody>
252 252 <tr>
253 253 <th scope="col"># Amp</th>
254 <th scope="col">Potencia (kW)</th>
254 <th scope="col">Power (kW)</th>
255 255 </tr>
256 256 <tr>
257 257 <th scope="row">P1</th>
@@ -278,6 +278,6
278 278 </div>
279 279 </div>
280 280
281 <script src="{% static 'js/atrad-conf.js' %}"></script>
281 <script src="{% static 'js/atrad-mainpage.js' %}"></script>
282 282
283 283 {% endblock %} No newline at end of file
@@ -26,7 +26,7
26 26 <div class="row ">
27 27 <div class="panel panel-default">
28 28 <div class="panel-heading">
29 <h3 class="panel-title">Amplifiers</h3>
29 <h3 class="panel-title">Amplifiers Temperature (°C)</h3>
30 30 </div>
31 31 <div class="panel-body">
32 32 <div class="card border-0">
@@ -55,7 +55,7
55 55 <div class="row">
56 56 <div class="panel panel-default">
57 57 <div class="panel-heading">
58 <h3 class="panel-title">Controllers and combiners</h3>
58 <h3 class="panel-title">Combiners Temperature °C</h3>
59 59 </div>
60 60 <div class="panel-body">
61 61 <div id="plot-temp-0"></div>
@@ -71,14 +71,14
71 71 console.log('Connecting... OK');
72 72 var basedata = JSON.parse('{{data|safe}}')
73 73 console.log(basedata);
74 makePlot("plot-temp-0",4,["PC1","PC2","PC3","PC4"],[10,40]);
74 makePlot("plot-temp-0",4,["PC1","PC2","PC3","PC4"],[10,40],basedata);
75 75 makePlot2("plot-temp-1",6,["PA1","PA2","PA3","PA4","PA5","PA6"],[10,40],basedata)
76 76 makePlot2("plot-temp-2",6,["PA1","PA2","PA3","PA4","PA5","PA6"],[10,40],basedata)
77 77 makePlot2("plot-temp-3",6,["PA1","PA2","PA3","PA4","PA5","PA6"],[10,40],basedata)
78 78 makePlot2("plot-temp-4",6,["PA1","PA2","PA3","PA4","PA5","PA6"],[10,40],basedata)
79 79 })
80 80 socket.on("temptx"+"{{id_tx}}", function(data) {
81 var controllers = [data.temp[0][1],data.temp[1][1],data.temp[2][1],data.temp[3][1]]
81 var combiners = [data.temp[0][8],data.temp[0][9],data.temp[2][8],data.temp[2][9]]
82 82 streamPlot2("plot-temp-0",data.time,controllers,4);
83 83 streamPlot2("plot-temp-1",data.time,data.temp[0].slice(2,8),6);
84 84 streamPlot2("plot-temp-2",data.time,data.temp[1].slice(2,8),6);
@@ -87,13 +87,19
87 87 })
88 88 });
89 89
90 function makePlot(div, n=1, names=["", ""],ranges){
90 function makePlot(div, n=1, names=["", ""],ranges,data){
91 91 var plotDiv = document.getElementById(div);
92 92 var traces = [];
93 var keys = ['combiner1','combiner2','combiner3','combiner4']
93 94 for (let i = 0; i < n; i++) {
94 traces.push({x: [], y: [],mode: 'lines', name: names[i]});
95 var x = [];
96 var y = [];
97 for(let j = 0;j < data.length; j++){
98 x[j] = data[j].datetime;
99 y[j] = data[j][keys[i]];
100 }
101 traces.push({x:x, y:y,mode: 'lines', name: names[i]});
95 102 }
96 traces.push({x: [], y: [],mode: 'lines',line: {color:'rgb(219, 64, 82)',dash: 'dot',width: 2},name:"nominal",showlegend: false});
97 103 var yrange = ranges;
98 104 var layout = {
99 105 width: 505,
@@ -112,7 +118,7
112 118 Plotly.newPlot(plotDiv, traces, layout,config);
113 119 };
114 120
115 function makePlot2(div, n=1, names=["", ""],ranges,data){
121 function makePlot2(div, n=1, names=["", ""],ranges,data,keys){
116 122 var plotDiv = document.getElementById(div);
117 123 var traces = [];
118 124 var keys = ['temp1','temp2','temp3','temp4','temp5','temp6']
@@ -129,7 +135,7
129 135 var yrange = ranges;
130 136 var layout = {
131 137 width: 505,
132 height: 400,
138 height: 300,
133 139 font: {size: 12},
134 140 margin: { t: 10, b:50, r:15 ,l:15},
135 141 xaxis: {
@@ -17,6 +17,7 from django.http import JsonResponse
17 17 from .mqtt import client as mqtt_client
18 18 from radarsys.socketconfig import sio as sio
19 19 from datetime import timedelta
20 from datetime import datetime
20 21
21 22 def atrad_conf(request, id_conf):
22 23
@@ -49,11 +50,18 def atrad_tx(request, id_conf, id_tx):
49 50 kwargs['id_tx'] = id_tx[-1]
50 51 kwargs['title'] = 'Temperature Details'
51 52 kwargs['button'] = 'Edit Configuration'
53 try:
52 54 time = ATRADData.objects.last().datetime
55 except:
56 time = datetime.now()
57
53 58 id_stx = (int(id_tx[-1])-1)*4+1
54 mydata = ATRADData.objects.filter(datetime__gte = (time-timedelta(hours=1)),nstx = id_stx).values('datetime','temp1_1','temp2_1','temp3_1','temp4_1','temp5_1','temp6_1',
55 'temp1_2','temp2_2','temp3_2','temp4_2','temp5_2','temp6_2','temp1_3','temp2_3','temp3_3','temp4_3','temp5_3','temp6_3',
56 'temp1_4','temp2_4','temp3_4','temp4_4','temp5_4','temp6_4')
59 mydata = ATRADData.objects.filter(datetime__gte = (time-timedelta(hours=1)),nstx = id_stx).values('datetime',
60 'temp1_1','temp2_1','temp3_1','temp4_1','temp5_1','temp6_1',
61 'temp1_2','temp2_2','temp3_2','temp4_2','temp5_2','temp6_2',
62 'temp1_3','temp2_3','temp3_3','temp4_3','temp5_3','temp6_3',
63 'temp1_4','temp2_4','temp3_4','temp4_4','temp5_4','temp6_4',
64 'combiner1','combiner2','combiner3','combiner4')
57 65 kwargs['data'] = json.dumps(list(mydata),default=str)
58 66 return render(request, 'atrad_tx.html', kwargs)
59 67
@@ -122,4 +130,4 def atrad_disconnect(sid):
122 130
123 131 @sio.event
124 132 def atrad_control_event(sid,message):
125 mqtt_client.publish('test/data2', json.dumps(message)) No newline at end of file
133 mqtt_client.publish(os.environ.get('MQTT_TOPIC_ATRAD_CONTROL', 'atrad/test2'), json.dumps(message)) No newline at end of file
@@ -341,7 +341,7 class JARSConfiguration(Configuration):
341 341 return False
342 342
343 343 json_data = json.dumps(data)
344 print("STATUS:", self.device.status,flush=True)
344 # print("STATUS:", self.device.status,flush=True)
345 345
346 346 try:
347 347 payload = self.request('write', 'post', json=json_data)
1 NO CONTENT: file renamed from apps/main/management/commands/hello.py to apps/main/management/commands/scheduler.py
@@ -784,21 +784,18 class Configuration(PolymorphicModel):
784 784 def stop_device(self):
785 785
786 786 self.message = 'Function not implemented'
787 print("BUENAS SEÑALES??? NO LO CREO2",flush=True)
788 787 return False
789 788
790 789
791 790 def start_device(self):
792 791
793 792 self.message = 'Function not implemented'
794 print("BUENAS SEÑALES??? NO LO CREO",flush=True)
795 793 return False
796 794
797 795
798 796 def write_device(self, parms):
799 797
800 798 self.message = 'Function not implemented'
801 print("BUENAS SEÑALES??? NO LO CREO3",flush=True)
802 799 return False
803 800
804 801 def write_device_mqtt(self, parms):
@@ -355,22 +355,14 def update_lines_position(request, conf_id):
355 355
356 356
357 357 def import_file(request, conf_id):
358 # print("HOLA",flush=True)
359 358 conf = get_object_or_404(RCConfiguration, pk=conf_id)
360 # print("HOLA2",flush=True)
361 359 if request.method=='POST':
362 360 form = RCImportForm(request.POST, request.FILES)
363 # print("HOLA3",flush=True)
364 361 if form.is_valid():
365 #print("HOLA4",flush=True)
366 362 # try:
367 #print("HOLA5",flush=True)
368 363 data = conf.import_from_file(request.FILES['file_name'])
369 #print("HOLA6",flush=True)
370 364 conf.dict_to_parms(data)
371 #print("1",flush=True)
372 365 conf.update_pulses()
373 #print("2",flush=True)
374 366 messages.success(request, 'Configuration "%s" loaded succesfully' % request.FILES['file_name'])
375 367 return redirect(conf.get_absolute_url_edit())
376 368
@@ -18,7 +18,7 services:
18 18 ofelia.enabled: "true"
19 19 # ofelia.job-exec.restart-reception.schedule: "0 1/5 * * * *"
20 20 ofelia.job-exec.test.schedule: "@every 5s"
21 ofelia.job-exec.test.command: "python manage.py hello"
21 ofelia.job-exec.test.command: "python manage.py scheduler"
22 22 # ofelia.job-exec.restart-pedestal.schedule: "0 2/10 * * * *"
23 23 # ofelia.job-exec.restart-pedestal.command: "python manage.py restart_pedestal"
24 24 # ofelia.job-exec.restart-experiment.schedule: "@midnight"
@@ -45,7 +45,7 services:
45 45 restart: always
46 46 build: ./nginx/
47 47 ports:
48 - '0.0.0.0:8086:80'
48 - '0.0.0.0:80:80'
49 49 volumes_from:
50 50 - radarsys
51 51 links:
@@ -31,6 +31,7 CSRF_TRUSTED_ORIGINS=[
31 31 "http://localhost:8030",
32 32 "http://127.0.0.1:8030",
33 33 "http://*.localhost:8086",
34 "http://0.0.0.0:8086",
34 35 "http://localhost:8086",
35 36 "http://127.0.0.1:8086"
36 37 ]
1 NO CONTENT: file renamed from radarsys/static/js/atrad-conf.js to radarsys/static/js/atrad-mainpage.js
1 NO CONTENT: modified file chmod 100644 => 100755
1 NO CONTENT: modified file chmod 100644 => 100755
1 NO CONTENT: modified file chmod 100644 => 100755
1 NO CONTENT: modified file chmod 100644 => 100755
1 NO CONTENT: modified file chmod 100644 => 100755
1 NO CONTENT: modified file chmod 100644 => 100755
1 NO CONTENT: modified file chmod 100644 => 100755
1 NO CONTENT: modified file chmod 100644 => 100755
1 NO CONTENT: modified file chmod 100644 => 100755
1 NO CONTENT: modified file chmod 100644 => 100755
1 NO CONTENT: modified file chmod 100644 => 100755
1 NO CONTENT: modified file chmod 100644 => 100755
1 NO CONTENT: modified file chmod 100644 => 100755
1 NO CONTENT: modified file chmod 100644 => 100755
1 NO CONTENT: modified file chmod 100644 => 100755
1 NO CONTENT: modified file chmod 100644 => 100755
1 NO CONTENT: modified file chmod 100644 => 100755
1 NO CONTENT: modified file chmod 100644 => 100755
1 NO CONTENT: modified file chmod 100644 => 100755
General Comments 0
You need to be logged in to leave comments. Login now