diff --git a/logger/FTLogger.py b/logger/FTLogger.py index 83f3a0a..2e828ac 100644 --- a/logger/FTLogger.py +++ b/logger/FTLogger.py @@ -78,30 +78,4 @@ while(1): if(waitTime < 0.1): waitTime = 0.1 # attesa - time.sleep(waitTime) - -# #eccezione da ctrl+c in terminale e chiusura -# except KeyboardInterrupt: -# lastLog = datetime.datetime.now() -# print (str(lastLog)+" Program End. Ctrl+C from user\r\n") -# try: -# logFile = open(LOG_path+"PyLog.txt", "a") -# except FileNotFoundError: -# print("Creating new PyLog.txt") -# logFile = open(LOG_path+"PyLog.txt", "w+") -# logFile.write(str(lastLog)+" Program end. Ctrl+C from user\r\n") -# logFile.close() -# exit() - -# #eccezione da errore e chiusura -# except Exception as errorMessage: -# lastLog = datetime.datetime.now() -# print(str(lastLog)+" Caught error " + str(errorMessage)+"\r\n") -# try: -# logFile = open(LOG_path+"PyLog.txt", "a") -# except FileNotFoundError: -# print("Creating new PyLog.txt") -# logFile = open(LOG_path+"PyLog.txt", "w+") -# logFile.write(str(lastLog)+" Caught error: "+str(errorMessage)+"\r\n") -# logFile.close() -# exit() \ No newline at end of file + time.sleep(waitTime) \ No newline at end of file diff --git a/server/FTServer.py b/server/FTServer.py index fed540b..07fb6ba 100644 --- a/server/FTServer.py +++ b/server/FTServer.py @@ -73,9 +73,13 @@ def api_channels_all(): CH = [0,0,0,0,0,0,0,0] OUT = [0,0,0,0,0,0,0,0] + OUTMIN = [0,0,0,0,0,0,0,0] + OUTMAX = [0,0,0,0,0,0,0,0] for numCh in range(0,8,+1): CH[numCh] = getRedisVal('RTDATA:CH:'+str(numCh)) OUT[numCh] = getRedisVal('RTDATA:OUT:'+str(numCh)) + OUTMIN[numCh] = getRedisVal('SETTINGS:OUT:MIN:'+str(numCh)) + OUTMAX[numCh] = getRedisVal('SETTINGS:OUT:MAX:'+str(numCh)) channelsData = { 'timeSrv' : getRedisVal('RTDATA:TIME:SRV'), @@ -85,6 +89,8 @@ def api_channels_all(): 'Status' : getRedisVal('SETTINGS:LOG:STATUS'), 'Channels': CH, 'Outs': OUT, + 'Outmin': OUTMIN, + 'Outmax': OUTMAX, 'ChA' : getRedisVal('SETTINGS:CHANNEL:A'), 'ChB' : getRedisVal('SETTINGS:CHANNEL:B'), 'ChScaleMax' : getRedisVal('SETTINGS:IN:MAX:'+str(numCh)), @@ -179,9 +185,6 @@ def selectChannelB(numChB): @flaskApp.route("/api/v1/setup/selectChannel/", methods=['PUT']) def setChannel(numCh): print(numCh) - # request_data = request.get_json() - # # devo leggere il channel attualmente selezionato, x ora cablo a 0... - # numCh = request_data['channel'] redSrv0.set('SETTINGS:SELECTED_CH', numCh) return "OK" @@ -208,7 +211,7 @@ def setScale(): @flaskApp.route("/api/v1/setup/resetSettings", methods=['POST']) def resetSetup(): - #setto i campi di redis alla situazione di partenza + #resetto i campi di redis alla situazione di partenza redSrv0.set('SETTINGS:LOG:FREQ',250) redSrv0.set('SETTINGS:WRITE:FREQ',1000) redSrv0.set('SETTINGS:LOG:STATUS',0) diff --git a/server/templates/logger.html b/server/templates/logger.html index 307802d..88c2d31 100644 --- a/server/templates/logger.html +++ b/server/templates/logger.html @@ -13,42 +13,6 @@ $("#divNewFile").toggle(); }; - function setGaugeA(chVal0){ - // Create knob elements - const knob0 = pureknob.createKnob(200, 200); - // Set properties knob0 - knob0.setProperty('angleStart', -0.8 * Math.PI); - knob0.setProperty('angleEnd', 0.8 * Math.PI); - knob0.setProperty('colorFG', '#07adec'); - knob0.setProperty('trackWidth', 0.3); - knob0.setProperty('valMin', 0); - knob0.setProperty('valMax', 100); - // Set initial value0 - knob0.setValue(chVal0); - // Create element node0 - const node0 = knob0.node(); - // Add it to the DOM. - $("#divChA").html(node0); - } - - function setGaugeB(chVal1){ - // Create knob elements - const knob1 = pureknob.createKnob(200, 200); - // Set properties knob1 - knob1.setProperty('angleStart', -0.8 * Math.PI); - knob1.setProperty('angleEnd', 0.8 * Math.PI); - knob1.setProperty('colorFG', '#07adec'); - knob1.setProperty('trackWidth', 0.3); - knob1.setProperty('valMin', 0); - knob1.setProperty('valMax', 100); - // Set initial value1 - knob1.setValue(chVal1); - // Create element node1 - const node1 = knob1.node(); - // Add it to the DOM. - $("#divChB").html(node1); - } - function dataRefresh() { // scarico i dati aggioranti $.ajax({url: "/api/v1/channels/all", success: function(result){ @@ -56,12 +20,14 @@ $("#SelChannelA").html(result.ChA); $("#ChannelA").html(result.Channels[result.ChA]); $("#OutputA").html(result.Outs[result.ChA]); - setGaugeA(result.Outs[result.ChA]); + + setGaugeA(result.Outs[result.ChA],result.Outmin[result.ChA],result.Outmax[result.ChA]); $("#SelChannelB").html(result.ChB); $("#ChannelB").html(result.Channels[result.ChB]); $("#OutputB").html(result.Outs[result.ChB]); - setGaugeB(result.Outs[result.ChB]); + + setGaugeB(result.Outs[result.ChB],result.Outmin[result.ChB],result.Outmax[result.ChB]); $("#LogFrequency").html(result.LogFreq); $("#WriteFrequency").html(result.WriteFreq); @@ -73,6 +39,42 @@ timeout = setTimeout(dataRefresh, intTime); }; + function setGaugeA(chValA,outMinA,outMaxA){ + // Create knob elements + const knob0 = pureknob.createKnob(200, 200); + // Set properties knob0 + knob0.setProperty('angleStart', -0.8 * Math.PI); + knob0.setProperty('angleEnd', 0.8 * Math.PI); + knob0.setProperty('colorFG', '#07adec'); + knob0.setProperty('trackWidth', 0.3); + knob0.setProperty('valMin', parseInt(outMinA)); + knob0.setProperty('valMax', parseInt(outMaxA)); + // Set initial value0 + knob0.setValue(chValA); + // Create element node0 + const node0 = knob0.node(); + // Add it to the DOM. + $("#divChA").html(node0); + } + + function setGaugeB(chValB,outMinB,outMaxB){ + // Create knob elements + const knob1 = pureknob.createKnob(200, 200); + // Set properties knob1 + knob1.setProperty('angleStart', -0.8 * Math.PI); + knob1.setProperty('angleEnd', 0.8 * Math.PI); + knob1.setProperty('colorFG', '#07adec'); + knob1.setProperty('trackWidth', 0.3); + knob1.setProperty('valMin', parseInt(outMinB)); + knob1.setProperty('valMax', parseInt(outMaxB)); + // Set initial value1 + knob1.setValue(chValB); + // Create element node1 + const node1 = knob1.node(); + // Add it to the DOM. + $("#divChB").html(node1); + } + // Funzione startLog: chiamata /api/v1/log/start per avviare log e dare nome function startLog(){ $.ajax({