public frmSensorOptions(IFormOptions opts) { options = opts as SensorOptions; InitializeComponent(); _tpy = new sensorType(options.thisSensorType); List<Node> allNodes = FrmMain.getAllConnectedNodes(); foreach (Node node in allNodes) { if (node.hasSensorOf(_tpy)) { cboNodes.Items.Add(node); } } if (cboNodes.Items.Count == 0) { lblError.Text = "No nodes of this type are connected"; btnOK.Enabled = false; cboNodes.Enabled = false; } else { lblError.Text = ""; cboNodes.SelectedIndex = 0; } if (options.thisSensor != null) cboNodes.SelectedItem = options.thisSensor; }
public bool Equals(sensorType other) { if (ReferenceEquals(null, other)) { return false; } if (ReferenceEquals(this, other)) { return true; } return Equals(other.friendlyType, this.friendlyType) && Equals(other.enumeratedType, this.enumeratedType); }
public void ReadXml(XmlReader reader) { short parentNodeId = 0; string port = null; bool encrypt = false; byte[] key = new byte[16]; bool readElement = false; while (!readElement) { switch (reader.Name) { case "ID": id = (short)reader.ReadElementContentAsInt(); break; case "nodeType": _cachedType = new sensorType((sensorTypeEnum)reader.ReadElementContentAsInt()); break; case "parentNodeID": parentNodeId = (short)reader.ReadElementContentAsInt(); break; case "driverPort": port = reader.ReadElementContentAsString(); break; case "driverEncrypt": encrypt = reader.ReadElementContentAsBoolean(); break; case "key": reader.ReadElementContentAsBinHex(key, 0, 16); break; case "selectedSensor": if (reader.NodeType == XmlNodeType.EndElement) readElement = true; else reader.Read(); break; default: reader.Read(); break; } } _parentNode = new Node(parentNodeId); }
public bool hasSensorOf(sensorType selectedType) { return getSensorsOfType(selectedType).Count != 0; }
public List<sensor> getSensorsOfType(sensorType sensorType) { return sensors.Values.Where(s => s.type.enumeratedType == sensorType.enumeratedType).ToList(); }