From 8cdc0938bd884c25b32bc974e75a4696bb84e7c3 Mon Sep 17 00:00:00 2001 From: Marco Locatelli Date: Fri, 2 Apr 2021 12:15:50 +0200 Subject: [PATCH] dati originali e scalati in 2 array --- logger/log/PyLog.txt | 1 + server/FTServer.py | 86 +++++------------ server/templates/about.html | 4 +- server/templates/logger.html | 92 ++++++++----------- server/templates/settings.html | 163 +++++++++++++++++++++++++-------- 5 files changed, 188 insertions(+), 158 deletions(-) diff --git a/logger/log/PyLog.txt b/logger/log/PyLog.txt index 7a9072d..94b20d1 100644 --- a/logger/log/PyLog.txt +++ b/logger/log/PyLog.txt @@ -83,3 +83,4 @@ 2021-04-01 15:20:07.442727 Caught error: name 'now' is not defined 2021-04-01 15:20:08.570454 Caught error: name 'now' is not defined 2021-04-01 15:21:11.244154 Caught error: name 'now' is not defined +2021-04-02 09:27:42.781175 Caught error: Connection closed by server. diff --git a/server/FTServer.py b/server/FTServer.py index 01521af..fed540b 100644 --- a/server/FTServer.py +++ b/server/FTServer.py @@ -4,22 +4,9 @@ from flask import Flask, render_template, jsonify, request from datetime import datetime from flask.wrappers import Request import redis -#import socket import os from werkzeug.utils import redirect -# RIVEDERE: fare un ciclo di 10 tentativi, pausa 3 sec, prima di uscire se non andasse, che così fatto come servizio si pianta - -#create a socket object -#s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) -#connect to the server on local computer -#s.connect(("8.8.8.8", 80)) -#assegno a variabile indirizzo ip per usi futuri -#ipv4 = s.getsocketname()[0] -#s.close() -#volendo stampo a video IPv4 -#print("Indirizzo Ipv4 assegnato: ",s.getsockname()[0]) - #assegno ipv4 statico ipv4 = '10.74.83.210' @@ -54,22 +41,6 @@ def logger(): 'timeLog' : getRedisVal('RTDATA:TIME:LOG'), 'LogFreq' : getRedisVal('SETTINGS:LOG:FREQ'), 'WriteFreq' : getRedisVal('SETTINGS:WRITE:FREQ'), - 'Ch0' : getRedisVal('RTDATA:CH:0'), - 'Ch1' : getRedisVal('RTDATA:CH:1'), - 'Ch2' : getRedisVal('RTDATA:CH:2'), - 'Ch3' : getRedisVal('RTDATA:CH:3'), - 'Ch4' : getRedisVal('RTDATA:CH:4'), - 'Ch5' : getRedisVal('RTDATA:CH:5'), - 'Ch6' : getRedisVal('RTDATA:CH:6'), - 'Ch7' : getRedisVal('RTDATA:CH:7'), - 'Out0' : getRedisVal('RTDATA:OUT:0'), - 'Out1' : getRedisVal('RTDATA:OUT:1'), - 'Out2' : getRedisVal('RTDATA:OUT:2'), - 'Out3' : getRedisVal('RTDATA:OUT:3'), - 'Out4' : getRedisVal('RTDATA:OUT:4'), - 'Out5' : getRedisVal('RTDATA:OUT:5'), - 'Out6' : getRedisVal('RTDATA:OUT:6'), - 'Out7' : getRedisVal('RTDATA:OUT:7') } #assegno il template html di riferimento return render_template('logger.html', **channelsData) @@ -81,22 +52,6 @@ def setup(): 'title' : 'Settings', 'LogFreq' : getRedisVal('SETTINGS:LOG:FREQ'), 'WriteFreq' : getRedisVal('SETTINGS:WRITE:FREQ'), - 'Ch0' : getRedisVal('RTDATA:CH:0'), - 'Ch1' : getRedisVal('RTDATA:CH:1'), - 'Ch2' : getRedisVal('RTDATA:CH:2'), - 'Ch3' : getRedisVal('RTDATA:CH:3'), - 'Ch4' : getRedisVal('RTDATA:CH:4'), - 'Ch5' : getRedisVal('RTDATA:CH:5'), - 'Ch6' : getRedisVal('RTDATA:CH:6'), - 'Ch7' : getRedisVal('RTDATA:CH:7'), - 'Out0' : getRedisVal('RTDATA:OUT:0'), - 'Out1' : getRedisVal('RTDATA:OUT:1'), - 'Out2' : getRedisVal('RTDATA:OUT:2'), - 'Out3' : getRedisVal('RTDATA:OUT:3'), - 'Out4' : getRedisVal('RTDATA:OUT:4'), - 'Out5' : getRedisVal('RTDATA:OUT:5'), - 'Out6' : getRedisVal('RTDATA:OUT:6'), - 'Out7' : getRedisVal('RTDATA:OUT:7') } #assegno il template html di riferimento return render_template('settings.html', **channelsData) @@ -115,28 +70,23 @@ def about(): def api_channels_all(): numCh = getRedisVal('SETTINGS:SELECTED_CH') #funzione api_channels_all: legge direttamente da redis, ritorna jsonify + + CH = [0,0,0,0,0,0,0,0] + OUT = [0,0,0,0,0,0,0,0] + for numCh in range(0,8,+1): + CH[numCh] = getRedisVal('RTDATA:CH:'+str(numCh)) + OUT[numCh] = getRedisVal('RTDATA:OUT:'+str(numCh)) + channelsData = { 'timeSrv' : getRedisVal('RTDATA:TIME:SRV'), 'timeLog' : getRedisVal('RTDATA:TIME:LOG'), 'LogFreq' : getRedisVal('SETTINGS:LOG:FREQ'), 'WriteFreq' : getRedisVal('SETTINGS:WRITE:FREQ'), 'Status' : getRedisVal('SETTINGS:LOG:STATUS'), - 'Ch0' : getRedisVal('RTDATA:CH:0'), - 'Ch1' : getRedisVal('RTDATA:CH:1'), - 'Ch2' : getRedisVal('RTDATA:CH:2'), - 'Ch3' : getRedisVal('RTDATA:CH:3'), - 'Ch4' : getRedisVal('RTDATA:CH:4'), - 'Ch5' : getRedisVal('RTDATA:CH:5'), - 'Ch6' : getRedisVal('RTDATA:CH:6'), - 'Ch7' : getRedisVal('RTDATA:CH:7'), - 'Out0' : getRedisVal('RTDATA:OUT:0'), - 'Out1' : getRedisVal('RTDATA:OUT:1'), - 'Out2' : getRedisVal('RTDATA:OUT:2'), - 'Out3' : getRedisVal('RTDATA:OUT:3'), - 'Out4' : getRedisVal('RTDATA:OUT:4'), - 'Out5' : getRedisVal('RTDATA:OUT:5'), - 'Out6' : getRedisVal('RTDATA:OUT:6'), - 'Out7' : getRedisVal('RTDATA:OUT:7'), + 'Channels': CH, + 'Outs': OUT, + 'ChA' : getRedisVal('SETTINGS:CHANNEL:A'), + 'ChB' : getRedisVal('SETTINGS:CHANNEL:B'), 'ChScaleMax' : getRedisVal('SETTINGS:IN:MAX:'+str(numCh)), 'ChScaleMin' : getRedisVal('SETTINGS:IN:MIN:'+str(numCh)), 'ChRealMax' : getRedisVal('SETTINGS:OUT:MAX:'+str(numCh)), @@ -214,8 +164,20 @@ def setupInMax(): redSrv0.set('SETTINGS:IN:MAX:'+ str(indCh), currChVal) return redirect("/settings") +@flaskApp.route("/api/v1/setup/selectChannelA/", methods=['PUT']) +def selectChannelA(numChA): + print(numChA) + redSrv0.set('SETTINGS:CHANNEL:A', numChA) + return "OK" + +@flaskApp.route("/api/v1/setup/selectChannelB/", methods=['PUT']) +def selectChannelB(numChB): + print(numChB) + redSrv0.set('SETTINGS:CHANNEL:B', numChB) + return "OK" + @flaskApp.route("/api/v1/setup/selectChannel/", methods=['PUT']) -def selectChannel(numCh): +def setChannel(numCh): print(numCh) # request_data = request.get_json() # # devo leggere il channel attualmente selezionato, x ora cablo a 0... diff --git a/server/templates/about.html b/server/templates/about.html index 4bfc5ea..e0168f8 100644 --- a/server/templates/about.html +++ b/server/templates/about.html @@ -19,11 +19,11 @@

Analog and Digital reader and logger software

-

Version 0.1.1

+

Version 0.2.1

Last Patched:
- 23 March 2021

+ 02/04/2021

diff --git a/server/templates/logger.html b/server/templates/logger.html index 98e32f4..307802d 100644 --- a/server/templates/logger.html +++ b/server/templates/logger.html @@ -13,11 +13,9 @@ $("#divNewFile").toggle(); }; - function setGauges(chVal0,chVal1){ - // Create knob elements, 300 x 300 px in size. + function setGaugeA(chVal0){ + // Create knob elements const knob0 = pureknob.createKnob(200, 200); - const knob1 = pureknob.createKnob(200, 200); - // Set properties knob0 knob0.setProperty('angleStart', -0.8 * Math.PI); knob0.setProperty('angleEnd', 0.8 * Math.PI); @@ -25,7 +23,17 @@ knob0.setProperty('trackWidth', 0.3); knob0.setProperty('valMin', 0); knob0.setProperty('valMax', 100); + // Set initial value0 + knob0.setValue(chVal0); + // Create element node0 + const node0 = knob0.node(); + // Add it to the DOM. + $("#divChA").html(node0); + } + function setGaugeB(chVal1){ + // Create knob elements + const knob1 = pureknob.createKnob(200, 200); // Set properties knob1 knob1.setProperty('angleStart', -0.8 * Math.PI); knob1.setProperty('angleEnd', 0.8 * Math.PI); @@ -33,59 +41,33 @@ knob1.setProperty('trackWidth', 0.3); knob1.setProperty('valMin', 0); knob1.setProperty('valMax', 100); - - // Set initial value0 - knob0.setValue(chVal0); - // Create element node0 - const node0 = knob0.node(); - // Set initial value1 knob1.setValue(chVal1); // Create element node1 const node1 = knob1.node(); - // Add it to the DOM. - $("#divCh0").html(node0); - $("#divCh1").html(node1); - // $("#divCh0").val(node); - // $("#divCh0").val(node); - //$("#divCh0").append(node); - // const elem0 = document.getElementById('divCh0'); - // elem0.appendChild(node); - // const elem1 = document.getElementById('divCh1'); - // elem1.appendChild(node); + $("#divChB").html(node1); } function dataRefresh() { // scarico i dati aggioranti $.ajax({url: "/api/v1/channels/all", success: function(result){ // compilo i dati scaricati - $("#Chan0").html(result.Ch0); - $("#Chan1").html(result.Ch1); - $("#Chan2").html(result.Ch2); - $("#Chan3").html(result.Ch3); - $("#Chan4").html(result.Ch4); - $("#Chan5").html(result.Ch5); - $("#Chan6").html(result.Ch6); - $("#Chan7").html(result.Ch7); - $("#Output0").html(result.Out0); - $("#Output1").html(result.Out1); - $("#Output2").html(result.Out2); - $("#Output3").html(result.Out3); - $("#Output4").html(result.Out4); - $("#Output5").html(result.Out5); - $("#Output6").html(result.Out6); - $("#Output7").html(result.Out7); + $("#SelChannelA").html(result.ChA); + $("#ChannelA").html(result.Channels[result.ChA]); + $("#OutputA").html(result.Outs[result.ChA]); + setGaugeA(result.Outs[result.ChA]); + + $("#SelChannelB").html(result.ChB); + $("#ChannelB").html(result.Channels[result.ChB]); + $("#OutputB").html(result.Outs[result.ChB]); + setGaugeB(result.Outs[result.ChB]); + $("#LogFrequency").html(result.LogFreq); $("#WriteFrequency").html(result.WriteFreq); $("#LoggerTime").html(result.timeLog); $("#ServerTime").html(result.timeSrv); - $("#ChanScaleMin").html(result.ChScaleMin); - $("#ChanScaleMax").html(result.ChScaleMax); - $("#ChanRealMin").html(result.ChRealMin); - $("#ChanRealMax").html(result.ChRealMax); $("#LastSessionName").html(result.LastSessionName); - setGauges(result.Out0,result.Out1); }}); timeout = setTimeout(dataRefresh, intTime); @@ -110,31 +92,29 @@ }; -
+
-
-
- - Channel A +
+
+ Channel A:
-
- Original: +
+ Original:
- Scaled: + Scaled:
-
-
- - Channel B +
+
+ Channel B:
-
- Original: +
+ Original:
- Scaled: + Scaled:
diff --git a/server/templates/settings.html b/server/templates/settings.html index f8917de..a28f5dd 100644 --- a/server/templates/settings.html +++ b/server/templates/settings.html @@ -5,6 +5,8 @@ -
-
-
- - Impostazioni Timer +
+
+
+
+
+ Channel A +
+
+
+ +
+
+
+
+ Original: +
+ Scaled: + +
-
-
-
- Periodo di campionamento (ms):   - +
+
+
+ Channel B
-
- Periodo di scrittura (ms):   - -
- +
+
+ +
- +
+
+ Original: +
+ Scaled: + +
@@ -132,6 +193,12 @@
@@ -203,6 +270,26 @@
+
+
+ + Impostazioni Timer +
+
+
+
+ Periodo di campionamento (ms):   + +
+
+ Periodo di scrittura (ms):   + +
+ +
+
+
+