display scaled values in logger page
This commit is contained in:
+15
-11
@@ -14,7 +14,11 @@ redSrv0 = redis.Redis(
|
||||
port=REDIS_PORT,
|
||||
db=0)
|
||||
|
||||
#se non c'è un valore nei campi di redis, gli do 0
|
||||
#se non c'è un valore nei campi di redis, popolo il db
|
||||
|
||||
LOG_path = "/home/pi/Flythis/logger/log/"
|
||||
DATA_path = "/home/pi/Flythis/logger/data/"
|
||||
|
||||
if redSrv0.get('SETTINGS:LOG:STATUS') is None:
|
||||
redSrv0.set('SETTINGS:LOG:STATUS',1)
|
||||
|
||||
@@ -52,10 +56,10 @@ try:
|
||||
#funzione salva time+data e otto valori letti su file
|
||||
def fileSave(CHvalue):
|
||||
try:
|
||||
logFile = open("PyLog.txt", "a")
|
||||
logFile = open(LOG_path, "a")
|
||||
except FileNotFoundError:
|
||||
print("Creating new PyLog.txt")
|
||||
logFile = open("PyLog.txt", "w+")
|
||||
logFile = open(LOG_path, "w+")
|
||||
logFile.write("\nTime: "+str(now))
|
||||
for chIndex in range(0,8,+1):
|
||||
logFile.write(" | CH "+str(chIndex)+" = %lf"%(CHvalue[chIndex]*5.0/0x7fffff))
|
||||
@@ -122,25 +126,25 @@ try:
|
||||
#eccezione da ctrl+c in terminale e chiusura
|
||||
except KeyboardInterrupt:
|
||||
GPIO.cleanup()
|
||||
print ("\r\nProgram End. Ctrl+C from user")
|
||||
print (str(now)+" Program End. Ctrl+C from user\r\n")
|
||||
try:
|
||||
logFile = open("PyLog.txt", "a")
|
||||
logFile = open(LOG_path+"PyLog.txt", "a")
|
||||
except FileNotFoundError:
|
||||
print("Creating new PyLog.txt")
|
||||
logFile = open("PyLog.txt", "w+")
|
||||
logFile.write("\r\nProgram end. Ctrl+C from user at time: "+str(now))
|
||||
logFile = open(LOG_path+"PyLog.txt", "w+")
|
||||
logFile.write(str(now)+" Program end. Ctrl+C from user\r\n")
|
||||
logFile.close()
|
||||
exit()
|
||||
|
||||
#eccezione da errore e chiusura
|
||||
except Exception as errorMessage:
|
||||
GPIO.cleanup()
|
||||
print("\r\nCaught error " + str(errorMessage))
|
||||
print(str(now)+" Caught error " + str(errorMessage)+"\r\n")
|
||||
try:
|
||||
logFile = open("PyLog.txt", "a")
|
||||
logFile = open(LOG_path+"PyLog.txt", "a")
|
||||
except FileNotFoundError:
|
||||
print("Creating new PyLog.txt")
|
||||
logFile = open("PyLog.txt", "w+")
|
||||
logFile.write("\r\nCaught error: "+str(errorMessage)+" at time: "+str(now))
|
||||
logFile = open(LOG_path+"PyLog.txt", "w+")
|
||||
logFile.write(str(now)+" Caught error: "+str(errorMessage)+"\r\n")
|
||||
logFile.close()
|
||||
exit()
|
||||
@@ -1,57 +0,0 @@
|
||||
|
||||
Program end by Ctrl+C from user at time: 2021-03-02 10:58:32.924038
|
||||
Program end by Ctrl+C from user at time: 2021-03-02 15:31:02.592220
|
||||
Program end. Ctrl+C from user at time: 2021-03-03 09:16:55.728488
|
||||
Program end. Ctrl+C from user at time: 2021-03-03 10:33:35.124096
|
||||
Program end. Ctrl+C from user at time: 2021-03-03 10:51:21.859527
|
||||
Program end. Ctrl+C from user at time: 2021-03-03 10:52:51.564834
|
||||
Program end. Ctrl+C from user at time: 2021-03-05 10:55:41.203884
|
||||
Program end. Ctrl+C from user at time: 2021-03-05 14:58:00.328326
|
||||
Program end. Ctrl+C from user at time: 2021-03-09 11:54:37.081347
|
||||
Program end. Ctrl+C from user at time: 2021-03-09 12:28:40.268269
|
||||
Program end. Ctrl+C from user at time: 2021-03-09 12:54:10.962510
|
||||
Program end. Ctrl+C from user at time: 2021-03-09 15:08:18.134550
|
||||
Program end. Ctrl+C from user at time: 2021-03-09 16:08:30.446015
|
||||
Program end. Ctrl+C from user at time: 2021-03-09 16:09:05.759802
|
||||
Program end. Ctrl+C from user at time: 2021-03-15 16:01:16.217190
|
||||
Program end. Ctrl+C from user at time: 2021-03-16 12:13:05.400117
|
||||
Program end. Ctrl+C from user at time: 2021-03-18 08:58:50.018800
|
||||
Caught error: Error 111 connecting to 127.0.0.1:6379. Connection refused. at time: 2021-03-18 10:21:27.190143
|
||||
Program end. Ctrl+C from user at time: 2021-03-18 12:11:40.393985
|
||||
Program end. Ctrl+C from user at time: 2021-03-18 12:12:18.995260
|
||||
Program end. Ctrl+C from user at time: 2021-03-18 12:13:20.497212
|
||||
Program end. Ctrl+C from user at time: 2021-03-18 12:13:25.594680
|
||||
Program end. Ctrl+C from user at time: 2021-03-18 12:14:18.546804
|
||||
Program end. Ctrl+C from user at time: 2021-03-18 12:14:41.216737
|
||||
Program end. Ctrl+C from user at time: 2021-03-18 14:09:28.913884
|
||||
Program end. Ctrl+C from user at time: 2021-03-18 14:15:12.712488
|
||||
Program end. Ctrl+C from user at time: 2021-03-18 14:42:56.107040
|
||||
Program end. Ctrl+C from user at time: 2021-03-18 14:43:54.837925
|
||||
Program end. Ctrl+C from user at time: 2021-03-18 14:57:58.864880
|
||||
Program end. Ctrl+C from user at time: 2021-03-18 15:02:53.303865
|
||||
Caught error: Error 111 connecting to 127.0.0.1:6379. Connection refused. at time: 2021-03-19 09:19:55.193580
|
||||
Program end. Ctrl+C from user at time: 2021-03-19 09:34:33.511872
|
||||
Program end. Ctrl+C from user at time: 2021-03-19 10:10:31.986759
|
||||
Program end. Ctrl+C from user at time: 2021-03-19 10:12:48.131123
|
||||
Program end. Ctrl+C from user at time: 2021-03-19 10:15:55.788262
|
||||
Program end. Ctrl+C from user at time: 2021-03-19 11:16:56.194264
|
||||
Program end. Ctrl+C from user at time: 2021-03-19 11:21:34.246971
|
||||
Caught error: 'NoneType' object has no attribute 'decode' at time: 2021-03-19 11:46:37.483097
|
||||
Program end. Ctrl+C from user at time: 2021-03-19 12:48:01.838556
|
||||
Program end. Ctrl+C from user at time: 2021-03-19 12:49:41.004201
|
||||
Program end. Ctrl+C from user at time: 2021-03-19 12:53:27.063207
|
||||
Program end. Ctrl+C from user at time: 2021-03-19 15:00:27.908197
|
||||
Program end. Ctrl+C from user at time: 2021-03-19 15:24:20.079220
|
||||
Program end. Ctrl+C from user at time: 2021-03-22 12:33:04.141973
|
||||
Program end. Ctrl+C from user at time: 2021-03-22 15:30:41.573572
|
||||
Program end. Ctrl+C from user at time: 2021-03-23 09:06:45.866191
|
||||
Caught error: 'NoneType' object has no attribute 'decode' at time: 2021-03-23 12:27:05.778515
|
||||
Program end. Ctrl+C from user at time: 2021-03-23 12:48:33.227212
|
||||
Program end. Ctrl+C from user at time: 2021-03-23 12:52:51.386359
|
||||
Caught error: 'NoneType' object has no attribute 'decode' at time: 2021-03-23 12:53:15.167221
|
||||
Program end. Ctrl+C from user at time: 2021-03-23 14:12:15.324783
|
||||
Program end. Ctrl+C from user at time: 2021-03-23 15:23:23.456196
|
||||
Program end. Ctrl+C from user at time: 2021-03-23 15:31:55.154641
|
||||
Program end. Ctrl+C from user at time: 2021-03-23 15:33:33.517326
|
||||
Program end. Ctrl+C from user at time: 2021-03-24 12:35:48.198605
|
||||
Program end. Ctrl+C from user at time: 2021-03-24 15:27:56.660342
|
||||
@@ -0,0 +1,9 @@
|
||||
2021-03-29 09:58:47.508544 Program end. Ctrl+C from user
|
||||
2021-03-29 09:58:49.419906 Program end. Ctrl+C from user
|
||||
2021-03-29 10:06:36.805375 Program end. Ctrl+C from user
|
||||
2021-03-29 10:16:34.873420 Program end. Ctrl+C from user
|
||||
2021-03-29 11:31:02.367011 Program end. Ctrl+C from user
|
||||
2021-03-29 11:36:21.793976 Program end. Ctrl+C from user
|
||||
2021-03-29 11:36:32.642389 Program end. Ctrl+C from user
|
||||
2021-03-29 11:36:39.298257 Program end. Ctrl+C from user
|
||||
2021-03-29 11:37:09.962049 Program end. Ctrl+C from user
|
||||
+30
-33
@@ -7,8 +7,6 @@ import redis
|
||||
import socket
|
||||
from werkzeug.utils import redirect
|
||||
|
||||
|
||||
|
||||
#create a socket object
|
||||
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
||||
|
||||
@@ -30,10 +28,10 @@ redSrv0 = redis.Redis(
|
||||
port=REDIS_PORT,
|
||||
db=0)
|
||||
|
||||
#funzione per leggere e decodificare da redis
|
||||
def getRedisVal(redisKey):
|
||||
return redSrv0.get(redisKey).decode('utf-8')
|
||||
|
||||
|
||||
flaskApp = Flask(__name__)
|
||||
@flaskApp.route("/")
|
||||
#funzione main: passa al template home il titolo
|
||||
@@ -49,17 +47,17 @@ def main():
|
||||
def logger():
|
||||
channelsData = {
|
||||
'title' : 'Logger',
|
||||
'timeSrv' : redSrv0.get('RTDATA:TIME:SRV').decode('utf-8'),
|
||||
'timeLog' : redSrv0.get('RTDATA:TIME:LOG').decode('utf-8'),
|
||||
'Freq' : redSrv0.get('SETTINGS:LOG:FREQ').decode('utf-8'),
|
||||
'Ch0' : redSrv0.get('RTDATA:CH:0').decode('utf-8'),
|
||||
'Ch1' : redSrv0.get('RTDATA:CH:1').decode('utf-8'),
|
||||
'Ch2' : redSrv0.get('RTDATA:CH:2').decode('utf-8'),
|
||||
'Ch3' : redSrv0.get('RTDATA:CH:3').decode('utf-8'),
|
||||
'Ch4' : redSrv0.get('RTDATA:CH:4').decode('utf-8'),
|
||||
'Ch5' : redSrv0.get('RTDATA:CH:5').decode('utf-8'),
|
||||
'Ch6' : redSrv0.get('RTDATA:CH:6').decode('utf-8'),
|
||||
'Ch7' : redSrv0.get('RTDATA:CH:7').decode('utf-8'),
|
||||
'timeSrv' : getRedisVal('RTDATA:TIME:SRV'),
|
||||
'timeLog' : getRedisVal('RTDATA:TIME:LOG'),
|
||||
'Freq' : getRedisVal('SETTINGS:LOG: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'),
|
||||
@@ -77,7 +75,7 @@ def logger():
|
||||
def setup():
|
||||
channelsData = {
|
||||
'title' : 'Settings',
|
||||
'Freq' : redSrv0.get('SETTINGS:LOG:FREQ').decode('utf-8'),
|
||||
'Freq' : getRedisVal('SETTINGS:LOG:FREQ'),
|
||||
'Ch0' : getRedisVal('RTDATA:CH:0'),
|
||||
'Ch1' : getRedisVal('RTDATA:CH:1'),
|
||||
'Ch2' : getRedisVal('RTDATA:CH:2'),
|
||||
@@ -113,17 +111,17 @@ def api_channels_all():
|
||||
numCh = redSrv0.get('SETTINGS:SELECTED_CH').decode('utf-8')
|
||||
#funzione api_channels_all: legge direttamente da redis, ritorna jsonify
|
||||
channelsData = {
|
||||
'timeSrv' : redSrv0.get('RTDATA:TIME:SRV').decode('utf-8'),
|
||||
'timeLog' : redSrv0.get('RTDATA:TIME:LOG').decode('utf-8'),
|
||||
'Freq' : redSrv0.get('SETTINGS:LOG:FREQ').decode('utf-8'),
|
||||
'Ch0' : redSrv0.get('RTDATA:CH:0').decode('utf-8'),
|
||||
'Ch1' : redSrv0.get('RTDATA:CH:1').decode('utf-8'),
|
||||
'Ch2' : redSrv0.get('RTDATA:CH:2').decode('utf-8'),
|
||||
'Ch3' : redSrv0.get('RTDATA:CH:3').decode('utf-8'),
|
||||
'Ch4' : redSrv0.get('RTDATA:CH:4').decode('utf-8'),
|
||||
'Ch5' : redSrv0.get('RTDATA:CH:5').decode('utf-8'),
|
||||
'Ch6' : redSrv0.get('RTDATA:CH:6').decode('utf-8'),
|
||||
'Ch7' : redSrv0.get('RTDATA:CH:7').decode('utf-8'),
|
||||
'timeSrv' : getRedisVal('RTDATA:TIME:SRV'),
|
||||
'timeLog' : getRedisVal('RTDATA:TIME:LOG'),
|
||||
'Freq' : getRedisVal('SETTINGS:LOG: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'),
|
||||
@@ -132,15 +130,14 @@ def api_channels_all():
|
||||
'Out5' : getRedisVal('RTDATA:OUT:5'),
|
||||
'Out6' : getRedisVal('RTDATA:OUT:6'),
|
||||
'Out7' : getRedisVal('RTDATA:OUT:7'),
|
||||
'ChScaleMax' : redSrv0.get('SETTINGS:IN:MAX:'+str(numCh)).decode('utf-8'),
|
||||
'ChScaleMin' : redSrv0.get('SETTINGS:IN:MIN:'+str(numCh)).decode('utf-8'),
|
||||
'ChRealMax' : redSrv0.get('SETTINGS:OUT:MAX:'+str(numCh)).decode('utf-8'),
|
||||
'ChRealMin' : redSrv0.get('SETTINGS:OUT:MIN:'+str(numCh)).decode('utf-8')
|
||||
'ChScaleMax' : getRedisVal('SETTINGS:IN:MAX:'+str(numCh)),
|
||||
'ChScaleMin' : getRedisVal('SETTINGS:IN:MIN:'+str(numCh)),
|
||||
'ChRealMax' : getRedisVal('SETTINGS:OUT:MAX:'+str(numCh)),
|
||||
'ChRealMin' : getRedisVal('SETTINGS:OUT:MIN:'+str(numCh))
|
||||
}
|
||||
# restituisce in formato json i dati letti da redis
|
||||
return jsonify(channelsData)
|
||||
|
||||
|
||||
# definisco una NUOVA route a cui rispondere su chiamta in metodo GET x restituire dati aggiornati
|
||||
@flaskApp.route("/api/v1/channels/current", methods=['GET'])
|
||||
def api_channels_current():
|
||||
@@ -177,7 +174,7 @@ def stop_log():
|
||||
@flaskApp.route("/api/v1/setup/saveInMin", methods=['PUT'])
|
||||
def setupInMin():
|
||||
# devo leggere il channel attualmente selezionato
|
||||
indCh = redSrv0.get('SETTINGS:SELECTED_CH').decode('utf-8')
|
||||
indCh = getRedisVal('SETTINGS:SELECTED_CH')
|
||||
currChVal = redSrv0.get('RTDATA:CH:'+ str(indCh))
|
||||
redSrv0.set('SETTINGS:IN:MIN:'+ str(indCh), currChVal)
|
||||
return redirect("/settings")
|
||||
@@ -185,7 +182,7 @@ def setupInMin():
|
||||
@flaskApp.route("/api/v1/setup/saveInMax", methods=['PUT'])
|
||||
def setupInMax():
|
||||
# devo leggere il channel attualmente selezionato
|
||||
indCh = redSrv0.get('SETTINGS:SELECTED_CH').decode('utf-8')
|
||||
indCh = getRedisVal('SETTINGS:SELECTED_CH')
|
||||
currChVal = redSrv0.get('RTDATA:CH:'+ str(indCh))
|
||||
redSrv0.set('SETTINGS:IN:MAX:'+ str(indCh), currChVal)
|
||||
return redirect("/settings")
|
||||
|
||||
@@ -13,41 +13,6 @@
|
||||
<script src="../static/js/bootstrap.bundle.min.js"></script>
|
||||
</head>
|
||||
<body class="sb-nav-fixed">
|
||||
<!-- <script>
|
||||
var intTime=350;
|
||||
// fix visualizzazioni
|
||||
fixDisplay();
|
||||
// avvio timer
|
||||
var timeout = setTimeout(dataRefresh, intTime);
|
||||
|
||||
function fixDisplay(){
|
||||
$("#divNewFile").toggle();
|
||||
}
|
||||
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);
|
||||
$("#LogFrequency").html(result.Freq);
|
||||
$("#LoggerTime").html(result.timeLog);
|
||||
$("#ServerTime").html(result.timeSrv);
|
||||
$("#ChanScaleMin1").html(result.ChScaleMin1);
|
||||
$("#ChanScaleMax1").html(result.ChScaleMax1);
|
||||
$("#ChanRealMin1").html(result.ChRealMin1);
|
||||
$("#ChanRealMax1").html(result.ChRealMax1);
|
||||
}});
|
||||
|
||||
timeout = setTimeout(dataRefresh, intTime);
|
||||
}
|
||||
|
||||
</script> -->
|
||||
<nav class="navbar navbar-expand-md bg-dark navbar-dark">
|
||||
<!-- Brand -->
|
||||
<a class="navbar-brand" href="/">ANALOGGER</a>
|
||||
|
||||
@@ -11,7 +11,8 @@
|
||||
|
||||
function fixDisplay(){
|
||||
$("#divNewFile").toggle();
|
||||
}
|
||||
};
|
||||
|
||||
function dataRefresh() {
|
||||
// scarico i dati aggioranti
|
||||
$.ajax({url: "/api/v1/channels/all", success: function(result){
|
||||
@@ -24,13 +25,21 @@
|
||||
$("#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);
|
||||
$("#LogFrequency").html(result.Freq);
|
||||
$("#LoggerTime").html(result.timeLog);
|
||||
$("#ServerTime").html(result.timeSrv);
|
||||
$("#ChanScaleMin1").html(result.ChScaleMin1);
|
||||
$("#ChanScaleMax1").html(result.ChScaleMax1);
|
||||
$("#ChanRealMin1").html(result.ChRealMin1);
|
||||
$("#ChanRealMax1").html(result.ChRealMax1);
|
||||
$("#ChanScaleMin").html(result.ChScaleMin);
|
||||
$("#ChanScaleMax").html(result.ChScaleMax);
|
||||
$("#ChanRealMin").html(result.ChRealMin);
|
||||
$("#ChanRealMax").html(result.ChRealMax);
|
||||
}});
|
||||
|
||||
timeout = setTimeout(dataRefresh, intTime);
|
||||
@@ -70,10 +79,35 @@
|
||||
$('#NewSessionName').val(name);
|
||||
}
|
||||
</script>
|
||||
<div class="container-fluid py-2">
|
||||
<div class="card mb-4">
|
||||
<div class="container-fluid py-2 text-center">
|
||||
<div class="row">
|
||||
<div class="card mb-4 col-6">
|
||||
<div class="card-header">
|
||||
Channel 1
|
||||
</div>
|
||||
<div class="card-body">
|
||||
Original: <span id="Chan0"></span>
|
||||
<br>
|
||||
<strong>Scaled: <span id="Output0"></span>
|
||||
</strong>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card mb-4 col-6">
|
||||
<div class="card-header">
|
||||
Channel 2
|
||||
</div>
|
||||
<div class="card-body">
|
||||
Original: <span id="Chan1"></span>
|
||||
<br>
|
||||
<strong>Scaled: <span id="Output1"></span>
|
||||
</strong>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- <div class="card mb-4">
|
||||
<div class="card-header">
|
||||
<i class="fas fa-table mr-1"></i>
|
||||
Channels Reading
|
||||
</div>
|
||||
<div class="card-body">
|
||||
@@ -106,11 +140,11 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div> -->
|
||||
|
||||
<div class="alert alert-info text-center">
|
||||
<i class="fas fa-table mr-1"></i>
|
||||
<strong>Logger Time: </strong> <span id="LoggerTime"></span>
|
||||
<i class="fas fa-table mr-1"></i>
|
||||
<br>
|
||||
<strong>Log frequency</strong> (edit in <a href="/settings">Settings</a>): <span id="LogFrequency"></span> (ms)
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user