-
Notifications
You must be signed in to change notification settings - Fork 9.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
5 changed files
with
98 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,30 @@ | ||
#!/usr/bin/env python | ||
|
||
#!/usr/bin/env python3 | ||
import sys | ||
import time | ||
from tools.zookeeper import Zookeeper | ||
|
||
# Usage: check_consumption.py <averaging_time_sec> <max_average_power_W> | ||
# Exit code: 0 -> passed | ||
# 1 -> failed | ||
from common.realtime import Ratekeeper | ||
from common.filter_simple import FirstOrderFilter | ||
from tools.zookeeper import Zookeeper | ||
|
||
if __name__ == "__main__": | ||
z = Zookeeper() | ||
z.set_device_power(True) | ||
z.set_device_ignition(False) | ||
|
||
duration = None | ||
if len(sys.argv) > 1: | ||
duration = int(sys.argv[1]) | ||
|
||
rate = 123 | ||
rk = Ratekeeper(rate, print_delay_threshold=None) | ||
fltr = FirstOrderFilter(0, 5, 1. / rate, initialized=False) | ||
|
||
try: | ||
start_time = time.monotonic() | ||
measurements = [] | ||
while duration is None or time.monotonic() - start_time < duration: | ||
p = z.read_power() | ||
print(round(p, 3), "W") | ||
measurements.append(p) | ||
time.sleep(0.25) | ||
fltr.update(z.read_power()) | ||
if rk.frame % rate == 0: | ||
print(f"{fltr.x:.2f} W") | ||
rk.keep_time() | ||
except KeyboardInterrupt: | ||
pass | ||
finally: | ||
average_power = sum(measurements)/len(measurements) | ||
print(f"Average power: {round(average_power, 4)}W") |
This file was deleted.
Oops, something went wrong.