Beispiel #1
0
 private void sendSensorStatusButton_Click_1(object sender, EventArgs e)
 {
     shield.sendSensorsStatus();
 }
Beispiel #2
0
        public void cellButtonClick(object sender, CellClickEventArgs e)
        {
            Debug.WriteLine(String.Format("Button clicked: ({0}, {1}, {2})", e.RowIndex, e.SubItem, e.Model));

            // Take some action on e.Model based on which button (e.ColumnIndex) was clicked

            ShieldProperty property = (ShieldProperty)e.Model;

            if (property.Name.Equals(property_TemperatureSensor_Temperature))
            {
                Shield shield = shields.shieldFromNodeId(property.NodeId);
                shield.sendSensorsStatus();
            }
            else if (property.Name.Equals(property_ShieldId))
            {
                Shield shield = shields.shieldFromNodeId(property.NodeId);
                shield.registerShield();
            }
            else if (property.Name.Equals(property_Enabled))
            {
                Shield shield = shields.shieldFromNodeId(property.ShieldNodeId);
                if (shield != null)
                {
                    Sensor sensor = (Sensor)shield.sensorFromNodeId(property.NodeId);
                    if (sensor != null)
                    {
                        sensor.enabled = !sensor.enabled;
                        if (sensor.enabled)
                        {
                            property.Value  = "true";
                            property.Action = "Disable";
                        }
                        else
                        {
                            property.Value  = "false";
                            property.Action = "Enable";
                        }
                        shield.sendSensorsStatus();
                    }
                }
            }
            else if (property.Name.Equals(property_DoorSensor_Open))
            {
                Shield     shield     = shields.shieldFromNodeId(property.ShieldNodeId);
                DoorSensor doorSensor = (DoorSensor)shield.sensorFromNodeId(property.NodeId);
                doorSensor.setStatusOpen(!doorSensor.getStatusOpen());
                if (doorSensor.getStatusOpen())
                {
                    property.Value  = "open";
                    property.Action = "close";
                }
                else
                {
                    property.Value  = "closed";
                    property.Action = "open";
                }
                shield.sendSensorsStatus();
            }
            // If something about the object changed, you probably want to refresh the model
            this.objectListView1.RefreshObject(e.Model);
            //this.objectListView1.Update();
            //this.objectListView1.SetObjects(propertyList);
            //this.objectListView1.Refresh();
        }