def __init__(self, name, description, units, stype, device, proxy, *formatted_params): self.basename = name self.device = device stype = Sensor.parse_type(stype) params = Sensor.parse_params(stype, formatted_params) Sensor.__init__(self, stype, device.name + '.' + name, description, units, params=params)
def add_sensors(self, sensor_infos): """Add fake sensors sensor_infos is a dict <sensor-name> : ( <description>, <unit>, <sensor-type>, <params>*) The sensor info is string-reprs of whatever they are, as they would be on the wire in a real KATCP connection. Values are passed to a katcp.Message object, so some automatic conversions are done, hence it is OK to pass numbers without stringifying them. """ # Check sensor validity. parse_type() and parse_params should raise if not OK for s_name, s_info in sensor_infos.items(): s_type = Sensor.parse_type(s_info[2]) s_params = Sensor.parse_params(s_type, s_info[3:]) self.fake_sensor_infos.update(sensor_infos) self._fic._interface_changed.set()