bottoni ok
This commit is contained in:
+15
-6
@@ -42,8 +42,8 @@ try:
|
||||
|
||||
#funzione salva time+data e otto valori letti su redis
|
||||
def redisSave(CHvalue):
|
||||
redTime = 'RTDATA:CH:TIME'
|
||||
redSrv0.set(redTime,str(now))
|
||||
redLastTime = 'RTDATA:CH:RECTIME'
|
||||
redSrv0.set(redLastTime,str(now))
|
||||
for CHcount in range(0,8,+1):
|
||||
redArea = 'RTDATA:CH:'+str(CHcount)
|
||||
strVal = "%lf" % (CHvalue[CHcount]*5.0/0x7fffff)
|
||||
@@ -51,11 +51,20 @@ try:
|
||||
|
||||
#ciclo principale, chiama le tre funzioni definite sopra
|
||||
while(1):
|
||||
redTime = 'RTDATA:CH:TIME'
|
||||
now = datetime.datetime.now()
|
||||
CHvalue = CH.ADS1256_GetAll()
|
||||
#videoPrint(CHvalue)
|
||||
#fileSave(CHvalue)
|
||||
redisSave(CHvalue)
|
||||
redSrv0.set(redTime,str(now))
|
||||
|
||||
# solo se su redis LOG è attivo...
|
||||
logStatus = redSrv0.get('RTDATA:LOG:STATUS').decode('utf-8')
|
||||
#print(logStatus)
|
||||
if logStatus == "1" :
|
||||
CHvalue = CH.ADS1256_GetAll()
|
||||
redisSave(CHvalue)
|
||||
#videoPrint(CHvalue)
|
||||
#fileSave(CHvalue)
|
||||
|
||||
|
||||
time.sleep(sampleTime/1000)
|
||||
|
||||
#eccezione da ctrl+c in terminale e chiusura
|
||||
|
||||
+7
-1
@@ -16,4 +16,10 @@ 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
|
||||
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
|
||||
@@ -69,16 +69,18 @@ def api_channels_all():
|
||||
|
||||
|
||||
# Route di comando x LOG
|
||||
@flaskApp.route("/api/v1/log/start", methods=['POST'])
|
||||
@flaskApp.route("/api/v1/log/start", methods=['PUT'])
|
||||
def start_log():
|
||||
#funzione start_log: scrive su redis
|
||||
#funzione start_log: scrive su redis LOG:STATUS -> 1
|
||||
redSrv0.set('RTDATA:LOG:STATUS', 1)
|
||||
return "OK"
|
||||
|
||||
|
||||
@flaskApp.route("/api/v1/log/stop", methods=['POST'])
|
||||
@flaskApp.route("/api/v1/log/stop", methods=['PUT'])
|
||||
def stop_log():
|
||||
#funzione start_log: scrive su redis
|
||||
#funzione stop_log: scrive su redis LOG:STATUS -> 0
|
||||
redSrv0.set('RTDATA:LOG:STATUS', 0)
|
||||
return "OK"
|
||||
|
||||
|
||||
#dichiaro host ipv4 (ottenuto sopra utilizzando il modulo socket)
|
||||
|
||||
@@ -29,16 +29,30 @@
|
||||
$("#Chan7").html(result.Ch7);
|
||||
$("#ServerTime").html(result.timeNow);
|
||||
$("#LoggerTime").html(result.timeLog);
|
||||
console.log(result);
|
||||
//console.log(result);
|
||||
}});
|
||||
timeout = setTimeout(dataRefresh, 200);
|
||||
}
|
||||
function startLog(){
|
||||
|
||||
$.ajax({
|
||||
type: 'PUT'
|
||||
,url: "/api/v1/log/start"
|
||||
,data: ""
|
||||
,success: function(){
|
||||
alert('Log Started');
|
||||
}
|
||||
})
|
||||
};
|
||||
|
||||
function stopLog(){
|
||||
|
||||
$.ajax({
|
||||
type: 'PUT'
|
||||
,url: "/api/v1/log/stop"
|
||||
,data: ""
|
||||
,success: function(){
|
||||
alert('Log Stopped');
|
||||
}
|
||||
})
|
||||
};
|
||||
|
||||
</script>
|
||||
@@ -64,17 +78,17 @@
|
||||
<div class="container-fluid py-2">
|
||||
<div class="row">
|
||||
<div class="col-xl-6">
|
||||
<div class="card-header">
|
||||
<i class="fas fa-chart-area mr-1"></i>
|
||||
Server time
|
||||
</div>
|
||||
<div class="card-header">
|
||||
<i class="fas fa-chart-area mr-1"></i>
|
||||
Server time
|
||||
</div>
|
||||
<p id="timeNow"><span id="ServerTime"></span></p>
|
||||
</div>
|
||||
<div class="col-xl-6">
|
||||
<div class="card-header">
|
||||
<i class="fas fa-chart-bar mr-1"></i>
|
||||
Last log time
|
||||
</div>
|
||||
<div class="card-header">
|
||||
<i class="fas fa-chart-bar mr-1"></i>
|
||||
Last log time
|
||||
</div>
|
||||
<p id="timeLog"><span id="LoggerTime"></span></p>
|
||||
</div>
|
||||
</div>
|
||||
@@ -116,6 +130,7 @@
|
||||
</div>
|
||||
<div class="card mb-4">
|
||||
<div class="card-header">
|
||||
<!--pulsanti start log e stop log-->
|
||||
<center>
|
||||
<button type="button" class="btn btn-success" onclick="startLog()">Start Log</button>
|
||||
<button type="button" class="btn btn-danger" onclick="stopLog()">Stop Log</button>
|
||||
@@ -128,6 +143,8 @@
|
||||
Record Log
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="row" id="divNewFile" visible="false">
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-2">check</div>
|
||||
<div class="col-2">Inizio</div>
|
||||
|
||||
Reference in New Issue
Block a user