Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
Rodriguez committed Nov 6, 2023
1 parent 127476c commit 6304141
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 8 deletions.
12 changes: 12 additions & 0 deletions client/panduza/interfaces/platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
3 changes: 3 additions & 0 deletions platform/panduza_platform/core/platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -391,8 +391,11 @@ async def __load_tree_task(self):
# Load config
await self.load_config_content_task(new_dtree)

# ---



# ---



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
54 changes: 47 additions & 7 deletions platform/panduza_platform/devices/panduza/server/itf_platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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

# ---

0 comments on commit 6304141

Please sign in to comment.