コード例 #1
0
 internal void OnMessage(InsteonMessage message)
 {
     if (message.MessageType == InsteonMessageType.DeviceLink)
     {
         InsteonAddress  address  = new InsteonAddress(message.Properties[PropertyKey.Address]);
         InsteonIdentity identity = new InsteonIdentity((byte)message.Properties[PropertyKey.DevCat], (byte)message.Properties[PropertyKey.SubCat], (byte)message.Properties[PropertyKey.FirmwareVersion]);
         InsteonDevice   device   = network.Devices.Add(address, identity);
         timer.Stop();
         IsInLinkingMode = false;
         if (linkingMode.HasValue)
         {
             if (linkingMode != InsteonLinkMode.Delete)
             {
                 OnDeviceLinked(device);
             }
             else
             {
                 OnDeviceUnlinked(device);
             }
         }
         else
         {
             OnDeviceLinked(device);
         }
     }
 }
コード例 #2
0
 private void OnDeviceUnlinked(InsteonDevice device)
 {
     if (DeviceUnlinked != null)
     {
         DeviceUnlinked(this, new InsteonDeviceEventArgs(device));
     }
 }
コード例 #3
0
ファイル: InsteonEvent.cs プロジェクト: fringebits/Insteon
        protected override void OnEnabling(EnablingEventArgs e)
        {
            InsteonAddress address;
            if (!InsteonAddress.TryParse(data.Device, out address))
            {
                ErrorLog.AddError(ErrorType.Failure, string.Format("Invalid INSTEON address '{0}'", data.Device));
                e.Cancel = true;
                return;
            }
            
            InsteonService.StartNetwork();
/*
            if (!InsteonService.VerifyConnection())
            {
                ErrorLog.AddError(ErrorType.Failure, string.Format("Lost connection to INSTEON network. {0}", InsteonService.SpecificConnection != null ? InsteonService.SpecificConnection.ToString() : string.Empty));
                e.Cancel = true;
                return;
            }
*/
            if (!InsteonService.Network.Devices.ContainsKey(address))
                device = InsteonService.Network.Devices.Add(address, new InsteonIdentity());
            else
                device = InsteonService.Network.Devices.Find(address);
            device.DeviceStatusChanged += device_DeviceStatusChanged;
        }
コード例 #4
0
 private void OnMessage(InsteonMessage message)
 {
     if (message.Properties.ContainsKey(PropertyKey.FromAddress))
     {
         int address = message.Properties[PropertyKey.FromAddress];
         if (network.Devices.ContainsKey(address))
         {
             Log.WriteLine("Device {0} received message {1}", InsteonAddress.Format(address), message.ToString());
             InsteonDevice device = network.Devices.Find(address);
             device.OnMessage(message);
         }
         else if (message.MessageType == InsteonMessageType.SetButtonPressed)
         {
             // don't warn about SetButtonPressed message from unknown devices, because it may be from a device about to be added
         }
         else if (network.AutoAdd)
         {
             Log.WriteLine("Unknown device {0} received message {1}, adding device", InsteonAddress.Format(address), message.ToString());
             InsteonDevice device = network.Devices.Add(new InsteonAddress(address), new InsteonIdentity());
             device.OnMessage(message);
         }
         else
         {
             Log.WriteLine("WARNING: Unknown device {0} received message {1}", InsteonAddress.Format(address), message.ToString());
         }
     }
     else
     {
         Log.WriteLine("Controller received message {0}", message.ToString());
         network.Controller.OnMessage(message);
     }
 }
コード例 #5
0
 private void OnDeviceUnlinked(InsteonDevice device)
 {
     if (DeviceUnlinked != null)
         DeviceUnlinked(this, new InsteonDeviceEventArgs(device));
 }
コード例 #6
0
 internal InsteonDeviceStatusChangedEventArgs(InsteonDevice device, InsteonDeviceStatus status)
 {
     this.Device       = device;
     this.DeviceStatus = status;
 }
コード例 #7
0
 internal InsteonDeviceStatusChangedEventArgs(InsteonDevice device, InsteonDeviceStatus status)
 {
     this.Device = device;
     this.DeviceStatus = status;
 }
コード例 #8
0
 private void OnDeviceUnlinked(InsteonDevice device)
 {
     DeviceUnlinked?.Invoke(this, new InsteonDeviceEventArgs(device));
 }
コード例 #9
0
 internal InsteonDeviceEventArgs(InsteonDevice device)
 {
     this.Device = device;
 }
コード例 #10
0
 internal InsteonDeviceEventArgs(InsteonDevice device)
 {
     this.Device = device;
 }