Esempio n. 1
0
 internal InsteonDevice(InsteonNetwork network, InsteonAddress address, InsteonIdentity identity)
 {
     this.network = network;
     Address      = address;
     Identity     = identity;
     ackTimer     = new Timer(PendingCommandTimerCallback, null, Timeout.Infinite, Constants.deviceAckTimeout);
 }
 internal InsteonDevice(InsteonNetwork network, InsteonAddress address, InsteonIdentity identity)
 {
     this.network = network;
     Address = address;
     Identity = identity;
     ackTimer = new Timer(PendingCommandTimerCallback, null, Timeout.Infinite, Constants.deviceAckTimeout);
 }
 private InsteonDeviceLinkRecord(int address, byte group, byte data1, byte data2, byte data3, byte flags) : this()
 {
     Address         = new InsteonAddress(address);
     Group           = group;
     Data1           = data1;
     Data2           = data2;
     Data3           = data3;
     LinkRecordFlags = flags;
 }
 private InsteonDeviceLinkRecord(int address, byte group, byte data1, byte data2, byte data3, byte flags) : this()
 {
     Address = new InsteonAddress(address);
     Group = group;
     Data1 = data1;
     Data2 = data2;
     Data3 = data3;
     LinkRecordFlags = flags;
 }
        public static InsteonDevice GetDevice(this InsteonIdentity insteonIdentity, InsteonNetwork network, InsteonAddress address)
        {
            if (insteonIdentity.IsEmpty)
            {
                return new InsteonDevice(network, address, insteonIdentity);
            }

            if (DeviceTypeLookup.ContainsKey(insteonIdentity.DevCat))
            {
                if (DeviceTypeLookup[insteonIdentity.DevCat].ContainsKey(insteonIdentity.SubCat))
                {
                    return DeviceTypeLookup[insteonIdentity.DevCat][insteonIdentity.SubCat](insteonIdentity, network, address);
                }
            }

            return new InsteonDevice(network, address, insteonIdentity);
        }
        /// <summary>
        /// Adds an INSTEON device to the list of known devices.
        /// </summary>
        /// <param name="address">The INSTEON address of the device to add.</param>
        /// <param name="identity">The INSTEON identity of the device to add.</param>
        /// <returns>Returns an object representing the specified device.</returns>
        /// <remarks>This method does not perform any INSTEON messaging, it only adds the specified device to a list of known devices.</remarks>
        public InsteonDevice Add(InsteonAddress address, InsteonIdentity identity)
        {
            if (identity.IsEmpty)
            {
                throw new Exception("Identity is empty.");
            }

            if (devices.ContainsKey(address.Value))
            {
                return(devices[address.Value]);
            }

            InsteonDevice device = identity.GetDevice(network, address);

            devices.Add(address.Value, device);
            OnDeviceAdded(device);
            return(device);
        }
        /// <summary>
        /// Converts the string representation of an INSTEON address to its numeric equivalent.
        /// </summary>
        /// <param name="value">A string specifying the INSTEON address, example: "19.9E.4E".</param>
        /// <param name="address">An object representing the resulting INSTEON address.</param>
        /// <returns>Returns true if the string was successfully parsed.</returns>
        /// <remarks>
        /// This method does not throw an exception.
        /// </remarks>
        public static bool TryParse(string value, out InsteonAddress address)
        {
            address = new InsteonAddress();
            if (string.IsNullOrEmpty(value))
            {
                return(false);
            }
            value = value.Trim();
            if (value.Length != 8)
            {
                return(false);
            }
            if (value[2] != '.' || value[5] != '.')
            {
                return(false);
            }
            byte a0 = byte.Parse(value.Substring(6, 2), NumberStyles.HexNumber);
            byte a1 = byte.Parse(value.Substring(3, 2), NumberStyles.HexNumber);
            byte a2 = byte.Parse(value.Substring(0, 2), NumberStyles.HexNumber);

            address = new InsteonAddress(a2, a1, a0);
            return(true);
        }
 internal MiniRemote(InsteonNetwork network, InsteonAddress address, InsteonIdentity identity, int buttonCount)
     : base(network, address, identity)
 {
     NumberOfButtons = buttonCount;
 }
 private static byte[] GetStandardMessage(InsteonAddress address, byte cmd1, byte cmd2)
 {
     // 0x0F is "Message Flags" - type and hops
     byte[] message = { (byte)InsteonModemSerialCommand.StandardOrExtendedMessage, address[2], address[1], address[0], (byte) MessageFlagsStandard.ThreeHopsThreeRemaining, cmd1, cmd2 };
     return message;
 }
 /// <summary>
 /// Converts the string representation of an INSTEON address to its numeric equivalent.
 /// </summary>
 /// <param name="value">A string specifying the INSTEON address, example: "19.9E.4E".</param>
 /// <param name="address">An object representing the resulting INSTEON address.</param>
 /// <returns>Returns true if the string was successfully parsed.</returns>
 /// <remarks>
 /// This method does not throw an exception.
 /// </remarks>
 public static bool TryParse(string value, out InsteonAddress address)
 {
     address = new InsteonAddress();
     if (string.IsNullOrEmpty(value))
     {
         return false;
     }
     value = value.Trim();
     if (value.Length != 8)
     {
         return false;
     }
     if (value[2] != '.' || value[5] != '.')
     {
         return false;
     }
     byte a0 = byte.Parse(value.Substring(6, 2), NumberStyles.HexNumber);
     byte a1 = byte.Parse(value.Substring(3, 2), NumberStyles.HexNumber);
     byte a2 = byte.Parse(value.Substring(0, 2), NumberStyles.HexNumber);
     address = new InsteonAddress(a2, a1, a0);
     return true;
 }
 /// <summary>
 /// Determiens whether the specified INSTEON device address is contained within the list of known devices.
 /// </summary>
 /// <param name="address">The specified INSTEON address.</param>
 /// <returns>Returns true if the list contains the specified INSTEON device.</returns>
 public bool ContainsKey(InsteonAddress address)
 {
     return(devices.ContainsKey(address.Value));
 }
 /// <summary>
 /// Finds the object representation of the specified device within the list of known devices.
 /// </summary>
 /// <param name="address">The specified INSTEON address.</param>
 /// <returns>Returns an object representing the specified INSTEON device.</returns>
 public InsteonDevice Find(InsteonAddress address)
 {
     return(devices[address.Value]);
 }
Esempio n. 13
0
 internal LeakSensor(InsteonNetwork network, InsteonAddress address, InsteonIdentity identity)
     : base(network, address, identity)
 {
 }
Esempio n. 14
0
 private static byte[] GetStandardMessage(InsteonAddress address, byte cmd1, byte cmd2)
 {
     // 0x0F is "Message Flags" - type and hops
     byte[] message = { (byte)InsteonModemSerialCommand.StandardOrExtendedMessage, address[2], address[1], address[0], (byte)MessageFlagsStandard.ThreeHopsThreeRemaining, cmd1, cmd2 };
     return(message);
 }
        public static InsteonDevice GetDevice(this InsteonIdentity insteonIdentity, InsteonNetwork network, InsteonAddress address)
        {
            if (insteonIdentity.IsEmpty)
            {
                return(new InsteonDevice(network, address, insteonIdentity));
            }

            if (DeviceTypeLookup.ContainsKey(insteonIdentity.DevCat))
            {
                if (DeviceTypeLookup[insteonIdentity.DevCat].ContainsKey(insteonIdentity.SubCat))
                {
                    return(DeviceTypeLookup[insteonIdentity.DevCat][insteonIdentity.SubCat](insteonIdentity, network, address));
                }
            }

            return(new InsteonDevice(network, address, insteonIdentity));
        }
Esempio n. 16
0
 internal IoLinc(InsteonNetwork network, InsteonAddress address, InsteonIdentity identity)
     : base(network, address, identity)
 {
 }
        internal DimmableLighting(InsteonNetwork network, InsteonAddress address, InsteonIdentity identity)
            : base(network, address, identity)
        {

        }
 internal SwitchedLighting(InsteonNetwork network, InsteonAddress address, InsteonIdentity identity) : base(network, address, identity) { }
 internal PowerLincUsbModem(InsteonNetwork network, InsteonAddress address, InsteonIdentity identity)
     : base(network, address, identity)
 {
 }