Index: leahi_dialin/td/modules/td_test_configs.py =================================================================== diff -u -r1f2bf6d939eb4033dbedb7d7005494cc12fccbc6 -r3f4937e339925dde0b95f08e49969f8983c5cba4 --- 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 3f4937e339925dde0b95f08e49969f8983c5cba4) @@ -18,8 +18,8 @@ from logging import Logger # Project imports -from leahi_dialin.common.constants import NO_RESET -from leahi_dialin.common.msg_defs import MsgIds, MsgFieldPositions +from leahi_dialin.common.constants import NO_RESET, MSG_HEADER_SIZE +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 @@ -48,19 +48,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 +75,30 @@ @param message: published TD test configurations message @return: None """ - print('test config response') payload = message['message'] - index = MsgFieldPositions.START_POS_FIELD_1 + index = MSG_HEADER_SIZE - for config in TDTestConfigOptions.__members__: - if 'NUM_OF_TEST_CONFIGS' not in config: - config_value, index = bytearray_to_integer(payload, index, False) + for config in TDTestConfigOptions: + if config != TDTestConfigOptions.NUM_OF_TEST_CONFIGS: + config_value, index = bytearray_to_integer(payload, index, False) # The return value is the incremented index self.td_test_configs[config] = config_value self.td_test_configs_response_timestamp = timestamp + +# ============================================================ Support ============================================================ + 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 + """ + 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