Index: dialin/hd/air_bubbles.py =================================================================== diff -u -r77e28fd838640e057e7a79c624345b34fd8545f9 -r2edb623be1497fb2df4d2608b8e22c39de31fab1 --- dialin/hd/air_bubbles.py (.../air_bubbles.py) (revision 77e28fd838640e057e7a79c624345b34fd8545f9) +++ dialin/hd/air_bubbles.py (.../air_bubbles.py) (revision 2edb623be1497fb2df4d2608b8e22c39de31fab1) @@ -40,9 +40,8 @@ FLUID_DETECTED_STATUS = 1 # Fluid (no air bubble) detected # Air bubble detectors state machine states - AIR_BUBBLE_INIT_STATE = 0 # Initial state + AIR_BUBBLE_NORMAL_STATE = 0 # Normal state AIR_BUBBLE_SELF_TEST_STATE = 1 # Self-test state - AIR_BUBBLE_NORMAL_STATE = 2 # Normal state def __init__(self, can_interface, logger: Logger): """ @@ -62,8 +61,8 @@ # Initialize status of ADA and ADV air bubble detectors to fluid (no air bubble) detected self.air_bubbles_status = [self.FLUID_DETECTED_STATUS, self.FLUID_DETECTED_STATUS] - # Initialize state of ADA and ADV air bubble detectors state machine to init - self.air_bubbles_state = [self.AIR_BUBBLE_INIT_STATE, self.AIR_BUBBLE_INIT_STATE] + # Initialize state of ADA and ADV air bubble detectors state machine to normal + self.air_bubbles_state = [self.AIR_BUBBLE_NORMAL_STATE, self.AIR_BUBBLE_NORMAL_STATE] def get_air_bubble_status(self, index: int) -> int: """ @@ -158,12 +157,13 @@ payload = integer_to_bytearray(index) message = DenaliMessage.build_message(channel_id=DenaliChannels.dialin_to_hd_ch_id, - message_id=MsgIds.MSG_ID_HD_BUBBLES_SELF_TEST_REQUEST.value, + message_id=MsgIds.MSG_ID_HD_BUBBLE_SELF_TEST_REQUEST.value, payload=payload) if index == self.ADA: self.logger.debug("Request air bubble self-test for detector ADA") elif index == self.ADV: + print("Self-testing ADV") self.logger.debug("Request air bubble self-test for detector ADV") # Send message @@ -198,7 +198,7 @@ message_id=MsgIds.MSG_ID_HD_BUBBLES_DATA_SEND_INTERVAL_OVERRIDE.value, payload=payload) - self.logger.debug("Override HD air bubbles data broadcast interval to"+ms+"ms") + self.logger.debug("Override HD air bubbles data broadcast interval to"+str(ms)+"ms") # Send message received_message = self.can_interface.send(message) Index: tests/hd_air_bubbles_data.py =================================================================== diff -u -r801527f052cc3ca768d768401164c0072892442d -r2edb623be1497fb2df4d2608b8e22c39de31fab1 --- tests/hd_air_bubbles_data.py (.../hd_air_bubbles_data.py) (revision 801527f052cc3ca768d768401164c0072892442d) +++ tests/hd_air_bubbles_data.py (.../hd_air_bubbles_data.py) (revision 2edb623be1497fb2df4d2608b8e22c39de31fab1) @@ -30,18 +30,46 @@ hd.cmd_log_in_to_hd() sleep(1) - #hd.air_bubbles.cmd_air_bubbles_data_broadcast_interval_override(100) + hd.air_bubbles.cmd_air_bubbles_data_broadcast_interval_override(100) + sleep(1) + i = 0 + while i < 5: + if hd.air_bubbles.air_bubbles_status[0] == hd.air_bubbles.FLUID_DETECTED_STATUS: + ADAStatus = "ADA fluid detected" + elif hd.air_bubbles.air_bubbles_status[0] == hd.air_bubbles.BUBBLE_DETECTED_STATUS: + ADAStatus = "ADA bubble detected" + if hd.air_bubbles.air_bubbles_status[1] == hd.air_bubbles.FLUID_DETECTED_STATUS: + ADVStatus = "ADV fluid detected" + elif hd.air_bubbles.air_bubbles_status[1] == hd.air_bubbles.BUBBLE_DETECTED_STATUS: + ADVStatus = "ADV bubble detected" + print("ADA Status = " + ADAStatus, " ADA State = " + str(hd.air_bubbles.air_bubbles_state[0]) + + " ADV Status = " + ADVStatus, " ADV State = " + str(hd.air_bubbles.air_bubbles_state[1])) + sleep(1) + i += 1 + # Self-test state #hd.air_bubbles.cmd_air_bubble_self_test_request(ADA) #sleep(0.1) - #hd.air_bubbles.cmd_air_bubble_self_test_request(ADV) - #sleep(0.1) + hd.air_bubbles.cmd_air_bubble_status_override( 1, 1) + sleep(0.1) + hd.air_bubbles.cmd_air_bubble_self_test_request(ADV) + counter = 0 + while True: - if hd.air_bubbles.air_bubbles_status == hd.air_bubbles.FLUID_DETECTED_STATUS: - status = "Fluid" - else: # BUBBLE_DETECTED - status = "Bubble" - print("Status = " + status, " State = " + str(hd.air_bubbles.air_bubbles_state)) + if ( counter == 50 ): + hd.air_bubbles.cmd_air_bubble_status_override( 1, 1, 1) + + if hd.air_bubbles.air_bubbles_status[0] == hd.air_bubbles.FLUID_DETECTED_STATUS: + ADAStatus = "ADA fluid detected" + elif hd.air_bubbles.air_bubbles_status[0] == hd.air_bubbles.BUBBLE_DETECTED_STATUS: + ADAStatus = "ADA bubble detected" + if hd.air_bubbles.air_bubbles_status[1] == hd.air_bubbles.FLUID_DETECTED_STATUS: + ADVStatus = "ADV fluid detected" + elif hd.air_bubbles.air_bubbles_status[1] == hd.air_bubbles.BUBBLE_DETECTED_STATUS: + ADVStatus = "ADV bubble detected" + print("ADA Status = " + ADAStatus, " ADA State = " + str(hd.air_bubbles.air_bubbles_state[0]) + + " ADV Status = " + ADVStatus, " ADV State = " + str(hd.air_bubbles.air_bubbles_state[1])) sleep(0.1) + counter += 1