diff --git a/PyLog.txt b/PyLog.txt index 26924f0..6634246 100644 --- a/PyLog.txt +++ b/PyLog.txt @@ -544,3 +544,60 @@ 17/05/2021 09:51:36 FTSampler caught error: int() argument must be a string, a bytes-like object or a number, not 'NoneType' 17/05/2021 11:12:38 FTSampler caught error: float() argument must be a string or a number, not 'NoneType' 21/05/2021 14:59:25 FTSampler caught error: int() argument must be a string, a bytes-like object or a number, not 'NoneType' +24/05/2021 16:26:29 FTSampler caught error: local variable 'numReqPowerOff' referenced before assignment +24/05/2021 16:26:42 FTSampler caught error: local variable 'numReqPowerOff' referenced before assignment +24/05/2021 16:39:31 FTSampler caught error: local variable 'numReqPowerOff' referenced before assignment +25/05/2021 13:20:29 FTSampler caught error: could not convert string to float: +25/05/2021 13:20:42 FTSampler caught error: could not convert string to float: +25/05/2021 13:53:58 FTSampler caught error: could not convert string to float: +25/05/2021 13:54:09 FTSampler caught error: could not convert string to float: +25/05/2021 13:54:29 FTSampler caught error: could not convert string to float: +25/05/2021 13:54:46 FTSampler caught error: could not convert string to float: +25/05/2021 14:00:26 FTSampler caught error: could not convert string to float: +25/05/2021 14:21:47 FTSampler caught error: Invalid input of type: 'timedelta'. Convert to a bytes, string, int or float first. +25/05/2021 14:21:53 FTSampler caught error: Invalid input of type: 'timedelta'. Convert to a bytes, string, int or float first. +25/05/2021 14:21:58 FTSampler caught error: Invalid input of type: 'timedelta'. Convert to a bytes, string, int or float first. +25/05/2021 14:22:04 FTSampler caught error: Invalid input of type: 'timedelta'. Convert to a bytes, string, int or float first. +25/05/2021 14:22:09 FTSampler caught error: Invalid input of type: 'timedelta'. Convert to a bytes, string, int or float first. +25/05/2021 14:22:15 FTSampler caught error: Invalid input of type: 'timedelta'. Convert to a bytes, string, int or float first. +25/05/2021 14:22:20 FTSampler caught error: Invalid input of type: 'timedelta'. Convert to a bytes, string, int or float first. +25/05/2021 14:22:26 FTSampler caught error: Invalid input of type: 'timedelta'. Convert to a bytes, string, int or float first. +25/05/2021 14:22:31 FTSampler caught error: Invalid input of type: 'timedelta'. Convert to a bytes, string, int or float first. +25/05/2021 14:22:35 FTSampler caught error: Invalid input of type: 'timedelta'. Convert to a bytes, string, int or float first. +25/05/2021 14:22:40 FTSampler caught error: Invalid input of type: 'timedelta'. Convert to a bytes, string, int or float first. +25/05/2021 14:22:46 FTSampler caught error: Invalid input of type: 'timedelta'. Convert to a bytes, string, int or float first. +25/05/2021 14:22:51 FTSampler caught error: Invalid input of type: 'timedelta'. Convert to a bytes, string, int or float first. +25/05/2021 14:22:57 FTSampler caught error: Invalid input of type: 'timedelta'. Convert to a bytes, string, int or float first. +25/05/2021 14:23:02 FTSampler caught error: Invalid input of type: 'timedelta'. Convert to a bytes, string, int or float first. +25/05/2021 14:23:08 FTSampler caught error: float() argument must be a string or a number, not 'datetime.timedelta' +25/05/2021 14:23:13 FTSampler caught error: float() argument must be a string or a number, not 'datetime.timedelta' +25/05/2021 14:23:19 FTSampler caught error: float() argument must be a string or a number, not 'datetime.timedelta' +25/05/2021 14:23:24 FTSampler caught error: float() argument must be a string or a number, not 'datetime.timedelta' +25/05/2021 14:23:29 FTSampler caught error: float() argument must be a string or a number, not 'datetime.timedelta' +25/05/2021 14:23:35 FTSampler caught error: float() argument must be a string or a number, not 'datetime.timedelta' +25/05/2021 14:23:40 FTSampler caught error: float() argument must be a string or a number, not 'datetime.timedelta' +25/05/2021 14:23:46 FTSampler caught error: float() argument must be a string or a number, not 'datetime.timedelta' +25/05/2021 14:23:51 FTSampler caught error: float() argument must be a string or a number, not 'datetime.timedelta' +25/05/2021 14:28:02 FTSampler caught error: 'datetime.timedelta' object has no attribute 'strftime' +25/05/2021 14:28:08 FTSampler caught error: 'datetime.timedelta' object has no attribute 'strftime' +25/05/2021 14:28:09 FTSampler caught error: 'datetime.timedelta' object has no attribute 'strftime' +25/05/2021 14:28:15 FTSampler caught error: 'datetime.timedelta' object has no attribute 'strftime' +25/05/2021 14:28:20 FTSampler caught error: 'datetime.timedelta' object has no attribute 'strftime' +25/05/2021 14:28:26 FTSampler caught error: 'datetime.timedelta' object has no attribute 'strftime' +25/05/2021 14:28:26 FTSampler caught error: 'datetime.timedelta' object has no attribute 'strftime' +25/05/2021 14:28:31 FTSampler caught error: 'datetime.timedelta' object has no attribute 'strftime' +25/05/2021 14:28:37 FTSampler caught error: 'datetime.timedelta' object has no attribute 'strftime' +25/05/2021 14:28:42 FTSampler caught error: 'datetime.timedelta' object has no attribute 'strftime' +25/05/2021 14:28:49 FTSampler caught error: 'datetime.timedelta' object has no attribute 'strftime' +25/05/2021 14:28:54 FTSampler caught error: 'datetime.timedelta' object has no attribute 'strftime' +25/05/2021 14:29:00 FTSampler caught error: 'datetime.timedelta' object has no attribute 'strftime' +25/05/2021 14:29:05 FTSampler caught error: 'datetime.timedelta' object has no attribute 'strftime' +25/05/2021 14:29:11 FTSampler caught error: 'datetime.timedelta' object has no attribute 'strftime' +25/05/2021 14:29:17 FTSampler caught error: 'datetime.timedelta' object has no attribute 'strftime' +25/05/2021 14:29:22 FTSampler caught error: 'datetime.timedelta' object has no attribute 'strftime' +25/05/2021 14:29:28 FTSampler caught error: 'datetime.timedelta' object has no attribute 'strftime' +25/05/2021 14:29:33 FTSampler caught error: 'datetime.timedelta' object has no attribute 'strftime' +25/05/2021 14:29:39 FTSampler caught error: 'datetime.timedelta' object has no attribute 'strftime' +25/05/2021 14:29:45 FTSampler caught error: 'datetime.timedelta' object has no attribute 'strftime' +25/05/2021 14:29:51 FTSampler caught error: 'datetime.timedelta' object has no attribute 'strftime' +25/05/2021 14:29:57 FTSampler caught error: 'datetime.timedelta' object has no attribute 'strftime' diff --git a/__pycache__/uptime.cpython-37.pyc b/__pycache__/uptime.cpython-37.pyc new file mode 100644 index 0000000..52603ab Binary files /dev/null and b/__pycache__/uptime.cpython-37.pyc differ diff --git a/sampler/FTSampler.py b/sampler/FTSampler.py index f1caad7..5704085 100644 --- a/sampler/FTSampler.py +++ b/sampler/FTSampler.py @@ -1,5 +1,6 @@ #!/usr/bin/python +import os import math import time import datetime @@ -14,8 +15,6 @@ redSrv0 = redis.Redis( port=REDIS_PORT, db=0) -numReqPowerOff = 0 - #funzione per leggere e decodificare da redis def getRedisVal(redisKey): if redSrv0.get(redisKey) is None: @@ -56,27 +55,26 @@ def getRmsVal(redisKey, numVal): LOG_path = "/home/pi/Flythis/" #intervallo in millisecondi fra un campionamento e il successivo -startingSampleFreq = 100 redSampleFreq = 'SETTINGS:LOG:FREQ' -redSrv0.set(redSampleFreq,startingSampleFreq) +redSrv0.set(redSampleFreq,100) #definizioni variabili redRmsList ='RTDATA:RMSLIST' redSamPer='SETTINGS:LOG:EXETIME' #se non c'è un valore nei campi di redis, popolo il db -redSrv0.set('SETTINGS:DECIMALS:COUNT',3) +redSrv0.set('SETTINGS:DECIMALS:COUNT',2) redSrv0.set('SETTINGS:LOG:STATUS',0) +redSrv0.set('SETTINGS:POWER:CH', 10) +redSrv0.set('SETTINGS:POWER:UPTIME', 180) if redSrv0.get('RTDATA:VALUE:UMEASURE') is None: redSrv0.set('RTDATA:VALUE:UMEASURE', "-") if redSrv0.get('SETTINGS:LOG:EXETIME') is None: redSrv0.set('SETTINGS:LOG:EXETIME', 1) if redSrv0.get('RTDATA:VALUE') is None: redSrv0.set('RTDATA:VALUE', 1) -if redSrv0.get('SETTINGS:POWER:CH') is None: - redSrv0.set('SETTINGS:POWER:CH', 10) if redSrv0.get('SETTINGS:POWER:THRESH') is None: - redSrv0.set('SETTINGS:POWER:THRESH', 1) + redSrv0.set('SETTINGS:POWER:THRESH', 0) if redSrv0.get('SETTINGS:POWER:OFF') is None: redSrv0.set('SETTINGS:POWER:OFF', 0) if redSrv0.get('SETTINGS:SMOOTHING:FUNCTION') is None: @@ -178,16 +176,17 @@ def scaleVal(inValue, chIndex): def checkPowerOff(): powerChannel = getRedisVal('SETTINGS:POWER:CH') if(int(powerChannel) < 10): + #controllo che non ci sia già una richiesta di spegnimento if(getRedisVal('SETTINGS:POWER:OFF')=="0"): limitVal = float(getRedisVal('SETTINGS:POWER:THRESH')) actVal = float(getRedisVal('RTDATA:CH:' + str(powerChannel))) - if(actVal > limitVal): - # resetto contatore - numReqPowerOff = 0 - else: - numReqPowerOff += 1 - if(numReqPowerOff > 10): - # chiedo spognimento + #controllo che il valore letto sia inferiore al valore impostato di soglia + if(actVal < limitVal): + #controllo che il sistema sia acceso da 180 secondi prima di spegnere + UptimePower = getRedisVal('SETTINGS:POWER:UPTIME') + sysUptime = os.popen("awk '{print $1}' /proc/uptime").readline() + if float(sysUptime) > float(UptimePower): + # chiedo spegnimento redSrv0.set('SETTINGS:POWER:OFF',1) def calculateValue(): @@ -224,6 +223,7 @@ try: endExec = datetime.datetime.now() # calcolo il delta time dovuto alle esecuzioni delta = endExec - now + redSrv0.set('SETTINGS:EXE:TIME',str(delta)) oldSPeriod=float(getRedisVal(redSamPer)) newSPeriod=0.5*oldSPeriod+0.5*(float(delta.microseconds/1000)) redSrv0.set(redSamPer,newSPeriod) diff --git a/server/FTServer.py b/server/FTServer.py index c5d59f3..6622b08 100644 --- a/server/FTServer.py +++ b/server/FTServer.py @@ -154,6 +154,7 @@ def api_channels_current(): 'MinIn' : getRedisVal('SETTINGS:IN:MIN:'+str(numCh)), 'UniMisura' : getRedisVal('SETTINGS:UNIT:MEASURE:'+str(numCh)), 'CurrentWorkFolder' : getRedisVal('SETTINGS:FOLDER:CURRENT'), + 'MinUptime' : getRedisVal('SETTINGS:POWER:UPTIME'), 'ShowDiv01' : showDiv1, 'ShowDiv02' : showDiv2, 'ShowDiv03' : showDiv3, @@ -297,6 +298,7 @@ def setupInMin(): indCh = getRedisVal('SETTINGS:SELECTED_CH') currChVal = redSrv0.get('RTDATA:CH:'+ str(indCh)) redSrv0.set('SETTINGS:IN:MIN:'+ str(indCh), currChVal) + redSrv0.save() return redirect("/settings") @flaskApp.route("/api/v1/setup/saveInMax", methods=['PUT']) @@ -305,43 +307,53 @@ def setupInMax(): indCh = getRedisVal('SETTINGS:SELECTED_CH') currChVal = redSrv0.get('RTDATA:CH:'+ str(indCh)) redSrv0.set('SETTINGS:IN:MAX:'+ str(indCh), currChVal) + redSrv0.save() return redirect("/settings") @flaskApp.route("/api/v1/setup/selectChannelA/", methods=['PUT']) def selectChannelA(numChA): redSrv0.set('SETTINGS:CHANNEL:A', numChA) + redSrv0.save() return "OK" @flaskApp.route("/api/v1/setup/selectChannelB/", methods=['PUT']) def selectChannelB(numChB): redSrv0.set('SETTINGS:CHANNEL:B', numChB) + redSrv0.save() return "OK" @flaskApp.route("/api/v1/setup/selectChannel/", methods=['PUT']) def setChannel(numCh): redSrv0.set('SETTINGS:SELECTED_CH', numCh) + redSrv0.save() return redirect("/settings") @flaskApp.route("/api/v1/setup/selectPowerChannel/", methods=['PUT']) def setPowerChannel(numPowerCh): redSrv0.set('SETTINGS:POWER:CH', numPowerCh) + redSrv0.save() return "OK" @flaskApp.route("/api/v1/setup/calcMeasureUnit", methods=['POST']) def VUnitMeasure(): CMeasureUnit = request.form['CalcUMeasure'] redSrv0.set('RTDATA:VALUE:UMEASURE', CMeasureUnit) + redSrv0.save() return redirect("/settings") @flaskApp.route("/api/v1/setup/selectProcessing/", methods=['PUT']) def setProcessing(processingType): redSrv0.set('SETTINGS:SMOOTHING:FUNCTION', processingType) + redSrv0.save() return "OK" @flaskApp.route("/api/v1/threshold", methods=['POST']) def setPowerThreshold(): powerThreshold = request.form['ChanThresh'] redSrv0.set('SETTINGS:POWER:THRESH', powerThreshold) + minUptime = request.form['MinUptime'] + redSrv0.set('SETTINGS:POWER:UPTIME', minUptime) + redSrv0.save() # rimando in settings return redirect("/settings") @@ -349,6 +361,7 @@ def setPowerThreshold(): def setSmoothFact(): smoothingFactor = request.form['SmoothFact'] redSrv0.set('SETTINGS:SMOOTHING:FACTOR', smoothingFactor) + redSrv0.save() # rimando in settings return redirect("/settings") @@ -359,6 +372,7 @@ def setWriteFrequency(): redSrv0.set('SETTINGS:WRITE:FREQ', newWriteFrequency) newLogFrequency = request.form['LogFreq'] redSrv0.set('SETTINGS:LOG:FREQ', newLogFrequency) + redSrv0.save() # rimando in settings return redirect("/settings") @@ -367,6 +381,7 @@ def setDecimalsCount(): #funzione set decimali, scrive su SETTINGS:DECIMALS:COUNT newDecimalsCount = request.form['DecimalsCount'] redSrv0.set('SETTINGS:DECIMALS:COUNT', newDecimalsCount) + redSrv0.save() # rimando in settings return redirect("/settings") @@ -396,6 +411,7 @@ def setScale(): redSrv0.set('SETTINGS:OUT:MAX:'+ str(indexCh), scaleMax) uniMisura = request.form['UniMisura'] redSrv0.set('SETTINGS:UNIT:MEASURE:'+ str(indexCh), uniMisura) + redSrv0.save() # rimando in settings return redirect("/settings") @@ -413,6 +429,7 @@ def resetSetup(): redSrv0.set('SETTINGS:OUT:MIN:'+str(numCh),0) redSrv0.set('SETTINGS:UNIT:MEASURE:'+str(numCh),"-") # rimando in settings + redSrv0.save() return redirect("/settings") @flaskApp.route("/api/v1/setup/poweroff", methods=['PUT']) diff --git a/server/templates/about.html b/server/templates/about.html index d5dd122..4103e47 100644 --- a/server/templates/about.html +++ b/server/templates/about.html @@ -28,9 +28,9 @@
Steamware 2021
- Analog/Digital logger software + Software di lettura e scrittura per canali analogici e digitali
- V 1.0.0 + V 1.0.1
diff --git a/server/templates/home.html b/server/templates/home.html index dbaf47a..06b141f 100644 --- a/server/templates/home.html +++ b/server/templates/home.html @@ -41,19 +41,19 @@

- About + Info
+
SHUT DOWN
diff --git a/server/templates/layout.html b/server/templates/layout.html index ce48149..4b39312 100644 --- a/server/templates/layout.html +++ b/server/templates/layout.html @@ -33,10 +33,10 @@ Logger diff --git a/server/templates/logger.html b/server/templates/logger.html index 5d3e23e..da94d10 100644 --- a/server/templates/logger.html +++ b/server/templates/logger.html @@ -309,7 +309,7 @@
- Channel A: + Canale A:
@@ -325,7 +325,7 @@
- Channel B: + Canale B:
@@ -355,11 +355,11 @@
+   Inizia Scrittura
+   Ferma Scrittura
@@ -386,11 +386,11 @@
+   Salva su USB
+   Elimina dati
diff --git a/server/templates/settings.html b/server/templates/settings.html index e1cf16f..229b93c 100644 --- a/server/templates/settings.html +++ b/server/templates/settings.html @@ -36,6 +36,7 @@ $("#ChanThresh").val(result.ChanThresh); $("#SmoothFact").val(result.SmoothFact); $("#CalcUMeasure").val(result.CalcUMeasure); + $("#MinUptime").val(result.MinUptime); // inizio nascondendo div2 e div3 $("#Div2").hide(); $("#Div3").hide(); @@ -252,7 +253,7 @@ Impostazioni scalatura
- +
@@ -296,9 +297,9 @@
-
+
-
+
@@ -340,7 +341,7 @@
- +
@@ -349,7 +350,7 @@
- Unità di misura della risultante [Valore B / (Valore A - Valore B)] + Unità di misura del risultato di [Valore B / (Valore A - Valore B)]
@@ -361,48 +362,6 @@
-
-
- Impostazioni canale e soglia per spegnimento -
-
-
-
- Impostazione canale analogico a soglia per gestione autospegnimento. -
-
-
-
-
- Selezione canale -
- -
-
-
-
-
- Soglia spegnimento:   -
- -
- -
-
-
-
-
-
Tipo processing @@ -444,7 +403,7 @@
- Decimals Count:   + Numero di cifre decimali:  
@@ -454,6 +413,50 @@
+
+
+ Impostazione canale da monitorare per soglia spegnimento +
+
+
+
+
+
+ Selezione canale +
+ +
+
+
+
+ Soglia spegnimento:   + +
+
+ Tempo minimo prima dello spegnimento (s):   + +
+
+
+
+ +
+
+
+
+
+
+
@@ -462,11 +465,11 @@
- Sample Period (ms):   + Periodo di campionamento (ms):  
- Log Period (ms):   + Periodo di scrittura su file (ms):  
@@ -483,14 +486,14 @@
- Reset default settings + Ripristina impostazioni predefinite
- +
diff --git a/uptime.py b/uptime.py new file mode 100644 index 0000000..4e1ddc6 --- /dev/null +++ b/uptime.py @@ -0,0 +1,8 @@ +#!/usr/bin/python + +import os + +raspbUptime = os.popen("awk '{print $1}' /proc/uptime").readline() +print(raspbUptime) +if float(raspbUptime) > 2000: + print("yo") \ No newline at end of file diff --git a/uptime.pyc b/uptime.pyc new file mode 100644 index 0000000..aa53771 Binary files /dev/null and b/uptime.pyc differ