Ejemplo n.º 1
0
 protected override int VerifyExtraResponseData(byte[] data, int pos)
 {
     id = new DeviceId(data[0], data[1], data[2]);
     category = data[3];
     subcategory = data[4];
     firmwareVersion = data[5];
     return 6;
 }
 /// <summary>
 /// Creates the record based onthe data from the modem.
 /// </summary>
 /// <param name="data">the data from the modem</param>
 public LinkingRecord(byte[] data)
 {
     flags     = data[0];
     group     = data[1];
     id        = new DeviceId(data[2], data[3], data[4]);
     linkData1 = data[5];
     linkData2 = data[6];
     linkData3 = data[7];
 }
 /// <summary>
 /// Creates the record based onthe data from the modem.
 /// </summary>
 /// <param name="data">the data from the modem</param>
 public LinkingRecord(byte[] data)
 {
     flags = data[0];
     group = data[1];
     id = new DeviceId(data[2], data[3], data[4]);
     linkData1 = data[5];
     linkData2 = data[6];
     linkData3 = data[7];
 }
 /// <summary>
 /// Create a new standard length command.
 /// </summary>
 /// <param name="id">id to sent to</param>
 /// <param name="cmd">cmd1 bit</param>
 /// <param name="cmd2">cmd2 bit</param>
 public InsteonPacket(DeviceId id, Command cmd, byte cmd2)
 {
     Command1 = (byte)cmd;
     Command2 = cmd2;
     FromAddress = id;
     ToAddress = id;
     flags = new InsteonFlags();
     flags.MessageType = InsteonFlags.MessageTypeEnum.Direct;
     flags.MaxHops = 0x3;
     flags.HopsLeft = 0x3;
 }
 /// <summary>
 /// Create from an input byte array from the power line modem.
 /// </summary>
 /// <param name="data">The input data</param>
 public InsteonPacket(byte[] data)
 {
     FromAddress = new DeviceId(data[0], data[1], data[2]);
     ToAddress = new DeviceId(data[3], data[4], data[5]);
     Flags = new InsteonFlags();
     Flags.FromByte(data[6]);
     Command1 = data[7];
     Command2 = data[8];
     UserData = new byte[data.Length - 9];
     Array.Copy(data, 9, UserData, 0, data.Length - 9);
 }
 /// <summary>
 /// Create from an input byte array from the power line modem.
 /// </summary>
 /// <param name="data">The input data</param>
 public InsteonPacket(byte[] data)
 {
     FromAddress = new DeviceId(data[0], data[1], data[2]);
     ToAddress   = new DeviceId(data[3], data[4], data[5]);
     Flags       = new InsteonFlags();
     Flags.FromByte(data[6]);
     Command1 = data[7];
     Command2 = data[8];
     UserData = new byte[data.Length - 9];
     Array.Copy(data, 9, UserData, 0, data.Length - 9);
 }
Ejemplo n.º 7
0
 public override bool Equals(object obj)
 {
     if (obj is DeviceId)
     {
         DeviceId id = (DeviceId)obj;
         return(id.Address[0] == this.Address[0] &&
                id.Address[1] == this.Address[1] &&
                id.Address[2] == this.Address[2]);
     }
     return(base.Equals(obj));
 }
 /// <summary>
 /// Create a new standard length command.
 /// </summary>
 /// <param name="id">id to sent to</param>
 /// <param name="cmd">cmd1 bit</param>
 /// <param name="cmd2">cmd2 bit</param>
 public InsteonPacket(DeviceId id, Command cmd, byte cmd2)
 {
     Command1          = (byte)cmd;
     Command2          = cmd2;
     FromAddress       = id;
     ToAddress         = id;
     flags             = new InsteonFlags();
     flags.MessageType = InsteonFlags.MessageTypeEnum.Direct;
     flags.MaxHops     = 0x3;
     flags.HopsLeft    = 0x3;
 }
 /// <summary>
 /// 
 /// Create a new device based on the exciting address and category details.
 /// </summary>
 /// <param name="id"></param>
 /// <param name="category"></param>
 /// <param name="subCategory"></param>
 /// <returns></returns>
 public DeviceBase CreateDevice(DeviceId id, byte category, byte subCategory)
 {
     switch ((DeviceCategory)category)
     {
         case DeviceCategory.DimmableLightingControl:
             return new DimmingLight(coms, id, category, subCategory);
         case DeviceCategory.SwitchedLightingControl:
             return new SwitchedLight(coms, id, category, subCategory);
         default:
             return new DeviceBase(coms, id, category, subCategory);
     }
 }
 /// <summary>
 /// Creates an insteon packet with an extended command.
 /// </summary>
 /// <param name="id"></param>
 /// <param name="cmd"></param>
 public InsteonPacket(DeviceId id, ExtendedCommand cmd, byte cmd2, byte[] data)
 {
     Command1              = (byte)((int)cmd >> 8);
     Command2              = (byte)(((int)cmd & 0xff) | cmd2);
     UserData              = data;
     FromAddress           = id;
     ToAddress             = id;
     flags                 = new InsteonFlags();
     flags.MessageType     = InsteonFlags.MessageTypeEnum.Direct;
     flags.ExtendedMessage = true;
     flags.MaxHops         = 0x3;
     flags.HopsLeft        = 0x3;
 }
 /// <summary>
 /// Creates an insteon packet with an extended command.
 /// </summary>
 /// <param name="id"></param>
 /// <param name="cmd"></param>
 public InsteonPacket(DeviceId id, ExtendedCommand cmd, byte cmd2, byte[] data)
 {
     Command1 = (byte)((int)cmd >> 8);
     Command2 = (byte)(((int)cmd & 0xff) | cmd2);
     UserData = data;
     FromAddress = id;
     ToAddress = id;
     flags = new InsteonFlags();
     flags.MessageType = InsteonFlags.MessageTypeEnum.Direct;
     flags.ExtendedMessage = true;
     flags.MaxHops = 0x3;
     flags.HopsLeft = 0x3;
 }
Ejemplo n.º 12
0
 /// <summary>
 /// Finds a device based on the byte address.
 /// </summary>
 /// <param name="address"></param>
 /// <param name="device"></param>
 /// <returns></returns>
 public bool FindDevice(DeviceId address,out DeviceBase device)
 {
     return devices.TryGetValue(address, out device);
 }
Ejemplo n.º 13
0
 /// <summary>
 /// The constructor for the on/off device.
 /// </summary>
 /// <param name="cms"></param>
 /// <param name="id"></param>
 /// <param name="category"></param>
 /// <param name="subcategory"></param>
 public OnOffDevice(InsteonCommunication coms, DeviceId id, byte category, byte subcategory)
     : base(coms, id, category, subcategory)
 {
     this.hasStatus = false;
     this.onLevel = 0;
 }
 public PoolAndSpaDevice(InsteonCommunication coms, DeviceId id, byte category, byte subcategory)
     : base(coms, id, category, subcategory)
 {
 }
Ejemplo n.º 15
0
 public Thermostat(InsteonCommunication coms, DeviceId id, byte category, byte subcategory)
     : base(coms, id, category, subcategory)
 {
 }
Ejemplo n.º 16
0
 private void AddDevice(DeviceId id, byte category, byte subcategory)
 {
     DeviceBase device = this.deviceFactory.CreateDevice(id, category, subcategory);
     this.devices[device.Address] = device;
     log.InfoFormat("Added device {0} called {1}", device.Address.ToString(), device.DeviceName);
     if (DeviceAdded != null)
     {
         DeviceAdded(this, new DeviceChangedEventArgs(device));
     }
 }
 public PowerLineModule(InsteonCommunication coms, DeviceId deviceId, byte category, byte subcategory, byte firmwareVersion)
     : base(coms, deviceId, category, subcategory)
 {
 }
Ejemplo n.º 18
0
 public DimmingLight(InsteonCommunication coms, DeviceId id, byte category, byte subcategory)
     : base(coms, id, category, subcategory)
 {
 }
Ejemplo n.º 19
0
 /// <summary>
 /// All the basic parts of the device, initialized here.
 /// </summary>
 /// <param name="coms"></param>
 /// <param name="deviceId"></param>
 /// <param name="category"></param>
 /// <param name="subcategory"></param>
 public DeviceBase(InsteonCommunication coms, DeviceId deviceId, byte category, byte subcategory)
 {
     this.coms = coms;
     this.deviceId = deviceId;
     this.category = category;
     this.subcategory = subcategory;
     if (DeviceSubcategoryLookup.ContainsKey(category))
     {
         DeviceCategoryData data = DeviceSubcategoryLookup[category];
         if (data.SubCategories.ContainsKey(subcategory))
         {
             this.deviceName = data.SubCategories[subcategory];
         }
         else
         {
             this.deviceName = String.Format(data.DefaultName, subcategory);
         }
     }
     else
     {
         this.deviceName = String.Format("Unknown Device {0:x} sub: {1:x}", category, subcategory);
     }
 }
 /// <summary>
 /// Creates a new standard length command.
 /// </summary>
 /// <param name="id">id to send to</param>
 /// <param name="cmd">Standard command to send</param>
 public InsteonPacket(DeviceId id, Command cmd)
     : this(id, cmd, 0)
 {
 }
 /// <summary>
 /// Creates a new standard length command.
 /// </summary>
 /// <param name="id">id to send to</param>
 /// <param name="cmd">Standard command to send</param>
 public InsteonPacket(DeviceId id, Command cmd)
     : this(id, cmd, 0)
 {
 }