diff --git a/pyhon/commands.py b/pyhon/commands.py index 1878f8a..6fad60a 100644 --- a/pyhon/commands.py +++ b/pyhon/commands.py @@ -2,12 +2,12 @@ from pyhon.parameter import HonParameterFixed, HonParameterEnum, HonParameterRan class HonCommand: - def __init__(self, name, attributes, connector, device, multi=None, category=""): + def __init__(self, name, attributes, connector, device, multi=None, program=""): self._connector = connector self._device = device self._name = name self._multi = multi or {} - self._category = category + self._program = program self._description = attributes.get("description", "") self._parameters = self._create_parameters(attributes.get("parameters", {})) self._ancillary_parameters = self._create_parameters(attributes.get("ancillaryParameters", {})) diff --git a/pyhon/device.py b/pyhon/device.py index 9157e0c..5e2b8c4 100644 --- a/pyhon/device.py +++ b/pyhon/device.py @@ -92,9 +92,10 @@ class HonDevice: commands[command] = HonCommand(command, attr, self._connector, self) elif "parameters" in attr[list(attr)[0]]: multi = {} - for category, attr2 in attr.items(): - cmd = HonCommand(command, attr2, self._connector, self, multi=multi, category=category) - multi[category] = cmd + for program, attr2 in attr.items(): + program = program.split(".")[-1].lower() + cmd = HonCommand(command, attr2, self._connector, self, multi=multi, program=program) + multi[program] = cmd commands[command] = cmd self._commands = commands diff --git a/pyhon/parameter.py b/pyhon/parameter.py index ca14b43..361d05d 100644 --- a/pyhon/parameter.py +++ b/pyhon/parameter.py @@ -93,7 +93,7 @@ class HonParameterEnum(HonParameter): @property def values(self): - return [str(value) for value in self._values] + return sorted([str(value) for value in self._values]) @property def value(self): @@ -111,7 +111,7 @@ class HonParameterProgram(HonParameterEnum): def __init__(self, key, command): super().__init__(key, {}) self._command = command - self._value = command._category + self._value = command._program self._values = command._multi self._typology = "enum"