def addSensorAlert(self, nodeId: int, sensorId: int, state: int, dataJson: str, changeState: bool, hasLatestData: bool, dataType: int, sensorData: Any, logger: logging.Logger = None) -> bool: sensor_alert = SensorAlert() sensor_alert.nodeId = nodeId sensor_alert.sensorId = sensorId sensor_alert.state = state sensor_alert.changeState = changeState sensor_alert.hasLatestData = hasLatestData sensor_alert.dataType = dataType sensor_alert.sensorData = sensorData if dataJson == "": sensor_alert.hasOptionalData = False else: sensor_alert.hasOptionalData = True sensor_alert.optionalData = json.loads(dataJson) self._sensor_alerts.append(sensor_alert) return True
def add_sensor_alert(self, node_id: int, sensor_id: int, state: int, optional_data: Optional[Dict[str, Any]], change_state: bool, has_latest_data: bool, data_type: int, sensor_data: Any, logger: logging.Logger = None) -> bool: sensor_alert = SensorAlert() sensor_alert.nodeId = node_id sensor_alert.sensorId = sensor_id sensor_alert.state = state sensor_alert.changeState = change_state sensor_alert.hasLatestData = has_latest_data sensor_alert.dataType = data_type sensor_alert.sensorData = sensor_data sensor_alert.hasOptionalData = False sensor_alert.optionalData = optional_data if optional_data: sensor_alert.hasOptionalData = True self._sensor_alerts.append(sensor_alert) return True
def _create_instrumentation_dummy(self) -> Instrumentation: alert_level = AlertLevel() alert_level.level = 1 alert_level.name = "Instrumentation Alert Level" alert_level.triggerAlertTriggered = True alert_level.triggerAlertNormal = True alert_level.instrumentation_cmd = "dummy.py" alert_level.instrumentation_timeout = 10 sensor_alert = SensorAlert() sensor_alert.nodeId = 2 sensor_alert.sensorId = 3 sensor_alert.description = "Instrumentation Sensor Alert" sensor_alert.timeReceived = 1337 sensor_alert.alertDelay = 20 sensor_alert.state = 1 sensor_alert.hasOptionalData = True sensor_alert.optionalData = {"key1": "value1", "key2": "value2"} sensor_alert.changeState = False sensor_alert.alertLevels = [1] sensor_alert.triggeredAlertLevels = [1] sensor_alert.hasLatestData = False sensor_alert.dataType = SensorDataType.NONE sensor_alert.sensorData = None logger = logging.getLogger("Instrumentation Test Case") return Instrumentation(alert_level, sensor_alert, logger)