@@ -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 | DOCKER_DATA=/data/dockers/radarsys/ |
|
18 | DOCKER_DATA=/data/dockers/radarsys/ | |
19 | LOCAL_IP=192.168.1.128 |
|
19 | LOCAL_IP=192.168.1.128 | |
20 |
|
20 | |||
21 |
|
|
21 | MQTT_SERVER=10.10.10.200 | |
22 | MQTT_SERVER = 192.168.100.5 |
|
22 | # MQTT_SERVER = 192.168.100.5 | |
23 | MQTT_PORT = 1883 |
|
23 | MQTT_PORT = 1883 | |
24 | MQTT_KEEPALIVE = 3660 |
|
24 | MQTT_KEEPALIVE = 3660 | |
25 |
|
25 | |||
26 |
MQTT_USER_ATRAD= |
|
26 | MQTT_USER_ATRAD='' | |
27 |
MQTT_PASSWORD_ATRAD = |
|
27 | MQTT_PASSWORD_ATRAD = '' | |
|
28 | MQTT_TOPIC_ATRAD_RECIEVE = "atrad/test4" | |||
|
29 | ||||
28 | MQTT_USER = abs |
|
30 | MQTT_USER = abs | |
29 | MQTT_PASSWORD = abs |
|
31 | MQTT_PASSWORD = abs | |
30 | MQTT_CLIENT_ID= abs_id |
|
32 | ||
31 | TOPIC_ABS=abs/beams |
|
33 | TOPIC_ABS=abs/beams | |
32 | TOPIC_ABS_ACK=abs/beams_ack |
|
34 | TOPIC_ABS_ACK=abs/beams_ack | |
33 | TOPIC_ABS_CHANGE=abs/change_beam |
|
35 | TOPIC_ABS_CHANGE=abs/change_beam |
@@ -6,3 +6,4 pipLibraries/ | |||||
6 | .env |
|
6 | .env | |
7 | remove_migrations.py |
|
7 | remove_migrations.py | |
8 | migrations/ |
|
8 | migrations/ | |
|
9 | builder |
@@ -339,7 +339,7 class ABSConfiguration(Configuration): | |||||
339 | try: |
|
339 | try: | |
340 | #self.write_device() |
|
340 | #self.write_device() | |
341 | send_task('task_change_beam', [self.id],) |
|
341 | send_task('task_change_beam', [self.id],) | |
342 | print("*************************RUNNING ABS**************************",flush=True) |
|
342 | # print("*************************RUNNING ABS**************************",flush=True) | |
343 | self.message = 'ABS running' |
|
343 | self.message = 'ABS running' | |
344 |
|
344 | |||
345 | except Exception as e: |
|
345 | except Exception as e: | |
@@ -357,7 +357,6 class ABSConfiguration(Configuration): | |||||
357 | self.device.status = 2 |
|
357 | self.device.status = 2 | |
358 | self.device.save() |
|
358 | self.device.save() | |
359 | self.message = 'ABS has been stopped.' |
|
359 | self.message = 'ABS has been stopped.' | |
360 | print("*************************STOPPED ABS**************************",flush=True) |
|
|||
361 | self.save() |
|
360 | self.save() | |
362 |
|
361 | |||
363 | return True |
|
362 | return True | |
@@ -379,7 +378,6 class ABSConfiguration(Configuration): | |||||
379 | This function sends the beams list to every abs module. |
|
378 | This function sends the beams list to every abs module. | |
380 | It needs 'module_conf' function |
|
379 | It needs 'module_conf' function | |
381 | """ |
|
380 | """ | |
382 | print("Write 3") |
|
|||
383 |
|
381 | |||
384 | beams = ABSBeam.objects.filter(abs_conf=self) |
|
382 | beams = ABSBeam.objects.filter(abs_conf=self) | |
385 | nbeams = len(beams) |
|
383 | nbeams = len(beams) | |
@@ -429,8 +427,6 class ABSConfiguration(Configuration): | |||||
429 | status = ['0'] * 64 |
|
427 | status = ['0'] * 64 | |
430 | n = 0 |
|
428 | n = 0 | |
431 |
|
429 | |||
432 | print("Llega una antes entrar a multicast4") |
|
|||
433 |
|
||||
434 | sock = self.send_multicast(message) |
|
430 | sock = self.send_multicast(message) | |
435 |
|
431 | |||
436 | while True: |
|
432 | while True: | |
@@ -453,7 +449,7 class ABSConfiguration(Configuration): | |||||
453 | sock.close() |
|
449 | sock.close() | |
454 | else: |
|
450 | else: | |
455 | self.message = "ABS Configuration does not have beams" |
|
451 | self.message = "ABS Configuration does not have beams" | |
456 | print('No beams') |
|
452 | # print('No beams') | |
457 | #Start DDS-RC-JARS |
|
453 | #Start DDS-RC-JARS | |
458 | if confdds: |
|
454 | if confdds: | |
459 | confdds.start_device() |
|
455 | confdds.start_device() | |
@@ -469,7 +465,7 class ABSConfiguration(Configuration): | |||||
469 | self.device.status = 0 |
|
465 | self.device.status = 0 | |
470 | self.module_status = ''.join(status) |
|
466 | self.module_status = ''.join(status) | |
471 | self.save() |
|
467 | self.save() | |
472 | print('Could not write ABS') |
|
468 | # print('Could not write ABS') | |
473 | #Start DDS-RC-JARS |
|
469 | #Start DDS-RC-JARS | |
474 | if confdds: |
|
470 | if confdds: | |
475 | confdds.start_device() |
|
471 | confdds.start_device() | |
@@ -493,12 +489,12 class ABSConfiguration(Configuration): | |||||
493 | if confjars: |
|
489 | if confjars: | |
494 | confjars.start_device() |
|
490 | confjars.start_device() | |
495 |
|
491 | |||
496 | print('Inicia intento de salvar device.status') |
|
492 | # print('Inicia intento de salvar device.status') | |
497 | self.device.status = 3 |
|
493 | self.device.status = 3 | |
498 | self.module_status = ''.join(status) |
|
494 | self.module_status = ''.join(status) | |
499 | #print(status) |
|
495 | #print(status) | |
500 | self.save() |
|
496 | self.save() | |
501 | print('Estatus salvado') |
|
497 | # print('Estatus salvado') | |
502 | conf_active, __ = ABSActive.objects.get_or_create(pk=1) |
|
498 | conf_active, __ = ABSActive.objects.get_or_create(pk=1) | |
503 | conf_active.conf = self |
|
499 | conf_active.conf = self | |
504 | conf_active.save() |
|
500 | conf_active.save() |
@@ -1,6 +1,7 | |||||
1 | from django.contrib import admin |
|
1 | from django.contrib import admin | |
2 | from .models import ATRADConfiguration |
|
2 | from .models import ATRADConfiguration, ATRADData | |
3 |
|
3 | |||
4 | # Register your models here. |
|
4 | # Register your models here. | |
5 |
|
5 | |||
6 | admin.site.register(ATRADConfiguration) |
|
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 | class UploadFileForm(forms.Form): |
|
25 | class UploadFileForm(forms.Form): | |
26 | title = forms.CharField(label='Extension Type', widget=forms.TextInput(attrs={'readonly':'readonly'})) |
|
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 | from .files import read_json_file |
|
6 | from .files import read_json_file | |
7 | import requests |
|
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 | def status_device(self): |
|
52 | def status_device(self): | |
20 |
|
53 |
@@ -1,39 +1,105 | |||||
1 | import os |
|
|||
2 |
|
|
1 | import paho.mqtt.client as mqtt | |
3 | from radarsys import settings |
|
2 | from radarsys import settings | |
4 | from radarsys.socketconfig import sio as sio |
|
3 | from radarsys.socketconfig import sio as sio | |
5 | import numpy as np |
|
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 | def on_connect(mqtt_client, userdata, flags, rc): |
|
79 | def on_connect(mqtt_client, userdata, flags, rc): | |
8 | if rc == 0: |
|
80 | if rc == 0: | |
9 |
|
|
81 | print('Connected successfullyasdss') | |
10 |
mqtt_client.subscribe( |
|
82 | mqtt_client.subscribe("atrad/test4") | |
|
83 | print("Exito") | |||
11 | else: |
|
84 | else: | |
12 | print('Bad connection. Code:', rc) |
|
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 | def on_message(mqtt_client, userdata, msg): |
|
87 | def on_message(mqtt_client, userdata, msg): | |
20 |
|
|
88 | print('Received message on topic: {} with payload: {}'.format(msg.topic,msg.payload), flush=True) | |
21 | trsi = [[],[],[],[]] |
|
89 | mainData, tempData = dataConvert(msg) | |
22 | mensaje = str(msg.payload) |
|
90 | # print("Recibi : {}".format(msg.payload),flush=True) | |
23 | datos = [i for i in mensaje[21:-1].split("*")] |
|
91 | #socket fot general data | |
24 | status=''.join([datos[i][3] for i in range(3)]) |
|
92 | sio.emit('test',data = mainData) | |
25 | for trs,i in zip(datos,[0,1,2,3]) : |
|
93 | print(mainData) | |
26 | trsi[i]= [int(i) for i in trs[1:-1].split(",")] |
|
94 | #socket for temperature details | |
27 | potencias = [trsi[0][34],trsi[0][36],trsi[2][32],trsi[2][34]] |
|
95 | sio.emit('temptx'+str(mainData['num'] + 1),data = tempData) | |
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}) |
|
|||
30 |
|
96 | |||
31 | client = mqtt.Client() |
|
97 | client = mqtt.Client() | |
32 | client.on_connect = on_connect |
|
98 | client.on_connect = on_connect | |
33 | client.on_message = on_message |
|
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 | client.connect( |
|
101 | client.connect( | |
36 | host=os.environ.get('MQTT_SERVER', '10.10.10.200'), |
|
102 | host=os.environ.get('MQTT_SERVER', '10.10.10.200'), | |
37 | port=int(settings.os.environ.get('MQTT_PORT', 1883)), |
|
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 | ) No newline at end of file |
|
105 | ) |
@@ -1,4 +1,5 | |||||
1 | {% extends "dev_conf.html" %} |
|
1 | {% extends "dev_conf.html" %} | |
|
2 | {% load static %} | |||
2 | {% block extra-head %} |
|
3 | {% block extra-head %} | |
3 | <style> |
|
4 | <style> | |
4 | .dot { |
|
5 | .dot { | |
@@ -8,281 +9,391 | |||||
8 | border-radius: 50%; |
|
9 | border-radius: 50%; | |
9 | display: inline-block; |
|
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 | </style> |
|
19 | </style> | |
|
20 | <link href="https://cdn.jsdelivr.net/gh/gitbrent/bootstrap4-toggle@3.6.1/css/bootstrap4-toggle.min.css" rel="stylesheet"> | |||
12 | {% endblock %} |
|
21 | {% endblock %} | |
13 |
|
22 | |||
14 |
{% block |
|
23 | {% block content-graph %} | |
15 | <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.3/jquery.min.js"></script> |
|
24 | <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.3/jquery.min.js"></script> | |
16 | <script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/socket.io/4.4.1/socket.io.min.js"></script> |
|
25 | <script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/socket.io/4.4.1/socket.io.min.js"></script> | |
17 |
|
26 | |||
18 | <div class="container-fluid"> |
|
27 | <div class="container-fluid"> | |
19 | <div class="row"> |
|
28 | <h1 class="py-4 text-center" >ATRAD Monitoring</h1> | |
20 | <div class="col-xs-12"> |
|
|||
21 | <h1>Atrad Monitor</h1> |
|
|||
22 | </div> |
|
|||
23 | </div> |
|
|||
24 |
|
29 | |||
25 | <div class="row "> |
|
30 | <!-- First row : Control--> | |
26 | <!-- Potencia --> |
|
31 | <div class="row"> | |
27 |
<div class="c |
|
32 | <div class="card border-light"> | |
28 |
<div class=" |
|
33 | <div class="card-body"> | |
29 | <div class="panel panel-default" style="width:100%;"> |
|
34 | <h3 class="card-title">Control</h3> | |
30 | <div class="panel-heading"> |
|
35 | <table class="table table-borderless"> | |
31 | <h3 class="panel-title">Potencia</h3> |
|
36 | <tbody> | |
32 |
< |
|
37 | <tr> | |
33 | <div class="panel-body"> |
|
38 | <th class="align-middle">Tx1</th> | |
34 | <div class="col-xs-12"> |
|
39 | <td> | |
35 | <div class="row"> |
|
40 | <button type="button" class="btn btn-outline-success" id="ONBtn1"> ON </button> | |
36 | <div id="plot-pot"></div> |
|
41 | <button type="button" class="btn btn-outline-danger" id="OFFBtn1"> OFF </button> | |
37 |
</d |
|
42 | </td> | |
38 |
</ |
|
43 | </tr> | |
39 |
< |
|
44 | <tr> | |
40 | <div class="panel-footer"> |
|
45 | <th class="align-middle">Tx2</th> | |
41 | <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#Pot1">T1</button> |
|
46 | <td> | |
42 |
<button type="button" class="btn btn- |
|
47 | <button type="button" class="btn btn-outline-success" id="ONBtn2"> ON </button> | |
43 | </div> |
|
48 | <button type="button" class="btn btn-outline-danger" id="OFFBtn2"> OFF </button> | |
44 |
</d |
|
49 | </td> | |
|
50 | </tr> | |||
|
51 | </tbody> | |||
|
52 | </table> | |||
45 | </div> |
|
53 | </div> | |
46 | </div> |
|
54 | </div> | |
47 | <div class="col col-xs-12"> |
|
55 | </div> | |
48 | <div class="panel panel-default"> |
|
56 | ||
49 | <div class="panel-heading"> |
|
57 | <!-- Second row : Status and alerts --> | |
50 | <h3 class="panel-title">Status</h3> |
|
58 | <div class="row"> | |
51 | </div> |
|
59 | <div class="card-deck"> | |
52 |
|
|
60 | <div class="card border-light"> | |
53 | <table class="table table-borderless" style="max-width: 300px;"> |
|
61 | <div class="card-body"> | |
|
62 | <h4 class="card-title">Status</h4> | |||
|
63 | <table class="table table-borderless"> | |||
54 | <tbody> |
|
64 | <tbody> | |
55 | <tr> |
|
65 | <tr> | |
56 | <th scope="row">Tx1</th> |
|
66 | <th scope="row">Tx1</th> | |
57 | <td><span id="status1" class="dot"></span></td> |
|
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 | </tr> |
|
69 | </tr> | |
60 | <tr> |
|
70 | <tr> | |
61 | <th scope="row">Tx2</th> |
|
71 | <th scope="row">Tx2</th> | |
62 | <td><span id="status2" class="dot"></span></td> |
|
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 | </tr> |
|
93 | </tr> | |
65 | </tbody> |
|
94 | </tbody> | |
66 | </table> |
|
95 | </table> | |
67 | </div> |
|
96 | </div> | |
68 | </div> |
|
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 | </div> |
|
104 | </div> | |
70 | </div> |
|
105 | </div> | |
71 |
|
106 | |||
72 | <!-- Temperatura --> |
|
107 | <!-- Third row : power graph--> | |
73 | <div class="row"> |
|
108 | <div class="row "> | |
74 |
<div class="c |
|
109 | <div class="card border-light"> | |
75 |
<div class=" |
|
110 | <div class="card-body"> | |
76 | <div class="panel-heading"> |
|
111 | <h3 class="card-title">Power graph</h3> | |
77 | <h3 class="panel-title">Temperatura</h3> |
|
112 | <div class="row justify-content-md-center"> | |
78 | </div> |
|
113 | <div class="col-md-9"> | |
79 |
<div |
|
114 | <div id="plot-pot"></div> | |
80 |
<div |
|
115 | </div> | |
81 |
|
|
116 | <div class="col-md-3 text-end"> | |
82 | <div id="plot-temp"></div> |
|
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 | </div> |
|
138 | </div> | |
84 | </div> |
|
139 | </div> | |
85 | </div> |
|
140 | </div> | |
86 | </div> |
|
141 | </div> | |
87 | </div> |
|
142 | </div> | |
88 | </div> |
|
143 | </div> | |
89 |
|
144 | <!--Temperature Graph--> | ||
90 | <div class="row"> |
|
145 | <div class="row "> | |
91 | <!-- Controles --> |
|
146 | <div class="card border-light"> | |
92 |
<div class="c |
|
147 | <div class="card-body"> | |
93 | <div class="panel panel-default"> |
|
148 | <h3 class="card-title">Temperature graph</h3> | |
94 |
<div class=" |
|
149 | <div class="row justify-content-md-center"> | |
95 | <h3 class="panel-title">Control</h3> |
|
150 | <div class="col-md-9"> | |
96 | </div> |
|
151 | <div id="plot-temp"></div> | |
97 | <div class="panel-body"> |
|
152 | </div> | |
98 |
<div class="col- |
|
153 | <div class="col-md-3 text-end"> | |
99 |
<div class=" |
|
154 | <div class="card-body"> | |
100 | <div class="form-group col-xs-6"> |
|
155 | <table class="table table-hover" style="max-width:170px;"> | |
101 | <form id="controlON" method="POST" action=''> |
|
156 | <tbody> | |
102 | <button type="summit" class="btn btn-secondary btn-lg">Prender</button> |
|
157 | <tr> | |
103 | </form> |
|
158 | <th scope="col"># Tx</th> | |
104 | </div> |
|
159 | <th scope="col">Temperature (°C)</th> | |
105 | <div class="form-group col-xs-6"> |
|
160 | </tr> | |
106 | <form id="controlOFF" method="POST" action=''> |
|
161 | <tr class="clickable-row" data-href="{% url 'url_tx_atrad' dev_conf.id 'tx1' %}"> | |
107 | <button type="summit" class="btn btn-secondary btn-lg">Apagar</button> |
|
162 | <th scope="row">1</th> | |
108 | </form> |
|
163 | <td><p id="temp1"></p></td> | |
109 |
</ |
|
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 | </div> |
|
171 | </div> | |
111 | </div> |
|
172 | </div> | |
112 | </div> |
|
173 | </div> | |
113 | </div> |
|
174 | </div> | |
114 | </div> |
|
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 | </div> |
|
176 | </div> | |
123 | </div> |
|
177 | </div> | |
124 |
|
178 | |||
125 | <!--Modales--> |
|
179 | <!--Modales--> | |
126 | <div class="modal fade" id="Pot1" role="dialog"> |
|
180 | <div class="modal fade" id="Pot-1" role="dialog"> | |
127 |
<div class="modal-dialog modal- |
|
181 | <div class="modal-dialog modal-lg" style="max-width:50%;min-width:750px"> | |
128 | <div class="modal-content"> |
|
182 | <div class="modal-content"> | |
129 | <div class="modal-header"> |
|
183 | <div class="modal-header"> | |
130 | <h4 class="modal-title">Potencia incidente - Transmisor 1</h4> |
|
184 | <h4 class="modal-title">Potencia incidente - Transmisor 1</h4> | |
131 | <button type="button" class="close" data-dismiss="modal">×</button> |
|
185 | <button type="button" class="close" data-dismiss="modal">×</button> | |
132 | </div> |
|
186 | </div> | |
133 | <div class="modal-body"> |
|
187 | <div class="modal-body"> | |
134 |
<div class=" |
|
188 | <div class="row"> | |
135 |
<div |
|
189 | <div class="col"> | |
136 | </div> |
|
190 | <div id="plot-pot-t1"></div> | |
137 | <div clas="col-xs-12"> |
|
191 | </div> | |
138 | <table class="table table-borderless"> |
|
192 | <div class="col"> | |
139 | <tbody> |
|
193 | <table class="table" style="max-width: 150px;"> | |
140 |
<t |
|
194 | <tbody> | |
141 |
<t |
|
195 | <tr> | |
142 |
<t |
|
196 | <th scope="col"># Amp</th> | |
143 |
<t |
|
197 | <th scope="col">Potencia (kW)</th> | |
144 | </tr> |
|
198 | </tr> | |
145 | <tr> |
|
199 | <tr> | |
146 |
<th scope="row">P |
|
200 | <th scope="row">P1</th> | |
147 |
<td> |
|
201 | <td><p id="pot1-1"></p></td> | |
148 |
< |
|
202 | </tr> | |
149 |
< |
|
203 | <tr> | |
150 | <tr> |
|
204 | <th scope="row">P2</th> | |
151 |
<t |
|
205 | <td><p id="pot1-2"></p></td> | |
152 |
< |
|
206 | </tr> | |
153 |
<t |
|
207 | <tr> | |
154 |
</t |
|
208 | <th scope="row">P3</th> | |
155 | <tr> |
|
209 | <td><p id="pot1-3"></p></td> | |
156 |
< |
|
210 | </tr> | |
157 |
<t |
|
211 | <tr> | |
158 |
<t |
|
212 | <th scope="row">P4</th> | |
159 | </tr> |
|
213 | <td><p id="pot1-4"></p></td> | |
160 |
</t |
|
214 | </tr> | |
161 |
</t |
|
215 | </tbody> | |
|
216 | </table> | |||
|
217 | </div> | |||
162 | </div> |
|
218 | </div> | |
163 | </div> |
|
219 | </div> | |
164 | </div> |
|
220 | </div> | |
165 | </div> |
|
221 | </div> | |
166 | </div> |
|
222 | </div> | |
167 |
|
223 | |||
168 | <div class="modal fade" id="Pot2" role="dialog"> |
|
224 | <div class="modal fade" id="Pot-2" role="dialog"> | |
169 |
<div class="modal-dialog modal- |
|
225 | <div class="modal-dialog modal-lg" style="max-width:50%;min-width:750px"> | |
170 | <div class="modal-content"> |
|
226 | <div class="modal-content"> | |
171 | <div class="modal-header"> |
|
227 | <div class="modal-header"> | |
172 | <h4 class="modal-title">Potencia incidente - Transmisor 2</h4> |
|
228 | <h4 class="modal-title">Potencia incidente - Transmisor 2</h4> | |
173 | <button type="button" class="close" data-dismiss="modal">×</button> |
|
229 | <button type="button" class="close" data-dismiss="modal">×</button> | |
174 | </div> |
|
230 | </div> | |
175 | <div class="modal-body"> |
|
231 | <div class="modal-body"> | |
176 |
<div class=" |
|
232 | <div class="row"> | |
177 |
<div |
|
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 | </div> |
|
262 | </div> | |
179 | </div> |
|
263 | </div> | |
180 | </div> |
|
264 | </div> | |
181 | </div> |
|
265 | </div> | |
182 | </div> |
|
266 | </div> | |
183 |
|
267 | |||
184 | <script type="text/javascript" charset="utf-8"> |
|
268 | <script> | |
185 | $(document).ready(function() { |
|
269 | $(document).ready(function() { | |
186 | var socket = io.connect('http://' + document.domain + ':' + location.port); |
|
270 | var socket = io.connect('http://' + document.domain + ':' + location.port); | |
187 |
|
271 | |||
188 | socket.on('connect', function(data) { |
|
272 | socket.on('connect', function(data) { | |
189 |
console.log('Connecting |
|
273 | console.log('Connecting OK'); | |
190 | makePlot("plot-temp",2,["T1","T2"],[14, 45]) |
|
274 | makePlot("plot-temp",2,["Tx1","Tx2"],[14, 45]) | |
191 | makePlot("plot-pot",2,["T1","T2"],[70,100]) |
|
275 | makePlot("plot-pot",2,["Tx1","Tx2"],[70,100]) | |
192 |
makePlot("plot-pot-t1",4,["P1","P2","P3","P4"],[0,2 |
|
276 | makePlot("plot-pot-t1",4,["P1","P2","P3","P4"],[0,25]) | |
193 |
makePlot("plot-pot-t2",4,["P1","P2","P3","P4"],[0,2 |
|
277 | makePlot("plot-pot-t2",4,["P1","P2","P3","P4"],[0,25]) | |
194 | }) |
|
278 | }) | |
195 |
|
279 | |||
196 | socket.on('test', function(data) { |
|
280 | socket.on('test', function(data) { | |
197 | let total = data.pow.reduce((a, b) => a + b, 0); |
|
281 | console.log(data) | |
198 | var id = (data.num/4)>>0; |
|
282 | UpdateData(data.num,data); | |
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);} |
|
|||
203 | }) |
|
283 | }) | |
204 |
$(' |
|
284 | $('#ONBtn1').click(function() { | |
205 | socket.emit('control_event', {data: 1}); |
|
285 | console.log("holaa") | |
206 | return false; |
|
286 | socket.emit('atrad_control_event', '11'); | |
207 | }); |
|
287 | }); | |
208 |
$(' |
|
288 | $('#ONBtn2').click(function(){ | |
209 | socket.emit('control_event', {data: 0}); |
|
289 | console.log("holaa2") | |
210 | return false; |
|
290 | socket.emit('atrad_control_event', '21'); | |
211 | }); |
|
291 | }); | |
212 |
$( |
|
292 | $('#OFFBtn1').click(function() { | |
213 | $("#box").animate({height: "300px"}); |
|
293 | socket.emit('atrad_control_event','10'); | |
214 | }); |
|
294 | }); | |
215 |
$( |
|
295 | $('#OFFBtn2').click(function(){ | |
216 | $("#box").animate({height: "100px"}); |
|
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 | var plotDiv = document.getElementById(div); |
|
316 | var plotDiv = document.getElementById(div); | |
222 | var traces = []; |
|
317 | var traces = []; | |
223 | for (let i = 0; i < n; i++) { |
|
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 | traces.push({x: [], y: [],mode: 'lines',line: {color:'rgb(219, 64, 82)',dash: 'dot',width: 2},name:"nominal",showlegend: false}); |
|
321 | traces.push({x: [], y: [],mode: 'lines',line: {color:'rgb(219, 64, 82)',dash: 'dot',width: 2},name:"nominal",showlegend: false}); | |
227 | var yrange = ranges; |
|
322 | var yrange = ranges; | |
228 | var layout = { |
|
323 | var layout = { | |
229 | height: 350, |
|
324 | width: 700, | |
230 | font: {size: 12}, |
|
325 | height: 350, | |
231 | margin: { t: 10, b:50}, |
|
326 | font: {size: 12}, | |
232 | xaxis: { |
|
327 | margin: { t: 10, b:40,}, | |
|
328 | xaxis: { | |||
233 | type: 'date' |
|
329 | type: 'date' | |
234 | }, |
|
330 | }, | |
235 | yaxis: { |
|
331 | yaxis: { | |
236 | range: yrange, |
|
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); |
|
339 | function streamPlot(div,x,y,ind,val){ | |
241 | }; |
|
|||
242 |
|
||||
243 | function streamPlot(div,x,y,ind,val){ |
|
|||
244 | var plotDiv = document.getElementById(div); |
|
340 | var plotDiv = document.getElementById(div); | |
245 | if (plotDiv.data[ind].x.length > 8){ |
|
341 | if (plotDiv.data[ind].x.length > 8){ | |
246 | plotDiv.data[2].x = plotDiv.data[2].x.slice(-23) |
|
342 | plotDiv.data[2].x = plotDiv.data[2].x.slice(-23) | |
247 | plotDiv.data[2].y = plotDiv.data[2].y.slice(-23) |
|
343 | plotDiv.data[2].y = plotDiv.data[2].y.slice(-23) | |
248 | plotDiv.data[ind].x = plotDiv.data[ind].x.slice(-11) |
|
344 | plotDiv.data[ind].x = plotDiv.data[ind].x.slice(-11) | |
249 | plotDiv.data[ind].y = plotDiv.data[ind].y.slice(-11) |
|
345 | plotDiv.data[ind].y = plotDiv.data[ind].y.slice(-11) | |
250 | } |
|
346 | } | |
251 | var tm = [x]; |
|
347 | var tm = [x]; | |
252 | var values = [y]; |
|
348 | var values = [y]; | |
253 | var data_update = {x: [tm,tm], y: [values,[val]]} |
|
349 | var data_update = {x: [tm,tm], y: [values,[val]]} | |
254 | Plotly.extendTraces(plotDiv, data_update,[ind,2]) |
|
350 | Plotly.extendTraces(plotDiv, data_update,[ind,2]) | |
255 |
|
|
351 | }; | |
256 |
|
|
352 | function streamPlot2(div,x,y){ | |
257 | var plotDiv = document.getElementById(div); |
|
353 | var plotDiv = document.getElementById(div); | |
258 | if (plotDiv.data[0].x.length > 8){ |
|
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 | plotDiv.data[i].x = plotDiv.data[i].x.slice(-11) |
|
356 | plotDiv.data[i].x = plotDiv.data[i].x.slice(-11) | |
261 | plotDiv.data[i].y = plotDiv.data[i].y.slice(-11) |
|
357 | plotDiv.data[i].y = plotDiv.data[i].y.slice(-11) | |
262 | } |
|
358 | } | |
263 | } |
|
359 | } | |
264 | var tm = [x]; |
|
360 | var tm = [x]; | |
265 | var values = []; |
|
361 | var values = []; | |
266 | for(let i=0;i<4;i++){ |
|
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 | var data_update = {x: [tm,tm,tm,tm], y: values} |
|
365 | var data_update = {x: [tm,tm,tm,tm], y: values} | |
270 | Plotly.extendTraces(plotDiv, data_update,[0,1,2,3]) |
|
366 | Plotly.extendTraces(plotDiv, data_update,[0,1,2,3]) | |
271 |
|
|
367 | }; | |
272 | function ligthStatus(div1,div2,status){ |
|
368 | ||
|
369 | function ligthStatus(id,status){ | |||
|
370 | let div1 = 'status'+(id+1); | |||
|
371 | let div2 = 'status-text'+(id+1); | |||
|
372 | ||||
273 | if(status==='0000'){ |
|
373 | if(status==='0000'){ | |
274 |
document.getElementById(div1).style.backgroundColor = " |
|
374 | document.getElementById(div1).style.backgroundColor = "red"; | |
275 |
document.getElementById(div2).innerHTML = "D |
|
375 | document.getElementById(div2).innerHTML = "Disable"; | |
276 | } |
|
376 | } | |
277 | else if(status==='1111'){ |
|
377 | else if(status==='1111'){ | |
278 | document.getElementById(div1).style.backgroundColor = "green"; |
|
378 | document.getElementById(div1).style.backgroundColor = "green"; | |
279 |
document.getElementById(div2).innerHTML = " |
|
379 | document.getElementById(div2).innerHTML = "Fully enable"; | |
280 | } |
|
380 | } | |
281 | else{ |
|
381 | else{ | |
282 | document.getElementById(div1).style.backgroundColor = "yellow"; |
|
382 | document.getElementById(div1).style.backgroundColor = "yellow"; | |
283 |
document.getElementById(div2).innerHTML = " |
|
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 | </script> |
|
397 | </script> | |
|
398 | ||||
288 | {% endblock %} No newline at end of file |
|
399 | {% endblock %} |
@@ -3,6 +3,8 from django.urls import path | |||||
3 | from . import views |
|
3 | from . import views | |
4 |
|
4 | |||
5 | urlpatterns = ( |
|
5 | urlpatterns = ( | |
|
6 | path('prueba/', views.atrad_prueba, name='url_prueba'), | |||
6 | path('<int:id_conf>/', views.atrad_conf, name='url_atrad_conf'), |
|
7 | path('<int:id_conf>/', views.atrad_conf, name='url_atrad_conf'), | |
7 | path('<int:id_conf>/edit/', views.atrad_conf_edit, name='url_edit_atrad_conf'), |
|
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 | ) No newline at end of file |
|
10 | ) |
@@ -1,9 +1,10 | |||||
1 | from django.shortcuts import redirect, render, get_object_or_404 |
|
1 | from django.shortcuts import redirect, render, get_object_or_404 | |
2 | from django.contrib import messages |
|
2 | from django.contrib import messages | |
3 | from django.http import HttpResponse |
|
3 | from django.http import HttpResponse | |
|
4 | from django.template.loader import get_template | |||
4 |
|
5 | |||
5 | from apps.main.models import Experiment |
|
6 | from apps.main.models import Experiment | |
6 | from .models import ATRADConfiguration |
|
7 | from .models import ATRADConfiguration, ATRADData | |
7 |
|
8 | |||
8 | from .forms import ATRADConfigurationForm, UploadFileForm |
|
9 | from .forms import ATRADConfigurationForm, UploadFileForm | |
9 | from apps.main.views import sidebar |
|
10 | from apps.main.views import sidebar | |
@@ -15,7 +16,7 import os | |||||
15 | from django.http import JsonResponse |
|
16 | from django.http import JsonResponse | |
16 | from .mqtt import client as mqtt_client |
|
17 | from .mqtt import client as mqtt_client | |
17 | from radarsys.socketconfig import sio as sio |
|
18 | from radarsys.socketconfig import sio as sio | |
18 |
|
19 | from datetime import timedelta | ||
19 |
|
20 | |||
20 | def atrad_conf(request, id_conf): |
|
21 | def atrad_conf(request, id_conf): | |
21 |
|
22 | |||
@@ -38,12 +39,27 def atrad_conf(request, id_conf): | |||||
38 | kwargs['button'] = 'Edit Configuration' |
|
39 | kwargs['button'] = 'Edit Configuration' | |
39 |
|
40 | |||
40 | #kwargs['no_play'] = True |
|
41 | #kwargs['no_play'] = True | |
41 |
|
||||
42 | ###### SIDEBAR ###### |
|
42 | ###### SIDEBAR ###### | |
43 | kwargs.update(sidebar(conf=conf)) |
|
43 | kwargs.update(sidebar(conf=conf)) | |
44 |
|
44 | |||
45 | return render(request, 'atrad_conf.html', kwargs) |
|
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 | def atrad_conf_edit(request, id_conf): |
|
63 | def atrad_conf_edit(request, id_conf): | |
48 |
|
64 | |||
49 | conf = get_object_or_404(ATRADConfiguration, pk=id_conf) |
|
65 | conf = get_object_or_404(ATRADConfiguration, pk=id_conf) | |
@@ -72,9 +88,6 def atrad_conf_edit(request, id_conf): | |||||
72 |
|
88 | |||
73 | return render(request, 'atrad_conf_edit.html', kwargs) |
|
89 | return render(request, 'atrad_conf_edit.html', kwargs) | |
74 |
|
90 | |||
75 | import os |
|
|||
76 | from django.http import HttpResponse# |
|
|||
77 |
|
||||
78 | def publish_message(request): |
|
91 | def publish_message(request): | |
79 | rc, mid = mqtt_client.publish('test/data2',1) |
|
92 | rc, mid = mqtt_client.publish('test/data2',1) | |
80 | return JsonResponse({'code1': 'HIKA', 'code2': 'LUCAS'}) |
|
93 | return JsonResponse({'code1': 'HIKA', 'code2': 'LUCAS'}) | |
@@ -83,9 +96,17 def monitor(request): | |||||
83 | kwargs = {'no_sidebar': True} |
|
96 | kwargs = {'no_sidebar': True} | |
84 | return render(request, 'monitor.html', kwargs) |
|
97 | return render(request, 'monitor.html', kwargs) | |
85 |
|
98 | |||
86 | def prueba(request): |
|
99 | def atrad_prueba(request): | |
87 | kwargs = {'no_sidebar': True} |
|
100 | keys = ['id','temp1','temp2','temp3','temp4','temp5','temp6'] | |
88 | return render(request, 'prueba.html', kwargs) |
|
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 | @sio.on('connection-bind') |
|
111 | @sio.on('connection-bind') | |
91 | def atrad_connection_bind(sid, data): |
|
112 | def atrad_connection_bind(sid, data): | |
@@ -97,12 +118,4 def atrad_disconnect(sid): | |||||
97 |
|
118 | |||
98 | @sio.event |
|
119 | @sio.event | |
99 | def atrad_control_event(sid,message): |
|
120 | def atrad_control_event(sid,message): | |
100 |
mqtt_client.publish('test/data2',message |
|
121 | mqtt_client.publish('test/data2', json.dumps(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 |
|
@@ -291,7 +291,6 class JARSConfiguration(Configuration): | |||||
291 | self.device.status = payload['status'] |
|
291 | self.device.status = payload['status'] | |
292 | self.device.save() |
|
292 | self.device.save() | |
293 | self.message = payload['message'] |
|
293 | self.message = payload['message'] | |
294 | print("------STOP JARS------",flush=True) |
|
|||
295 | except Exception as e: |
|
294 | except Exception as e: | |
296 | self.device.status = 0 |
|
295 | self.device.status = 0 | |
297 | self.message = str(e) |
|
296 | self.message = str(e) | |
@@ -318,11 +317,8 class JARSConfiguration(Configuration): | |||||
318 |
|
317 | |||
319 | if self.device.status == 3: |
|
318 | if self.device.status == 3: | |
320 | self.message = 'Could not configure device. Software Acquisition is running' |
|
319 | self.message = 'Could not configure device. Software Acquisition is running' | |
|
320 | print('Could not configure device. Software Acquisition is running') | |||
321 | return False |
|
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 | data = self.experiment.parms_to_dict() |
|
323 | data = self.experiment.parms_to_dict() | |
328 | #print(data) |
|
324 | #print(data) | |
@@ -349,14 +345,12 class JARSConfiguration(Configuration): | |||||
349 | self.device.save() |
|
345 | self.device.save() | |
350 | if self.device.status == 1: |
|
346 | if self.device.status == 1: | |
351 | return False |
|
347 | return False | |
352 | print("------ JARS WRITED ------",flush=True) |
|
|||
353 |
|
348 | |||
354 | except Exception as e: |
|
349 | except Exception as e: | |
355 | self.device.status = 0 |
|
350 | self.device.status = 0 | |
356 | self.message = str(e) |
|
351 | self.message = str(e) | |
357 | self.device.save() |
|
352 | self.device.save() | |
358 | return False |
|
353 | return False | |
359 | print("FINAL STATUS:", self.device.status,flush=True) |
|
|||
360 | return True |
|
354 | return True | |
361 |
|
355 | |||
362 | def start_device(self): |
|
356 | def start_device(self): | |
@@ -375,7 +369,6 class JARSConfiguration(Configuration): | |||||
375 | self.message = str(e) |
|
369 | self.message = str(e) | |
376 | self.device.save() |
|
370 | self.device.save() | |
377 | return False |
|
371 | return False | |
378 | print("------START JARS------",flush=True) |
|
|||
379 | return True |
|
372 | return True | |
380 |
|
373 | |||
381 | def get_log(self): |
|
374 | def get_log(self): |
@@ -12,7 +12,7 from apps.main.models import Experiment, Configuration | |||||
12 |
|
12 | |||
13 | class Command(BaseCommand): |
|
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 | Example: |
|
16 | Example: | |
17 | manage.py restart_experiment |
|
17 | manage.py restart_experiment | |
18 | """ |
|
18 | """ | |
@@ -35,13 +35,38 class Command(BaseCommand): | |||||
35 |
|
35 | |||
36 | else: |
|
36 | else: | |
37 | radar=campaign.get_experiments_by_radar(radar=None) |
|
37 | radar=campaign.get_experiments_by_radar(radar=None) | |
38 | radar_id=radar[0]["id"] |
|
38 | # print(campaign.name) | |
39 | if campaign.experiments.all()[0].status !=1: |
|
39 | for rad in radar: | |
40 | print(campaign.name, "\t\t Stopping Campaign...") |
|
40 | radar_id=rad["id"] | |
41 | a=radar_stop_scheduler(campaign.id,radar_id,campaign.experiments.all()[0].id) |
|
41 | # print(radar_id, " ", rad["name"]) | |
42 | print("New Status: ", a) |
|
42 | for exp in range(len(rad["experiments"])): | |
43 | else: |
|
43 | experiment=rad["experiments"][exp] | |
44 | print(campaign.name,"\t\t\t Campaign already stooped") |
|
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 | def radar_write_start_scheduler(id_camp,id_radar): |
|
71 | def radar_write_start_scheduler(id_camp,id_radar): | |
47 | campaign = get_object_or_404(Campaign, pk=id_camp) |
|
72 | campaign = get_object_or_404(Campaign, pk=id_camp) | |
@@ -54,6 +79,8 def radar_write_start_scheduler(id_camp,id_radar): | |||||
54 | # print(exp) |
|
79 | # print(exp) | |
55 | if exp.status == 2: |
|
80 | if exp.status == 2: | |
56 | print('\t\t\t {} \t\t Experiment already runnnig'.format(exp)) |
|
81 | print('\t\t\t {} \t\t Experiment already runnnig'.format(exp)) | |
|
82 | elif exp.status==5: | |||
|
83 | print('Experiment {} busy'.format(exp)) | |||
57 | else: |
|
84 | else: | |
58 | exp.status = exp.start() |
|
85 | exp.status = exp.start() | |
59 | if exp.status == 0: |
|
86 | if exp.status == 0: |
@@ -425,6 +425,9 class Experiment(models.Model): | |||||
425 | Configure and start experiments's devices |
|
425 | Configure and start experiments's devices | |
426 | ABS-CGS-DDS-RC-JARS |
|
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 | confs = [] |
|
432 | confs = [] | |
430 | allconfs = Configuration.objects.filter(experiment=self, type = 0).order_by('-device__device_type__sequence') |
|
433 | allconfs = Configuration.objects.filter(experiment=self, type = 0).order_by('-device__device_type__sequence') | |
@@ -437,18 +440,32 class Experiment(models.Model): | |||||
437 | else: |
|
440 | else: | |
438 | confs = allconfs |
|
441 | confs = allconfs | |
439 |
|
442 | |||
440 | print("confs: ",confs) |
|
443 | ||
441 | #try: |
|
|||
442 | for conf in confs: |
|
444 | for conf in confs: | |
443 |
print( |
|
445 | print(conf.device) | |
444 |
conf. |
|
446 | print(conf.device.status) | |
445 | conf.write_device() |
|
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 | conf.device.conf_active = conf.pk |
|
459 | conf.device.conf_active = conf.pk | |
447 | conf.device.save() |
|
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 | time.sleep(1) |
|
467 | time.sleep(1) | |
450 | #except: |
|
468 | ||
451 | #return 0 |
|
|||
452 | return 2 |
|
469 | return 2 | |
453 |
|
470 | |||
454 |
|
471 |
@@ -5733,7 +5733,7 button.list-group-item-danger.active:focus { | |||||
5733 | } |
|
5733 | } | |
5734 | .panel-default > .panel-heading { |
|
5734 | .panel-default > .panel-heading { | |
5735 | color: #333; |
|
5735 | color: #333; | |
5736 |
background-color: #f |
|
5736 | background-color: #ffffff; | |
5737 | border-color: #ddd; |
|
5737 | border-color: #ddd; | |
5738 | } |
|
5738 | } | |
5739 | .panel-default > .panel-heading + .panel-collapse > .panel-body { |
|
5739 | .panel-default > .panel-heading + .panel-collapse > .panel-body { |
@@ -60,9 +60,9 | |||||
60 | {% else %} |
|
60 | {% else %} | |
61 | <div class="col-md-3 hidden-xs hidden-sm" role="complementary"> |
|
61 | <div class="col-md-3 hidden-xs hidden-sm" role="complementary"> | |
62 | <br><br> |
|
62 | <br><br> | |
63 |
|
|
63 | <div id="sidebar"> | |
64 |
|
|
64 | {% block sidebar%} | |
65 |
|
|
65 | {% include "sidebar_devices.html" %} | |
66 | {% endblock %} |
|
66 | {% endblock %} | |
67 | </div> |
|
67 | </div> | |
68 | </div> |
|
68 | </div> | |
@@ -88,12 +88,11 | |||||
88 | {% endfor %} |
|
88 | {% endfor %} | |
89 | {% endif %} |
|
89 | {% endif %} | |
90 | {% endblock %} |
|
90 | {% endblock %} | |
91 |
|
91 | {% block content %} | ||
92 |
{% block |
|
92 | {% endblock %} | |
93 | {% endblock %} |
|
|||
94 |
|
||||
95 | </div> |
|
93 | </div> | |
96 |
|
94 | {% block content-graph %} | ||
|
95 | {% endblock %} | |||
97 |
|
96 | |||
98 | </div><!--/row--> |
|
97 | </div><!--/row--> | |
99 | </div> <!-- container --> |
|
98 | </div> <!-- container --> |
@@ -40,6 +40,8 | |||||
40 | {% endfor%} |
|
40 | {% endfor%} | |
41 | </tr> |
|
41 | </tr> | |
42 | {% for object in objects %} |
|
42 | {% for object in objects %} | |
|
43 | <p>{{ object }}</p> | |||
|
44 | <p>{{ objects }}</p> | |||
43 | <tr class="clickable-row" data-href="{{object.get_absolute_url}}"> |
|
45 | <tr class="clickable-row" data-href="{{object.get_absolute_url}}"> | |
44 | <td>{{ forloop.counter|add:offset }}</td> |
|
46 | <td>{{ forloop.counter|add:offset }}</td> | |
45 | {% for key in keys %} |
|
47 | {% for key in keys %} |
@@ -46,7 +46,7 | |||||
46 | {% else %} |
|
46 | {% else %} | |
47 | <td class="text-info"><strong> Connected </strong></td> |
|
47 | <td class="text-info"><strong> Connected </strong></td> | |
48 | {% endif %} |
|
48 | {% endif %} | |
49 |
|
|
49 | </tr> | |
50 |
|
50 | |||
51 | {% for key in dev_conf_keys %} |
|
51 | {% for key in dev_conf_keys %} | |
52 | <tr> |
|
52 | <tr> |
@@ -199,9 +199,11 class RCConfiguration(Configuration): | |||||
199 | 'params': json.dumps(line_data['params']) |
|
199 | 'params': json.dumps(line_data['params']) | |
200 | } |
|
200 | } | |
201 | ) |
|
201 | ) | |
|
202 | print(line,flush=True) | |||
202 |
|
203 | |||
203 | for i, line in enumerate(self.get_lines()): |
|
204 | for i, line in enumerate(self.get_lines()): | |
204 | line_params = json.loads(line.params) |
|
205 | line_params = json.loads(line.params) | |
|
206 | print("accedimos a dict_to5",flush=True) | |||
205 | if 'TX_ref' in line_params: |
|
207 | if 'TX_ref' in line_params: | |
206 | if line_params['TX_ref'] in (0, '0'): |
|
208 | if line_params['TX_ref'] in (0, '0'): | |
207 | line_params['TX_ref'] = '0' |
|
209 | line_params['TX_ref'] = '0' | |
@@ -552,7 +554,7 class RCConfiguration(Configuration): | |||||
552 | return True |
|
554 | return True | |
553 |
|
555 | |||
554 | def write_device(self, raw=False): |
|
556 | def write_device(self, raw=False): | |
555 |
print("write device") |
|
557 | print("write device",flush=True) | |
556 |
|
558 | |||
557 | if not raw: |
|
559 | if not raw: | |
558 | clock = RCClock.objects.get(rc_configuration=self) |
|
560 | clock = RCClock.objects.get(rc_configuration=self) | |
@@ -561,8 +563,10 class RCConfiguration(Configuration): | |||||
561 | else: |
|
563 | else: | |
562 | data = {'manual': [clock.multiplier, clock.divisor, clock.reference]} |
|
564 | data = {'manual': [clock.multiplier, clock.divisor, clock.reference]} | |
563 | payload = self.request('setfreq', 'post', data=json.dumps(data)) |
|
565 | payload = self.request('setfreq', 'post', data=json.dumps(data)) | |
|
566 | print(payload) | |||
564 | if payload['command'] != 'ok': |
|
567 | if payload['command'] != 'ok': | |
565 | self.message = 'RC write: {}'.format(payload['command']) |
|
568 | self.message = 'RC write: {}'.format(payload['command']) | |
|
569 | print('RC write: {}'.format(payload['command'])) | |||
566 | else: |
|
570 | else: | |
567 | self.message = payload['programming'] |
|
571 | self.message = payload['programming'] | |
568 | if payload['programming'] == 'fail': |
|
572 | if payload['programming'] == 'fail': | |
@@ -616,10 +620,12 class RCConfiguration(Configuration): | |||||
616 | self.device.status = 3 |
|
620 | self.device.status = 3 | |
617 | self.device.save() |
|
621 | self.device.save() | |
618 | self.message = 'RC configured and started' |
|
622 | self.message = 'RC configured and started' | |
|
623 | print('RC configured and started') | |||
619 | else: |
|
624 | else: | |
620 | self.device.status = 1 |
|
625 | self.device.status = 1 | |
621 | self.device.save() |
|
626 | self.device.save() | |
622 | self.message = 'RC write: {}'.format(payload['write']) |
|
627 | self.message = 'RC write: {}'.format(payload['write']) | |
|
628 | print('RC write: {}'.format(payload['write'])) | |||
623 | return False |
|
629 | return False | |
624 |
|
630 | |||
625 | #payload = self.request('start', 'post') |
|
631 | #payload = self.request('start', 'post') | |
@@ -682,8 +688,11 class RCLine(models.Model): | |||||
682 | ordering = ['channel'] |
|
688 | ordering = ['channel'] | |
683 |
|
689 | |||
684 | def __str__(self): |
|
690 | def __str__(self): | |
685 |
|
|
691 | print("AAAA: ",self.rc_configuration,flush=True) | |
686 |
|
|
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 | def jsonify(self): |
|
697 | def jsonify(self): | |
689 |
|
698 |
@@ -355,20 +355,27 def update_lines_position(request, conf_id): | |||||
355 |
|
355 | |||
356 |
|
356 | |||
357 | def import_file(request, conf_id): |
|
357 | def import_file(request, conf_id): | |
358 |
|
358 | print("HOLA",flush=True) | ||
359 | conf = get_object_or_404(RCConfiguration, pk=conf_id) |
|
359 | conf = get_object_or_404(RCConfiguration, pk=conf_id) | |
|
360 | print("HOLA2",flush=True) | |||
360 | if request.method=='POST': |
|
361 | if request.method=='POST': | |
361 | form = RCImportForm(request.POST, request.FILES) |
|
362 | form = RCImportForm(request.POST, request.FILES) | |
|
363 | print("HOLA3",flush=True) | |||
362 | if form.is_valid(): |
|
364 | if form.is_valid(): | |
363 | try: |
|
365 | print("HOLA4",flush=True) | |
364 | data = conf.import_from_file(request.FILES['file_name']) |
|
366 | # try: | |
365 | conf.dict_to_parms(data) |
|
367 | print("HOLA5",flush=True) | |
366 | conf.update_pulses() |
|
368 | data = conf.import_from_file(request.FILES['file_name']) | |
367 | messages.success(request, 'Configuration "%s" loaded succesfully' % request.FILES['file_name']) |
|
369 | print("HOLA6",flush=True) | |
368 | return redirect(conf.get_absolute_url_edit()) |
|
370 | conf.dict_to_parms(data) | |
369 |
|
371 | print("1",flush=True) | ||
370 | except Exception as e: |
|
372 | conf.update_pulses() | |
371 | messages.error(request, 'Error parsing file: "%s" - %s' % (request.FILES['file_name'], repr(e))) |
|
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 | else: |
|
379 | else: | |
373 | messages.warning(request, 'Your current configuration will be replaced') |
|
380 | messages.warning(request, 'Your current configuration will be replaced') | |
374 | form = RCImportForm() |
|
381 | form = RCImportForm() |
@@ -35,6 +35,8 services: | |||||
35 | - pgdata:/var/lib/postgresql/data |
|
35 | - pgdata:/var/lib/postgresql/data | |
36 | ports: |
|
36 | ports: | |
37 | - 5432:5432 |
|
37 | - 5432:5432 | |
|
38 | expose: | |||
|
39 | - 5432 | |||
38 | env_file: .env |
|
40 | env_file: .env | |
39 |
|
41 | |||
40 | #Web Server |
|
42 | #Web Server |
@@ -29,7 +29,10 ALLOWED_HOSTS = ['*'] | |||||
29 | CSRF_TRUSTED_ORIGINS=[ |
|
29 | CSRF_TRUSTED_ORIGINS=[ | |
30 | "http://*.localhost:8030", |
|
30 | "http://*.localhost:8030", | |
31 | "http://localhost:8030", |
|
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 | #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/ |
|
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 | from django.urls import include, path |
|
1 | from django.urls import include, path | |
2 | from django.contrib import admin |
|
2 | from django.contrib import admin | |
3 | #from django.contrib.staticfiles.urls import staticfiles_urlpatterns |
|
|||
4 |
|
3 | |||
5 | urlpatterns = [ |
|
4 | urlpatterns = [ | |
6 | path('admin/',admin.site.urls), |
|
5 | path('admin/',admin.site.urls), | |
@@ -15,6 +14,4 urlpatterns = [ | |||||
15 | path('misc/',include('apps.misc.urls')), |
|
14 | path('misc/',include('apps.misc.urls')), | |
16 | path('dds_rest/', include('apps.dds_rest.urls')), |
|
15 | path('dds_rest/', include('apps.dds_rest.urls')), | |
17 | path('atrad/', include('apps.atrad.urls')), |
|
16 | path('atrad/', include('apps.atrad.urls')), | |
18 |
] |
|
17 | ] No newline at end of file | |
19 |
|
||||
20 | #urlpatterns += staticfiles_urlpatterns() |
|
General Comments 0
You need to be logged in to leave comments.
Login now