From 04402e72b636acd7cbc99a08e4b66aac66613f50 Mon Sep 17 00:00:00 2001 From: Alexander Zaft Date: Wed, 24 Jan 2024 14:55:33 +0100 Subject: [PATCH] mlz: Zapf fix unit handling and small errors Change-Id: Iaa5ed175582d8399cc0c69ba72c3ab8e6e51ecf6 Reviewed-on: https://forge.frm2.tum.de/review/c/secop/frappy/+/32920 Tested-by: Jenkins Automated Tests Tested-by: Enrico Faulhaber Reviewed-by: Enrico Faulhaber --- frappy_mlz/plc_zapf.py | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/frappy_mlz/plc_zapf.py b/frappy_mlz/plc_zapf.py index 4fb45d6..a05c2f6 100644 --- a/frappy_mlz/plc_zapf.py +++ b/frappy_mlz/plc_zapf.py @@ -99,6 +99,8 @@ class ZapfPinata(Pinata): 'min': max(devinfo.info['absmin'], -UNLIMITED), 'max': min(devinfo.info['absmax'], UNLIMITED), } + if devinfo.info['unit'] and devinfo.info['basetype'] == 'float': + config['value']['unit'] = devinfo.info['unit'] if devinfo.info['access'] == 'rw': config['target'] = { 'min': config['value']['min'], @@ -131,8 +133,6 @@ STATUS_MAP = { class PLCBase: status = Parameter(datatype=StatusType(Drivable, 'INITIALIZING', 'DISABLED', 'STARTING')) - status_code = Parameter('raw internal status code', - IntRange(0, 2**32-1)) plcio = Property('plc io device', ValueType()) plc_name = Property('plc io device', StringType(), export=True) _pinata = Attached(ZapfPinata) # TODO: make this automatic? @@ -159,9 +159,15 @@ class PLCBase: dataty = cls._map_datatype(info) if dataty is None: continue - param = Parameter(info['description'], - dataty, - readonly=readonly) + if info['basetype'] == 'float' and info['unit']: # TODO: better handling + param = Parameter(info['description'], + dataty, + unit=info['unit'], + readonly=readonly) + else: + param = Parameter(info['description'], + dataty, + readonly=readonly) def read_param(self, parameter=parameter): code, val = self.plcio.get_param_raw(parameter) @@ -223,7 +229,7 @@ class PLCBase: if not add_members: return cls new_name = '_' + cls.__name__ + '_' \ - + internalize_name("blub") + + internalize_name("extended") return type(new_name, (cls,), add_members) @classmethod @@ -254,10 +260,6 @@ class PLCBase: msg.append(self.plcio.decode_errid(err_id)) return status, ', '.join(msg) - def read_status_code(self): - state, reason, aux, _ = self.plcio.read_status() - return state << 28 | reason << 24 | aux - @Command() def stop(self): """Stop the operation of this module.