Index: dialin/dg/concentrate_pumps.py =================================================================== diff -u -rd531ce09d0240e0ae542ea33cf8ebe4b8169825b -rab4ad43e62b63fb9594ec7100dddc3a08785539c --- dialin/dg/concentrate_pumps.py (.../concentrate_pumps.py) (revision d531ce09d0240e0ae542ea33cf8ebe4b8169825b) +++ dialin/dg/concentrate_pumps.py (.../concentrate_pumps.py) (revision ab4ad43e62b63fb9594ec7100dddc3a08785539c) @@ -20,8 +20,16 @@ from ..utils.base import _AbstractSubSystem, _publish from ..common.msg_defs import MsgIds from logging import Logger +import enum +class ConcentratePumpsEnum(enum.Enum): + CP1 = 0 + CP2 = 1 + @classmethod + def has_value(cls, value): + return value in cls._value2member_map_ + class ConcentratePumps(_AbstractSubSystem): """ ConcentratePumps @@ -89,32 +97,28 @@ self.concentrate_pump_cp2_target = cp2_target[0] self.concentrate_pump_cp2 = cp2[0] - def cmd_concentrate_pump_on_request(self): - payload = integer_to_bytearray(1) - message = DenaliMessage.build_message(channel_id=DenaliChannels.dialin_to_dg_ch_id, - message_id=MsgIds.MSG_ID_CONCENTRATE_PUMP_STATE_CHANGE_REQUEST.value, - payload=payload) - # Send message - received_message = self.can_interface.send(message) - self.logger.debug("Requested to turn concentrate pumps on!") + def cmd_concentrate_pump_state_change_request(self, pump_id, on=False): + """ + Constructs and sends the concentrate pump state change request command - # If there is content... - if received_message is not None: - # response payload is OK or not OK - return received_message['message'][DenaliMessage.PAYLOAD_START_INDEX] - else: - self.logger.error("Timeout!!!!") - return False + @param pump_id: unsigned int - concentrate pump ID + @param on: bool - 1 to turn on, 0 to turn off + @return: 1 if successful, zero otherwise - - def cmd_concentrate_pump_off_request(self): - payload = integer_to_bytearray(0) + Concentrate pump IDs: \n + 0 = CP1 \n + 1 = CP2 \n + """ + payload = integer_to_bytearray(0) + integer_to_bytearray(on) + integer_to_bytearray(pump_id) message = DenaliMessage.build_message(channel_id=DenaliChannels.dialin_to_dg_ch_id, message_id=MsgIds.MSG_ID_CONCENTRATE_PUMP_STATE_CHANGE_REQUEST.value, payload=payload) # Send message received_message = self.can_interface.send(message) - self.logger.debug("Requested to turn concentrate pumps off") + if on: + self.logger.debug("Requested to turn on concentrate pump: CP" + str(pump_id)) + else: + self.logger.debug("Requested to turn off concentrate pump: CP" + str(pump_id)) # If there is content... if received_message is not None: