Skip to content

Commit

Permalink
Merge pull request #39 from H3c702/testingtool
Browse files Browse the repository at this point in the history
Testingtool
  • Loading branch information
DevTown authored Jan 23, 2023
2 parents 9d7131a + d4e9b12 commit d654b9b
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 3 deletions.
6 changes: 5 additions & 1 deletion Hector9000/HectorHardware.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,11 @@ def arm_isInOutPos(self):
log("arm_isInOutPos = False")
return pos

def scale_readout(self):
def scale_readout(self) -> object:
"""
:rtype: object
"""
weight = self.hx.get_weight(5)
return weight

Expand Down
78 changes: 78 additions & 0 deletions Hector9000/tools/hardwaretesttool.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# Nee to install pip install console-menu
from consolemenu import *
from consolemenu.format import *
from consolemenu.items import *

import time

#from Hector9000.conf import HectorConfig as config

from Hector9000.HectorHardware import HectorHardware as Hector
#from Hector9000.HectorSimulator import HectorSimulator as Hector


def Main():
menu_format = MenuFormatBuilder().set_border_style_type(MenuBorderStyleType.HEAVY_BORDER) \
.set_prompt("SELECT>") \
.set_title_align('center') \
.set_subtitle_align('center') \
.set_left_margin(4) \
.set_right_margin(4) \
.show_header_bottom_border(True)

menu = ConsoleMenu("Hector9000 - HardwareTestingTool", "Test the hardware of it´s function.", formatter=menu_format)
menu.clear_screen_before_render = False

menu.append_item(FunctionItem("Test Arm", testArm))
menu.append_item(FunctionItem("Test Pump", testPump))
menu.append_item(FunctionItem("Test Vents", testVent))
menu.append_item(FunctionItem("Test Scale", testScale()))
menu.show()


def testVent():
print("Test Vents:")
for vnum in range(12):
print("Open Valve:" + vnum + " for 1 sec")
Hector.valve_open(vnum)
time.sleep(1)
print("Close Valve:" + vnum)
Hector.valve_close(vnum)

print("Test End.")


def testScale():
print("Test Scale:")
print("Tare:")
Hector.scale_tare()
print("Add weight.")
print("Wait 10 sec.")
time.sleep(5)
print("Radout scale")
readout = Hector.scale_readout()
print(readout)


def testPump():
print("Test Pump:")
print("Start pump for 3 sec")
Hector.pump_start()
time.sleep(3)
print("Stop Pump.")
Hector.pump_stop()


def testArm():
print("Test Arm ")
print("Move Out")
Hector.arm_out()
print("Wait 5 sec")
time.sleep(5)
print("Arm Pos:" + Hector.arm_isInOutPos())
print("Move in")
Hector.arm_in()


if __name__ == "__main__":
Main()
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ Adafruit-PCA9685==1.0.1
Adafruit-PureIO==1.1.5
atomicwrites==1.3.0
adafruit-circuitpython-neopixel==6.0.0
console-menu==0.7.1
attrs==19.1.0
board==0.0.0.post0
certifi==2018.11.29
certifi==2022.12.7
chardet==3.0.4
docutils==0.14
idna==2.8
Expand Down
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@
'adafruit-circuitpython-neopixel==6.0.0',
'attrs==19.1.0',
'board==0.0.0.post0',
'certifi==2018.11.29',
'certifi==2022.12.7',
'console-menu==0.7.1',
'chardet==3.0.4',
'docutils==0.14',
'idna==2.8',
Expand Down

0 comments on commit d654b9b

Please sign in to comment.