diff --git a/sampler/FTSampler.py b/sampler/FTSampler.py index cd9862b..cc46038 100644 --- a/sampler/FTSampler.py +++ b/sampler/FTSampler.py @@ -32,16 +32,18 @@ redSamPer='SETTINGS:LOG:EXETIME' redSampleFreq = 'SETTINGS:LOG:FREQ' #se non c'è un valore nei campi di redis, popolo il db -redSrv0.set('SETTINGS:LOG:STATUS',0) -redSrv0.set('SETTINGS:POWER:OFF',0) +redSrv0.set('SETTINGS:LOG:STATUS', 0) +redSrv0.set('SETTINGS:POWER:OFF', 0) if redSrv0.get('SETTINGS:WARNING:EXETIME') is None: - redSrv0.set('SETTINGS:WARNING:EXETIME',0) + redSrv0.set('SETTINGS:WARNING:EXETIME', 0) if redSrv0.get('RTDATA:EWMA:VETO') is None: - redSrv0.set('RTDATA:EWMA:VETO',0) + redSrv0.set('RTDATA:EWMA:VETO', 0) if redSrv0.get('SETTINGS:LOG:FREQ') is None: - redSrv0.set('SETTINGS:LOG:FREQ', 70) + redSrv0.set('SETTINGS:LOG:FREQ', 20) if redSrv0.get('SETTINGS:DECIMALS:COUNT') is None: - redSrv0.set('SETTINGS:DECIMALS:COUNT',1) + redSrv0.set('SETTINGS:DECIMALS:COUNT', 3) +if redSrv0.get('SETTINGS:DECIMALS:DISPLAY') is None: + redSrv0.set('SETTINGS:DECIMALS:DISPLAY', 1) if redSrv0.get('RTDATA:VALUE:K1CONST') is None: redSrv0.set('RTDATA:VALUE:K1CONST', 0) if redSrv0.get('RTDATA:VALUE:K2CONST') is None: @@ -67,23 +69,23 @@ if redSrv0.get('RTDATA:VALUE:SMRAW') is None: if redSrv0.get('SETTINGS:POWER:THRESH') is None: redSrv0.set('SETTINGS:POWER:THRESH', 0) if redSrv0.get('SETTINGS:SMOOTHING:FUNCTION') is None: - redSrv0.set('SETTINGS:SMOOTHING:FUNCTION', 0) + redSrv0.set('SETTINGS:SMOOTHING:FUNCTION', 2) if redSrv0.get('SETTINGS:SMOOTHING:FACTOR') is None: - redSrv0.set('SETTINGS:SMOOTHING:FACTOR', 5) + redSrv0.set('SETTINGS:SMOOTHING:FACTOR', 25) if redSrv0.get('SETTINGS:SMOOTHING:EFACT') is None: redSrv0.set('SETTINGS:SMOOTHING:EFACT', 3) if redSrv0.get('SETTINGS:PASSWORD:CURRENT') is None: - redSrv0.set('SETTINGS:PASSWORD:CURRENT',"-") + redSrv0.set('SETTINGS:PASSWORD:CURRENT', "-") if redSrv0.get('SETTINGS:FOLDER:CURRENT') is None: redSrv0.set('SETTINGS:FOLDER:CURRENT', "") if redSrv0.get('SETTINGS:SELECTED_CH') is None: - redSrv0.set('SETTINGS:SELECTED_CH',0) + redSrv0.set('SETTINGS:SELECTED_CH', 0) if redSrv0.get('SETTINGS:CHANNEL:A') is None: - redSrv0.set('SETTINGS:CHANNEL:A',2) + redSrv0.set('SETTINGS:CHANNEL:A', 2) if redSrv0.get('SETTINGS:CHANNEL:B') is None: - redSrv0.set('SETTINGS:CHANNEL:B',3) + redSrv0.set('SETTINGS:CHANNEL:B', 3) if redSrv0.get('RTDATA:SESSION:NAME') is None: - redSrv0.set('RTDATA:SESSION:NAME',"") + redSrv0.set('RTDATA:SESSION:NAME', "") for numCh in range(0,8,+1): if redSrv0.get('SETTINGS:IN:MAX:'+str(numCh)) is None: @@ -137,6 +139,27 @@ def redisSave(CHvalues): roundedOut = round(scaleVal(CHvalues[chIndex], chIndex), decimalsCount) redSrv0.set(redAreaOut,roundedOut) + +#funzione di gestione dei valori grezzi di ingresso dei canali x taratura min/MAX +def setupScale(CHvalues): + decimalsCount = int(getRedisVal('SETTINGS:DECIMALS:COUNT')) + redLastLog = 'RTDATA:TIME:LOG' + dateFormat ="%d/%m/%Y %H:%M:%S" + rawLastLog = datetime.datetime.now() + lastLog = rawLastLog.strftime(dateFormat) + redSrv0.set(redLastLog,str(lastLog)) + for chIndex in range(0,8,+1): + redAreaIn = 'RTDATA:CH:'+str(chIndex) + redAreaOut = 'RTDATA:OUT:'+str(chIndex) + strValIn = float("%.4f" % (CHvalues[chIndex])) + #salvo valore IN filtrato + redSrv0.set(redAreaIn,round(strValIn,decimalsCount)) + # salvo i valori scalati in OUT + roundedOut = round(scaleVal(CHvalues[chIndex], chIndex), decimalsCount) + redSrv0.set(redAreaOut,roundedOut) + + + #funzione di refresh valori scalati def scaleVal(inValue, chIndex): #rileggo da redis i valori min/max secondo chIndex @@ -262,6 +285,8 @@ try: meanValues = calcMean(dataBox) #salvo valori redisSave(meanValues) + #verifica se sono in fase di salvataggio min/max x taratura valori ingresso + setupScale(meanValues) # controllo soglia spegnimento checkPowerOff() # calcolo il valore k*[V2/(V1-V2)] + offset diff --git a/server/FTServer.py b/server/FTServer.py index 7c05da5..b9c9f62 100644 --- a/server/FTServer.py +++ b/server/FTServer.py @@ -118,6 +118,7 @@ def api_channels_all(): 'timeSrv' : getRedisVal('RTDATA:TIME:SRV'), 'WriteFreq' : getRedisVal('SETTINGS:WRITE:FREQ'), 'DecimalsCount' : getRedisVal('SETTINGS:DECIMALS:COUNT'), + 'DecimalsDisplay' : getRedisVal('SETTINGS:DECIMALS:DISPLAY'), 'Status' : getRedisVal('SETTINGS:LOG:STATUS'), 'Channels': CH, 'Outs': OUT, @@ -181,6 +182,7 @@ def api_channels_current(): 'timeSrv' : getRedisVal('RTDATA:TIME:SRV'), 'LogFreq' : getRedisVal('SETTINGS:LOG:FREQ'), 'DecimalsCount' : getRedisVal('SETTINGS:DECIMALS:COUNT'), + 'DecimalsDisplay' : getRedisVal('SETTINGS:DECIMALS:DISPLAY'), 'WriteFreq' : getRedisVal('SETTINGS:WRITE:FREQ'), 'TimeBeforeWrite' : getRedisVal('SETTINGS:LOG:WAITIME'), 'CurrIn' : getRedisVal('RTDATA:CH:'+str(numCh)), @@ -360,6 +362,20 @@ def insertPassword(): redSrv0.set('SETTINGS:PASSWORD:CURRENT', currentPassword, ex=3600) return redirect("/settings") +@flaskApp.route("/api/v1/setup/setupValues", methods=['PUT']) +def setupValues(): + redSrv0.set('SETTINGS:SMOOTHING:FACTOR', 100) + redSrv0.set('SETTINGS:LOG:FREQ', 10) + redSrv0.save() + return redirect("/settings") + +@flaskApp.route("/api/v1/setup/workingValues", methods=['PUT']) +def workingValues(): + redSrv0.set('SETTINGS:SMOOTHING:FACTOR', 25) + redSrv0.set('SETTINGS:LOG:FREQ', 20) + redSrv0.save() + return redirect("/settings") + @flaskApp.route("/api/v1/setup/saveInMin", methods=['PUT']) def setupInMin(): # devo leggere il channel attualmente selezionato @@ -444,25 +460,34 @@ def setEFact(): @flaskApp.route("/api/v1/frequency", methods=['POST']) def setWriteFrequency(): #funzione set frequenza scrive su redis LOG:FREQ prendendolo dall'input in pagina html con nome LogFreq - newWriteFrequency = request.form['WriteFreq'] - redSrv0.set('SETTINGS:WRITE:FREQ', newWriteFrequency) newLogFrequency = request.form['LogFreq'] redSrv0.set('SETTINGS:LOG:FREQ', newLogFrequency) + newWriteFrequency = request.form['WriteFreq'] + redSrv0.set('SETTINGS:WRITE:FREQ', newWriteFrequency) timeBeforeWrite = request.form['TimeBeforeWrite'] redSrv0.set('SETTINGS:LOG:WAITIME', timeBeforeWrite) redSrv0.save() # rimando in settings return redirect("/settings") -@flaskApp.route("/api/v1/decimals", methods=['POST']) +@flaskApp.route("/api/v1/decimalsCount", methods=['POST']) def setDecimalsCount(): - #funzione set decimali, scrive su SETTINGS:DECIMALS:COUNT + #funzione set decimali per i calcoli, scrive su SETTINGS:DECIMALS:COUNT newDecimalsCount = request.form['DecimalsCount'] redSrv0.set('SETTINGS:DECIMALS:COUNT', newDecimalsCount) redSrv0.save() # rimando in settings return redirect("/settings") +@flaskApp.route("/api/v1/decimalsDisplay", methods=['POST']) +def setDecimalsDisplay(): + #funzione set decimali da mostrare, scrive su SETTINGS:DECIMALS:DISPLAY + newDecimalsDisplay = request.form['DecimalsDisplay'] + redSrv0.set('SETTINGS:DECIMALS:DISPLAY', newDecimalsDisplay) + redSrv0.save() + # rimando in settings + return redirect("/settings") + @flaskApp.route("/api/v1/kconst", methods=['POST']) def setKConst(): #scrive su redis la costante K diff --git a/server/templates/about.html b/server/templates/about.html index 02cbaea..68b5880 100644 --- a/server/templates/about.html +++ b/server/templates/about.html @@ -18,7 +18,6 @@ } }}); }; -
@@ -27,7 +26,7 @@
Egalware 2023
- Ver 1.8.4 + V 1.8.9
diff --git a/server/templates/layout.html b/server/templates/layout.html index f6bd787..6b59398 100644 --- a/server/templates/layout.html +++ b/server/templates/layout.html @@ -46,22 +46,32 @@
-
-
+
+
Data e ora
-
-
- -
-
-
-
- - - +
+
+
+
+ +
+
- +
+
+
+
+
+ +
+ +
+ +
+
+
+
@@ -70,14 +80,15 @@
-
-
-
-
-
© Egalware 2022-2023 +
+
+
+ V 1.8.9 +
+
+ © Egalware 2023 +
-
-
diff --git a/server/templates/logger.html b/server/templates/logger.html index 409679b..d6e0247 100644 --- a/server/templates/logger.html +++ b/server/templates/logger.html @@ -15,26 +15,26 @@ timeoutFast = setInterval(dataRefresh, intTime); timeoutSlow = setInterval(fixTables, intTimeSlow); - function fixFloat(actVal, numCount) + function fixFloat(actVal, numDisplay) { - return parseFloat(actVal).toFixed(numCount) + return parseFloat(actVal).toFixed(numDisplay) } function dataRefresh() { // scarico i dati aggioranti $.ajax({url: "/api/v1/channels/all", success: function(result){ - numCount = parseInt(result.DecimalsCount) + numDisplay = parseInt(result.DecimalsDisplay) var divWidth = document.getElementById("divChA").offsetWidth // compilo i dati scaricati $("#SelChannelA").html(result.ChA); - $("#OutputA").html(fixFloat(result.Outs[result.ChA],numCount)); + $("#OutputA").html(fixFloat(result.Outs[result.ChA],numDisplay)); setGaugeA(divWidth,result.Outs[result.ChA],result.Outmin[result.ChA],result.Outmax[result.ChA]); $("#SelChannelB").html(result.ChB); - $("#OutputB").html(fixFloat(result.Outs[result.ChB],numCount)); + $("#OutputB").html(fixFloat(result.Outs[result.ChB],numDisplay)); setGaugeB(divWidth,result.Outs[result.ChB],result.Outmin[result.ChB],result.Outmax[result.ChB]); @@ -42,8 +42,8 @@ $("#ServerTime").html(result.timeSrv); $("#LastSessionName").html(result.LastSessionName); $("#CurrentFolder").html(result.CurrentWorkFolder); - $("#ResultValue").html(result.ResultValue); - $("#RealValue").html(result.RealValue); + $("#ResultValue").html(fixFloat(result.ResultValue,numDisplay)); + $("#RealValue").html(fixFloat(result.RealValue,numDisplay)); $("#Crono").html(result.Crono); if(result.GateOpen == "0") @@ -122,6 +122,7 @@ $("#CalcMeasure2").html(result.CalcUMeasure); $("#SmoothFact").html(result.SmoothFact); $("#LogFreq").html(result.LogFreq); + $("#RecPeriod").html(result.SmoothFact*result.LogFreq); }}); // A ogni giro di data refresh fix di tabella cartelle e tabella file }; @@ -385,21 +386,58 @@
-
-
- Media Grezza: +
+ Media Grezza: +
+
+ Media Corretta: +
+
+
-
- Media Corretta: +
+
-
-
+
+
+
+
+
+ Smooth Factor: +
+
+ Sample Period: +
+
+ Record Period: +
+
+ System Load: +
+
+ +
+
+ ms +
+
+ ms +
+
+ + + +
+
+
+
+
@@ -456,24 +494,9 @@

-
-
-
-
- Smooth Factor: -
-
- Sample Period: ms -
- - - -
-
-


-{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/server/templates/settings.html b/server/templates/settings.html index b278d21..d52ae8f 100644 --- a/server/templates/settings.html +++ b/server/templates/settings.html @@ -20,12 +20,14 @@ $.ajax({url: "/api/v1/channels/current", success: function(result){ // compilo i dati scaricati numCount = parseInt(result.DecimalsCount) + numDisplay = parseInt(result.DecimalsDisplay) $("#CurrIn").html(fixFloat(result.CurrIn,numCount)); $("#CurrOut").html(fixFloat(result.CurrOut, numCount)); $("#LogFreq").val(result.LogFreq); $("#WriteFreq").val(result.WriteFreq); $("#TimeBeforeWrite").val(result.TimeBeforeWrite); $("#DecimalsCount").val(result.DecimalsCount); + $("#DecimalsDisplay").val(result.DecimalsDisplay); $("#ServerTime").html(result.timeSrv); $("#ddlChannels").val(result.numCh); $("#MinOut").val(result.MinOut); @@ -42,16 +44,20 @@ $("#EFact").val(result.EFact); $("#CalcUMeasure").val(result.CalcUMeasure); $("#MinUptime").val(result.MinUptime); + $("#RecPeriod").html(result.SmoothFact*result.LogFreq); // inizio nascondendo div2 e div3 + $("#Div1").show(); $("#Div2").hide(); $("#Div3").hide(); if(result.ShowDiv02 == "1") { $("#Div2").show(); + $("#Div1").hide(); } if(result.ShowDiv03 == "1") { $("#Div3").show(); + $("#Div1").hide(); } }}); } @@ -60,6 +66,7 @@ $.ajax({url: "/api/v1/channels/current", success: function(result){ // compilo i dati scaricati numCount = parseInt(result.DecimalsCount) + numDisplay = parseInt(result.DecimalsDisplay) $("#CurrIn").html(fixFloat(result.CurrIn,numCount)); $("#CurrOut").html(fixFloat(result.CurrOut, numCount)); $("#LoggerTime").html(result.timeLog); @@ -74,6 +81,7 @@ $.ajax({url: "/api/v1/channels/all", success: function(result){ numCount = parseInt(result.DecimalsCount) + numDisplay = parseInt(result.DecimalsDisplay) $("#SelChannelA").val(result.ChA); $("#ChannelA").html(fixFloat(result.Channels[result.ChA],numCount+1)); $("#OutputA").html(fixFloat(result.Outs[result.ChA],numCount)); @@ -87,6 +95,7 @@ $("#LogFrequency").html(result.LogFreq); $("#WriteFrequency").html(result.WriteFreq); $("#DecimalsCount").html(result.DecimalsCount); + $("#DecimalsDisplay").html(result.DecimalsDisplay); $("#ServerTime").html(result.timeSrv); $("#ChanScaleMin").html(result.ChScaleMin); $("#ChanScaleMax").html(result.ChScaleMax); @@ -96,6 +105,34 @@ }}); }; + function setupValues(){ + $.ajax({ + type: 'PUT' + ,url: "/api/v1/setup/setupValues" + ,data: "" + ,success: function(){ + alert('Setup Values'); + } + }) + refreshInput(); + refreshSettings(); + dataRefresh(); + }; + + function workingValues(){ + $.ajax({ + type: 'PUT' + ,url: "/api/v1/setup/workingValues" + ,data: "" + ,success: function(){ + alert('Working Values'); + } + }) + refreshInput(); + refreshSettings(); + dataRefresh(); + }; + function saveMin(){ $.ajax({ type: 'PUT' @@ -177,7 +214,7 @@ }); }; - //funzione powerOff: chiede conferma per spegnimento. + //funzione Settings Reset chiede conferma prima di flushare DB redis function settingsReset(){ var R = confirm("Reset impostazioni?"); if (R == true){ @@ -205,54 +242,56 @@
-
-
-
-
- Canale A -
- +
+
+
+
+
+ Canale A +
+ +
+
+ Nativo: +
+ Scalato: +
-
- Nativo: -
- Scalato: +
+
+
+
+
+ Canale B +
+ +
+
+
+ Nativo: +
+ Scalato: -
-
-
-
-
-
- Canale B -
-
-
-
- Nativo: -
- Scalato: -
@@ -262,157 +301,117 @@
- Impostazioni scalatura + Taratura
-
- -
-
-
+
+
+
+ Canale n° +
-
-
-
-
-
-
-
Input Attuale:   000
-
-
-
-
-
-
-
-
-
-
-
Output attuale:   {{ Out0 }}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
-
IN
-
-
-
-
-
-
+
+
-
-
-
-
OUT
-
-
-
-
-
-
+
+ Min
-
+
+ Now
-
-
-
- Unità di misura:   - +
+ Max
-
-
- +
+ Out
-
-
- -
-
-
-
- - Valori per calcolo risultante = k1*x^2 + k2*x + offset -
-
-
-
-
- Costante k1:   +
+
+ +
- -
-
-
- Costante k2:   +
+
- -
-
-
- Offset o:   +
+
+ +
+
+
+ Inp +
+
+
+ +
+ +
+
+
+
+ +
+
+
+ +
+ +
+
-
-
-
- +
+
+
+ Unità di misura:   +
+ +
+
+
+
+
+
-
- Unità di misura del risultato di [Valore B / (Valore A - Valore B)] +
+ + Processing e Timer +
+
+  ms +
-
-
-
- Unità di misura:   - - -
-
-
-
-
-
- Tipo processing -
-
+
+
+
+
+
-
+
Selezione Processing
@@ -424,18 +423,18 @@
-
+
Fattore di Smoothing:  
- +
-
+
Valore per EWMA:  
@@ -445,6 +444,33 @@
+
+
+
+ Periodo di campionamento (ms):   +
+ +
+
+
+ Periodo di scrittura su file (ms):   +
+ +
+
+
+
+ Ritardo prima scrittura su file (s):   +
+ +
+
+
+
+ +
+
+
@@ -453,15 +479,84 @@ Numero Decimali
-
-
-
-
- Numero di cifre decimali:   +
+
+ +
+
+ Decimali calcolo:   +
+ +
+ +
- -
- + +
+
+
+ Decimali display:   +
+ +
+ +
+
+
+
+
+
+
+
+
+ Valori per calcolo risultante = k1*x^2 + k2*x + offset +
+
+
+
+
+
+
+ Costante k1:   +
+ +
+
+
+ Costante k2:   +
+ +
+
+
+ Offset o:   +
+ +
+
+
+ +
+
+
+
+
+
+
+
+ Unità di misura del risultato di [Valore B / (Valore A - Valore B)] +
+
+
+
+
+ Unità di misura:   +
+ +
+
+
+
@@ -471,10 +566,10 @@
Impostazione canale da monitorare per soglia spegnimento
-
+
-
+
Selezione canale
@@ -492,56 +587,27 @@
-
- Soglia spegnimento:   +
+
+ Soglia spegnimento:  +
-
- Attesa minima prima dello spegnimento:   +
+
+ Attesa spegnimento (sec):   +
-
-
+
-
-
-
- - Impostazioni Timer -
-
-
-
- Periodo di campionamento (ms):   - -
-
- Periodo di scrittura su file (ms):   - -
-
-
- Ritardo prima scrittura su file (s):   - -
-
-
-
-
- -
-
-
-
-
-
@@ -549,11 +615,9 @@
-
-
+
-
@@ -561,4 +625,4 @@
-{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/server/test.sh b/server/test.sh new file mode 100644 index 0000000..b9b6041 --- /dev/null +++ b/server/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash + + +if [ -a /dev/sd[a-z]1 ] +then + /bin/mount /dev/sd[a-z]1 /mnt/USB +else + /bin/mount /dev/sd[a-z] /mnt/USB +fi