From cae57c612e84f2f12bffb5ae330d56a584fd4115 Mon Sep 17 00:00:00 2001 From: Marco Locatelli Date: Fri, 14 May 2021 15:19:30 +0200 Subject: [PATCH 1/3] calcolo valore risultante --- PyLog.txt | 153 +++++++++++++++++++++++++++++++++++ logger/FTLogger.py | 6 +- sampler/FTSampler.py | 27 ++++++- server/FTServer.py | 3 +- server/templates/logger.html | 11 +++ 5 files changed, 193 insertions(+), 7 deletions(-) diff --git a/PyLog.txt b/PyLog.txt index a04241d..1c12e46 100644 --- a/PyLog.txt +++ b/PyLog.txt @@ -388,3 +388,156 @@ 29/04/2021 17:04:46 FTSampler caught error: can only concatenate str (not "int") to str 30/04/2021 09:58:45 FTSampler caught error: int() argument must be a string, a bytes-like object or a number, not 'NoneType' 30/04/2021 09:58:51 FTSampler caught error: int() argument must be a string, a bytes-like object or a number, not 'NoneType' +14/05/2021 12:58:54 FTSampler caught error: unsupported operand type(s) for -: 'str' and 'str' +14/05/2021 12:58:59 FTSampler caught error: unsupported operand type(s) for -: 'str' and 'str' +14/05/2021 12:59:05 FTSampler caught error: unsupported operand type(s) for -: 'str' and 'str' +14/05/2021 12:59:10 FTSampler caught error: unsupported operand type(s) for -: 'str' and 'str' +14/05/2021 12:59:16 FTSampler caught error: unsupported operand type(s) for -: 'str' and 'str' +14/05/2021 12:59:21 FTSampler caught error: unsupported operand type(s) for -: 'str' and 'str' +14/05/2021 12:59:27 FTSampler caught error: unsupported operand type(s) for -: 'str' and 'str' +14/05/2021 12:59:32 FTSampler caught error: unsupported operand type(s) for -: 'str' and 'str' +14/05/2021 12:59:38 FTSampler caught error: unsupported operand type(s) for -: 'str' and 'str' +14/05/2021 12:59:43 FTSampler caught error: unsupported operand type(s) for -: 'str' and 'str' +14/05/2021 12:59:49 FTSampler caught error: unsupported operand type(s) for -: 'str' and 'str' +14/05/2021 12:59:54 FTSampler caught error: unsupported operand type(s) for -: 'str' and 'str' +14/05/2021 13:00:00 FTSampler caught error: unsupported operand type(s) for -: 'str' and 'str' +14/05/2021 13:00:05 FTSampler caught error: unsupported operand type(s) for -: 'str' and 'str' +14/05/2021 13:00:11 FTSampler caught error: unsupported operand type(s) for -: 'str' and 'str' +14/05/2021 13:00:16 FTSampler caught error: unsupported operand type(s) for -: 'str' and 'str' +14/05/2021 13:00:22 FTSampler caught error: unsupported operand type(s) for -: 'str' and 'str' +14/05/2021 13:00:27 FTSampler caught error: unsupported operand type(s) for -: 'str' and 'str' +14/05/2021 13:00:33 FTSampler caught error: unsupported operand type(s) for -: 'str' and 'str' +14/05/2021 13:00:38 FTSampler caught error: unsupported operand type(s) for -: 'str' and 'str' +14/05/2021 13:00:44 FTSampler caught error: unsupported operand type(s) for -: 'str' and 'str' +14/05/2021 13:00:49 FTSampler caught error: unsupported operand type(s) for -: 'str' and 'str' +14/05/2021 13:00:55 FTSampler caught error: unsupported operand type(s) for -: 'str' and 'str' +14/05/2021 13:01:00 FTSampler caught error: unsupported operand type(s) for -: 'str' and 'str' +14/05/2021 13:01:06 FTSampler caught error: unsupported operand type(s) for -: 'str' and 'str' +14/05/2021 13:01:11 FTSampler caught error: unsupported operand type(s) for -: 'str' and 'str' +14/05/2021 13:01:17 FTSampler caught error: unsupported operand type(s) for -: 'str' and 'str' +14/05/2021 13:01:22 FTSampler caught error: unsupported operand type(s) for -: 'str' and 'str' +14/05/2021 13:01:28 FTSampler caught error: unsupported operand type(s) for -: 'str' and 'str' +14/05/2021 13:01:33 FTSampler caught error: unsupported operand type(s) for -: 'str' and 'str' +14/05/2021 13:01:39 FTSampler caught error: unsupported operand type(s) for -: 'str' and 'str' +14/05/2021 13:01:44 FTSampler caught error: unsupported operand type(s) for -: 'str' and 'str' +14/05/2021 13:01:50 FTSampler caught error: unsupported operand type(s) for -: 'str' and 'str' +14/05/2021 13:01:53 FTSampler caught error: unsupported operand type(s) for -: 'str' and 'str' +14/05/2021 13:01:55 FTSampler caught error: unsupported operand type(s) for -: 'str' and 'str' +14/05/2021 13:02:01 FTSampler caught error: unsupported operand type(s) for -: 'str' and 'str' +14/05/2021 13:02:06 FTSampler caught error: unsupported operand type(s) for -: 'str' and 'str' +14/05/2021 13:02:12 FTSampler caught error: unsupported operand type(s) for -: 'str' and 'str' +14/05/2021 13:02:17 FTSampler caught error: unsupported operand type(s) for -: 'str' and 'str' +14/05/2021 13:02:23 FTSampler caught error: invalid literal for int() with base 10: '46.414' +14/05/2021 13:02:24 FTSampler caught error: invalid literal for int() with base 10: '46.412' +14/05/2021 13:02:28 FTSampler caught error: invalid literal for int() with base 10: '46.412' +14/05/2021 13:02:34 FTSampler caught error: invalid literal for int() with base 10: '46.404' +14/05/2021 13:02:39 FTSampler caught error: invalid literal for int() with base 10: '46.412' +14/05/2021 13:02:45 FTSampler caught error: unsupported operand type(s) for /: 'str' and 'float' +14/05/2021 13:02:47 FTSampler caught error: unsupported operand type(s) for /: 'str' and 'float' +14/05/2021 13:02:48 FTSampler caught error: unsupported operand type(s) for /: 'str' and 'float' +14/05/2021 13:02:52 FTSampler caught error: unsupported operand type(s) for /: 'str' and 'float' +14/05/2021 13:02:58 FTSampler caught error: unsupported operand type(s) for /: 'str' and 'float' +14/05/2021 13:03:03 FTSampler caught error: unsupported operand type(s) for /: 'str' and 'float' +14/05/2021 13:03:09 FTSampler caught error: unsupported operand type(s) for /: 'str' and 'float' +14/05/2021 13:03:14 FTSampler caught error: unsupported operand type(s) for /: 'str' and 'float' +14/05/2021 13:06:06 FTSampler end. Ctrl+C from user +14/05/2021 13:06:23 FTSampler end. Ctrl+C from user +14/05/2021 14:49:20 FTSampler caught error: Invalid input of type: 'datetime'. Convert to a bytes, string, int or float first. +14/05/2021 14:49:21 FTSampler caught error: Invalid input of type: 'datetime'. Convert to a bytes, string, int or float first. +14/05/2021 14:49:26 FTSampler caught error: Invalid input of type: 'datetime'. Convert to a bytes, string, int or float first. +14/05/2021 14:49:31 FTSampler caught error: Invalid input of type: 'datetime'. Convert to a bytes, string, int or float first. +14/05/2021 14:49:37 FTSampler caught error: Invalid input of type: 'datetime'. Convert to a bytes, string, int or float first. +14/05/2021 14:49:43 FTSampler caught error: Invalid input of type: 'datetime'. Convert to a bytes, string, int or float first. +14/05/2021 14:49:48 FTSampler caught error: Invalid input of type: 'datetime'. Convert to a bytes, string, int or float first. +14/05/2021 14:49:54 FTSampler caught error: Invalid input of type: 'datetime'. Convert to a bytes, string, int or float first. +14/05/2021 14:49:59 FTSampler caught error: Invalid input of type: 'timedelta'. Convert to a bytes, string, int or float first. +14/05/2021 14:50:05 FTSampler caught error: Invalid input of type: 'timedelta'. Convert to a bytes, string, int or float first. +14/05/2021 14:50:50 FTSampler caught error: unsupported operand type(s) for +: 'float' and 'str' +14/05/2021 14:50:55 FTSampler caught error: unsupported operand type(s) for +: 'float' and 'str' +14/05/2021 14:51:01 FTSampler caught error: unsupported operand type(s) for +: 'float' and 'str' +14/05/2021 14:51:06 FTSampler caught error: unsupported operand type(s) for +: 'float' and 'str' +14/05/2021 14:51:12 FTSampler caught error: unsupported operand type(s) for +: 'float' and 'str' +14/05/2021 14:51:18 FTSampler caught error: unsupported operand type(s) for +: 'float' and 'str' +14/05/2021 14:54:28 FTSampler caught error: could not convert string to float: '69.686 ms' +14/05/2021 14:54:34 FTSampler caught error: could not convert string to float: '69.686 ms' +14/05/2021 14:54:39 FTSampler caught error: could not convert string to float: '69.686 ms' +14/05/2021 14:54:44 FTSampler caught error: could not convert string to float: '69.686 ms' +14/05/2021 14:54:50 FTSampler caught error: could not convert string to float: '69.686 ms' +14/05/2021 14:54:56 FTSampler caught error: could not convert string to float: '69.686 ms' +14/05/2021 14:55:01 FTSampler caught error: could not convert string to float: '69.686 ms' +14/05/2021 14:55:07 FTSampler caught error: could not convert string to float: '69.686 ms' +14/05/2021 14:55:12 FTSampler caught error: could not convert string to float: '69.686 ms' +14/05/2021 14:55:18 FTSampler caught error: could not convert string to float: '69.686 ms' +14/05/2021 14:55:20 FTSampler caught error: could not convert string to float: '69.686 ms' +14/05/2021 14:55:25 FTSampler caught error: could not convert string to float: '69.686 ms' +14/05/2021 14:55:31 FTSampler caught error: could not convert string to float: '69.686 ms' +14/05/2021 14:55:36 FTSampler caught error: could not convert string to float: '69.686 ms' +14/05/2021 14:55:42 FTSampler caught error: could not convert string to float: '69.686 ms' +14/05/2021 14:55:47 FTSampler caught error: could not convert string to float: '69.686 ms' +14/05/2021 14:55:53 FTSampler caught error: could not convert string to float: '69.686 ms' +14/05/2021 14:55:58 FTSampler caught error: could not convert string to float: '69.686 ms' +14/05/2021 14:56:04 FTSampler caught error: could not convert string to float: '69.686 ms' +14/05/2021 14:56:09 FTSampler caught error: could not convert string to float: '69.686 ms' +14/05/2021 14:56:15 FTSampler caught error: could not convert string to float: '69.686 ms' +14/05/2021 14:56:20 FTSampler caught error: could not convert string to float: '69.686 ms' +14/05/2021 14:56:22 FTSampler caught error: could not convert string to float: '69.686 ms' +14/05/2021 14:56:25 FTSampler caught error: could not convert string to float: '69.686 ms' +14/05/2021 14:56:28 FTSampler caught error: could not convert string to float: '69.686 ms' +14/05/2021 14:56:34 FTSampler caught error: could not convert string to float: '69.686 ms' +14/05/2021 14:58:30 FTSampler caught error: float() argument must be a string or a number, not 'NoneType' +14/05/2021 14:58:36 FTSampler caught error: float() argument must be a string or a number, not 'NoneType' +14/05/2021 14:58:41 FTSampler caught error: float() argument must be a string or a number, not 'NoneType' +14/05/2021 14:58:47 FTSampler caught error: float() argument must be a string or a number, not 'NoneType' +14/05/2021 14:58:52 FTSampler caught error: float() argument must be a string or a number, not 'NoneType' +14/05/2021 14:58:58 FTSampler caught error: float() argument must be a string or a number, not 'NoneType' +14/05/2021 14:59:03 FTSampler caught error: float() argument must be a string or a number, not 'NoneType' +14/05/2021 14:59:09 FTSampler caught error: float() argument must be a string or a number, not 'NoneType' +14/05/2021 14:59:14 FTSampler caught error: float() argument must be a string or a number, not 'NoneType' +14/05/2021 14:59:20 FTSampler caught error: float() argument must be a string or a number, not 'NoneType' +14/05/2021 14:59:25 FTSampler caught error: float() argument must be a string or a number, not 'NoneType' +14/05/2021 14:59:31 FTSampler caught error: float() argument must be a string or a number, not 'NoneType' +14/05/2021 14:59:36 FTSampler caught error: float() argument must be a string or a number, not 'NoneType' +14/05/2021 14:59:42 FTSampler caught error: float() argument must be a string or a number, not 'NoneType' +14/05/2021 14:59:48 FTSampler caught error: float() argument must be a string or a number, not 'NoneType' +14/05/2021 14:59:53 FTSampler caught error: float() argument must be a string or a number, not 'NoneType' +14/05/2021 14:59:58 FTSampler caught error: float() argument must be a string or a number, not 'NoneType' +14/05/2021 15:00:04 FTSampler caught error: float() argument must be a string or a number, not 'NoneType' +14/05/2021 15:00:10 FTSampler caught error: float() argument must be a string or a number, not 'NoneType' +14/05/2021 15:00:15 FTSampler caught error: float() argument must be a string or a number, not 'NoneType' +14/05/2021 15:00:18 FTSampler caught error: float() argument must be a string or a number, not 'NoneType' +14/05/2021 15:00:20 FTSampler caught error: float() argument must be a string or a number, not 'NoneType' +14/05/2021 15:00:26 FTSampler caught error: float() argument must be a string or a number, not 'NoneType' +14/05/2021 15:00:31 FTSampler caught error: float() argument must be a string or a number, not 'NoneType' +14/05/2021 15:00:37 FTSampler caught error: float() argument must be a string or a number, not 'NoneType' +14/05/2021 15:00:42 FTSampler caught error: float() argument must be a string or a number, not 'NoneType' +14/05/2021 15:00:48 FTSampler caught error: float() argument must be a string or a number, not 'NoneType' +14/05/2021 15:00:54 FTSampler caught error: float() argument must be a string or a number, not 'NoneType' +14/05/2021 15:00:59 FTSampler caught error: float() argument must be a string or a number, not 'NoneType' +14/05/2021 15:01:05 FTSampler caught error: float() argument must be a string or a number, not 'NoneType' +14/05/2021 15:01:10 FTSampler caught error: float() argument must be a string or a number, not 'NoneType' +14/05/2021 15:01:15 FTSampler caught error: float() argument must be a string or a number, not 'NoneType' +14/05/2021 15:01:21 FTSampler caught error: float() argument must be a string or a number, not 'NoneType' +14/05/2021 15:01:27 FTSampler caught error: float() argument must be a string or a number, not 'NoneType' +14/05/2021 15:01:32 FTSampler caught error: float() argument must be a string or a number, not 'NoneType' +14/05/2021 15:01:38 FTSampler caught error: float() argument must be a string or a number, not 'NoneType' +14/05/2021 15:01:43 FTSampler caught error: float() argument must be a string or a number, not 'NoneType' +14/05/2021 15:01:48 FTSampler caught error: float() argument must be a string or a number, not 'NoneType' +14/05/2021 15:01:54 FTSampler caught error: float() argument must be a string or a number, not 'NoneType' +14/05/2021 15:01:59 FTSampler caught error: float() argument must be a string or a number, not 'NoneType' +14/05/2021 15:02:05 FTSampler caught error: float() argument must be a string or a number, not 'NoneType' +14/05/2021 15:02:10 FTSampler caught error: float() argument must be a string or a number, not 'NoneType' +14/05/2021 15:02:16 FTSampler caught error: float() argument must be a string or a number, not 'NoneType' +14/05/2021 15:02:21 FTSampler caught error: float() argument must be a string or a number, not 'NoneType' +14/05/2021 15:02:27 FTSampler caught error: float() argument must be a string or a number, not 'NoneType' +14/05/2021 15:02:33 FTSampler caught error: float() argument must be a string or a number, not 'NoneType' +14/05/2021 15:02:38 FTSampler caught error: float() argument must be a string or a number, not 'NoneType' +14/05/2021 15:02:43 FTSampler caught error: float() argument must be a string or a number, not 'NoneType' +14/05/2021 15:02:49 FTSampler caught error: float() argument must be a string or a number, not 'NoneType' +14/05/2021 15:02:54 FTSampler caught error: float() argument must be a string or a number, not 'NoneType' +14/05/2021 15:03:00 FTSampler caught error: float() argument must be a string or a number, not 'NoneType' +14/05/2021 15:03:06 FTSampler caught error: float() argument must be a string or a number, not 'NoneType' +14/05/2021 15:03:11 FTSampler caught error: float() argument must be a string or a number, not 'NoneType' +14/05/2021 15:03:17 FTSampler caught error: float() argument must be a string or a number, not 'NoneType' +14/05/2021 15:03:32 FTSampler caught error: float() argument must be a string or a number, not 'NoneType' +14/05/2021 15:04:59 FTSampler end. Ctrl+C from user +14/05/2021 15:15:22 FTSampler caught error: int() argument must be a string, a bytes-like object or a number, not 'NoneType' diff --git a/logger/FTLogger.py b/logger/FTLogger.py index 6385c02..ca1cb32 100644 --- a/logger/FTLogger.py +++ b/logger/FTLogger.py @@ -49,6 +49,7 @@ if redSrv0.get('SETTINGS:FOLDER:CURRENT') is None: #funzione salva time+data e otto valori letti su file SE LOG è 1 def fileSave(): + resultValue = getRedisVal('RTDATA:VALUE') currentFolder = getRedisVal('SETTINGS:FOLDER:CURRENT') workingDirectory = (DATA_path+currentFolder) #dò un nome al nuovo file @@ -65,9 +66,8 @@ def fileSave(): for chIndex in range(0,2,+1): channelOut = getRedisVal('RTDATA:OUT:'+str(chIndex)) csvRow += channelOut+"," - # tolgo ultimo "," - l = len(csvRow) - csvRow = csvRow[:l-1] + #aggiungo il valore risultante calcolato V1/(V2-V1) + csvRow += resultValue # scrivo in blocco la riga dei valori outFile.write(csvRow +"\r\n") outFile.close() diff --git a/sampler/FTSampler.py b/sampler/FTSampler.py index 6d8e8a1..fcfe7f0 100644 --- a/sampler/FTSampler.py +++ b/sampler/FTSampler.py @@ -60,12 +60,16 @@ redSrv0.set(redSampleFreq,startingSampleFreq) #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:LOG:STATUS',0) - +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: @@ -179,6 +183,17 @@ def checkPowerOff(): # chiedo spognimento redSrv0.set('SETTINGS:POWER:OFF',1) +def calculateValue(): + ch1 = getRedisVal('SETTINGS:CHANNEL:A') + ch2 = getRedisVal('SETTINGS:CHANNEL:B') + v1 = getRedisVal('RTDATA:OUT:' + ch1) + v2 = getRedisVal('RTDATA:OUT:' + ch2) + den = (float(v1)-float(v2)) + if(den < 0.00001): + den = 0.00001 + newValue = float(v2)/float(den) + redSrv0.set('RTDATA:VALUE',newValue) + # init oggetto lettura da try: CH = ADS1256.ADS1256() @@ -196,17 +211,23 @@ try: redisSave(CHvalue) # controllo soglia spegnimento checkPowerOff() + #calcolo il valore [V2/(V1-V2)] + calculateValue() # riporto ultima esecuzione ad adesso endExec = datetime.datetime.now() # calcolo il delta time dovuto alle esecuzioni delta = endExec - now + oldSPeriod=float(getRedisVal(redSamPer)) + newSPeriod=0.5*oldSPeriod+0.5*(float(delta.microseconds/1000)) + redSrv0.set(redSamPer,newSPeriod) waitTime = int(getRedisVal(redSampleFreq)) / 1000 - delta.microseconds/1000000 - if(waitTime < 0.1): - waitTime = 0.1 + if(waitTime < 0.01): + waitTime = 0.01 # attesa time.sleep(waitTime) #print('read done: ' + str(getRedisVal(redSampleFreq)) + ' | ' + str(waitTime)) + #eccezione da ctrl+c in terminale e chiusura except KeyboardInterrupt: now = datetime.datetime.now() diff --git a/server/FTServer.py b/server/FTServer.py index 424f11e..5923b15 100644 --- a/server/FTServer.py +++ b/server/FTServer.py @@ -111,7 +111,8 @@ def api_channels_all(): 'CurrentWorkFolder' : getRedisVal('SETTINGS:FOLDER:CURRENT'), 'RealDateStatus' : getRedisVal('SETTINGS:TIME:REAL'), 'SelPowerChannel' : getRedisVal('SETTINGS:POWER:CH'), - 'SelProcessing' : getRedisVal('SETTINGS:SMOOTHING:FUNCTION') + 'SelProcessing' : getRedisVal('SETTINGS:SMOOTHING:FUNCTION'), + 'ResultValue' : getRedisVal('RTDATA:VALUE') } # restituisce in formato json i dati letti da redis return jsonify(channelsData) diff --git a/server/templates/logger.html b/server/templates/logger.html index cc519f9..9a3bca8 100644 --- a/server/templates/logger.html +++ b/server/templates/logger.html @@ -41,6 +41,7 @@ $("#ServerTime").html(result.timeSrv); $("#LastSessionName").html(result.LastSessionName); $("#CurrentFolder").html(result.CurrentWorkFolder); + $("#ResultValue").html(result.ResultValue); if(result.GateOpen == "0") { @@ -338,6 +339,16 @@ +
+
+ Calcolo risultante +
+
+
+ Valore B / (Valore A - Valore B) =   +
+
+
From 22c58401365211ea9ad4c34ae5bd1543a9340e0e Mon Sep 17 00:00:00 2001 From: Marco Locatelli Date: Mon, 17 May 2021 11:28:22 +0200 Subject: [PATCH 2/3] correzione: log su file dei canali A e B + fix --- PyLog.txt | 2 ++ logger/FTLogger.py | 13 +++++++++---- sampler/FTSampler.py | 6 ++---- server/FTServer.py | 2 +- server/templates/logger.html | 6 ++---- 5 files changed, 16 insertions(+), 13 deletions(-) diff --git a/PyLog.txt b/PyLog.txt index 1c12e46..ab4945d 100644 --- a/PyLog.txt +++ b/PyLog.txt @@ -541,3 +541,5 @@ 14/05/2021 15:03:32 FTSampler caught error: float() argument must be a string or a number, not 'NoneType' 14/05/2021 15:04:59 FTSampler end. Ctrl+C from user 14/05/2021 15:15:22 FTSampler caught error: int() argument must be a string, a bytes-like object or a number, not 'NoneType' +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' diff --git a/logger/FTLogger.py b/logger/FTLogger.py index ca1cb32..8f70f62 100644 --- a/logger/FTLogger.py +++ b/logger/FTLogger.py @@ -62,10 +62,15 @@ def fileSave(): except FileNotFoundError: outFile = open(workingDirectory+"/"+dataFileName, "w+") # dichiaro una stringa in cui accumulo i valori - csvRow = str(lastLog) +"," - for chIndex in range(0,2,+1): - channelOut = getRedisVal('RTDATA:OUT:'+str(chIndex)) - csvRow += channelOut+"," + csvRow = str(lastLog) +"," + # scrivo le letture del canale A + chA = getRedisVal('SETTINGS:CHANNEL:A') + chAOut = getRedisVal('RTDATA:OUT:'+str(chA)) + csvRow += chAOut+"," + # scrivo le letture del canale B + chB = getRedisVal('SETTINGS:CHANNEL:B') + chBOut = getRedisVal('RTDATA:OUT:'+str(chB)) + csvRow += chBOut+"," #aggiungo il valore risultante calcolato V1/(V2-V1) csvRow += resultValue # scrivo in blocco la riga dei valori diff --git a/sampler/FTSampler.py b/sampler/FTSampler.py index fcfe7f0..7b064de 100644 --- a/sampler/FTSampler.py +++ b/sampler/FTSampler.py @@ -54,7 +54,7 @@ def getRmsVal(redisKey, numVal): LOG_path = "/home/pi/Flythis/" #intervallo in millisecondi fra un campionamento e il successivo -startingSampleFreq = 250 +startingSampleFreq = 100 redSampleFreq = 'SETTINGS:LOG:FREQ' redSrv0.set(redSampleFreq,startingSampleFreq) @@ -192,7 +192,7 @@ def calculateValue(): if(den < 0.00001): den = 0.00001 newValue = float(v2)/float(den) - redSrv0.set('RTDATA:VALUE',newValue) + redSrv0.set('RTDATA:VALUE',round(newValue,3)) # init oggetto lettura da try: @@ -225,8 +225,6 @@ try: waitTime = 0.01 # attesa time.sleep(waitTime) - #print('read done: ' + str(getRedisVal(redSampleFreq)) + ' | ' + str(waitTime)) - #eccezione da ctrl+c in terminale e chiusura except KeyboardInterrupt: diff --git a/server/FTServer.py b/server/FTServer.py index 5923b15..fcca00e 100644 --- a/server/FTServer.py +++ b/server/FTServer.py @@ -394,7 +394,7 @@ def setScale(): @flaskApp.route("/api/v1/setup/resetSettings", methods=['POST']) def resetSetup(): #resetto i campi di redis alla situazione di partenza - redSrv0.set('SETTINGS:LOG:FREQ',250) + redSrv0.set('SETTINGS:LOG:FREQ',100) redSrv0.set('SETTINGS:WRITE:FREQ',1000) redSrv0.set('SETTINGS:LOG:STATUS',0) redSrv0.set('SETTINGS:SELECTED_CH',0) diff --git a/server/templates/logger.html b/server/templates/logger.html index 9a3bca8..aafc514 100644 --- a/server/templates/logger.html +++ b/server/templates/logger.html @@ -343,10 +343,8 @@
Calcolo risultante
-
-
- Valore B / (Valore A - Valore B) =   -
+
+ [Valore B / (Valore A - Valore B)] =  
From eb3f9bdf988410d6d10097d0fa19c408abc20eeb Mon Sep 17 00:00:00 2001 From: Marco Locatelli Date: Fri, 21 May 2021 15:04:56 +0200 Subject: [PATCH 3/3] =?UTF-8?q?Unit=C3=A0=20di=20misura=20del=20valore=20c?= =?UTF-8?q?alcolato?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- PyLog.txt | 1 + sampler/FTSampler.py | 8 ++++---- server/FTServer.py | 8 ++++++++ server/templates/logger.html | 17 +++++++++-------- server/templates/settings.html | 15 +++++++++++++++ 5 files changed, 37 insertions(+), 12 deletions(-) diff --git a/PyLog.txt b/PyLog.txt index ab4945d..26924f0 100644 --- a/PyLog.txt +++ b/PyLog.txt @@ -543,3 +543,4 @@ 14/05/2021 15:15:22 FTSampler caught error: int() argument must be a string, a bytes-like object or a number, not 'NoneType' 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' diff --git a/sampler/FTSampler.py b/sampler/FTSampler.py index 7b064de..d3922c8 100644 --- a/sampler/FTSampler.py +++ b/sampler/FTSampler.py @@ -65,7 +65,8 @@ 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:LOG:STATUS',0) - +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: @@ -80,7 +81,6 @@ if redSrv0.get('SETTINGS:SMOOTHING:FUNCTION') is None: redSrv0.set('SETTINGS:SMOOTHING:FUNCTION', 0) if redSrv0.get('SETTINGS:SMOOTHING:FACTOR') is None: redSrv0.set('SETTINGS:SMOOTHING:FACTOR', 10) - if redSrv0.get('SETTINGS:PASSWORD:CURRENT') is None: redSrv0.set('SETTINGS:PASSWORD:CURRENT',"-") if redSrv0.get('SETTINGS:FOLDER:CURRENT') is None: @@ -189,8 +189,8 @@ def calculateValue(): v1 = getRedisVal('RTDATA:OUT:' + ch1) v2 = getRedisVal('RTDATA:OUT:' + ch2) den = (float(v1)-float(v2)) - if(den < 0.00001): - den = 0.00001 + if(den < 0.001): + den = 0.001 newValue = float(v2)/float(den) redSrv0.set('RTDATA:VALUE',round(newValue,3)) diff --git a/server/FTServer.py b/server/FTServer.py index fcca00e..c5d59f3 100644 --- a/server/FTServer.py +++ b/server/FTServer.py @@ -100,6 +100,7 @@ def api_channels_all(): 'Outmin': OUTMIN, 'Outmax': OUTMAX, 'UniMeasure' : UNIMISURA, + 'CalcUMeasure' : getRedisVal('RTDATA:VALUE:UMEASURE'), 'ChA' : getRedisVal('SETTINGS:CHANNEL:A'), 'ChB' : getRedisVal('SETTINGS:CHANNEL:B'), 'ChScaleMax' : getRedisVal('SETTINGS:IN:MAX:'+str(numCh)), @@ -138,6 +139,7 @@ def api_channels_current(): #funzione api_channels_all: legge direttamente da redis, ritorna jsonify result = { 'numCh' : numCh, + 'CalcUMeasure' : getRedisVal('RTDATA:VALUE:UMEASURE'), 'SmoothFact' : getRedisVal('SETTINGS:SMOOTHING:FACTOR'), 'ChanThresh' : getRedisVal('SETTINGS:POWER:THRESH'), 'timeSrv' : getRedisVal('RTDATA:TIME:SRV'), @@ -325,6 +327,12 @@ def setPowerChannel(numPowerCh): redSrv0.set('SETTINGS:POWER:CH', numPowerCh) return "OK" +@flaskApp.route("/api/v1/setup/calcMeasureUnit", methods=['POST']) +def VUnitMeasure(): + CMeasureUnit = request.form['CalcUMeasure'] + redSrv0.set('RTDATA:VALUE:UMEASURE', CMeasureUnit) + return redirect("/settings") + @flaskApp.route("/api/v1/setup/selectProcessing/", methods=['PUT']) def setProcessing(processingType): redSrv0.set('SETTINGS:SMOOTHING:FUNCTION', processingType) diff --git a/server/templates/logger.html b/server/templates/logger.html index aafc514..5d3e23e 100644 --- a/server/templates/logger.html +++ b/server/templates/logger.html @@ -91,7 +91,7 @@ //scarico unità di misura dei canali mostrati $("#UniMisuA").html(result.UniMeasure[result.ChA]); $("#UniMisuB").html(result.UniMeasure[result.ChB]); - + $("#CalcUMeasure").html(result.CalcUMeasure); }}); // A ogni giro di data refresh fix di tabella cartelle e tabella file @@ -339,14 +339,15 @@
-
-
- Calcolo risultante -
-
- [Valore B / (Valore A - Valore B)] =   -
+
+
+ Calcolo risultante [Valore B / (Valore A - Valore B)]
+
+   + +
+
diff --git a/server/templates/settings.html b/server/templates/settings.html index 29712e2..e1cf16f 100644 --- a/server/templates/settings.html +++ b/server/templates/settings.html @@ -35,6 +35,7 @@ $("#UniMisura").val(result.UniMisura); $("#ChanThresh").val(result.ChanThresh); $("#SmoothFact").val(result.SmoothFact); + $("#CalcUMeasure").val(result.CalcUMeasure); // inizio nascondendo div2 e div3 $("#Div2").hide(); $("#Div3").hide(); @@ -346,6 +347,20 @@
+
+
+ Unità di misura della risultante [Valore B / (Valore A - Valore B)] +
+
+
+
+ Unità di misura:   + + +
+
+
+
Impostazioni canale e soglia per spegnimento