From d048dc6541d1ed832d6f5a3b264c4213656f3202 Mon Sep 17 00:00:00 2001 From: Nico Melone Date: Sun, 5 Feb 2023 09:01:48 -0600 Subject: [PATCH] added runtimestats --- .DS_Store | Bin 18436 -> 18436 bytes advvfdipp/advvfdippv2/advvfdipp.py | 14 ++++++++++++-- advvfdipp/advvfdippv2/config.txt | 2 +- piflow/PiFlow.py | 10 +++++++++- piflow/config.txt | 2 +- 5 files changed, 23 insertions(+), 5 deletions(-) diff --git a/.DS_Store b/.DS_Store index c8ca8674d4beec07de0acd0a26f4bc3d86cc16b0..9d60b1da61592cebc3a0fd40508d55ee26f14f35 100644 GIT binary patch delta 20 ccmZpfz}PZ@al;!WM#jnKl*BeOD>JGB08eTLg8%>k delta 20 ccmZpfz}PZ@al;!WMuy4fl*BeOD>JGB08d~Bf&c&j diff --git a/advvfdipp/advvfdippv2/advvfdipp.py b/advvfdipp/advvfdippv2/advvfdipp.py index 4e88b7b..2a441ad 100644 --- a/advvfdipp/advvfdippv2/advvfdipp.py +++ b/advvfdipp/advvfdippv2/advvfdipp.py @@ -5,6 +5,7 @@ import json import os import time from random import randint +from datetime import datetime as dt # PERSISTENCE FILE import persistence PERSIST = persistence.load("extra_data.json") @@ -69,7 +70,7 @@ class start(threading.Thread, deviceBase): mqtt=mqtt, Nodes=Nodes) self.daemon = True - self.version = "16" + self.version = "17" self.finished = threading.Event() self.force_send = False self.public_ip_address = "" @@ -81,7 +82,8 @@ class start(threading.Thread, deviceBase): self.rts = RTS() self.rts.loadDataFromFile() self.rts.saveDataToFile() - + self.rts.manageTime() + self.today = dt.now().date() threading.Thread.start(self) # this is a required function for all drivers, its goal is to upload some piece of data @@ -154,6 +156,14 @@ class start(threading.Thread, deviceBase): #time.sleep(TAG_DATAERROR_SLEEPTIME) # sleep to allow Micro800 to handle ENET requests except Exception as e: log.info("Error: {}".format(e)) + try: + self.rts.manageTime() + if dt.now().date() != self.today: + self.sendtodbDev(1, "avgFrequency30Days", self.rts.calculateAverageHertzMultiDay(),0,'advvfdipp') + self.sendtodbDev(1, "percentRunTime30Days", self.rts.calculateRunPercentMultiDay(), 0,'advvfdipp') + self.today = dt.now().date() + except Exception as e: + log.error("Error: {}".format(e)) time.sleep(30) #sleep for 30 seconds after a full poll # print("advvfdipp driver still alive...") if self.force_send: diff --git a/advvfdipp/advvfdippv2/config.txt b/advvfdipp/advvfdippv2/config.txt index d4ba304..e45da15 100644 --- a/advvfdipp/advvfdippv2/config.txt +++ b/advvfdipp/advvfdippv2/config.txt @@ -9,7 +9,7 @@ "file5": "runtimeStats.py" }, "deviceName": "advvfdipp", - "releaseVersion": "16", + "releaseVersion": "17", "driverFileName": "advvfdipp.py", "driverId": "0100" } \ No newline at end of file diff --git a/piflow/PiFlow.py b/piflow/PiFlow.py index 2571748..8bf5291 100644 --- a/piflow/PiFlow.py +++ b/piflow/PiFlow.py @@ -103,7 +103,7 @@ class start(threading.Thread, deviceBase): mqtt=mqtt, Nodes=Nodes) self.daemon = True - self.version = "27" + self.version = "28" self.finished = threading.Event() self.force_send = False self.public_ip_address = "" @@ -204,8 +204,16 @@ class start(threading.Thread, deviceBase): self.sendtodbDev(1, chan.mesh_name, chan.value, 0, 'PiFlow') if chan.value > 0: self.sendtodbDev(1, "run_status", "Running", 0, 'PiFlow') + if not self.rts.runs[self.rts.todayString]["run_" + str(self.rts.currentRun)]["start"]: + self.rts.startRun() + self.rts.saveDataToFile() else: self.sendtodbDev(1,"run_status", "Stopped", 0, 'PiFlow') + if self.rts.runs[self.rts.todayString]["run_" + str(self.rts.currentRun)]["start"] and not self.rts.runs[self.rts.todayString]["run_" + str(self.rts.currentRun)]["end"]: + self.rts.endRun() + self.rts.saveDataToFile() + + self.sendtodbDev(1, "percentRunTime30Days", self.rts.calculateRunPercentMultiDay(), 0,'PiFlow') elif chan.mesh_name == "run_status": if "Operating" in val and not self.rts.runs[self.rts.todayString]["run_" + str(self.rts.currentRun)]["start"]: self.rts.startRun() diff --git a/piflow/config.txt b/piflow/config.txt index 470ddeb..3a5efaf 100644 --- a/piflow/config.txt +++ b/piflow/config.txt @@ -3,7 +3,7 @@ "driverFileName":"PiFlow.py", "deviceName":"piflow", "driverId":"0280", -"releaseVersion":"27", +"releaseVersion":"28", "files": { "file1":"PiFlow.py", "file2":"Channel.py",