diff --git a/client/panduza/interfaces/platform.py b/client/panduza/interfaces/platform.py index 5314239..21a022b 100644 --- a/client/panduza/interfaces/platform.py +++ b/client/panduza/interfaces/platform.py @@ -35,6 +35,18 @@ def __post_init__(self): RwField( name_ = "content" ) ) + # === CONFIG === + self.add_attribute( + Attribute( name_ = "device" ) + ).add_field( + RwField( name_ = "hunting" ) + ).add_field( + RwField( name_ = "max" ) + ).add_field( + RwField( name_ = "hunted" ) + ).add_field( + RwField( name_ = "store" ) + ) if self.ensure: self.ensure_init() diff --git a/platform/panduza_platform/core/platform.py b/platform/panduza_platform/core/platform.py index 48afcc4..ef8766a 100644 --- a/platform/panduza_platform/core/platform.py +++ b/platform/panduza_platform/core/platform.py @@ -391,8 +391,11 @@ async def __load_tree_task(self): # Load config await self.load_config_content_task(new_dtree) + # --- + + # --- diff --git a/platform/panduza_platform/devices/panduza/fake_bps/dev_fake_bps.py b/platform/panduza_platform/devices/panduza/fake_bps/dev_fake_bps.py index 4147ff0..d88c5f9 100644 --- a/platform/panduza_platform/devices/panduza/fake_bps/dev_fake_bps.py +++ b/platform/panduza_platform/devices/panduza/fake_bps/dev_fake_bps.py @@ -28,7 +28,9 @@ async def _PZA_DEV_mount_interfaces(self): for chan in range(0, number_of_channel): - self.mount_interface(InterfacePanduzaFakeBpc(name=f":channel_{chan}:_ctrl")) + self.mount_interface( + InterfacePanduzaFakeBpc(name=f":channel_{chan}:_ctrl") + ) am = InterfacePanduzaFakeAmmeter(name=f":channel_{chan}:_am") self.mount_interface(am) diff --git a/platform/panduza_platform/devices/panduza/server/itf_platform.py b/platform/panduza_platform/devices/panduza/server/itf_platform.py index 21e8961..6fd84c8 100644 --- a/platform/panduza_platform/devices/panduza/server/itf_platform.py +++ b/platform/panduza_platform/devices/panduza/server/itf_platform.py @@ -25,15 +25,10 @@ async def _PZA_DRV_loop_init(self): """From PlatformDriver """ - # Set command handlers self.__cmd_handlers = { "dtree": self.__handle_cmds_set_dtree, - - - # "voltage": self.__handle_cmds_set_voltage, - # "current": self.__handle_cmds_set_current, - # "settings": self.__handle_cmds_set_settings, + "device": self.__handle_cmds_set_device, } # Append a task to refresh platform data @@ -84,7 +79,16 @@ async def __refresh_platform_data_task(self): } }) - + await self._update_attributes_from_dict({ + "device": { + "hunting": False, + "max": 0, + "hunted": 0, + "store": [], + } + }) + + # --- async def __handle_cmds_set_dtree(self, cmd_att): @@ -117,3 +121,39 @@ async def __set_config_content(self, value): async def __get_config_content(self): return self.platform.dtree + # --- + + async def __handle_cmds_set_device(self, cmd_att): + """ + """ + update_obj = {} + self.log.info(cmd_att) + + await self._prepare_update(update_obj, + "device", cmd_att, + "hunting", [bool] + , self.__set_device_hunting + , self.__get_device_hunting) + + # await self._prepare_update(update_obj, + # "enable", cmd_att, + # "polling_cycle", [float, int] + # , self.__set_poll_cycle_enable + # , self.__get_poll_cycle_enable) + + await self._update_attributes_from_dict(update_obj) + + # --- + + async def __set_device_hunting(self, value): + self.log.info(value) + # await self.platform.load_config_content_task(value) + pass + + # --- + + async def __get_device_hunting(self): + return self.platform.dtree + + # --- +