@@ -0,0 +1,136 | |||
|
1 | {% extends "base.html" %} | |
|
2 | {% load static %} | |
|
3 | {% block title %}ATRAD Tx{{id_tx}} Temperatures{% endblock %} | |
|
4 | {% block content-title %}{{title}}{% endblock %} | |
|
5 | {% block content-suptitle %}Tx {{id_tx}}{% endblock %} | |
|
6 | ||
|
7 | {% block extra-head %} | |
|
8 | <style> | |
|
9 | .panel-body { | |
|
10 | background:#ffffff;} | |
|
11 | .panel-footer { | |
|
12 | background:#ffffff;} | |
|
13 | .card-body { | |
|
14 | padding-top: 1px; | |
|
15 | padding-bottom: 1px; | |
|
16 | } | |
|
17 | </style> | |
|
18 | {% endblock %} | |
|
19 | ||
|
20 | {% block content-graph %} | |
|
21 | <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.3/jquery.min.js"></script> | |
|
22 | <script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/socket.io/4.4.1/socket.io.min.js"></script> | |
|
23 | ||
|
24 | <div class="container-fluid"> | |
|
25 | <!-- Temperatura generales --> | |
|
26 | <div class="row "> | |
|
27 | <div class="panel panel-default"> | |
|
28 | <div class="panel-heading"> | |
|
29 | <h3 class="panel-title">Amplifiers</h3> | |
|
30 | </div> | |
|
31 | <div class="panel-body"> | |
|
32 | <div class="card border-0"> | |
|
33 | <div class="row"> | |
|
34 | <div class="card-body"> | |
|
35 | <h5 class="card-title">Amplifier 1</h5> | |
|
36 | <div id="plot-temp-1"></div> | |
|
37 | </div> | |
|
38 | <div class="card-body"> | |
|
39 | <h5 class="card-title">Amplifier 2</h5> | |
|
40 | <div id="plot-temp-2"></div> | |
|
41 | </div> | |
|
42 | <div class="card-body"> | |
|
43 | <h5 class="card-title">Amplifier 3</h5> | |
|
44 | <div id="plot-temp-3"></div> | |
|
45 | </div> | |
|
46 | <div class="card-body"> | |
|
47 | <h5 class="card-title">Amplifier 4</h5> | |
|
48 | <div id="plot-temp-4"></div> | |
|
49 | </div> | |
|
50 | </div> | |
|
51 | </div> | |
|
52 | </div> | |
|
53 | </div> | |
|
54 | </div> | |
|
55 | <div class="row"> | |
|
56 | <div class="panel panel-default"> | |
|
57 | <div class="panel-heading"> | |
|
58 | <h3 class="panel-title">Controllers and combiners</h3> | |
|
59 | </div> | |
|
60 | <div class="panel-body"> | |
|
61 | <div id="plot-temp-0"></div> | |
|
62 | </div> | |
|
63 | </div> | |
|
64 | </div> | |
|
65 | </div> | |
|
66 | ||
|
67 | <script> | |
|
68 | $(document).ready(function() { | |
|
69 | var socket = io.connect('http://' + document.domain + ':' + location.port); | |
|
70 | socket.on('connect', function(data) { | |
|
71 | console.log('Connecting... OK'); | |
|
72 | var data = '{{data|safe}}'.split(',') | |
|
73 | console.log(data); | |
|
74 | makePlot("plot-temp-0",4,["PC1","PC2","PC3","PC4"],[0,40]); | |
|
75 | makePlot("plot-temp-1",6,["PA1","PA2","PA3","PA4","PA5","PA6"],[0,40]) | |
|
76 | makePlot("plot-temp-2",6,["PA1","PA2","PA3","PA4","PA5","PA6"],[0,40]) | |
|
77 | makePlot("plot-temp-3",6,["PA1","PA2","PA3","PA4","PA5","PA6"],[0,40]) | |
|
78 | makePlot("plot-temp-4",6,["PA1","PA2","PA3","PA4","PA5","PA6"],[0,40]) | |
|
79 | }) | |
|
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]] | |
|
82 | streamPlot2("plot-temp-0",data.time,controllers,4); | |
|
83 | streamPlot2("plot-temp-1",data.time,data.temp[0].slice(1,7),6); | |
|
84 | streamPlot2("plot-temp-2",data.time,data.temp[1].slice(1,7),6); | |
|
85 | streamPlot2("plot-temp-3",data.time,data.temp[2].slice(1,7),6); | |
|
86 | streamPlot2("plot-temp-4",data.time,data.temp[3].slice(1,7),6); | |
|
87 | }) | |
|
88 | }); | |
|
89 | ||
|
90 | function makePlot(div, n=1, names=["", ""],ranges){ | |
|
91 | var plotDiv = document.getElementById(div); | |
|
92 | var traces = []; | |
|
93 | for (let i = 0; i < n; i++) { | |
|
94 | traces.push({x: [], y: [],mode: 'lines', name: names[i]}); | |
|
95 | } | |
|
96 | traces.push({x: [], y: [],mode: 'lines',line: {color:'rgb(219, 64, 82)',dash: 'dot',width: 2},name:"nominal",showlegend: false}); | |
|
97 | var yrange = ranges; | |
|
98 | var layout = { | |
|
99 | width: 505, | |
|
100 | height: 400, | |
|
101 | font: {size: 12}, | |
|
102 | margin: { t: 10, b:50, r:15 ,l:15}, | |
|
103 | xaxis: { | |
|
104 | type: 'date' | |
|
105 | }, | |
|
106 | yaxis: { | |
|
107 | range: yrange, | |
|
108 | }, | |
|
109 | legend: {"orientation": "h"}, | |
|
110 | }; | |
|
111 | var config = {responsive: true} | |
|
112 | Plotly.newPlot(plotDiv, traces, layout,config); | |
|
113 | }; | |
|
114 | ||
|
115 | function streamPlot2(div,x,y,cant){ | |
|
116 | var plotDiv = document.getElementById(div); | |
|
117 | if (plotDiv.data[0].x.length > 8){ | |
|
118 | for(let i=0;i<cant;i++){ | |
|
119 | plotDiv.data[i].x = plotDiv.data[i].x.slice(-11) | |
|
120 | plotDiv.data[i].y = plotDiv.data[i].y.slice(-11) | |
|
121 | } | |
|
122 | } | |
|
123 | var tm = []; | |
|
124 | var values = []; | |
|
125 | var index = [] | |
|
126 | for(let i=0;i<cant;i++){ | |
|
127 | values[i]=[y[i]]; | |
|
128 | tm[i] = [x]; | |
|
129 | index[i] = i; | |
|
130 | } | |
|
131 | var data_update = {x: tm, y: values} | |
|
132 | Plotly.extendTraces(plotDiv, data_update,index) | |
|
133 | }; | |
|
134 | ||
|
135 | </script> | |
|
136 | {% endblock %} No newline at end of file |
@@ -0,0 +1,28 | |||
|
1 | {% extends "dev_conf.html" %} | |
|
2 | {% load static %} | |
|
3 | ||
|
4 | ||
|
5 | {% block content-graph %} | |
|
6 | ||
|
7 | <p>The queryset object:</p> | |
|
8 | {{ mymembers }} | |
|
9 | ||
|
10 | <p>Last time {{last}}</p> | |
|
11 | ||
|
12 | ||
|
13 | <table> | |
|
14 | <tr> | |
|
15 | {% for key in keys %} | |
|
16 | <th>{{key}}</th> | |
|
17 | {% endfor %} | |
|
18 | </tr> | |
|
19 | {% for data in temps %} | |
|
20 | <tr> | |
|
21 | {% for key in keys %} | |
|
22 | <td>{{data|attr:key }}</td> | |
|
23 | {% endfor %} | |
|
24 | </tr> | |
|
25 | {% endfor %} | |
|
26 | </table> | |
|
27 | {% endblock %} | |
|
28 |
@@ -0,0 +1,128 | |||
|
1 | $(document).ready(function() { | |
|
2 | var socket = io.connect('http://' + document.domain + ':' + location.port); | |
|
3 | ||
|
4 | socket.on('connect', function(data) { | |
|
5 | console.log('Connecting... OK'); | |
|
6 | makePlot("plot-temp",2,["T1","T2"],[14, 45]) | |
|
7 | makePlot("plot-pot",2,["T1","T2"],[70,100]) | |
|
8 | makePlot("plot-pot-t1",4,["P1","P2","P3","P4"],[0,26]) | |
|
9 | makePlot("plot-pot-t2",4,["P1","P2","P3","P4"],[0,26]) | |
|
10 | $("#temp-info-1").hide(); | |
|
11 | $("#temp-info-2").hide(); | |
|
12 | }) | |
|
13 | ||
|
14 | socket.on('test', function(data) { | |
|
15 | let total = data.pow.reduce((a, b) => a + b, 0); | |
|
16 | var id = (data.num/4)>>0; | |
|
17 | streamPlot("plot-pot",data.time,total/1000.0,id,81); | |
|
18 | streamPlot("plot-temp",data.time,data.tmax[0],id,40); | |
|
19 | if(id == 0){ | |
|
20 | streamPlot2("plot-pot-t1",data.time,data.pow); | |
|
21 | ligthStatus('status1','status-text1',data.status); | |
|
22 | PotenciaAmplificador(['#pot1-1','#pot1-2','#pot1-3','#pot1-4'],data.pow); | |
|
23 | $('#temp-1').text(data.tmax[0]); | |
|
24 | if(eval(data.tmax[0])>30){ | |
|
25 | $("#temp-info-1").show(); | |
|
26 | $("#temp-info-1").text("TX"+(id+1)+" - Amplificador " + data.tmax[1]); | |
|
27 | } | |
|
28 | else{$("#status-temp").hide();} | |
|
29 | } | |
|
30 | else if(id == 1){ | |
|
31 | streamPlot2("plot-pot-t2",data.time,data.pow); | |
|
32 | ligthStatus('status2','status-text2',data.status); | |
|
33 | PotenciaAmplificador(['#pot2-1','#pot2-2','#pot2-3','#pot2-4'],data.pow); | |
|
34 | $('#temp-2').text(data.tmax[0]); | |
|
35 | if(eval(data.tmax[0])>30){ | |
|
36 | $("#temp-info-2").show(); | |
|
37 | $("#temp-info-2").text("TX"+(id+1)+" - Amplificador " + data.tmax[1]); | |
|
38 | } | |
|
39 | else{$("#status-temp").hide();} | |
|
40 | } | |
|
41 | }) | |
|
42 | $('form#controlON').submit(function(event) { | |
|
43 | socket.emit('control_event', {data: 1}); | |
|
44 | return false; | |
|
45 | }); | |
|
46 | $('form#controlOFF').submit(function(event) { | |
|
47 | socket.emit('control_event', {data: 0}); | |
|
48 | return false; | |
|
49 | }); | |
|
50 | $('#plot1').on('show.bs.modal', function(){ | |
|
51 | PotenciaAmplificador(['pot1-1','pot1-2','pot1-3','pot1-4']); | |
|
52 | }); | |
|
53 | $('#plot1').on('show.bs.modal', function(){ | |
|
54 | PotenciaAmplificador(['pot2-1','pot2-2','pot2-3','pot2-4']); | |
|
55 | }); | |
|
56 | }); | |
|
57 | ||
|
58 | function makePlot(div, n=1, names=["", ""],ranges){ | |
|
59 | var plotDiv = document.getElementById(div); | |
|
60 | var traces = []; | |
|
61 | for (let i = 0; i < n; i++) { | |
|
62 | traces.push({x: [], y: [],mode: 'lines', name: names[i]}); | |
|
63 | } | |
|
64 | traces.push({x: [], y: [],mode: 'lines',line: {color:'rgb(219, 64, 82)',dash: 'dot',width: 2},name:"nominal",showlegend: false}); | |
|
65 | var yrange = ranges; | |
|
66 | var layout = { | |
|
67 | autosize: true, | |
|
68 | font: {size: 12}, | |
|
69 | margin: { t: 10, b:50 }, | |
|
70 | xaxis: { | |
|
71 | type: 'date' | |
|
72 | }, | |
|
73 | yaxis: { | |
|
74 | range: yrange, | |
|
75 | }, | |
|
76 | }; | |
|
77 | ||
|
78 | Plotly.plot(plotDiv, traces, layout); | |
|
79 | }; | |
|
80 | ||
|
81 | function streamPlot(div,x,y,ind,val){ | |
|
82 | var plotDiv = document.getElementById(div); | |
|
83 | if (plotDiv.data[ind].x.length > 8){ | |
|
84 | plotDiv.data[2].x = plotDiv.data[2].x.slice(-23) | |
|
85 | plotDiv.data[2].y = plotDiv.data[2].y.slice(-23) | |
|
86 | plotDiv.data[ind].x = plotDiv.data[ind].x.slice(-11) | |
|
87 | plotDiv.data[ind].y = plotDiv.data[ind].y.slice(-11) | |
|
88 | } | |
|
89 | var tm = [x]; | |
|
90 | var values = [y]; | |
|
91 | var data_update = {x: [tm,tm], y: [values,[val]]} | |
|
92 | Plotly.extendTraces(plotDiv, data_update,[ind,2]) | |
|
93 | }; | |
|
94 | function streamPlot2(div,x,y){ | |
|
95 | var plotDiv = document.getElementById(div); | |
|
96 | if (plotDiv.data[0].x.length > 8){ | |
|
97 | for(let i=0;i<4;i++){ | |
|
98 | plotDiv.data[i].x = plotDiv.data[i].x.slice(-11) | |
|
99 | plotDiv.data[i].y = plotDiv.data[i].y.slice(-11) | |
|
100 | } | |
|
101 | } | |
|
102 | var tm = [x]; | |
|
103 | var values = []; | |
|
104 | for(let i=0;i<4;i++){ | |
|
105 | values[i]=[y[i]/1000.0]; | |
|
106 | } | |
|
107 | var data_update = {x: [tm,tm,tm,tm], y: values} | |
|
108 | Plotly.extendTraces(plotDiv, data_update,[0,1,2,3]) | |
|
109 | }; | |
|
110 | function ligthStatus(div1,div2,status){ | |
|
111 | if(status==='0000'){ | |
|
112 | document.getElementById(div1).style.backgroundColor = "red"; | |
|
113 | document.getElementById(div2).innerHTML = "Desabilitado"; | |
|
114 | } | |
|
115 | else if(status==='1111'){ | |
|
116 | document.getElementById(div1).style.backgroundColor = "green"; | |
|
117 | document.getElementById(div2).innerHTML = "Habilitado"; | |
|
118 | } | |
|
119 | else{ | |
|
120 | document.getElementById(div1).style.backgroundColor = "yellow"; | |
|
121 | document.getElementById(div2).innerHTML = "Incompleto"; | |
|
122 | } | |
|
123 | } | |
|
124 | function PotenciaAmplificador(div,data){ | |
|
125 | for(let i=0; i<4; i++){ | |
|
126 | $(div[i]).text(data[i]/1000.0); | |
|
127 | } | |
|
128 | } No newline at end of file |
@@ -0,0 +1,56 | |||
|
1 | * { | |
|
2 | margin: 0; | |
|
3 | padding: 0; | |
|
4 | font-family: "Montserrat"; | |
|
5 | } | |
|
6 | ||
|
7 | body { | |
|
8 | background-color: #fff3f5; | |
|
9 | } | |
|
10 | body .switch { | |
|
11 | display: block; | |
|
12 | margin: 30px; | |
|
13 | } | |
|
14 | body .switch h3 { | |
|
15 | font-weight: 400; | |
|
16 | padding-bottom: 6px; | |
|
17 | } | |
|
18 | body .switch input[type=checkbox] { | |
|
19 | display: none; | |
|
20 | } | |
|
21 | body .switch input[type=checkbox]:checked + label { | |
|
22 | background-color: #2f7df9; | |
|
23 | } | |
|
24 | body .switch input[type=checkbox]:checked + label:after { | |
|
25 | left: 33px; | |
|
26 | } | |
|
27 | body .switch label { | |
|
28 | transition: all 200ms ease-in-out; | |
|
29 | display: inline-block; | |
|
30 | position: relative; | |
|
31 | height: 40px; | |
|
32 | width: 70px; | |
|
33 | border-radius: 40px; | |
|
34 | cursor: pointer; | |
|
35 | background-color: #ddd; | |
|
36 | color: transparent; | |
|
37 | } | |
|
38 | body .switch label:after { | |
|
39 | transition: all 200ms ease-in-out; | |
|
40 | content: " "; | |
|
41 | position: absolute; | |
|
42 | height: 34px; | |
|
43 | width: 34px; | |
|
44 | border-radius: 50%; | |
|
45 | background-color: white; | |
|
46 | top: 3px; | |
|
47 | left: 3px; | |
|
48 | right: auto; | |
|
49 | box-shadow: 1px 1px 1px gray; | |
|
50 | } | |
|
51 | body .switch.colored input[type=checkbox]:checked + label { | |
|
52 | background-color: #55c946; | |
|
53 | } | |
|
54 | body .switch.colored label { | |
|
55 | background-color: #ff4949; | |
|
56 | } No newline at end of file |
@@ -0,0 +1,127 | |||
|
1 | $(document).ready(function() { | |
|
2 | var socket = io.connect('http://' + document.domain + ':' + location.port); | |
|
3 | ||
|
4 | socket.on('connect', function(data) { | |
|
5 | console.log('Connecting OK'); | |
|
6 | makePlot("plot-temp",2,["Tx1","Tx2"],[14, 45]) | |
|
7 | makePlot("plot-pot",2,["Tx1","Tx2"],[70,100]) | |
|
8 | makePlot("plot-pot-t1",4,["P1","P2","P3","P4"],[0,25]) | |
|
9 | makePlot("plot-pot-t2",4,["P1","P2","P3","P4"],[0,25]) | |
|
10 | }) | |
|
11 | ||
|
12 | socket.on('test', function(data) { | |
|
13 | UpdateData(data.num,data); | |
|
14 | }) | |
|
15 | $('#ONBtn1').click(function() { | |
|
16 | console.log("holaa") | |
|
17 | socket.emit('atrad_control_event', '11'); | |
|
18 | }); | |
|
19 | $('#ONBtn2').click(function(){ | |
|
20 | console.log("holaa2") | |
|
21 | socket.emit('atrad_control_event', '21'); | |
|
22 | }); | |
|
23 | $('#OFFBtn1').click(function() { | |
|
24 | socket.emit('atrad_control_event','10'); | |
|
25 | }); | |
|
26 | $('#OFFBtn2').click(function(){ | |
|
27 | socket.emit('atrad_control_event', '20'); | |
|
28 | }); | |
|
29 | }); | |
|
30 | ||
|
31 | function UpdateData(id,data){ | |
|
32 | let total = data.pow.reduce((a, b) => a + b, 0)/1000.0; | |
|
33 | streamPlot("plot-pot",data.time,total,id,81); | |
|
34 | streamPlot("plot-temp",data.time,data.tmax[0],id,40); | |
|
35 | streamPlot2("plot-pot-t"+(id+1),data.time,data.pow); | |
|
36 | ligthStatus(id,data.status); | |
|
37 | PotenciaAmplificador(id,data.pow,total); | |
|
38 | $('#temp'+(id+1)).text(data.tmax[0]); | |
|
39 | if(eval(data.tmax[0])>20){ | |
|
40 | $('#alert-time'+(id+1)).text(data.time.slice(-8,)); | |
|
41 | $('#alert-temp'+(id+1)).text(data.tmax[0]); | |
|
42 | $('#alert-loc'+(id+1)).text('Tx'+(id+1)+' '+data.tmax[1]); | |
|
43 | } | |
|
44 | } | |
|
45 | ||
|
46 | function makePlot(div, n=1, names=["", ""],ranges){ | |
|
47 | var plotDiv = document.getElementById(div); | |
|
48 | var traces = []; | |
|
49 | for (let i = 0; i < n; i++) { | |
|
50 | traces.push({x: [], y: [],mode: 'lines', name: names[i]}); | |
|
51 | } | |
|
52 | traces.push({x: [], y: [],mode: 'lines',line: {color:'rgb(219, 64, 82)',dash: 'dot',width: 2},name:"nominal",showlegend: false}); | |
|
53 | var yrange = ranges; | |
|
54 | var layout = { | |
|
55 | width: 700, | |
|
56 | height: 350, | |
|
57 | font: {size: 12}, | |
|
58 | margin: { t: 10, b:40,}, | |
|
59 | xaxis: { | |
|
60 | type: 'date' | |
|
61 | }, | |
|
62 | yaxis: { | |
|
63 | range: yrange, | |
|
64 | }, | |
|
65 | }; | |
|
66 | var config = {responsive: true} | |
|
67 | Plotly.newPlot(plotDiv, traces, layout,config); | |
|
68 | }; | |
|
69 | ||
|
70 | function streamPlot(div,x,y,ind,val){ | |
|
71 | var plotDiv = document.getElementById(div); | |
|
72 | if (plotDiv.data[ind].x.length > 8){ | |
|
73 | plotDiv.data[2].x = plotDiv.data[2].x.slice(-23) | |
|
74 | plotDiv.data[2].y = plotDiv.data[2].y.slice(-23) | |
|
75 | plotDiv.data[ind].x = plotDiv.data[ind].x.slice(-11) | |
|
76 | plotDiv.data[ind].y = plotDiv.data[ind].y.slice(-11) | |
|
77 | } | |
|
78 | var tm = [x]; | |
|
79 | var values = [y]; | |
|
80 | var data_update = {x: [tm,tm], y: [values,[val]]} | |
|
81 | Plotly.extendTraces(plotDiv, data_update,[ind,2]) | |
|
82 | }; | |
|
83 | function streamPlot2(div,x,y){ | |
|
84 | var plotDiv = document.getElementById(div); | |
|
85 | if (plotDiv.data[0].x.length > 8){ | |
|
86 | for(let i=0;i<4;i++){ | |
|
87 | plotDiv.data[i].x = plotDiv.data[i].x.slice(-11) | |
|
88 | plotDiv.data[i].y = plotDiv.data[i].y.slice(-11) | |
|
89 | } | |
|
90 | } | |
|
91 | var tm = [x]; | |
|
92 | var values = []; | |
|
93 | for(let i=0;i<4;i++){ | |
|
94 | values[i]=[y[i]/1000.0]; | |
|
95 | } | |
|
96 | var data_update = {x: [tm,tm,tm,tm], y: values} | |
|
97 | Plotly.extendTraces(plotDiv, data_update,[0,1,2,3]) | |
|
98 | }; | |
|
99 | ||
|
100 | function ligthStatus(id,status){ | |
|
101 | let div1 = 'status'+(id+1); | |
|
102 | let div2 = 'status-text'+(id+1); | |
|
103 | ||
|
104 | if(status==='0000'){ | |
|
105 | document.getElementById(div1).style.backgroundColor = "red"; | |
|
106 | document.getElementById(div2).innerHTML = "Disable"; | |
|
107 | } | |
|
108 | else if(status==='1111'){ | |
|
109 | document.getElementById(div1).style.backgroundColor = "green"; | |
|
110 | document.getElementById(div2).innerHTML = "Fully enable"; | |
|
111 | } | |
|
112 | else{ | |
|
113 | document.getElementById(div1).style.backgroundColor = "yellow"; | |
|
114 | document.getElementById(div2).innerHTML = "Not fully enable"; | |
|
115 | } | |
|
116 | }; | |
|
117 | ||
|
118 | function PotenciaAmplificador(id,data1,data2){ | |
|
119 | let div = '#pot'+(id+1); | |
|
120 | for(let i=1; i<5; i++){ | |
|
121 | $(div+'-'+i).text(data1[i-1]/1000.0); | |
|
122 | } | |
|
123 | $(div).text(data2); | |
|
124 | } | |
|
125 | $(".clickable-row").click(function() { | |
|
126 | window.open($(this).data("href"),); | |
|
127 | }); No newline at end of file |
@@ -18,16 +18,18 TZ=America/Lima | |||
|
18 | 18 | DOCKER_DATA=/data/dockers/radarsys/ |
|
19 | 19 | LOCAL_IP=192.168.1.128 |
|
20 | 20 | |
|
21 |
|
|
|
22 | MQTT_SERVER = 192.168.100.5 | |
|
21 | MQTT_SERVER=10.10.10.200 | |
|
22 | # MQTT_SERVER = 192.168.100.5 | |
|
23 | 23 | MQTT_PORT = 1883 |
|
24 | 24 | MQTT_KEEPALIVE = 3660 |
|
25 | 25 | |
|
26 |
MQTT_USER_ATRAD= |
|
|
27 |
MQTT_PASSWORD_ATRAD = |
|
|
26 | MQTT_USER_ATRAD='' | |
|
27 | MQTT_PASSWORD_ATRAD = '' | |
|
28 | MQTT_TOPIC_ATRAD_RECIEVE = "atrad/test4" | |
|
29 | ||
|
28 | 30 | MQTT_USER = abs |
|
29 | 31 | MQTT_PASSWORD = abs |
|
30 | MQTT_CLIENT_ID= abs_id | |
|
32 | ||
|
31 | 33 | TOPIC_ABS=abs/beams |
|
32 | 34 | TOPIC_ABS_ACK=abs/beams_ack |
|
33 | 35 | TOPIC_ABS_CHANGE=abs/change_beam |
@@ -339,7 +339,7 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) | |
|
342 | # print("*************************RUNNING ABS**************************",flush=True) | |
|
343 | 343 | self.message = 'ABS running' |
|
344 | 344 | |
|
345 | 345 | except Exception as e: |
@@ -357,7 +357,6 class ABSConfiguration(Configuration): | |||
|
357 | 357 | self.device.status = 2 |
|
358 | 358 | self.device.save() |
|
359 | 359 | self.message = 'ABS has been stopped.' |
|
360 | print("*************************STOPPED ABS**************************",flush=True) | |
|
361 | 360 | self.save() |
|
362 | 361 | |
|
363 | 362 | return True |
@@ -379,7 +378,6 class ABSConfiguration(Configuration): | |||
|
379 | 378 | This function sends the beams list to every abs module. |
|
380 | 379 | It needs 'module_conf' function |
|
381 | 380 | """ |
|
382 | print("Write 3") | |
|
383 | 381 | |
|
384 | 382 | beams = ABSBeam.objects.filter(abs_conf=self) |
|
385 | 383 | nbeams = len(beams) |
@@ -429,8 +427,6 class ABSConfiguration(Configuration): | |||
|
429 | 427 | status = ['0'] * 64 |
|
430 | 428 | n = 0 |
|
431 | 429 | |
|
432 | print("Llega una antes entrar a multicast4") | |
|
433 | ||
|
434 | 430 | sock = self.send_multicast(message) |
|
435 | 431 | |
|
436 | 432 | while True: |
@@ -453,7 +449,7 class ABSConfiguration(Configuration): | |||
|
453 | 449 | sock.close() |
|
454 | 450 | else: |
|
455 | 451 | self.message = "ABS Configuration does not have beams" |
|
456 | print('No beams') | |
|
452 | # print('No beams') | |
|
457 | 453 | #Start DDS-RC-JARS |
|
458 | 454 | if confdds: |
|
459 | 455 | confdds.start_device() |
@@ -469,7 +465,7 class ABSConfiguration(Configuration): | |||
|
469 | 465 | self.device.status = 0 |
|
470 | 466 | self.module_status = ''.join(status) |
|
471 | 467 | self.save() |
|
472 | print('Could not write ABS') | |
|
468 | # print('Could not write ABS') | |
|
473 | 469 | #Start DDS-RC-JARS |
|
474 | 470 | if confdds: |
|
475 | 471 | confdds.start_device() |
@@ -493,12 +489,12 class ABSConfiguration(Configuration): | |||
|
493 | 489 | if confjars: |
|
494 | 490 | confjars.start_device() |
|
495 | 491 | |
|
496 | print('Inicia intento de salvar device.status') | |
|
492 | # print('Inicia intento de salvar device.status') | |
|
497 | 493 | self.device.status = 3 |
|
498 | 494 | self.module_status = ''.join(status) |
|
499 | 495 | #print(status) |
|
500 | 496 | self.save() |
|
501 | print('Estatus salvado') | |
|
497 | # print('Estatus salvado') | |
|
502 | 498 | conf_active, __ = ABSActive.objects.get_or_create(pk=1) |
|
503 | 499 | conf_active.conf = self |
|
504 | 500 | conf_active.save() |
@@ -1,6 +1,7 | |||
|
1 | 1 | from django.contrib import admin |
|
2 | from .models import ATRADConfiguration | |
|
2 | from .models import ATRADConfiguration, ATRADData | |
|
3 | 3 | |
|
4 | 4 | # Register your models here. |
|
5 | 5 | |
|
6 | 6 | admin.site.register(ATRADConfiguration) |
|
7 | admin.site.register(ATRADData) No newline at end of file |
@@ -24,4 +24,4 class ATRADConfigurationForm(forms.ModelForm): | |||
|
24 | 24 | |
|
25 | 25 | class UploadFileForm(forms.Form): |
|
26 | 26 | title = forms.CharField(label='Extension Type', widget=forms.TextInput(attrs={'readonly':'readonly'})) |
|
27 |
file = forms.FileField() |
|
|
27 | file = forms.FileField() No newline at end of file |
@@ -5,16 +5,49 from django.core.validators import MinValueValidator, MaxValueValidator | |||
|
5 | 5 | |
|
6 | 6 | from .files import read_json_file |
|
7 | 7 | import requests |
|
8 | # Create your models here. validators=[MinValueValidator(62.5e6), MaxValueValidator(450e6)] | |
|
9 | 8 | |
|
10 | class ATRADConfiguration(Configuration): | |
|
9 | class ATRADData(models.Model): | |
|
10 | datetime = models.DateTimeField() | |
|
11 | ||
|
12 | nstx = models.SmallIntegerField() | |
|
13 | status = models.SmallIntegerField() | |
|
14 | temp_cll = models.SmallIntegerField() | |
|
15 | nboards = models.SmallIntegerField() | |
|
16 | ||
|
17 | tempdvr = models.SmallIntegerField() | |
|
18 | potincdvr = models.SmallIntegerField() | |
|
19 | potretdvr = models.SmallIntegerField() | |
|
20 | ||
|
21 | temp1 = models.SmallIntegerField() | |
|
22 | potinc1 = models.SmallIntegerField() | |
|
23 | potret1 = models.SmallIntegerField() | |
|
24 | temp2 = models.SmallIntegerField() | |
|
25 | potinc2 = models.SmallIntegerField() | |
|
26 | potret2 = models.SmallIntegerField() | |
|
27 | temp3 = models.SmallIntegerField() | |
|
28 | potinc3 = models.SmallIntegerField() | |
|
29 | potret3 = models.SmallIntegerField() | |
|
30 | temp4 = models.SmallIntegerField() | |
|
31 | potinc4 = models.SmallIntegerField() | |
|
32 | potret4 = models.SmallIntegerField() | |
|
33 | temp5 = models.SmallIntegerField() | |
|
34 | potinc5 = models.SmallIntegerField() | |
|
35 | potret5 = models.SmallIntegerField() | |
|
36 | temp6 = models.SmallIntegerField() | |
|
37 | potinc6 = models.SmallIntegerField() | |
|
38 | potret6 = models.SmallIntegerField() | |
|
11 | 39 | |
|
12 | topic = models.PositiveIntegerField(verbose_name='Topic',validators=[MaxValueValidator(10)], default = 0) | |
|
13 | 40 | |
|
14 | def verify_frequencies(self): | |
|
15 | 41 | |
|
16 | return True | |
|
42 | class Meta: | |
|
43 | db_table = 'atrad_datas' | |
|
44 | ||
|
45 | def __unicode__(self): | |
|
46 | return u'%s' % (self.name) | |
|
17 | 47 | |
|
48 | class ATRADConfiguration(Configuration): | |
|
49 | ||
|
50 | topic = models.PositiveIntegerField(verbose_name='Topic',validators=[MaxValueValidator(10)], default = 0) | |
|
18 | 51 | |
|
19 | 52 | def status_device(self): |
|
20 | 53 |
@@ -1,39 +1,105 | |||
|
1 | import os | |
|
2 | 1 |
|
|
3 | 2 | from radarsys import settings |
|
4 | 3 | from radarsys.socketconfig import sio as sio |
|
5 | 4 | import numpy as np |
|
5 | import psycopg2 | |
|
6 | import os | |
|
7 | ||
|
8 | def insert(time,data): | |
|
9 | sql = """INSERT INTO atrad_datas( | |
|
10 | datetime,nstx,status,temp_cll,nboards,tempdvr,potincdvr,potretdvr, | |
|
11 | temp1,potinc1,potret1,temp2,potinc2,potret2,temp3,potinc3,potret3, | |
|
12 | temp4,potinc4,potret4,temp5,potinc5,potret5,temp6,potinc6,potret6) | |
|
13 | VALUES(%s,%s,%s,%s,%s,%s,%s,%s, | |
|
14 | %s,%s,%s,%s,%s,%s,%s,%s,%s, | |
|
15 | %s,%s,%s,%s,%s,%s,%s,%s,%s);""" | |
|
16 | try: | |
|
17 | # connect to the PostgreSQL database | |
|
18 | conn = psycopg2.connect(database="radarsys", user='docker', password='docker', host='radarsys-postgres', port= '5432') | |
|
19 | # create a new cursor | |
|
20 | cur = conn.cursor() | |
|
21 | # execute the INSERT statement | |
|
22 | #data_tuple = [tuple(i[:]) for i in a] | |
|
23 | values = (time,) + tuple(data[0][:25]) | |
|
24 | cur.execute(sql, values) | |
|
25 | ||
|
26 | # get the generated id back | |
|
27 | #vendor_id = cur.fetchone()[0] | |
|
28 | ||
|
29 | # commit the changes to the database | |
|
30 | conn.commit() | |
|
31 | # close communication with the database | |
|
32 | cur.close() | |
|
33 | except (Exception, psycopg2.DatabaseError) as error: | |
|
34 | print(error) | |
|
35 | finally: | |
|
36 | if conn is not None: | |
|
37 | conn.close() | |
|
38 | ||
|
39 | def maxTemperature(trs): | |
|
40 | temps = GetTemperatures(trs) | |
|
41 | maxT_STX = [max(i) for i in temps] | |
|
42 | maxT = max(maxT_STX) | |
|
43 | STXnum = maxT_STX.index(maxT) | |
|
44 | STXloc = temps[STXnum].index(maxT) | |
|
45 | maxT_loc = 'Amp ' + str(STXnum+1) | |
|
46 | ||
|
47 | if STXloc == 0: | |
|
48 | maxT_loc = maxT_loc + " Controller" | |
|
49 | elif STXloc<7: | |
|
50 | maxT_loc = maxT_loc + " PA " + str(STXloc+1) | |
|
51 | else: | |
|
52 | maxT_loc = maxT_loc + " Combiners" | |
|
53 | ||
|
54 | return maxT,maxT_loc,temps | |
|
55 | ||
|
56 | def dataConvert(msg): | |
|
57 | msgStr = str(msg.payload) | |
|
58 | msgClean = [i for i in msgStr[21:-1].split("*")] | |
|
59 | dataSTX = [[],[],[],[]] | |
|
60 | for trs,i in zip(msgClean,[0,1,2,3]) : | |
|
61 | dataSTX[i]= [int(i) for i in trs[1:-1].split(",")] | |
|
62 | # Data to database | |
|
63 | insert(msgStr[2:21],dataSTX) | |
|
64 | # Data to send by socket | |
|
65 | id_STX = dataSTX[0][0] // 4 | |
|
66 | status = ''.join([msgClean[i][3] for i in [0,1,2,3]]) | |
|
67 | powers = [dataSTX[0][34],dataSTX[0][36],dataSTX[2][32],dataSTX[2][34]] | |
|
68 | tmax,index,tempData = maxTemperature(dataSTX) | |
|
69 | #Json to send | |
|
70 | data = {'time':msgStr[2:21],'num':id_STX,'pow':powers,'tmax':[str(tmax),index],'status':status} | |
|
71 | data_temp = {'time':msgStr[2:21],'temp':tempData} | |
|
72 | return data, data_temp | |
|
73 | ||
|
74 | def GetTemperatures(data): | |
|
75 | np_data = [np.array(i) for i in data] | |
|
76 | temps = [i[i<40] for i in np_data] | |
|
77 | return [i[i>15].tolist() for i in temps] | |
|
6 | 78 | |
|
7 | 79 | def on_connect(mqtt_client, userdata, flags, rc): |
|
8 | 80 | if rc == 0: |
|
9 |
|
|
|
10 |
mqtt_client.subscribe( |
|
|
81 | print('Connected successfullyasdss') | |
|
82 | mqtt_client.subscribe("atrad/test4") | |
|
83 | print("Exito") | |
|
11 | 84 | else: |
|
12 | 85 | print('Bad connection. Code:', rc) |
|
13 | 86 | |
|
14 | def maxima_temp(trs): | |
|
15 | np_array = [np.array(i) for i in trs] | |
|
16 | temps = [max(i[i<40]) for i in np_array] | |
|
17 | return max(temps) | |
|
18 | ||
|
19 | 87 | def on_message(mqtt_client, userdata, msg): |
|
20 |
|
|
|
21 | trsi = [[],[],[],[]] | |
|
22 | mensaje = str(msg.payload) | |
|
23 | datos = [i for i in mensaje[21:-1].split("*")] | |
|
24 | status=''.join([datos[i][3] for i in range(3)]) | |
|
25 | for trs,i in zip(datos,[0,1,2,3]) : | |
|
26 | trsi[i]= [int(i) for i in trs[1:-1].split(",")] | |
|
27 | potencias = [trsi[0][34],trsi[0][36],trsi[2][32],trsi[2][34]] | |
|
28 | tmax = maxima_temp(trsi) | |
|
29 | sio.emit('test', data={'time':mensaje[2:21],'num':trsi[0][0],'pow':potencias,'tmax':str(tmax),'status':status}) | |
|
88 | print('Received message on topic: {} with payload: {}'.format(msg.topic,msg.payload), flush=True) | |
|
89 | mainData, tempData = dataConvert(msg) | |
|
90 | # print("Recibi : {}".format(msg.payload),flush=True) | |
|
91 | #socket fot general data | |
|
92 | sio.emit('test',data = mainData) | |
|
93 | print(mainData) | |
|
94 | #socket for temperature details | |
|
95 | sio.emit('temptx'+str(mainData['num'] + 1),data = tempData) | |
|
30 | 96 | |
|
31 | 97 | client = mqtt.Client() |
|
32 | 98 | client.on_connect = on_connect |
|
33 | 99 | client.on_message = on_message |
|
34 | client.username_pw_set(os.environ.get('MQTT_USER_ATRAD', 'atrad'), os.environ.get('MQTT_PASSWORD_ATRAD', 'atrad')) | |
|
100 | client.username_pw_set( '','') | |
|
35 | 101 | client.connect( |
|
36 | 102 | host=os.environ.get('MQTT_SERVER', '10.10.10.200'), |
|
37 | 103 | port=int(settings.os.environ.get('MQTT_PORT', 1883)), |
|
38 |
keepalive=int(os.environ.get('MQTT_KEEPALIVE', |
|
|
104 | keepalive=int(os.environ.get('MQTT_KEEPALIVE', 60)) | |
|
39 | 105 | ) No newline at end of file |
@@ -1,4 +1,5 | |||
|
1 | 1 | {% extends "dev_conf.html" %} |
|
2 | {% load static %} | |
|
2 | 3 | {% block extra-head %} |
|
3 | 4 | <style> |
|
4 | 5 | .dot { |
@@ -8,281 +9,391 | |||
|
8 | 9 | border-radius: 50%; |
|
9 | 10 | display: inline-block; |
|
10 | 11 | } |
|
12 | .row{ | |
|
13 | margin-top: 3px; | |
|
14 | margin-bottom: 3px; | |
|
15 | } | |
|
16 | .th { | |
|
17 | vertical-align: middle; | |
|
18 | } | |
|
11 | 19 | </style> |
|
20 | <link href="https://cdn.jsdelivr.net/gh/gitbrent/bootstrap4-toggle@3.6.1/css/bootstrap4-toggle.min.css" rel="stylesheet"> | |
|
12 | 21 | {% endblock %} |
|
13 | 22 | |
|
14 |
{% block |
|
|
23 | {% block content-graph %} | |
|
15 | 24 | <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.3/jquery.min.js"></script> |
|
16 | 25 | <script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/socket.io/4.4.1/socket.io.min.js"></script> |
|
17 | 26 | |
|
18 | 27 | <div class="container-fluid"> |
|
19 | <div class="row"> | |
|
20 | <div class="col-xs-12"> | |
|
21 | <h1>Atrad Monitor</h1> | |
|
22 | </div> | |
|
23 | </div> | |
|
28 | <h1 class="py-4 text-center" >ATRAD Monitoring</h1> | |
|
24 | 29 | |
|
25 | <div class="row "> | |
|
26 | <!-- Potencia --> | |
|
27 |
<div class="c |
|
|
28 |
<div class=" |
|
|
29 | <div class="panel panel-default" style="width:100%;"> | |
|
30 | <div class="panel-heading"> | |
|
31 | <h3 class="panel-title">Potencia</h3> | |
|
32 |
< |
|
|
33 | <div class="panel-body"> | |
|
34 | <div class="col-xs-12"> | |
|
35 | <div class="row"> | |
|
36 | <div id="plot-pot"></div> | |
|
37 |
</d |
|
|
38 |
</ |
|
|
39 |
< |
|
|
40 | <div class="panel-footer"> | |
|
41 | <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#Pot1">T1</button> | |
|
42 |
<button type="button" class="btn btn- |
|
|
43 | </div> | |
|
44 |
</d |
|
|
30 | <!-- First row : Control--> | |
|
31 | <div class="row"> | |
|
32 | <div class="card border-light"> | |
|
33 | <div class="card-body"> | |
|
34 | <h3 class="card-title">Control</h3> | |
|
35 | <table class="table table-borderless"> | |
|
36 | <tbody> | |
|
37 | <tr> | |
|
38 | <th class="align-middle">Tx1</th> | |
|
39 | <td> | |
|
40 | <button type="button" class="btn btn-outline-success" id="ONBtn1"> ON </button> | |
|
41 | <button type="button" class="btn btn-outline-danger" id="OFFBtn1"> OFF </button> | |
|
42 | </td> | |
|
43 | </tr> | |
|
44 | <tr> | |
|
45 | <th class="align-middle">Tx2</th> | |
|
46 | <td> | |
|
47 | <button type="button" class="btn btn-outline-success" id="ONBtn2"> ON </button> | |
|
48 | <button type="button" class="btn btn-outline-danger" id="OFFBtn2"> OFF </button> | |
|
49 | </td> | |
|
50 | </tr> | |
|
51 | </tbody> | |
|
52 | </table> | |
|
45 | 53 | </div> |
|
46 | 54 | </div> |
|
47 | <div class="col col-xs-12"> | |
|
48 | <div class="panel panel-default"> | |
|
49 | <div class="panel-heading"> | |
|
50 | <h3 class="panel-title">Status</h3> | |
|
51 | </div> | |
|
52 |
|
|
|
53 | <table class="table table-borderless" style="max-width: 300px;"> | |
|
55 | </div> | |
|
56 | ||
|
57 | <!-- Second row : Status and alerts --> | |
|
58 | <div class="row"> | |
|
59 | <div class="card-deck"> | |
|
60 | <div class="card border-light"> | |
|
61 | <div class="card-body"> | |
|
62 | <h4 class="card-title">Status</h4> | |
|
63 | <table class="table table-borderless"> | |
|
54 | 64 | <tbody> |
|
55 | 65 | <tr> |
|
56 | 66 | <th scope="row">Tx1</th> |
|
57 | 67 | <td><span id="status1" class="dot"></span></td> |
|
58 |
<td><p id="status-text1" class="font-weight-bold"> |
|
|
68 | <td><p id="status-text1" class="font-weight-bold">No data</p></td> | |
|
59 | 69 | </tr> |
|
60 | 70 | <tr> |
|
61 | 71 | <th scope="row">Tx2</th> |
|
62 | 72 | <td><span id="status2" class="dot"></span></td> |
|
63 |
<td><p id="status-text2" class="font-weight-bold"> |
|
|
73 | <td><p id="status-text2" class="font-weight-bold">No data</p></td> | |
|
74 | </tr> | |
|
75 | </tbody> | |
|
76 | </table> | |
|
77 | </div> | |
|
78 | </div> | |
|
79 | <div class="card border-light"> | |
|
80 | <div class="card-body"> | |
|
81 | <h4 class="card-title">High Temperature Alerts</h4> | |
|
82 | <table class="table table-borderless"> | |
|
83 | <tbody> | |
|
84 | <tr> | |
|
85 | <th scope="row"><p id="alert-time1" class="font-weight-bold"></p></th> | |
|
86 | <td><p id="alert-temp1" class="font-weight-bold"></p></td> | |
|
87 | <td><p id="alert-loc1" class="font-weight-bold"></p></td> | |
|
88 | </tr> | |
|
89 | <tr> | |
|
90 | <th scope="row"><p id="alert-time2" class="font-weight-bold"></p></th> | |
|
91 | <td><p id="alert-temp2" class="font-weight-bold"></p></td> | |
|
92 | <td><p id="alert-loc2" class="font-weight-bold"></p></td> | |
|
64 | 93 | </tr> |
|
65 | 94 | </tbody> |
|
66 | 95 | </table> |
|
67 | 96 | </div> |
|
68 | 97 | </div> |
|
98 | <div class="card border-light"> | |
|
99 | <div class="card-body"> | |
|
100 | <h4 class="card-title">Power Alerts</h4> | |
|
101 | Lorem ipsum dolor sit amet consectetur adipisicing elit. Tempora quisquam cupiditate sunt eaque distinctio explicabo aliquam blanditiis illo eligendi eveniet culpa, vel laboriosam! Facilis dolores assumenda autem. Maiores, quibusdam eum. | |
|
102 | </div> | |
|
103 | </div> | |
|
69 | 104 | </div> |
|
70 | 105 | </div> |
|
71 | 106 | |
|
72 | <!-- Temperatura --> | |
|
73 | <div class="row"> | |
|
74 |
<div class="c |
|
|
75 |
<div class=" |
|
|
76 | <div class="panel-heading"> | |
|
77 | <h3 class="panel-title">Temperatura</h3> | |
|
78 | </div> | |
|
79 |
<div |
|
|
80 |
<div |
|
|
81 |
|
|
|
82 | <div id="plot-temp"></div> | |
|
107 | <!-- Third row : power graph--> | |
|
108 | <div class="row "> | |
|
109 | <div class="card border-light"> | |
|
110 | <div class="card-body"> | |
|
111 | <h3 class="card-title">Power graph</h3> | |
|
112 | <div class="row justify-content-md-center"> | |
|
113 | <div class="col-md-9"> | |
|
114 | <div id="plot-pot"></div> | |
|
115 | </div> | |
|
116 | <div class="col-md-3 text-end"> | |
|
117 | <div class="card-body"> | |
|
118 | <table class="table" style="max-width:170px;"> | |
|
119 | <tbody> | |
|
120 | <tr> | |
|
121 | <th scope="col"># Tx</th> | |
|
122 | <th scope="col">Power (kW)</th> | |
|
123 | </tr> | |
|
124 | <tr> | |
|
125 | <th scope="row">1</th> | |
|
126 | <td><p id="pot1"></p></td> | |
|
127 | </tr> | |
|
128 | <tr> | |
|
129 | <th scope="row">2</th> | |
|
130 | <td><p id="pot2"></p></td> | |
|
131 | </tr> | |
|
132 | </tbody> | |
|
133 | </table> | |
|
134 | </div> | |
|
135 | <div class="card-body"> | |
|
136 | <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#Pot-1">T1</button> | |
|
137 | <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#Pot-2">T2</button> | |
|
83 | 138 | </div> |
|
84 | 139 | </div> |
|
85 | 140 | </div> |
|
86 | 141 | </div> |
|
87 | 142 | </div> |
|
88 | 143 | </div> |
|
89 | ||
|
90 | <div class="row"> | |
|
91 | <!-- Controles --> | |
|
92 |
<div class="c |
|
|
93 | <div class="panel panel-default"> | |
|
94 |
<div class=" |
|
|
95 | <h3 class="panel-title">Control</h3> | |
|
96 | </div> | |
|
97 | <div class="panel-body"> | |
|
98 |
<div class="col- |
|
|
99 |
<div class=" |
|
|
100 | <div class="form-group col-xs-6"> | |
|
101 | <form id="controlON" method="POST" action=''> | |
|
102 | <button type="summit" class="btn btn-secondary btn-lg">Prender</button> | |
|
103 | </form> | |
|
104 | </div> | |
|
105 | <div class="form-group col-xs-6"> | |
|
106 | <form id="controlOFF" method="POST" action=''> | |
|
107 | <button type="summit" class="btn btn-secondary btn-lg">Apagar</button> | |
|
108 | </form> | |
|
109 |
</ |
|
|
144 | <!--Temperature Graph--> | |
|
145 | <div class="row "> | |
|
146 | <div class="card border-light"> | |
|
147 | <div class="card-body"> | |
|
148 | <h3 class="card-title">Temperature graph</h3> | |
|
149 | <div class="row justify-content-md-center"> | |
|
150 | <div class="col-md-9"> | |
|
151 | <div id="plot-temp"></div> | |
|
152 | </div> | |
|
153 | <div class="col-md-3 text-end"> | |
|
154 | <div class="card-body"> | |
|
155 | <table class="table table-hover" style="max-width:170px;"> | |
|
156 | <tbody> | |
|
157 | <tr> | |
|
158 | <th scope="col"># Tx</th> | |
|
159 | <th scope="col">Temperature (°C)</th> | |
|
160 | </tr> | |
|
161 | <tr class="clickable-row" data-href="{% url 'url_tx_atrad' dev_conf.id 'tx1' %}"> | |
|
162 | <th scope="row">1</th> | |
|
163 | <td><p id="temp1"></p></td> | |
|
164 | </tr> | |
|
165 | <tr class="clickable-row" data-href="{% url 'url_tx_atrad' dev_conf.id 'tx2' %}"> | |
|
166 | <th scope="row">2</th> | |
|
167 | <td><p id="temp2"></p></td> | |
|
168 | </tr> | |
|
169 | </tbody> | |
|
170 | </table> | |
|
110 | 171 | </div> |
|
111 | 172 | </div> |
|
112 | 173 | </div> |
|
113 | 174 | </div> |
|
114 | 175 | </div> |
|
115 | ||
|
116 | <div class="col-xs-6"> | |
|
117 | <div class="panel panel-default"> | |
|
118 | <div class="panel-heading"> | |
|
119 | </div> | |
|
120 | </div> | |
|
121 | </div> | |
|
122 | 176 | </div> |
|
123 | 177 | </div> |
|
124 | 178 | |
|
125 | 179 | <!--Modales--> |
|
126 | <div class="modal fade" id="Pot1" role="dialog"> | |
|
127 |
<div class="modal-dialog modal- |
|
|
180 | <div class="modal fade" id="Pot-1" role="dialog"> | |
|
181 | <div class="modal-dialog modal-lg" style="max-width:50%;min-width:750px"> | |
|
128 | 182 | <div class="modal-content"> |
|
129 | 183 | <div class="modal-header"> |
|
130 | 184 | <h4 class="modal-title">Potencia incidente - Transmisor 1</h4> |
|
131 | 185 | <button type="button" class="close" data-dismiss="modal">×</button> |
|
132 | 186 | </div> |
|
133 | 187 | <div class="modal-body"> |
|
134 |
<div class=" |
|
|
135 |
<div |
|
|
136 | </div> | |
|
137 | <div clas="col-xs-12"> | |
|
138 | <table class="table table-borderless"> | |
|
139 | <tbody> | |
|
140 |
<t |
|
|
141 |
<t |
|
|
142 |
<t |
|
|
143 |
<t |
|
|
144 | </tr> | |
|
145 | <tr> | |
|
146 |
<th scope="row">P |
|
|
147 |
<td> |
|
|
148 |
< |
|
|
149 |
< |
|
|
150 | <tr> | |
|
151 |
<t |
|
|
152 |
< |
|
|
153 |
<t |
|
|
154 |
</t |
|
|
155 | <tr> | |
|
156 |
< |
|
|
157 |
<t |
|
|
158 |
<t |
|
|
159 | </tr> | |
|
160 |
</t |
|
|
161 |
</t |
|
|
188 | <div class="row"> | |
|
189 | <div class="col"> | |
|
190 | <div id="plot-pot-t1"></div> | |
|
191 | </div> | |
|
192 | <div class="col"> | |
|
193 | <table class="table" style="max-width: 150px;"> | |
|
194 | <tbody> | |
|
195 | <tr> | |
|
196 | <th scope="col"># Amp</th> | |
|
197 | <th scope="col">Potencia (kW)</th> | |
|
198 | </tr> | |
|
199 | <tr> | |
|
200 | <th scope="row">P1</th> | |
|
201 | <td><p id="pot1-1"></p></td> | |
|
202 | </tr> | |
|
203 | <tr> | |
|
204 | <th scope="row">P2</th> | |
|
205 | <td><p id="pot1-2"></p></td> | |
|
206 | </tr> | |
|
207 | <tr> | |
|
208 | <th scope="row">P3</th> | |
|
209 | <td><p id="pot1-3"></p></td> | |
|
210 | </tr> | |
|
211 | <tr> | |
|
212 | <th scope="row">P4</th> | |
|
213 | <td><p id="pot1-4"></p></td> | |
|
214 | </tr> | |
|
215 | </tbody> | |
|
216 | </table> | |
|
217 | </div> | |
|
162 | 218 | </div> |
|
163 | 219 | </div> |
|
164 | 220 | </div> |
|
165 | 221 | </div> |
|
166 | 222 | </div> |
|
167 | 223 | |
|
168 | <div class="modal fade" id="Pot2" role="dialog"> | |
|
169 |
<div class="modal-dialog modal- |
|
|
224 | <div class="modal fade" id="Pot-2" role="dialog"> | |
|
225 | <div class="modal-dialog modal-lg" style="max-width:50%;min-width:750px"> | |
|
170 | 226 | <div class="modal-content"> |
|
171 | 227 | <div class="modal-header"> |
|
172 | 228 | <h4 class="modal-title">Potencia incidente - Transmisor 2</h4> |
|
173 | 229 | <button type="button" class="close" data-dismiss="modal">×</button> |
|
174 | 230 | </div> |
|
175 | 231 | <div class="modal-body"> |
|
176 |
<div class=" |
|
|
177 |
<div |
|
|
232 | <div class="row"> | |
|
233 | <div class="col"> | |
|
234 | <div id="plot-pot-t2"></div> | |
|
235 | </div> | |
|
236 | <div class="col"> | |
|
237 | <table class="table" style="max-width: 150px;"> | |
|
238 | <tbody> | |
|
239 | <tr> | |
|
240 | <th scope="col"># Amp</th> | |
|
241 | <th scope="col">Potencia (kW)</th> | |
|
242 | </tr> | |
|
243 | <tr> | |
|
244 | <th scope="row">P1</th> | |
|
245 | <td><p id="pot2-1"></p></td> | |
|
246 | </tr> | |
|
247 | <tr> | |
|
248 | <th scope="row">P2</th> | |
|
249 | <td><p id="pot2-2"></p></td> | |
|
250 | </tr> | |
|
251 | <tr> | |
|
252 | <th scope="row">P3</th> | |
|
253 | <td><p id="pot2-3"></p></td> | |
|
254 | </tr> | |
|
255 | <tr> | |
|
256 | <th scope="row">P4</th> | |
|
257 | <td><p id="pot2-4"></p></td> | |
|
258 | </tr> | |
|
259 | </tbody> | |
|
260 | </table> | |
|
261 | </div> | |
|
178 | 262 | </div> |
|
179 | 263 | </div> |
|
180 | 264 | </div> |
|
181 | 265 | </div> |
|
182 | 266 | </div> |
|
183 | 267 | |
|
184 | <script type="text/javascript" charset="utf-8"> | |
|
268 | <script> | |
|
185 | 269 | $(document).ready(function() { |
|
186 | 270 | var socket = io.connect('http://' + document.domain + ':' + location.port); |
|
187 | 271 | |
|
188 | 272 | socket.on('connect', function(data) { |
|
189 |
console.log('Connecting |
|
|
190 | makePlot("plot-temp",2,["T1","T2"],[14, 45]) | |
|
191 | makePlot("plot-pot",2,["T1","T2"],[70,100]) | |
|
192 |
makePlot("plot-pot-t1",4,["P1","P2","P3","P4"],[0,2 |
|
|
193 |
makePlot("plot-pot-t2",4,["P1","P2","P3","P4"],[0,2 |
|
|
273 | console.log('Connecting OK'); | |
|
274 | makePlot("plot-temp",2,["Tx1","Tx2"],[14, 45]) | |
|
275 | makePlot("plot-pot",2,["Tx1","Tx2"],[70,100]) | |
|
276 | makePlot("plot-pot-t1",4,["P1","P2","P3","P4"],[0,25]) | |
|
277 | makePlot("plot-pot-t2",4,["P1","P2","P3","P4"],[0,25]) | |
|
194 | 278 | }) |
|
195 | 279 | |
|
196 | 280 | socket.on('test', function(data) { |
|
197 | let total = data.pow.reduce((a, b) => a + b, 0); | |
|
198 | var id = (data.num/4)>>0; | |
|
199 | streamPlot("plot-pot",data.time,total/1000.0,id,81); | |
|
200 | streamPlot("plot-temp",data.time,data.tmax,id>>0,40); | |
|
201 | if(id == 0){streamPlot2("plot-pot-t1",data.time,data.pow);ligthStatus('status1','status-text1',data.status);} | |
|
202 | if(id == 1){streamPlot2("plot-pot-t2",data.time,data.pow);ligthStatus('status2','status-text2',data.status);} | |
|
281 | console.log(data) | |
|
282 | UpdateData(data.num,data); | |
|
203 | 283 | }) |
|
204 |
$(' |
|
|
205 | socket.emit('control_event', {data: 1}); | |
|
206 | return false; | |
|
284 | $('#ONBtn1').click(function() { | |
|
285 | console.log("holaa") | |
|
286 | socket.emit('atrad_control_event', '11'); | |
|
207 | 287 | }); |
|
208 |
$(' |
|
|
209 | socket.emit('control_event', {data: 0}); | |
|
210 | return false; | |
|
288 | $('#ONBtn2').click(function(){ | |
|
289 | console.log("holaa2") | |
|
290 | socket.emit('atrad_control_event', '21'); | |
|
211 | 291 | }); |
|
212 |
$( |
|
|
213 | $("#box").animate({height: "300px"}); | |
|
292 | $('#OFFBtn1').click(function() { | |
|
293 | socket.emit('atrad_control_event','10'); | |
|
214 | 294 | }); |
|
215 |
$( |
|
|
216 | $("#box").animate({height: "100px"}); | |
|
295 | $('#OFFBtn2').click(function(){ | |
|
296 | socket.emit('atrad_control_event', '20'); | |
|
217 | 297 | }); |
|
218 |
|
|
|
298 | }); | |
|
299 | ||
|
300 | function UpdateData(id,data){ | |
|
301 | let total = data.pow.reduce((a, b) => a + b, 0)/1000.0; | |
|
302 | streamPlot("plot-pot",data.time,total,id,81); | |
|
303 | streamPlot("plot-temp",data.time,data.tmax[0],id,40); | |
|
304 | streamPlot2("plot-pot-t"+(id+1),data.time,data.pow); | |
|
305 | ligthStatus(id,data.status); | |
|
306 | PotenciaAmplificador(id,data.pow,total); | |
|
307 | $('#temp'+(id+1)).text(data.tmax[0]); | |
|
308 | if(eval(data.tmax[0])>20){ | |
|
309 | $('#alert-time'+(id+1)).text(data.time.slice(-8,)); | |
|
310 | $('#alert-temp'+(id+1)).text(data.tmax[0]); | |
|
311 | $('#alert-loc'+(id+1)).text('Tx'+(id+1)+' '+data.tmax[1]); | |
|
312 | } | |
|
313 | } | |
|
219 | 314 | |
|
220 |
|
|
|
315 | function makePlot(div, n=1, names=["", ""],ranges){ | |
|
221 | 316 | var plotDiv = document.getElementById(div); |
|
222 | 317 | var traces = []; |
|
223 | 318 | for (let i = 0; i < n; i++) { |
|
224 | traces.push({x: [], y: [],mode: 'lines', name: names[i]}); | |
|
319 | traces.push({x: [], y: [],mode: 'lines', name: names[i]}); | |
|
225 | 320 | } |
|
226 | 321 | traces.push({x: [], y: [],mode: 'lines',line: {color:'rgb(219, 64, 82)',dash: 'dot',width: 2},name:"nominal",showlegend: false}); |
|
227 | 322 | var yrange = ranges; |
|
228 | 323 | var layout = { |
|
229 | height: 350, | |
|
230 | font: {size: 12}, | |
|
231 | margin: { t: 10, b:50}, | |
|
232 | xaxis: { | |
|
324 | width: 700, | |
|
325 | height: 350, | |
|
326 | font: {size: 12}, | |
|
327 | margin: { t: 10, b:40,}, | |
|
328 | xaxis: { | |
|
233 | 329 | type: 'date' |
|
234 | }, | |
|
235 | yaxis: { | |
|
330 | }, | |
|
331 | yaxis: { | |
|
236 | 332 | range: yrange, |
|
237 | }, | |
|
333 | }, | |
|
238 | 334 | }; |
|
335 | var config = {responsive: true} | |
|
336 | Plotly.newPlot(plotDiv, traces, layout,config); | |
|
337 | }; | |
|
239 | 338 | |
|
240 | Plotly.plot(plotDiv, traces, layout); | |
|
241 | }; | |
|
242 | ||
|
243 | function streamPlot(div,x,y,ind,val){ | |
|
339 | function streamPlot(div,x,y,ind,val){ | |
|
244 | 340 | var plotDiv = document.getElementById(div); |
|
245 | 341 | if (plotDiv.data[ind].x.length > 8){ |
|
246 | plotDiv.data[2].x = plotDiv.data[2].x.slice(-23) | |
|
247 | plotDiv.data[2].y = plotDiv.data[2].y.slice(-23) | |
|
248 | plotDiv.data[ind].x = plotDiv.data[ind].x.slice(-11) | |
|
249 | plotDiv.data[ind].y = plotDiv.data[ind].y.slice(-11) | |
|
342 | plotDiv.data[2].x = plotDiv.data[2].x.slice(-23) | |
|
343 | plotDiv.data[2].y = plotDiv.data[2].y.slice(-23) | |
|
344 | plotDiv.data[ind].x = plotDiv.data[ind].x.slice(-11) | |
|
345 | plotDiv.data[ind].y = plotDiv.data[ind].y.slice(-11) | |
|
250 | 346 | } |
|
251 | 347 | var tm = [x]; |
|
252 | 348 | var values = [y]; |
|
253 | 349 | var data_update = {x: [tm,tm], y: [values,[val]]} |
|
254 | 350 | Plotly.extendTraces(plotDiv, data_update,[ind,2]) |
|
255 |
|
|
|
256 |
|
|
|
351 | }; | |
|
352 | function streamPlot2(div,x,y){ | |
|
257 | 353 | var plotDiv = document.getElementById(div); |
|
258 | 354 | if (plotDiv.data[0].x.length > 8){ |
|
259 | for(let i=0;i<4;i++){ | |
|
355 | for(let i=0;i<4;i++){ | |
|
260 | 356 | plotDiv.data[i].x = plotDiv.data[i].x.slice(-11) |
|
261 | 357 | plotDiv.data[i].y = plotDiv.data[i].y.slice(-11) |
|
262 | } | |
|
358 | } | |
|
263 | 359 | } |
|
264 | 360 | var tm = [x]; |
|
265 | 361 | var values = []; |
|
266 | 362 | for(let i=0;i<4;i++){ |
|
267 | values[i]=[y[i]/1000.0]; | |
|
363 | values[i]=[y[i]/1000.0]; | |
|
268 | 364 | } |
|
269 | 365 | var data_update = {x: [tm,tm,tm,tm], y: values} |
|
270 | 366 | Plotly.extendTraces(plotDiv, data_update,[0,1,2,3]) |
|
271 |
|
|
|
272 | function ligthStatus(div1,div2,status){ | |
|
367 | }; | |
|
368 | ||
|
369 | function ligthStatus(id,status){ | |
|
370 | let div1 = 'status'+(id+1); | |
|
371 | let div2 = 'status-text'+(id+1); | |
|
372 | ||
|
273 | 373 | if(status==='0000'){ |
|
274 |
document.getElementById(div1).style.backgroundColor = " |
|
|
275 |
document.getElementById(div2).innerHTML = "D |
|
|
374 | document.getElementById(div1).style.backgroundColor = "red"; | |
|
375 | document.getElementById(div2).innerHTML = "Disable"; | |
|
276 | 376 | } |
|
277 | 377 | else if(status==='1111'){ |
|
278 | document.getElementById(div1).style.backgroundColor = "green"; | |
|
279 |
document.getElementById(div2).innerHTML = " |
|
|
378 | document.getElementById(div1).style.backgroundColor = "green"; | |
|
379 | document.getElementById(div2).innerHTML = "Fully enable"; | |
|
280 | 380 | } |
|
281 | 381 | else{ |
|
282 | document.getElementById(div1).style.backgroundColor = "yellow"; | |
|
283 |
document.getElementById(div2).innerHTML = " |
|
|
382 | document.getElementById(div1).style.backgroundColor = "yellow"; | |
|
383 | document.getElementById(div2).innerHTML = "Not fully enable"; | |
|
284 | 384 | } |
|
285 | } | |
|
385 | }; | |
|
286 | 386 | |
|
387 | function PotenciaAmplificador(id,data1,data2){ | |
|
388 | let div = '#pot'+(id+1); | |
|
389 | for(let i=1; i<5; i++){ | |
|
390 | $(div+'-'+i).text(data1[i-1]/1000.0); | |
|
391 | } | |
|
392 | $(div).text(data2); | |
|
393 | } | |
|
394 | $(".clickable-row").click(function() { | |
|
395 | window.open($(this).data("href"),); | |
|
396 | }); | |
|
287 | 397 | </script> |
|
398 | ||
|
288 | 399 | {% endblock %} No newline at end of file |
@@ -3,6 +3,8 from django.urls import path | |||
|
3 | 3 | from . import views |
|
4 | 4 | |
|
5 | 5 | urlpatterns = ( |
|
6 | path('prueba/', views.atrad_prueba, name='url_prueba'), | |
|
6 | 7 | path('<int:id_conf>/', views.atrad_conf, name='url_atrad_conf'), |
|
7 | 8 | path('<int:id_conf>/edit/', views.atrad_conf_edit, name='url_edit_atrad_conf'), |
|
9 | path('<int:id_conf>/<slug:id_tx>/', views.atrad_tx, name='url_tx_atrad'), | |
|
8 | 10 | ) No newline at end of file |
@@ -1,9 +1,10 | |||
|
1 | 1 | from django.shortcuts import redirect, render, get_object_or_404 |
|
2 | 2 | from django.contrib import messages |
|
3 | 3 | from django.http import HttpResponse |
|
4 | from django.template.loader import get_template | |
|
4 | 5 | |
|
5 | 6 | from apps.main.models import Experiment |
|
6 | from .models import ATRADConfiguration | |
|
7 | from .models import ATRADConfiguration, ATRADData | |
|
7 | 8 | |
|
8 | 9 | from .forms import ATRADConfigurationForm, UploadFileForm |
|
9 | 10 | from apps.main.views import sidebar |
@@ -15,7 +16,7 import os | |||
|
15 | 16 | from django.http import JsonResponse |
|
16 | 17 | from .mqtt import client as mqtt_client |
|
17 | 18 | from radarsys.socketconfig import sio as sio |
|
18 | ||
|
19 | from datetime import timedelta | |
|
19 | 20 | |
|
20 | 21 | def atrad_conf(request, id_conf): |
|
21 | 22 | |
@@ -38,12 +39,27 def atrad_conf(request, id_conf): | |||
|
38 | 39 | kwargs['button'] = 'Edit Configuration' |
|
39 | 40 | |
|
40 | 41 | #kwargs['no_play'] = True |
|
41 | ||
|
42 | 42 | ###### SIDEBAR ###### |
|
43 | 43 | kwargs.update(sidebar(conf=conf)) |
|
44 | 44 | |
|
45 | 45 | return render(request, 'atrad_conf.html', kwargs) |
|
46 | 46 | |
|
47 | def atrad_tx(request, id_conf, id_tx): | |
|
48 | kwargs = {} | |
|
49 | kwargs['id_tx'] = id_tx[-1] | |
|
50 | kwargs['keys'] = ['id','temp1','temp2','temp3','temp4','temp5','temp6'] | |
|
51 | kwargs['title'] = 'Temperature Details' | |
|
52 | kwargs['button'] = 'Edit Configuration' | |
|
53 | time = ATRADData.objects.last().datetime | |
|
54 | mydata = ATRADData.objects.filter(datetime__gte = (time-timedelta(minutes=20)),nstx=1).values_list('datetime','temp1','temp2','temp3','temp4','temp5','temp6') | |
|
55 | kwargs['data'] = QuerytoStr(mydata) | |
|
56 | return render(request, 'atrad_tx.html', kwargs) | |
|
57 | ||
|
58 | def QuerytoStr(data): | |
|
59 | time = data[0] | |
|
60 | strdata = str(time) | |
|
61 | return strdata | |
|
62 | ||
|
47 | 63 | def atrad_conf_edit(request, id_conf): |
|
48 | 64 | |
|
49 | 65 | conf = get_object_or_404(ATRADConfiguration, pk=id_conf) |
@@ -72,9 +88,6 def atrad_conf_edit(request, id_conf): | |||
|
72 | 88 | |
|
73 | 89 | return render(request, 'atrad_conf_edit.html', kwargs) |
|
74 | 90 | |
|
75 | import os | |
|
76 | from django.http import HttpResponse# | |
|
77 | ||
|
78 | 91 | def publish_message(request): |
|
79 | 92 | rc, mid = mqtt_client.publish('test/data2',1) |
|
80 | 93 | return JsonResponse({'code1': 'HIKA', 'code2': 'LUCAS'}) |
@@ -83,9 +96,17 def monitor(request): | |||
|
83 | 96 | kwargs = {'no_sidebar': True} |
|
84 | 97 | return render(request, 'monitor.html', kwargs) |
|
85 | 98 | |
|
86 | def prueba(request): | |
|
87 | kwargs = {'no_sidebar': True} | |
|
88 | return render(request, 'prueba.html', kwargs) | |
|
99 | def atrad_prueba(request): | |
|
100 | keys = ['id','temp1','temp2','temp3','temp4','temp5','temp6'] | |
|
101 | time = ATRADData.objects.last().datetime | |
|
102 | mydata = ATRADData.objects.filter(datetime__gte = (time-timedelta(hours=1))).values('id','temp1','temp2','temp3','temp4','temp5','temp6') | |
|
103 | template = get_template('prueba.html') | |
|
104 | context = { | |
|
105 | 'last' : time, | |
|
106 | 'temps': mydata, | |
|
107 | 'keys' : keys, | |
|
108 | } | |
|
109 | return HttpResponse(template.render(context, request)) | |
|
89 | 110 | |
|
90 | 111 | @sio.on('connection-bind') |
|
91 | 112 | def atrad_connection_bind(sid, data): |
@@ -97,12 +118,4 def atrad_disconnect(sid): | |||
|
97 | 118 | |
|
98 | 119 | @sio.event |
|
99 | 120 | def atrad_control_event(sid,message): |
|
100 |
mqtt_client.publish('test/data2',message |
|
|
101 | ||
|
102 | def hello(data): | |
|
103 | try: | |
|
104 | rc, mid = mqtt_client.publish('test/data2', 'Hello') | |
|
105 | sio.emit('test', data={'topic':mid, 'status': 'Not Running'}) | |
|
106 | except: | |
|
107 | print('ERROR', flush=True) | |
|
108 | return HttpResponse("Hello") No newline at end of file | |
|
121 | mqtt_client.publish('test/data2', json.dumps(message)) |
@@ -291,7 +291,6 class JARSConfiguration(Configuration): | |||
|
291 | 291 | self.device.status = payload['status'] |
|
292 | 292 | self.device.save() |
|
293 | 293 | self.message = payload['message'] |
|
294 | print("------STOP JARS------",flush=True) | |
|
295 | 294 | except Exception as e: |
|
296 | 295 | self.device.status = 0 |
|
297 | 296 | self.message = str(e) |
@@ -318,11 +317,8 class JARSConfiguration(Configuration): | |||
|
318 | 317 | |
|
319 | 318 | if self.device.status == 3: |
|
320 | 319 | self.message = 'Could not configure device. Software Acquisition is running' |
|
320 | print('Could not configure device. Software Acquisition is running') | |
|
321 | 321 | return False |
|
322 | ||
|
323 | print("------ JARS WRITING ------",flush=True) | |
|
324 | self.device.status = 5 #Busy | |
|
325 | print("STATUS:", self.device.status,flush=True) | |
|
326 | 322 | |
|
327 | 323 | data = self.experiment.parms_to_dict() |
|
328 | 324 | #print(data) |
@@ -349,14 +345,12 class JARSConfiguration(Configuration): | |||
|
349 | 345 | self.device.save() |
|
350 | 346 | if self.device.status == 1: |
|
351 | 347 | return False |
|
352 | print("------ JARS WRITED ------",flush=True) | |
|
353 | 348 | |
|
354 | 349 | except Exception as e: |
|
355 | 350 | self.device.status = 0 |
|
356 | 351 | self.message = str(e) |
|
357 | 352 | self.device.save() |
|
358 | 353 | return False |
|
359 | print("FINAL STATUS:", self.device.status,flush=True) | |
|
360 | 354 | return True |
|
361 | 355 | |
|
362 | 356 | def start_device(self): |
@@ -375,7 +369,6 class JARSConfiguration(Configuration): | |||
|
375 | 369 | self.message = str(e) |
|
376 | 370 | self.device.save() |
|
377 | 371 | return False |
|
378 | print("------START JARS------",flush=True) | |
|
379 | 372 | return True |
|
380 | 373 | |
|
381 | 374 | def get_log(self): |
@@ -12,7 +12,7 from apps.main.models import Experiment, Configuration | |||
|
12 | 12 | |
|
13 | 13 | class Command(BaseCommand): |
|
14 | 14 | """ |
|
15 | Restart experiment every night at 05:00 am. | |
|
15 | Restart experiment_number every night at 05:00 am. | |
|
16 | 16 | Example: |
|
17 | 17 | manage.py restart_experiment |
|
18 | 18 | """ |
@@ -35,13 +35,38 class Command(BaseCommand): | |||
|
35 | 35 | |
|
36 | 36 | else: |
|
37 | 37 | radar=campaign.get_experiments_by_radar(radar=None) |
|
38 | radar_id=radar[0]["id"] | |
|
39 | if campaign.experiments.all()[0].status !=1: | |
|
40 | print(campaign.name, "\t\t Stopping Campaign...") | |
|
41 | a=radar_stop_scheduler(campaign.id,radar_id,campaign.experiments.all()[0].id) | |
|
42 | print("New Status: ", a) | |
|
43 | else: | |
|
44 | print(campaign.name,"\t\t\t Campaign already stooped") | |
|
38 | # print(campaign.name) | |
|
39 | for rad in radar: | |
|
40 | radar_id=rad["id"] | |
|
41 | # print(radar_id, " ", rad["name"]) | |
|
42 | for exp in range(len(rad["experiments"])): | |
|
43 | experiment=rad["experiments"][exp] | |
|
44 | experiment_id= experiment.id | |
|
45 | if experiment.status!=1: | |
|
46 | print("Stopping Campaign {}, located on {}, the experiment {} with ID {}".format(campaign.name,rad["name"],experiment.name,experiment.id)) | |
|
47 | status=radar_stop_scheduler(campaign.id,radar_id,experiment.id) | |
|
48 | if status == 0: | |
|
49 | print("ERROR, status= {}".format(status)) | |
|
50 | # print("New Status: ", status) | |
|
51 | else: | |
|
52 | print("{} Experiment of the Campaign {} already stooped".format(experiment.name,campaign.name)) | |
|
53 | print("\n") | |
|
54 | ||
|
55 | # radar_id=radar[0]["id"] | |
|
56 | # if campaign.experiments.all()[0].status !=1: | |
|
57 | # print(campaign.name, "\t\t Stopping Campaign...") | |
|
58 | # a=radar_stop_scheduler(campaign.id,radar_id,campaign.experiments.all()[0].id) | |
|
59 | # print("New Status: ", a) | |
|
60 | # else: | |
|
61 | # print(campaign.name,"\t\t\t Campaign already stooped") | |
|
62 | ||
|
63 | ||
|
64 | # EXP_STATES = ( | |
|
65 | # (0,'Error'), #RED | |
|
66 | # (1,'Cancelled'), #YELLOW | |
|
67 | # (2,'Running'), #GREEN | |
|
68 | # (3,'Scheduled'), #BLUE | |
|
69 | # (4,'Unknown'), #WHITE | |
|
45 | 70 | |
|
46 | 71 | def radar_write_start_scheduler(id_camp,id_radar): |
|
47 | 72 | campaign = get_object_or_404(Campaign, pk=id_camp) |
@@ -54,6 +79,8 def radar_write_start_scheduler(id_camp,id_radar): | |||
|
54 | 79 | # print(exp) |
|
55 | 80 | if exp.status == 2: |
|
56 | 81 | print('\t\t\t {} \t\t Experiment already runnnig'.format(exp)) |
|
82 | elif exp.status==5: | |
|
83 | print('Experiment {} busy'.format(exp)) | |
|
57 | 84 | else: |
|
58 | 85 | exp.status = exp.start() |
|
59 | 86 | if exp.status == 0: |
@@ -425,6 +425,9 class Experiment(models.Model): | |||
|
425 | 425 | Configure and start experiments's devices |
|
426 | 426 | ABS-CGS-DDS-RC-JARS |
|
427 | 427 | ''' |
|
428 | self.status=5 #Busy | |
|
429 | self.save() | |
|
430 | # print("Guardando STATUS: {}".format(self.status)) | |
|
428 | 431 | |
|
429 | 432 | confs = [] |
|
430 | 433 | allconfs = Configuration.objects.filter(experiment=self, type = 0).order_by('-device__device_type__sequence') |
@@ -437,18 +440,32 class Experiment(models.Model): | |||
|
437 | 440 | else: |
|
438 | 441 | confs = allconfs |
|
439 | 442 | |
|
440 | print("confs: ",confs) | |
|
441 | #try: | |
|
443 | ||
|
442 | 444 | for conf in confs: |
|
443 |
print( |
|
|
444 |
conf. |
|
|
445 | conf.write_device() | |
|
445 | print(conf.device) | |
|
446 | print(conf.device.status) | |
|
447 | print("--------------",flush=True) | |
|
448 | print("Stop ",conf.name,flush=True) | |
|
449 | if conf.stop_device() ==False: | |
|
450 | print("Falló Stop ",conf.name) | |
|
451 | print("Cancelando Campaña...",flush=True) | |
|
452 | return 0 | |
|
453 | print("Write ",conf.name,flush=True) | |
|
454 | if conf.write_device() ==False: | |
|
455 | print("Falló Write ",conf.name) | |
|
456 | print("Cancelando Campaña...",flush=True) | |
|
457 | return 0 | |
|
458 | print("Save",conf.name,flush=True) | |
|
446 | 459 | conf.device.conf_active = conf.pk |
|
447 | 460 | conf.device.save() |
|
448 | conf.start_device() | |
|
461 | print("Start",conf.name,flush=True) | |
|
462 | if conf.start_device()==False: | |
|
463 | print("Falló Start ",conf.name) | |
|
464 | print("Cancelando Campaña...",flush=True) | |
|
465 | return 0 | |
|
466 | print("--- CONFIGURACIÓN EXITOSA ---",flush=True) | |
|
449 | 467 | time.sleep(1) |
|
450 | #except: | |
|
451 | #return 0 | |
|
468 | ||
|
452 | 469 | return 2 |
|
453 | 470 | |
|
454 | 471 |
@@ -5733,7 +5733,7 button.list-group-item-danger.active:focus { | |||
|
5733 | 5733 | } |
|
5734 | 5734 | .panel-default > .panel-heading { |
|
5735 | 5735 | color: #333; |
|
5736 |
background-color: #f |
|
|
5736 | background-color: #ffffff; | |
|
5737 | 5737 | border-color: #ddd; |
|
5738 | 5738 | } |
|
5739 | 5739 | .panel-default > .panel-heading + .panel-collapse > .panel-body { |
@@ -60,9 +60,9 | |||
|
60 | 60 | {% else %} |
|
61 | 61 | <div class="col-md-3 hidden-xs hidden-sm" role="complementary"> |
|
62 | 62 | <br><br> |
|
63 |
|
|
|
64 |
|
|
|
65 |
|
|
|
63 | <div id="sidebar"> | |
|
64 | {% block sidebar%} | |
|
65 | {% include "sidebar_devices.html" %} | |
|
66 | 66 | {% endblock %} |
|
67 | 67 | </div> |
|
68 | 68 | </div> |
@@ -88,12 +88,11 | |||
|
88 | 88 | {% endfor %} |
|
89 | 89 | {% endif %} |
|
90 | 90 | {% endblock %} |
|
91 | ||
|
92 |
{% block |
|
|
93 | {% endblock %} | |
|
94 | ||
|
91 | {% block content %} | |
|
92 | {% endblock %} | |
|
95 | 93 | </div> |
|
96 | ||
|
94 | {% block content-graph %} | |
|
95 | {% endblock %} | |
|
97 | 96 | |
|
98 | 97 | </div><!--/row--> |
|
99 | 98 | </div> <!-- container --> |
@@ -40,6 +40,8 | |||
|
40 | 40 | {% endfor%} |
|
41 | 41 | </tr> |
|
42 | 42 | {% for object in objects %} |
|
43 | <p>{{ object }}</p> | |
|
44 | <p>{{ objects }}</p> | |
|
43 | 45 | <tr class="clickable-row" data-href="{{object.get_absolute_url}}"> |
|
44 | 46 | <td>{{ forloop.counter|add:offset }}</td> |
|
45 | 47 | {% for key in keys %} |
@@ -46,7 +46,7 | |||
|
46 | 46 | {% else %} |
|
47 | 47 | <td class="text-info"><strong> Connected </strong></td> |
|
48 | 48 | {% endif %} |
|
49 |
|
|
|
49 | </tr> | |
|
50 | 50 | |
|
51 | 51 | {% for key in dev_conf_keys %} |
|
52 | 52 | <tr> |
@@ -199,9 +199,11 class RCConfiguration(Configuration): | |||
|
199 | 199 | 'params': json.dumps(line_data['params']) |
|
200 | 200 | } |
|
201 | 201 | ) |
|
202 | print(line,flush=True) | |
|
202 | 203 | |
|
203 | 204 | for i, line in enumerate(self.get_lines()): |
|
204 | 205 | line_params = json.loads(line.params) |
|
206 | print("accedimos a dict_to5",flush=True) | |
|
205 | 207 | if 'TX_ref' in line_params: |
|
206 | 208 | if line_params['TX_ref'] in (0, '0'): |
|
207 | 209 | line_params['TX_ref'] = '0' |
@@ -552,7 +554,7 class RCConfiguration(Configuration): | |||
|
552 | 554 | return True |
|
553 | 555 | |
|
554 | 556 | def write_device(self, raw=False): |
|
555 |
print("write device") |
|
|
557 | print("write device",flush=True) | |
|
556 | 558 | |
|
557 | 559 | if not raw: |
|
558 | 560 | clock = RCClock.objects.get(rc_configuration=self) |
@@ -561,8 +563,10 class RCConfiguration(Configuration): | |||
|
561 | 563 | else: |
|
562 | 564 | data = {'manual': [clock.multiplier, clock.divisor, clock.reference]} |
|
563 | 565 | payload = self.request('setfreq', 'post', data=json.dumps(data)) |
|
566 | print(payload) | |
|
564 | 567 | if payload['command'] != 'ok': |
|
565 | 568 | self.message = 'RC write: {}'.format(payload['command']) |
|
569 | print('RC write: {}'.format(payload['command'])) | |
|
566 | 570 | else: |
|
567 | 571 | self.message = payload['programming'] |
|
568 | 572 | if payload['programming'] == 'fail': |
@@ -616,10 +620,12 class RCConfiguration(Configuration): | |||
|
616 | 620 | self.device.status = 3 |
|
617 | 621 | self.device.save() |
|
618 | 622 | self.message = 'RC configured and started' |
|
623 | print('RC configured and started') | |
|
619 | 624 | else: |
|
620 | 625 | self.device.status = 1 |
|
621 | 626 | self.device.save() |
|
622 | 627 | self.message = 'RC write: {}'.format(payload['write']) |
|
628 | print('RC write: {}'.format(payload['write'])) | |
|
623 | 629 | return False |
|
624 | 630 | |
|
625 | 631 | #payload = self.request('start', 'post') |
@@ -682,8 +688,11 class RCLine(models.Model): | |||
|
682 | 688 | ordering = ['channel'] |
|
683 | 689 | |
|
684 | 690 | def __str__(self): |
|
685 |
|
|
|
686 |
|
|
|
691 | print("AAAA: ",self.rc_configuration,flush=True) | |
|
692 | ret = u'{}|{} - {}'.format(self.pk, self.get_name(),self.rc_configuration.name) | |
|
693 | return ret | |
|
694 | # if self.rc_configuration: | |
|
695 | # return u'{}|{} - {}'.format(self.pk, self.get_name(), self.rc_configuration.name) | |
|
687 | 696 | |
|
688 | 697 | def jsonify(self): |
|
689 | 698 |
@@ -355,20 +355,27 def update_lines_position(request, conf_id): | |||
|
355 | 355 | |
|
356 | 356 | |
|
357 | 357 | def import_file(request, conf_id): |
|
358 | ||
|
358 | print("HOLA",flush=True) | |
|
359 | 359 | conf = get_object_or_404(RCConfiguration, pk=conf_id) |
|
360 | print("HOLA2",flush=True) | |
|
360 | 361 | if request.method=='POST': |
|
361 | 362 | form = RCImportForm(request.POST, request.FILES) |
|
363 | print("HOLA3",flush=True) | |
|
362 | 364 | if form.is_valid(): |
|
363 | try: | |
|
364 | data = conf.import_from_file(request.FILES['file_name']) | |
|
365 | conf.dict_to_parms(data) | |
|
366 | conf.update_pulses() | |
|
367 | messages.success(request, 'Configuration "%s" loaded succesfully' % request.FILES['file_name']) | |
|
368 | return redirect(conf.get_absolute_url_edit()) | |
|
369 | ||
|
370 | except Exception as e: | |
|
371 | messages.error(request, 'Error parsing file: "%s" - %s' % (request.FILES['file_name'], repr(e))) | |
|
365 | print("HOLA4",flush=True) | |
|
366 | # try: | |
|
367 | print("HOLA5",flush=True) | |
|
368 | data = conf.import_from_file(request.FILES['file_name']) | |
|
369 | print("HOLA6",flush=True) | |
|
370 | conf.dict_to_parms(data) | |
|
371 | print("1",flush=True) | |
|
372 | conf.update_pulses() | |
|
373 | print("2",flush=True) | |
|
374 | messages.success(request, 'Configuration "%s" loaded succesfully' % request.FILES['file_name']) | |
|
375 | return redirect(conf.get_absolute_url_edit()) | |
|
376 | ||
|
377 | # except Exception as e: | |
|
378 | # messages.error(request, 'Error parsing file: "%s" - %s' % (request.FILES['file_name'], repr(e))) | |
|
372 | 379 | else: |
|
373 | 380 | messages.warning(request, 'Your current configuration will be replaced') |
|
374 | 381 | form = RCImportForm() |
@@ -35,6 +35,8 services: | |||
|
35 | 35 | - pgdata:/var/lib/postgresql/data |
|
36 | 36 | ports: |
|
37 | 37 | - 5432:5432 |
|
38 | expose: | |
|
39 | - 5432 | |
|
38 | 40 | env_file: .env |
|
39 | 41 | |
|
40 | 42 | #Web Server |
@@ -29,7 +29,10 ALLOWED_HOSTS = ['*'] | |||
|
29 | 29 | CSRF_TRUSTED_ORIGINS=[ |
|
30 | 30 | "http://*.localhost:8030", |
|
31 | 31 | "http://localhost:8030", |
|
32 | "http://127.0.0.1:8030" | |
|
32 | "http://127.0.0.1:8030", | |
|
33 | "http://*.localhost:8086", | |
|
34 | "http://localhost:8086", | |
|
35 | "http://127.0.0.1:8086" | |
|
33 | 36 | ] |
|
34 | 37 | #Si se requiere que la aplicación salga de este entorno, para otros usuarios es necesario hacer una API request https://fractalideas.com/blog/making-react-and-django-play-well-together-single-page-app-model/ |
|
35 | 38 |
@@ -1,6 +1,5 | |||
|
1 | 1 | from django.urls import include, path |
|
2 | 2 | from django.contrib import admin |
|
3 | #from django.contrib.staticfiles.urls import staticfiles_urlpatterns | |
|
4 | 3 | |
|
5 | 4 | urlpatterns = [ |
|
6 | 5 | path('admin/',admin.site.urls), |
@@ -15,6 +14,4 urlpatterns = [ | |||
|
15 | 14 | path('misc/',include('apps.misc.urls')), |
|
16 | 15 | path('dds_rest/', include('apps.dds_rest.urls')), |
|
17 | 16 | path('atrad/', include('apps.atrad.urls')), |
|
18 |
] |
|
|
19 | ||
|
20 | #urlpatterns += staticfiles_urlpatterns() | |
|
17 | ] No newline at end of file |
General Comments 0
You need to be logged in to leave comments.
Login now