Index: dialin/common/msg_ids.py =================================================================== diff -u -r0decd02e6202cacf8daf0cfc8a7fa6ac67da5ad7 -r68197254bdb86290c04a7cf222ae123970fd7cdb --- dialin/common/msg_ids.py (.../msg_ids.py) (revision 0decd02e6202cacf8daf0cfc8a7fa6ac67da5ad7) +++ dialin/common/msg_ids.py (.../msg_ids.py) (revision 68197254bdb86290c04a7cf222ae123970fd7cdb) @@ -384,6 +384,7 @@ MSG_ID_HD_RAM_STATUS_OVERRIDE = 0x8099 MSG_ID_HD_VALVES_STATES_PUBLISH_INTERVAL_OVERRIDE = 0x809A MSG_ID_HD_CAN_RECEIVE_ACK_MESSAGE_OVERRIDE = 0x809B + MSG_ID_HD_RECIRULATION_PCT_OVERRIDE = 0x809C MSG_ID_DG_TESTER_LOGIN_REQUEST = 0xA000 MSG_ID_DG_ALARM_STATE_OVERRIDE = 0xA001 Index: dialin/hd/reservoirs.py =================================================================== diff -u -r9bc00e997e91dab8b404aa877b02ae3d4100d417 -r68197254bdb86290c04a7cf222ae123970fd7cdb --- dialin/hd/reservoirs.py (.../reservoirs.py) (revision 9bc00e997e91dab8b404aa877b02ae3d4100d417) +++ dialin/hd/reservoirs.py (.../reservoirs.py) (revision 68197254bdb86290c04a7cf222ae123970fd7cdb) @@ -22,7 +22,7 @@ from ..common.msg_defs import MsgIds, MsgFieldPositions from ..protocols.CAN import DenaliMessage, DenaliChannels from ..utils.base import AbstractSubSystem, publish, DialinEnum -from ..utils.conversions import integer_to_bytearray +from ..utils.conversions import integer_to_bytearray, float_to_bytearray @unique @@ -90,10 +90,37 @@ message['message'][MsgFieldPositions.START_POS_FIELD_6:MsgFieldPositions.END_POS_FIELD_6]))[0] self.time_wait_to_fill = struct.unpack('i', bytearray( message['message'][MsgFieldPositions.START_POS_FIELD_7:MsgFieldPositions.END_POS_FIELD_7]))[0] - - self.temp_remove_fill_flow = struct.unpack('f', bytearray( message['message'][MsgFieldPositions.START_POS_FIELD_8:MsgFieldPositions.END_POS_FIELD_8]))[0] self.hd_reservoirs_timestamp = timestamp + def cmd_recirulation_pct_override(self, recirulation_pct: float) -> int: + """ + Constructs and sends a recirulation percentage override message to the HD. + Constraints: + Must be logged into HD. + + @return: 1 if successful, zero otherwise + """ + pct = float_to_bytearray(recirulation_pct) + payload = pct + + message = DenaliMessage.build_message(channel_id=DenaliChannels.dialin_to_hd_ch_id, + message_id=MsgIds.MSG_ID_HD_RECIRULATION_PCT_OVERRIDE.value, + payload=payload) + + self.logger.debug("Setting recirulation percentage.") + + # Send message + received_message = self.can_interface.send(message) + + # If there is content... + if received_message is not None: + self.logger.debug("Recirulation percentage set to to " + + str(received_message['message'][DenaliMessage.PAYLOAD_START_INDEX])) + # response payload is OK or not OK + return received_message['message'][DenaliMessage.PAYLOAD_START_INDEX] + else: + self.logger.debug("Timeout!!!!") + return False