From 7a8a95fde921e54d1482b76a1e3e99dc5d5bdcd2 Mon Sep 17 00:00:00 2001 From: Chadwick Boulay Date: Mon, 11 Mar 2024 13:38:29 -0400 Subject: [PATCH] Allow enable / disable sorting through _configure_channel_hoops --- pycbsdk/cbhw/device/nsp.py | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/pycbsdk/cbhw/device/nsp.py b/pycbsdk/cbhw/device/nsp.py index 3037890..525b661 100644 --- a/pycbsdk/cbhw/device/nsp.py +++ b/pycbsdk/cbhw/device/nsp.py @@ -536,10 +536,17 @@ def _configure_channel_hoops(self, chid: int, attr_value: dict): attr_value: a dictionary of dictionaries of dictionaries. The outer dictionary keys are the 1-based unit ids. The middle dictionary keys are the 1-based hoop ids. - The inner dictionary has fields 'time', 'min', and 'max'. - e.g. attr_value = {1: { - 1: {'time': 13, 'min': -975, 'max': -646}, - 2: {'time': 6, 'min': 108, 'max': 342} + The inner dictionary has mandatory fields 'time', 'min', and 'max' + and optional field 'enabled' (or 'valid' is accepted). + All values are assumed integers. + e.g. attr_value = { + 1: { + 1: {'time': 13, 'min': -975, 'max': -646, 'enabled': 1}, + 2: {'time': 6, 'min': 108, 'max': 342, 'enabled': 1} + }, + 2: { + ... + }, ... } This will set the first two hoops for unit-1. """ @@ -548,7 +555,10 @@ def _configure_channel_hoops(self, chid: int, attr_value: dict): for un_id, hoop_dicts in attr_value.items(): for hp_id, hp in hoop_dicts.items(): pkt.spkhoops[un_id-1][hp_id-1] = CBHoop( - valid=1, time=hp["time"], min=hp["min"], max=hp["max"] + valid=int(hp["enabled"] if "enabled" in hp else hp.get("valid", 1)), + time=int(hp["time"]), + min=int(hp["min"]), + max=int(hp["max"]) ) self._send_packet(pkt)