예제 #1
0
 static void X10_RfSecurityReceived(object sender, RfSecurityReceivedEventArgs args)
 {
     Console.WriteLine("Received RF Security event {0} from address {1}", args.Event, args.Address.ToString("X3"));
 }
예제 #2
0
        private void X10lib_RfSecurityReceived(object sender, RfSecurityReceivedEventArgs args)
        {
            string address    = "S-" + args.Address.ToString("X6");
            var    moduleType = ModuleTypes.Sensor;

            if (args.Event.ToString().StartsWith("DoorSensor1_"))
            {
                address   += "01";
                moduleType = ModuleTypes.DoorWindow;
            }
            else if (args.Event.ToString().StartsWith("DoorSensor2_"))
            {
                address   += "02";
                moduleType = ModuleTypes.DoorWindow;
            }
            else if (args.Event.ToString().StartsWith("Motion_"))
            {
                moduleType = ModuleTypes.Sensor;
            }
            else if (args.Event.ToString().StartsWith("Remote_"))
            {
                address    = "S-REMOTE";
                moduleType = ModuleTypes.Sensor;
            }
            var module = securityModules.Find(m => m.Address == address);

            if (module == null)
            {
                module             = new InterfaceModule();
                module.Domain      = this.GetDomain();
                module.Address     = address;
                module.Description = "X10 Security";
                module.ModuleType  = moduleType;
                module.CustomData  = 0.0D;
                securityModules.Add(module);
                OnInterfacePropertyChanged(this.GetDomain(), "RF", "X10 RF Receiver", ModuleEvents.Receiver_Status, "Added security module " + address);
                OnInterfaceModulesChanged(this.GetDomain());
            }
            switch (args.Event)
            {
            case X10RfSecurityEvent.DoorSensor1_Alert:
            case X10RfSecurityEvent.DoorSensor2_Alert:
                OnInterfacePropertyChanged(module.Domain, module.Address, "X10 Security Sensor", ModuleEvents.Status_Level, 1);
                OnInterfacePropertyChanged(module.Domain, module.Address, "X10 Security Sensor", ModuleEvents.Sensor_Tamper, 0);
                break;

            case X10RfSecurityEvent.DoorSensor1_Alert_Tarmper:
            case X10RfSecurityEvent.DoorSensor2_Alert_Tamper:
                OnInterfacePropertyChanged(module.Domain, module.Address, "X10 Security Sensor", ModuleEvents.Status_Level, 1);
                OnInterfacePropertyChanged(module.Domain, module.Address, "X10 Security Sensor", ModuleEvents.Sensor_Tamper, 1);
                break;

            case X10RfSecurityEvent.DoorSensor1_Normal:
            case X10RfSecurityEvent.DoorSensor2_Normal:
                OnInterfacePropertyChanged(module.Domain, module.Address, "X10 Security Sensor", ModuleEvents.Status_Level, 0);
                OnInterfacePropertyChanged(module.Domain, module.Address, "X10 Security Sensor", ModuleEvents.Sensor_Tamper, 0);
                break;

            case X10RfSecurityEvent.DoorSensor1_Normal_Tamper:
            case X10RfSecurityEvent.DoorSensor2_Normal_Tamper:
                OnInterfacePropertyChanged(module.Domain, module.Address, "X10 Security Sensor", ModuleEvents.Status_Level, 0);
                OnInterfacePropertyChanged(module.Domain, module.Address, "X10 Security Sensor", ModuleEvents.Sensor_Tamper, 1);
                break;

            case X10RfSecurityEvent.DoorSensor1_BatteryLow:
            case X10RfSecurityEvent.DoorSensor2_BatteryLow:
            case X10RfSecurityEvent.Motion_BatteryLow:
                OnInterfacePropertyChanged(module.Domain, module.Address, "X10 Security Sensor", ModuleEvents.Status_Battery, 10);
                break;

            case X10RfSecurityEvent.DoorSensor1_BatteryOk:
            case X10RfSecurityEvent.DoorSensor2_BatteryOk:
            case X10RfSecurityEvent.Motion_BatteryOk:
                OnInterfacePropertyChanged(module.Domain, module.Address, "X10 Security Sensor", ModuleEvents.Status_Battery, 100);
                break;

            case X10RfSecurityEvent.Motion_Alert:
                OnInterfacePropertyChanged(module.Domain, module.Address, "X10 Security Sensor", ModuleEvents.Status_Level, 1);
                break;

            case X10RfSecurityEvent.Motion_Normal:
                OnInterfacePropertyChanged(module.Domain, module.Address, "X10 Security Sensor", ModuleEvents.Status_Level, 0);
                break;

            case X10RfSecurityEvent.Remote_Arm:
            case X10RfSecurityEvent.Remote_Disarm:
            case X10RfSecurityEvent.Remote_Panic:
            case X10RfSecurityEvent.Remote_Panic_15:
            case X10RfSecurityEvent.Remote_LightOn:
            case X10RfSecurityEvent.Remote_LightOff:
                var evt = args.Event.ToString();
                evt = evt.Substring(evt.IndexOf('_') + 1);
                OnInterfacePropertyChanged(module.Domain, module.Address, "X10 Security Remote", ModuleEvents.Sensor_Key, evt);
                break;
            }
        }
예제 #3
0
파일: Program.cs 프로젝트: slashx57/Domino
 static void X10_RfSecurityReceived(object sender, RfSecurityReceivedEventArgs args)
 {
     logger.Info("Received RF Security event {0} from address {1}", args.Event, args.Address.ToString("X3"));
 }
예제 #4
0
        private void W800Rf32_RfSecurityReceived(object sender, RfSecurityReceivedEventArgs args)
        {
            //args.Event == X10RfSecurityEvent.
            string address    = "S-" + args.Address.ToString("X2");
            var    moduleType = ModuleTypes.Generic;

            if (args.Event.ToString().StartsWith("DoorSensor1_"))
            {
                address   += "01";
                moduleType = ModuleTypes.DoorWindow;
            }
            else if (args.Event.ToString().StartsWith("DoorSensor2_"))
            {
                address   += "02";
                moduleType = ModuleTypes.DoorWindow;
            }
            else if (args.Event.ToString().StartsWith("Motion_"))
            {
                moduleType = ModuleTypes.Sensor;
            }
            else if (args.Event.ToString().StartsWith("Remote_"))
            {
                address    = "S-REMOTE";
                moduleType = ModuleTypes.Sensor;
            }
            var module = modules.Find(m => m.Address == address);

            if (module == null)
            {
                module             = new InterfaceModule();
                module.Domain      = X10_DOMAIN;
                module.Address     = address;
                module.Description = "W800RF32 security module";
                module.ModuleType  = moduleType;
                module.CustomData  = 0.0D;
                modules.Add(module);
                RaisePropertyChanged(this.Domain, "1", "W800RF32 Receiver", "Receiver.Status", "Added security module " + address);
                if (InterfaceModulesChangedAction != null)
                {
                    InterfaceModulesChangedAction(new InterfaceModulesChangedAction()
                    {
                        Domain = this.Domain
                    });
                }
            }
            switch (args.Event)
            {
            case X10RfSecurityEvent.DoorSensor1_Alert:
            case X10RfSecurityEvent.DoorSensor2_Alert:
                RaisePropertyChanged(module.Domain, module.Address, "X10 Module", "Status.Level", 1);
                break;

            case X10RfSecurityEvent.DoorSensor1_Normal:
            case X10RfSecurityEvent.DoorSensor2_Normal:
                RaisePropertyChanged(module.Domain, module.Address, "X10 Module", "Status.Level", 0);
                break;

            case X10RfSecurityEvent.DoorSensor1_BatteryLow:
            case X10RfSecurityEvent.DoorSensor2_BatteryLow:
                RaisePropertyChanged(module.Domain, module.Address, "X10 Module", "Status.Battery", 10);
                break;

            case X10RfSecurityEvent.DoorSensor1_BatteryOk:
            case X10RfSecurityEvent.DoorSensor2_BatteryOk:
                RaisePropertyChanged(module.Domain, module.Address, "X10 Module", "Status.Battery", 100);
                break;

            case X10RfSecurityEvent.Motion_Alert:
                RaisePropertyChanged(module.Domain, module.Address, "X10 Module", "Status.Level", 1);
                break;

            case X10RfSecurityEvent.Motion_Normal:
                RaisePropertyChanged(module.Domain, module.Address, "X10 Module", "Status.Level", 0);
                break;

            case X10RfSecurityEvent.Remote_Arm:
            case X10RfSecurityEvent.Remote_Disarm:
            case X10RfSecurityEvent.Remote_Panic:
            case X10RfSecurityEvent.Remote_LightOn:
            case X10RfSecurityEvent.Remote_LightOff:
                var evt = args.Event.ToString();
                evt = evt.Substring(evt.IndexOf('_') + 1);
                RaisePropertyChanged(module.Domain, module.Address, "X10 Module", "Sensor.Key", evt);
                break;
            }
        }
예제 #5
0
        private void X10lib_RfSecurityReceived(object sender, RfSecurityReceivedEventArgs args)
        {
            ModuleTypes moduleType; string address;

            ParseSecurityModuleAddress(args.Address.ToString("X6"), args.Event.ToString(), out moduleType, out address);
            var module = GetSecurityModuleByAddress(address, moduleType);

            switch (args.Event)
            {
            case X10RfSecurityEvent.DoorSensor1_Alert:
            case X10RfSecurityEvent.DoorSensor2_Alert:
                OnInterfacePropertyChanged(module.Domain, module.Address, "X10 Security Sensor", ModuleEvents.Status_Level, 1);
                OnInterfacePropertyChanged(module.Domain, module.Address, "X10 Security Sensor", ModuleEvents.Sensor_Tamper, 0);
                break;

            case X10RfSecurityEvent.DoorSensor1_Alert_Tarmper:
            case X10RfSecurityEvent.DoorSensor2_Alert_Tamper:
                OnInterfacePropertyChanged(module.Domain, module.Address, "X10 Security Sensor", ModuleEvents.Status_Level, 1);
                OnInterfacePropertyChanged(module.Domain, module.Address, "X10 Security Sensor", ModuleEvents.Sensor_Tamper, 1);
                break;

            case X10RfSecurityEvent.DoorSensor1_Normal:
            case X10RfSecurityEvent.DoorSensor2_Normal:
                OnInterfacePropertyChanged(module.Domain, module.Address, "X10 Security Sensor", ModuleEvents.Status_Level, 0);
                OnInterfacePropertyChanged(module.Domain, module.Address, "X10 Security Sensor", ModuleEvents.Sensor_Tamper, 0);
                break;

            case X10RfSecurityEvent.DoorSensor1_Normal_Tamper:
            case X10RfSecurityEvent.DoorSensor2_Normal_Tamper:
                OnInterfacePropertyChanged(module.Domain, module.Address, "X10 Security Sensor", ModuleEvents.Status_Level, 0);
                OnInterfacePropertyChanged(module.Domain, module.Address, "X10 Security Sensor", ModuleEvents.Sensor_Tamper, 1);
                break;

            case X10RfSecurityEvent.DoorSensor1_BatteryLow:
            case X10RfSecurityEvent.DoorSensor2_BatteryLow:
            case X10RfSecurityEvent.Motion_BatteryLow:
                OnInterfacePropertyChanged(module.Domain, module.Address, "X10 Security Sensor", ModuleEvents.Status_Battery, 10);
                break;

            case X10RfSecurityEvent.DoorSensor1_BatteryOk:
            case X10RfSecurityEvent.DoorSensor2_BatteryOk:
            case X10RfSecurityEvent.Motion_BatteryOk:
                OnInterfacePropertyChanged(module.Domain, module.Address, "X10 Security Sensor", ModuleEvents.Status_Battery, 100);
                break;

            case X10RfSecurityEvent.Motion_Alert:
                OnInterfacePropertyChanged(module.Domain, module.Address, "X10 Security Sensor", ModuleEvents.Status_Level, 1);
                break;

            case X10RfSecurityEvent.Motion_Normal:
                OnInterfacePropertyChanged(module.Domain, module.Address, "X10 Security Sensor", ModuleEvents.Status_Level, 0);
                break;

            case X10RfSecurityEvent.Remote_ArmAway:
            case X10RfSecurityEvent.Remote_ArmHome:
            case X10RfSecurityEvent.Remote_Disarm:
            case X10RfSecurityEvent.Remote_Panic:
            case X10RfSecurityEvent.Remote_Panic_15:
            case X10RfSecurityEvent.Remote_LightOn:
            case X10RfSecurityEvent.Remote_LightOff:
                var evt = args.Event.ToString();
                evt = evt.Substring(evt.IndexOf('_') + 1);
                OnInterfacePropertyChanged(module.Domain, module.Address, "X10 Security Remote", ModuleEvents.Sensor_Key, evt);
                break;
            }
        }