Skip to content

Commit

Permalink
Added on_property method to get_point and set_point. Replaced and ext…
Browse files Browse the repository at this point in the history
…ended broken functionality to get_priortity_array on get_point.
  • Loading branch information
davidraker authored and craig8 committed Jul 1, 2024
1 parent 84ca12b commit 94c9080
Showing 1 changed file with 17 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -108,16 +108,25 @@ def ping_target(self):
if not pinged:
self.schedule_ping()

def get_point(self, point_name, get_priority_array=False):
def get_point(self, point_name, on_property=None):
register = self.get_register_by_name(point_name)
property_name = "priorityArray" if get_priority_array else register.property
register_index = None if get_priority_array else register.index
result = self.vip.rpc.call(self.proxy_address, 'read_property',
self.target_address, register.object_type,
register.instance_number, property_name, register_index).get(timeout=self.timeout)
if on_property is None:
result = self.vip.rpc.call(self.proxy_address, 'read_property',
self.target_address, register.object_type,
register.instance_number, register.property, register.index).get(timeout=self.timeout)
else:
point_map = {}
point_map[register.point_name] = [register.object_type,
register.instance_number,
on_property,
register.index]
result = self.vip.rpc.call(self.proxy_address, 'read_properties',
self.target_address, point_map,
self.max_per_request, True).get(timeout=self.timeout)
result = list(result.values())[0]
return result

def set_point(self, point_name, value, priority=None):
def set_point(self, point_name, value, priority=None, on_property=None):
# TODO: support writing from an array.
register = self.get_register_by_name(point_name)
if register.read_only:
Expand All @@ -130,7 +139,7 @@ def set_point(self, point_name, value, priority=None):
args = [self.target_address, value,
register.object_type,
register.instance_number,
register.property,
on_property if on_property is not None else register.property,
priority if priority is not None else register.priority,
register.index]
result = self.vip.rpc.call(self.proxy_address, 'write_property', *args).get(timeout=self.timeout)
Expand Down

0 comments on commit 94c9080

Please sign in to comment.