Ejemplo n.º 1
0
 private static byte ToggleSwitch(SwitchBinary sw)
 {
     if (sw != null)
     {
         DebugLogger.Logger.Trace(string.Format("Switch in state: {0}", sw.State.ToString()));
         if (sw.State == 0xff)
         {
             DebugLogger.Logger.Trace("And then there was darkness...");
             sw.Off();
         }
         else
         {
             DebugLogger.Logger.Trace("Let there be light!");
             sw.On();
         }
     }
     return sw.State;
 }
Ejemplo n.º 2
0
        private void CreateNode(byte nodeId, bool sleeping, byte basicType, byte genericType, byte specificType)
        {
            DebugLogger.Logger.Trace("");
            ZWaveNode node = null;
            switch (genericType)
            {
                case ZWaveProtocol.Type.Generic.SWITCH_BINARY:
                    node = new SwitchBinary(this._port, nodeId);
                    break;
                case ZWaveProtocol.Type.Generic.SENSOR_BINARY:
                    node = new SensorBinary(this._port, nodeId);
                    break;
                case ZWaveProtocol.Type.Generic.SENSOR_MULTILEVEL:
                    node = new SensorBinary(this._port, nodeId);
                    break;
                case ZWaveProtocol.Type.Generic.METER:
                    node = new Meter(this._port, nodeId);
                    break;
                case ZWaveProtocol.Type.Generic.SWITCH_MULTILEVEL:
                    node = new SwitchMultilevel(this._port, nodeId);
                    break;
                default:
                    DebugLogger.Logger.Warn("Unknown node found: NODE_ID = " + nodeId.ToString("X2") + " GENERIC_TYPE: " + genericType.ToString("X2"));
                    break;
            }

            if (node != null)
            {
                DebugLogger.Logger.Trace("Node found: NODE_ID = " + nodeId.ToString("X2") + ", GENERIC_TYPE: " + Utils.GenericTypeToString(genericType) + ", SPECIFIC_TYPE: " + specificType.ToString("X2"));
                DebugLogger.Logger.Trace("Sleeping: " + sleeping);

                if(!this.Nodes.ContainsKey(nodeId))
                    this.Nodes.Add(nodeId, node);

                node.IsSleepingNode = sleeping;

                if (sleeping)
                {
                    this.SetWakeupInterval(nodeId);
                }

                node.NodeInitializedEvent += NodeInitialized;
                node.Initialize();
            }
        }