close power meter gracefully

This commit is contained in:
Kevin Hester
2024-06-25 12:22:47 -07:00
parent d448ea5767
commit d1aadf0c8e
3 changed files with 9 additions and 0 deletions

View File

@@ -20,6 +20,9 @@ class PowerMeter:
self.prevPowerTime = datetime.now()
self.prevWattHour = self._getRawWattHour()
def close(self) -> None:
"""Close the power meter."""
def getAverageWatts(self) -> float:
"""Get watts consumed since last call to this method."""
now = datetime.now()

View File

@@ -37,6 +37,11 @@ class PPK2PowerSupply(PowerSupply):
super().__init__() # we call this late so that the port is already open and _getRawWattHour callback works
def close(self) -> None:
"""Close the power meter."""
self.r.stop_measuring()
super().close()
def setIsSupply(self, s: bool):
"""If in supply mode we will provide power ourself, otherwise we are just an amp meter."""
if (