/// <summary>
 /// Raises the RF security received event.
 /// </summary>
 /// <param name="args">Arguments.</param>
 protected virtual void OnRfSecurityReceived(RfSecurityReceivedEventArgs args)
 {
     if (RfSecurityReceived != null)
         RfSecurityReceived(this, args);
 }
Beispiel #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;
     }
 }
Beispiel #3
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.Domain;
         module.Address = address;
         module.Description = "X10 Security";
         module.ModuleType = moduleType;
         module.CustomData = 0.0D;
         securityModules.Add(module);
         RaisePropertyChanged(this.Domain, "RF", "X10 RF 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", ModuleParameters.MODPAR_STATUS_LEVEL, 1);
         break;
     case X10RfSecurityEvent.DoorSensor1_Normal:
     case X10RfSecurityEvent.DoorSensor2_Normal:
         RaisePropertyChanged(module.Domain, module.Address, "X10 Module", ModuleParameters.MODPAR_STATUS_LEVEL, 0);
         break;
     case X10RfSecurityEvent.DoorSensor1_BatteryLow:
     case X10RfSecurityEvent.DoorSensor2_BatteryLow:
         RaisePropertyChanged(module.Domain, module.Address, "X10 Module", ModuleParameters.MODPAR_STATUS_BATTERY, 10);
         break;
     case X10RfSecurityEvent.DoorSensor1_BatteryOk:
     case X10RfSecurityEvent.DoorSensor2_BatteryOk:
         RaisePropertyChanged(module.Domain, module.Address, "X10 Module", ModuleParameters.MODPAR_STATUS_BATTERY, 100);
         break;
     case X10RfSecurityEvent.Motion_Alert:
         RaisePropertyChanged(module.Domain, module.Address, "X10 Module", ModuleParameters.MODPAR_STATUS_LEVEL, 1);
         break;
     case X10RfSecurityEvent.Motion_Normal:
         RaisePropertyChanged(module.Domain, module.Address, "X10 Module", ModuleParameters.MODPAR_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;
     }
 }