Index: leahi_dialin/fp/filtration_purification.py =================================================================== diff -u -r79697500614904bafb56f3d33e368b954ba78f7d -r89bc63999a581c9bf99c68f20ad05b30b6dcf0cb --- leahi_dialin/fp/filtration_purification.py (.../filtration_purification.py) (revision 79697500614904bafb56f3d33e368b954ba78f7d) +++ leahi_dialin/fp/filtration_purification.py (.../filtration_purification.py) (revision 89bc63999a581c9bf99c68f20ad05b30b6dcf0cb) @@ -94,6 +94,7 @@ self._handler_fp_debug_event_sync) # create properties + self.fp_defeaturized = False self.fp_op_mode_timestamp = 0.0 self.fp_debug_events_timestamp = 0.0 self.fp_version_response_timestamp = 0.0 @@ -121,7 +122,7 @@ self.temperatures = FPTemperatureSensors(self.can_interface, self.logger) self.test_configs = FPTestConfig(self.can_interface, self.logger) self.valves = FPValves(self.can_interface, self.logger) - self.dd_proxy = DDProxy(self.can_interface, self.logger) + self.dd_proxy = DDProxy(self.can_interface, self.logger, fp = self) @publish(["msg_id_fp_debug_event", "fp_debug_events_timestamp","fp_debug_events"]) def _handler_fp_debug_event_sync(self, message, timestamp = 0.0): Index: leahi_dialin/fp/modules/temperatures.py =================================================================== diff -u -ra6c8026470fbbead9a90b727be257d3076397670 -r89bc63999a581c9bf99c68f20ad05b30b6dcf0cb --- leahi_dialin/fp/modules/temperatures.py (.../temperatures.py) (revision a6c8026470fbbead9a90b727be257d3076397670) +++ leahi_dialin/fp/modules/temperatures.py (.../temperatures.py) (revision 89bc63999a581c9bf99c68f20ad05b30b6dcf0cb) @@ -126,6 +126,7 @@ self.logger.debug("Timeout!!!!") return False + def cmd_temperatures_value_override(self, sensor_index: int, sensor_value: float, reset: int = NO_RESET) -> int: """ Constructs and sends the value override of a temperature sensor. @@ -182,4 +183,4 @@ return received_message['message'][DenaliMessage.PAYLOAD_START_INDEX] else: self.logger.debug("Timeout!!!!") - return False \ No newline at end of file + return False Index: leahi_dialin/fp/proxies/dd_proxy.py =================================================================== diff -u -r68422d08c4141999a13496343264483a32314d37 -r89bc63999a581c9bf99c68f20ad05b30b6dcf0cb --- leahi_dialin/fp/proxies/dd_proxy.py (.../dd_proxy.py) (revision 68422d08c4141999a13496343264483a32314d37) +++ leahi_dialin/fp/proxies/dd_proxy.py (.../dd_proxy.py) (revision 89bc63999a581c9bf99c68f20ad05b30b6dcf0cb) @@ -13,28 +13,30 @@ # @date (original) 02-Apr-2020 # ############################################################################ -import struct + from logging import Logger -from leahi_dialin.common.msg_defs import MsgIds, MsgFieldPositions +from leahi_dialin.common.msg_defs import MsgIds +from leahi_dialin.common.fp_defs import FPOpModes from leahi_dialin.protocols.CAN import DenaliMessage, DenaliCanMessenger, DenaliChannels -from leahi_dialin.utils.base import AbstractSubSystem, publish -from leahi_dialin.utils.conversions import integer_to_bytearray, byte_to_bytearray, float_to_bytearray +from leahi_dialin.utils.base import AbstractSubSystem +from leahi_dialin.utils.conversions import integer_to_bytearray, float_to_bytearray class DDProxy(AbstractSubSystem): """ Filtration Purification (FP) Dialin API sub-class for DD proxy ( injection ) related commands. """ - def __init__(self, can_interface: DenaliCanMessenger, logger: Logger): + def __init__(self, can_interface: DenaliCanMessenger, logger: Logger, fp): """ ROProxy constructor @param can_interface: the Denali CAN interface object """ super().__init__() + self._fp = fp self.can_interface = can_interface self.logger = logger @@ -60,3 +62,24 @@ self.logger.debug("Sending DD start stop request to FP.") self.can_interface.send(message, 0) + + def cmd_send_dd_mode_change_request(self, op_mode: int) -> int: + """ + Constructs and sends a set operation mode request command via internal CAN bus. + Constraints: + Must be logged into FP. + Transition from current to requested op mode must be legal. + NOTE: for POST the FP device shall be in Standby Mode + + @param op_mode: ID of operation mode to transition to + + @return: 1 if successful, zero otherwise + """ + + target_opmode = op_mode + if op_mode in [FPOpModes.MODE_PRE_GENP, FPOpModes.MODE_DPGP]: + target_opmode = FPOpModes.MODE_DPGP if self._fp.fp_defeaturized else FPOpModes.MODE_PRE_GENP + elif op_mode in [FPOpModes.MODE_GENP, FPOpModes.MODE_DEGP]: + target_opmode = FPOpModes.MODE_DEGP if self._fp.fp_defeaturized else FPOpModes.MODE_GENP + + return self._fp.cmd_fp_set_operation_mode(target_opmode)