Ejemplo n.º 1
0
        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;
        }
Ejemplo n.º 2
0
 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);
 }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
 public bool hasSensorOf(sensorType selectedType)
 {
     return getSensorsOfType(selectedType).Count != 0;
 }
Ejemplo n.º 5
0
 public List<sensor> getSensorsOfType(sensorType sensorType)
 {
     return sensors.Values.Where(s => s.type.enumeratedType == sensorType.enumeratedType).ToList();
 }