private void CreateInputsOutputs(Node node) { foreach (var sensor in node.sensors) { AddInputOutput(sensor); } }
public LogicalHardwareNode(Node node) : base(0, 0) { this.nodeId = node.nodeId; this.Title = node.GetSimpleName1(); this.gateway = LogicalHardwareNodesEngine.gateway; this.Type = "Nodes/HardwareNode"; CreateInputsOutputs(node); }
private static void OnNewNodeEvent(Node node) { hub.Clients.All.OnNewNodeEvent(node); }
private static void OnNodeUpdatedEvent(Node node) { hub.Clients.All.OnNodeUpdatedEvent(node); }
public bool UpdateNodeSettings(Node node) { gateway.UpdateNodeSettings(node); return true; }
public void UpdateNodeSettings(Node node) { Node oldNode = GetNode(node.nodeId); oldNode.name = node.name; foreach (var sensor in node.sensors) { Sensor oldSensor = oldNode.GetSensor(sensor.sensorId); oldSensor.description = sensor.description; oldSensor.storeHistoryEnabled = sensor.storeHistoryEnabled; oldSensor.storeHistoryEveryChange = sensor.storeHistoryEveryChange; oldSensor.storeHistoryWithInterval = sensor.storeHistoryWithInterval; oldSensor.invertData = sensor.invertData; oldSensor.remapEnabled = sensor.remapEnabled; oldSensor.remapFromMin = sensor.remapFromMin; oldSensor.remapFromMax = sensor.remapFromMax; oldSensor.remapToMin = sensor.remapToMin; oldSensor.remapToMax = sensor.remapToMax; } }
public void AddNode(Node node) { nodes.Add(node); }
private void UpdateNodeFromMessage(Message mes) { Node node = GetNode(mes.nodeId); if (node == null) { node = new Node(mes.nodeId); nodes.Add(node); if (OnNewNodeEvent != null) OnNewNodeEvent(node); DebugGatewayState($"New node (id: {node.nodeId}) registered"); } node.UpdateLastSeenNow(); if (OnNodeLastSeenUpdatedEvent != null) OnNodeLastSeenUpdatedEvent(node); if (mes.sensorId == 255) { if (mes.messageType == MessageType.C_PRESENTATION) { if (mes.subType == (int)SensorType.S_ARDUINO_NODE) { node.isRepeatingNode = false; } else if (mes.subType == (int)SensorType.S_ARDUINO_REPEATER_NODE) { node.isRepeatingNode = true; } if (OnNodeUpdatedEvent != null) OnNodeUpdatedEvent(node); DebugGatewayState($"Node {node.nodeId} updated"); } else if (mes.messageType == MessageType.C_INTERNAL) { if (mes.subType == (int)InternalDataType.I_SKETCH_NAME) { node.name = mes.payload; if (OnNodeUpdatedEvent != null) OnNodeUpdatedEvent(node); DebugGatewayState($"Node {node.nodeId} updated"); } else if (mes.subType == (int)InternalDataType.I_SKETCH_VERSION) { node.version = mes.payload; if (OnNodeUpdatedEvent != null) OnNodeUpdatedEvent(node); DebugGatewayState($"Node {node.nodeId} updated"); } else if (mes.subType == (int)InternalDataType.I_BATTERY_LEVEL) { node.batteryLevel = Int32.Parse(mes.payload); if (OnNodeBatteryUpdatedEvent != null) OnNodeBatteryUpdatedEvent(node); return; } } } }
public Sensor(int sensorId, Node ownerNode) { this.sensorId = sensorId; this.nodeId = ownerNode.nodeId; }