Index: leahi_dialin/td/modules/td_test_configs.py =================================================================== diff -u -r1f2bf6d939eb4033dbedb7d7005494cc12fccbc6 -rba415df9f8e76d6b0f21e8f69ba99346e42f7b09 --- leahi_dialin/td/modules/td_test_configs.py (.../td_test_configs.py) (revision 1f2bf6d939eb4033dbedb7d7005494cc12fccbc6) +++ leahi_dialin/td/modules/td_test_configs.py (.../td_test_configs.py) (revision ba415df9f8e76d6b0f21e8f69ba99346e42f7b09) @@ -19,13 +19,14 @@ # Project imports from leahi_dialin.common.constants import NO_RESET -from leahi_dialin.common.msg_defs import MsgIds, MsgFieldPositions +from leahi_dialin.common.generic_defs import DataTypes +from leahi_dialin.common.msg_ids import MsgIds from leahi_dialin.common.override_templates import cmd_generic_override from leahi_dialin.common.test_config_defs import TDTestConfigOptions from leahi_dialin.protocols.CAN import CanMessenger, CanChannels from leahi_dialin.utils.abstract_classes import AbstractSubSystem from leahi_dialin.utils.base import publish -from leahi_dialin.utils.conversions import integer_to_bytearray, bytearray_to_integer +from leahi_dialin.utils.conversions import integer_to_bytearray class TDTestConfig(AbstractSubSystem): @@ -48,19 +49,25 @@ function = self._handler_td_test_config_sync) self.td_test_configs_response_timestamp = 0.0 #: The timestamp of the latest message - self.td_test_configs = dict() #: The Test Config data in dictionary format + self.td_test_configs = {} - def cmd_get_test_config_status(self, config: int): - """ - Returns the status of a test config - @param config: (int) Test config to set - @return: the status of a test config +# ============================================================ Properties ============================================================ + @property + def td_test_configs(self) -> dict: """ - return self.td_test_configs[TDTestConfigOptions(config).name] + The current Test Configs data + """ + return self._test_configs + @td_test_configs.setter + def td_test_configs(self, value): + self._test_configs = value + + +# ============================================================ Handlers ============================================================ @publish(['msg_id_td_send_test_config', 'td_test_configs', 'td_test_configs_response_timestamp']) def _handler_td_test_config_sync(self, message, timestamp=0.0): """ @@ -69,17 +76,29 @@ @param message: published TD test configurations message @return: None """ - print('test config response') - payload = message['message'] - index = MsgFieldPositions.START_POS_FIELD_1 + msg_list = [] + for config in TDTestConfigOptions: + if config != TDTestConfigOptions.NUM_OF_TEST_CONFIGS: + msg_list.append(self.fp_test_configs, config, DataTypes.U08) - for config in TDTestConfigOptions.__members__: - if 'NUM_OF_TEST_CONFIGS' not in config: - config_value, index = bytearray_to_integer(payload, index, False) - self.td_test_configs[config] = config_value + self.process_into_vars(decoder_list = msg_list, message = message) self.td_test_configs_response_timestamp = timestamp + +# ============================================================ Support ============================================================ + def get_test_config_status(self, config: int): + """ + Returns the status of a test config + + @param config: (int) Test config to set + @return: the status of a test config + """ + return self.td_test_configs[TDTestConfigOptions(config).name] + + + +# ============================================================ Overrides and Requests ============================================================ def cmd_set_test_config(self, config: int, reset: int = NO_RESET): """ Constructs and sends the TD test config