generated from HyperloopUPV-H8/template-project
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
82 additions
and
43 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
Submodule JSON_ADE
updated
from d25514 to 474ff3
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,96 +1,119 @@ | ||
import enum | ||
import sys, os | ||
|
||
from Tests import PCU | ||
from PCU import PCU | ||
from runner import runner | ||
from vmcu.assertions import * | ||
|
||
sys.path.append(os.path.join(os.path.dirname(__file__), "VirtualMCU", "src")) | ||
|
||
|
||
@runner.test() | ||
def PCU_test(): | ||
pcu = PCU() | ||
|
||
check(pcu.is_state(PCU.StateMachine.GENERAL, PCU.General_SM.CONNECTING)) | ||
check( | ||
pcu.is_state, | ||
args=(PCU.StateMachine.GENERAL, PCU.General_SM.CONNECTING), | ||
msg="PCU should be in CONNECTNG state!", | ||
) | ||
|
||
# Now PCU is on Connecting state | ||
|
||
pcu.connect_gui() | ||
completes( | ||
wait_until_true( | ||
pcu.is_state(PCU.StateMachine.GENERAL, PCU.General_SM.OPERATIONAL) | ||
), | ||
wait_until_true(pcu.is_state), | ||
args=(PCU.StateMachine.GENERAL, PCU.General_SM.OPERATIONAL), | ||
before=seconds(1), | ||
msg="PCU should be in OPERATIONAL state!", | ||
) | ||
|
||
# Now PCU is on Operational state | ||
|
||
check(pcu.is_state(PCU.StateMachine.OPERATIONAL, PCU.Operational_SM.IDLE)) | ||
check( | ||
pcu.is_state, | ||
args=(PCU.StateMachine.OPERATIONAL, PCU.Operational_SM.IDLE), | ||
msg="PCU should be in OPERATIONAL-IDLE state!", | ||
) | ||
|
||
# Now PCU is on Operational - Idle state | ||
|
||
enable_order = pcu.packets.serialize_packet(500) | ||
pcu.transmit(enable_order) | ||
|
||
completes( | ||
wait_until_true(pcu.get_enable()), | ||
wait_until_true(pcu.get_enable), | ||
before=seconds(1), | ||
msg="PCU enable should be enabled", | ||
) | ||
|
||
disable_order = pcu.packets.serialize_packet(501) | ||
pcu.transmit(disable_order) | ||
|
||
completes( | ||
wait_until_true(not pcu.get_enable()), | ||
wait_until_true(lambda: not pcu.get_enable()), | ||
before=seconds(1), | ||
msg="PCU enable should be disabled", | ||
) | ||
|
||
send_pwm_U_order = pcu.packets.serialize_packet(502, "U", 1000, 90) | ||
pcu.transmit(send_pwm_U_order) | ||
|
||
completes( | ||
wait_until_true(pcu.check_pwm(PCU.PWM.U, 1000, 90)), | ||
wait_until_true(pcu.check_pwm), | ||
before=seconds(1), | ||
args=(PCU.PWM.U, 1000, 90), | ||
msg="PWM U is not at 1KHz and 90%% duty", | ||
) | ||
|
||
check(pcu.is_state(PCU.StateMachine.OPERATIONAL, PCU.Operational_SM.PWM)) | ||
check( | ||
pcu.is_state, | ||
args=(PCU.StateMachine.OPERATIONAL, PCU.Operational_SM.PWM), | ||
msg="PCU should be in OPERATIONAL-PWM state!", | ||
) | ||
|
||
# Now PCU is on Operational - PWM state | ||
|
||
send_pwm_V_order = pcu.packets.serialize_packet(502, "V", 2000, 80) | ||
pcu.transmit(send_pwm_V_order) | ||
|
||
completes( | ||
wait_until_true(pcu.check_pwm(PCU.PWM.V, 2000, 80)), | ||
wait_until_true(pcu.check_pwm), | ||
args=(PCU.PWM.V, 2000, 80), | ||
before=seconds(1), | ||
msg="PWM V is not at 2KHz and 80%% duty", | ||
) | ||
|
||
send_pwm_W_order = pcu.packets.serialize_packet(502, "W", 3000, 70) | ||
pcu.transmit(send_pwm_W_order) | ||
|
||
completes( | ||
wait_until_true(pcu.check_pwm(PCU.PWM.W, 3000, 70)), | ||
wait_until_true(pcu.check_pwm), | ||
args=(PCU.PWM.W, 3000, 70), | ||
before=seconds(1), | ||
msg="PWM W is not at 3KHz and 70%% duty", | ||
) | ||
|
||
stop_pwm_order = pcu.packets.serialize_packet(504) | ||
stop_pwm_order = pcu.packets.serialize_packet(503) | ||
pcu.transmit(stop_pwm_order) | ||
|
||
check(pcu.is_state(PCU.StateMachine.OPERATIONAL, PCU.Operational_SM.IDLE)) | ||
check( | ||
pcu.is_state, | ||
args=(PCU.StateMachine.OPERATIONAL, PCU.Operational_SM.IDLE), | ||
msg="PCU should be in OPERATIONAL-IDLE state!", | ||
) | ||
|
||
# TODO check pwms are powered off | ||
|
||
# Now PCU is on Operational - Idle state | ||
|
||
pcu.disconnect_gui() | ||
|
||
check(pcu.is_state(PCU.StateMachine.GENERAL, PCU.General_SM.FAULT)) | ||
check( | ||
pcu.is_state, | ||
args=(PCU.StateMachine.GENERAL, PCU.General_SM.FAULT), | ||
msg="PCU should be in FAULT state!", | ||
) | ||
|
||
# Now PCU is on FAULT state | ||
|
||
check(not pcu.get_enable()) | ||
# TODO check PWMs are off | ||
check(lambda: not pcu.get_enable(), msg="PCU enable should be disabled") | ||
# # TODO check PWMs are off | ||
|
||
|
||
runner.run() # Runs the tests, do not delete! |