Esempio n. 1
0
        public static AlarmValue Parse(byte[] message)
        {
            AlarmValue alarm = new AlarmValue();

            alarm.Value = message[3];

            //Version 2 sends the value in argument 7
            if (message.Length >= 7)
            {
                alarm.Value = message[7];
            }

            //
            byte cmdClass = message[0];

            if (cmdClass == (byte)CommandClass.SensorAlarm)
            {
                alarm.Parameter = (ZWaveAlarmType)Enum.Parse(typeof(ZWaveAlarmType), message[3].ToString());
                alarm.Value     = message[4];
            }
            //
            switch (alarm.Parameter)
            {
            case ZWaveAlarmType.CarbonDioxide:
                alarm.EventType = EventParameter.AlarmCarbonDioxide;
                break;

            case ZWaveAlarmType.CarbonMonoxide:
                alarm.EventType = EventParameter.AlarmCarbonMonoxide;
                break;

            case ZWaveAlarmType.Smoke:
                alarm.EventType = EventParameter.AlarmSmoke;
                break;

            case ZWaveAlarmType.Heat:
                alarm.EventType = EventParameter.AlarmHeat;
                break;

            case ZWaveAlarmType.Flood:
                alarm.EventType = EventParameter.AlarmFlood;
                break;

            //case ZWaveSensorAlarmParameter.GENERIC:
            default:
                alarm.EventType = EventParameter.AlarmGeneric;
                break;
            }
            //
            return(alarm);
        }
Esempio n. 2
0
        public static AlarmValue Parse(byte[] message)
        {
            AlarmValue alarm = new AlarmValue();
            alarm.Value = message[3];

            //Version 2 sends the value in argument 7
            if (message.Length > 7) {
                alarm.Value = message[7];
            }

            //
            byte cmdClass = message[0];
            if (cmdClass == (byte) CommandClass.SensorAlarm)
            {
                alarm.Parameter = (ZWaveAlarmType) Enum.Parse(typeof (ZWaveAlarmType), message[3].ToString());
                alarm.Value = message[4];
            }
            //
            switch (alarm.Parameter)
            {
                case ZWaveAlarmType.CarbonDioxide:
                    alarm.EventType = EventParameter.AlarmCarbonDioxide;
                    break;
                case ZWaveAlarmType.CarbonMonoxide:
                    alarm.EventType = EventParameter.AlarmCarbonMonoxide;
                    break;
                case ZWaveAlarmType.Smoke:
                    alarm.EventType = EventParameter.AlarmSmoke;
                    break;
                case ZWaveAlarmType.Heat:
                    alarm.EventType = EventParameter.AlarmHeat;
                    break;
                case ZWaveAlarmType.Flood:
                    alarm.EventType = EventParameter.AlarmFlood;
                    break;
            }
            //
            return alarm;
        }
Esempio n. 3
0
 public static AlarmValue Parse(byte[] message)
 {
     AlarmValue alarm = new AlarmValue();
     alarm.Value = message[10];
     //
     byte cmdClass = message[7];
     if (cmdClass == (byte)CommandClass.SensorAlarm)
     {
         alarm.Parameter = (ZWaveAlarmType)Enum.Parse(typeof(ZWaveAlarmType), message[10].ToString());
         alarm.Value = message[11];
     }
     //
     switch (alarm.Parameter)
     {
     case ZWaveAlarmType.CarbonDioxide:
         alarm.EventType = EventParameter.AlarmCarbonDioxide;
         break;
     case ZWaveAlarmType.CarbonMonoxide:
         alarm.EventType = EventParameter.AlarmCarbonMonoxide;
         break;
     case ZWaveAlarmType.Smoke:
         alarm.EventType = EventParameter.AlarmSmoke;
         break;
     case ZWaveAlarmType.Heat:
         alarm.EventType = EventParameter.AlarmHeat;
         break;
     case ZWaveAlarmType.Flood:
         alarm.EventType = EventParameter.AlarmFlood;
         break;
     //case ZWaveSensorAlarmParameter.GENERIC:
     default:
         alarm.EventType = EventParameter.AlarmGeneric;
         break;
     }
     //
     return alarm;
 }
Esempio n. 4
0
        public static AlarmValue Parse(byte[] message)
        {
            AlarmValue alarm    = new AlarmValue();
            byte       cmdClass = message[0];

            if (cmdClass == (byte)CommandClass.SensorAlarm)
            {
                alarm.Parameter = (ZWaveAlarmType)Enum.Parse(typeof(ZWaveAlarmType), message[3].ToString());
                alarm.Value     = message[4];
            }
            else
            {
                if (message.Length > 7)
                {
                    // Version 2
                    alarm.Detail    = (ZWaveAlarmDetailType)Enum.Parse(typeof(ZWaveAlarmDetailType), message[7].ToString());
                    alarm.Parameter = (ZWaveAlarmType)Enum.Parse(typeof(ZWaveAlarmType), message[6].ToString());
                    alarm.Value     = message[7];
                }
                else
                {
                    // Version 1
                    alarm.Parameter = (ZWaveAlarmType)Enum.Parse(typeof(ZWaveAlarmType), message[2].ToString());
                    alarm.Value     = message[3];
                }
            }

            switch (alarm.Parameter)
            {
            case ZWaveAlarmType.CarbonDioxide:
                alarm.EventType = EventParameter.AlarmCarbonDioxide;
                break;

            case ZWaveAlarmType.CarbonMonoxide:
                alarm.EventType = EventParameter.AlarmCarbonMonoxide;
                break;

            case ZWaveAlarmType.Smoke:
                alarm.EventType = EventParameter.AlarmSmoke;
                break;

            case ZWaveAlarmType.Heat:
                alarm.EventType = EventParameter.AlarmHeat;
                break;

            case ZWaveAlarmType.Flood:
                alarm.EventType = EventParameter.AlarmFlood;
                break;

            case ZWaveAlarmType.AccessControl:
                alarm.EventType = EventParameter.AlarmDoorWindow;
                if (alarm.Detail != ZWaveAlarmDetailType.Generic)
                {
                    if (alarm.Detail == ZWaveAlarmDetailType.AccessDoorOpen)
                    {
                        alarm.Value = 0x01;
                    }
                    if (alarm.Detail == ZWaveAlarmDetailType.AccessDoorClosed)
                    {
                        alarm.Value = 0x00;
                    }
                }
                break;

            case ZWaveAlarmType.Burglar:
                alarm.EventType = EventParameter.AlarmTampered;
                if (alarm.Detail != ZWaveAlarmDetailType.Generic)
                {
                    if (alarm.Detail == ZWaveAlarmDetailType.HomeSecTamper)
                    {
                        alarm.Value = 0x01;
                    }
                }
                break;
            }

            //
            return(alarm);
        }
Esempio n. 5
0
        public static AlarmValue Parse(byte[] message)
        {
            AlarmValue alarm    = new AlarmValue();
            byte       cmdClass = message[0];

            if (cmdClass == (byte)CommandClass.SensorAlarm)
            {
                alarm.Parameter = (ZWaveAlarmType)Enum.Parse(typeof(ZWaveAlarmType), message[3].ToString());
                alarm.Value     = message[4];
            }
            else // CommandClass.Alarm
            {
                // TODO: change this to --> if (node.GetCommandClass(CommandClass.Alarm).Version == 2) ...
                if (message.Length > 7)
                {
                    // Version 2
                    alarm.Event     = (ZWaveAlarmEvent)Enum.Parse(typeof(ZWaveAlarmEvent), message[7].ToString());
                    alarm.Parameter = (ZWaveAlarmType)Enum.Parse(typeof(ZWaveAlarmType), message[6].ToString());
                    alarm.Value     = message[5];
                }
                else
                {
                    // Version 1
                    alarm.Parameter = (ZWaveAlarmType)Enum.Parse(typeof(ZWaveAlarmType), message[2].ToString());
                    alarm.Value     = message[3];
                }
            }

            switch (alarm.Parameter)
            {
            case ZWaveAlarmType.CarbonDioxide:
                alarm.EventType = EventParameter.AlarmCarbonDioxide;
                break;

            case ZWaveAlarmType.CarbonMonoxide:
                alarm.EventType = EventParameter.AlarmCarbonMonoxide;
                break;

            case ZWaveAlarmType.Smoke:
                alarm.EventType = EventParameter.AlarmSmoke;
                break;

            case ZWaveAlarmType.Heat:
                alarm.EventType = EventParameter.AlarmHeat;
                break;

            case ZWaveAlarmType.Flood:
                alarm.EventType = EventParameter.AlarmFlood;
                break;

            case ZWaveAlarmType.AccessControl:
                alarm.EventType = EventParameter.AlarmDoorWindow;
                switch (alarm.Event)
                {
                case ZWaveAlarmEvent.AccessDoorOpen:
                    alarm.Value = 1;
                    break;

                case ZWaveAlarmEvent.AccessDoorClosed:
                    alarm.Value = 0;
                    break;
                }
                break;

            case ZWaveAlarmType.Burglar:
                alarm.EventType = EventParameter.AlarmGeneric;
                switch (alarm.Event)
                {
                case ZWaveAlarmEvent.HomeSecurityTamper:
                    alarm.EventType = EventParameter.AlarmTampered;
                    break;

                case ZWaveAlarmEvent.HomeSecurityMotion:
                case ZWaveAlarmEvent.HomeSecurityPir:
                    alarm.EventType = EventParameter.SensorMotion;
                    break;
                }
                break;
            }

            return(alarm);
        }
Esempio n. 6
0
        public static AlarmValue Parse(byte[] message)
        {
            AlarmValue alarm = new AlarmValue();
            byte cmdClass = message[0];

            if (cmdClass == (byte)CommandClass.SensorAlarm)
            {
                alarm.Parameter = (ZWaveAlarmType)Enum.Parse(typeof(ZWaveAlarmType), message[3].ToString());
                alarm.Value = message[4];
            }
            else // CommandClass.Alarm
            {
                // TODO: change this to --> if (node.GetCommandClass(CommandClass.Alarm).Version == 2) ...
                if (message.Length > 7)
                {
                    // Version 2
                    alarm.Event = (ZWaveAlarmEvent)Enum.Parse(typeof(ZWaveAlarmEvent), message[7].ToString());
                    alarm.Parameter = (ZWaveAlarmType)Enum.Parse(typeof(ZWaveAlarmType), message[6].ToString());
                    alarm.Value = message[5];
                }
                else
                {
                    // Version 1
                    alarm.Parameter = (ZWaveAlarmType)Enum.Parse(typeof(ZWaveAlarmType), message[2].ToString());
                    alarm.Value = message[3];
                }
            }

            switch (alarm.Parameter)
            {
            case ZWaveAlarmType.CarbonDioxide:
                alarm.EventType = EventParameter.AlarmCarbonDioxide;
                break;
            case ZWaveAlarmType.CarbonMonoxide:
                alarm.EventType = EventParameter.AlarmCarbonMonoxide;
                break;
            case ZWaveAlarmType.Smoke:
                alarm.EventType = EventParameter.AlarmSmoke;
                break;
            case ZWaveAlarmType.Heat:
                alarm.EventType = EventParameter.AlarmHeat;
                break;
            case ZWaveAlarmType.Flood:
                alarm.EventType = EventParameter.AlarmFlood;
                break;
            case ZWaveAlarmType.AccessControl:
                alarm.EventType = EventParameter.AlarmDoorWindow;
                switch (alarm.Event)
                {
                case ZWaveAlarmEvent.AccessDoorOpen:
                    alarm.Value = 1;
                    break;
                case ZWaveAlarmEvent.AccessDoorClosed:
                    alarm.Value = 0;
                    break;
                }
                break;
            case ZWaveAlarmType.Burglar:
                alarm.EventType = EventParameter.AlarmGeneric;
                switch (alarm.Event)
                {
                case ZWaveAlarmEvent.HomeSecurityTamper:
                    alarm.EventType = EventParameter.AlarmTampered;
                    break;
                case ZWaveAlarmEvent.HomeSecurityMotion:
                case ZWaveAlarmEvent.HomeSecurityPir:
                    alarm.EventType = EventParameter.SensorMotion;
                    break;
                }
                break;
            }

            return alarm;
        }
        public static AlarmValue Parse(byte[] message)
        {
            AlarmValue alarm = new AlarmValue();
            byte cmdClass = message[0];

            if (cmdClass == (byte)CommandClass.SensorAlarm)
            {
                alarm.Parameter = (ZWaveAlarmType)Enum.Parse(typeof(ZWaveAlarmType), message[3].ToString());
                alarm.Value = message[4];
            }
            else
            {
                if (message.Length > 7)
                {
                    // Version 2
                    alarm.Detail = (ZWaveAlarmDetailType)Enum.Parse(typeof(ZWaveAlarmDetailType), message[7].ToString());
                    alarm.Parameter = (ZWaveAlarmType)Enum.Parse(typeof(ZWaveAlarmType), message[6].ToString());
                    alarm.Value = message[7];
                }
                else
                {
                    // Version 1
                    alarm.Parameter = (ZWaveAlarmType)Enum.Parse(typeof(ZWaveAlarmType), message[2].ToString());
                    alarm.Value = message[3];
                }
            }

            switch (alarm.Parameter)
            {
            case ZWaveAlarmType.CarbonDioxide:
                alarm.EventType = EventParameter.AlarmCarbonDioxide;
                break;
            case ZWaveAlarmType.CarbonMonoxide:
                alarm.EventType = EventParameter.AlarmCarbonMonoxide;
                break;
            case ZWaveAlarmType.Smoke:
                alarm.EventType = EventParameter.AlarmSmoke;
                break;
            case ZWaveAlarmType.Heat:
                alarm.EventType = EventParameter.AlarmHeat;
                break;
            case ZWaveAlarmType.Flood:
                alarm.EventType = EventParameter.AlarmFlood;
                break;
            case ZWaveAlarmType.AccessControl:
                alarm.EventType = EventParameter.AlarmDoorWindow;
                if (alarm.Detail != ZWaveAlarmDetailType.Generic)
                {
                    if (alarm.Detail == ZWaveAlarmDetailType.AccessDoorOpen)
                    {
                        alarm.Value = 0x01;
                    }
                    if (alarm.Detail == ZWaveAlarmDetailType.AccessDoorClosed)
                    {
                        alarm.Value = 0x00;
                    }
                }
                break;
            case ZWaveAlarmType.Burglar:
                alarm.EventType = EventParameter.AlarmTampered;
                if (alarm.Detail != ZWaveAlarmDetailType.Generic)
                {
                    if (alarm.Detail == ZWaveAlarmDetailType.HomeSecTamper)
                    {
                        alarm.Value = 0x01;
                    }
                }
                break;
            }

            //
            return alarm;
        }