public static string GetDeviceLetter(HouseCode code) { switch (code) { case HouseCode.A: return("A"); case HouseCode.B: return("B"); case HouseCode.C: return("C"); case HouseCode.D: return("D"); case HouseCode.E: return("E"); case HouseCode.F: return("F"); case HouseCode.G: return("G"); case HouseCode.H: return("H"); case HouseCode.I: return("I"); case HouseCode.J: return("J"); case HouseCode.K: return("K"); case HouseCode.L: return("L"); case HouseCode.M: return("M"); case HouseCode.N: return("N"); case HouseCode.O: return("O"); case HouseCode.P: return("P"); } throw (new ApplicationException("House Code out of range")); }
public X10ExtendedCommand(HouseCode houseCode) { this.House = houseCode; }
/// <summary> /// Creates the function code <see cref="byte"/> to send to the controller /// </summary> /// <param name="houseCode"><see cref="HouseCode"/></param> /// <param name="functionCode"><see cref="FunctionCode"/></param> /// <returns><see cref="byte"/> to send</returns> private static byte CreateFunctionCode(HouseCode houseCode, FunctionCode functionCode) { BitArray result = new BitArray(8); BitArray ba = new BitArray(new[] { (byte)functionCode }); result[3] = ba[3]; result[2] = ba[2]; result[1] = ba[1]; result[0] = ba[0]; ba = new BitArray(new[] { (byte)houseCode }); result[7] = ba[3]; result[6] = ba[2]; result[5] = ba[1]; result[4] = ba[0]; byte[] byteArray = new byte[(int)Math.Ceiling((double)result.Length / 8)]; result.CopyTo(byteArray, 0); return byteArray[0]; }
/// <summary> /// Creates the address code <see cref="byte"/> to send to the controller /// </summary> /// <param name="houseCode"><see cref="HouseCode"/></param> /// <param name="deviceCode"><see cref="DeviceCode"/></param> /// <returns><see cref="byte"/> to send</returns> private static byte CreateAddressCode(HouseCode houseCode, DeviceCode deviceCode) { // create code BitArray result = new BitArray(8); BitArray ba = new BitArray(new byte[] { (byte)deviceCode }); result[3] = ba[3]; result[2] = ba[2]; result[1] = ba[1]; result[0] = ba[0]; ba = new BitArray(new byte[] { (byte)houseCode }); result[7] = ba[3]; result[6] = ba[2]; result[5] = ba[1]; result[4] = ba[0]; byte[] byteArray = new byte[(int)Math.Ceiling((double)result.Length / 8)]; result.CopyTo(byteArray, 0); return byteArray[0]; }
public static string GetDeviceLetter(HouseCode code) { switch (code) { case HouseCode.A: return "A"; case HouseCode.B: return "B"; case HouseCode.C: return "C"; case HouseCode.D: return "D"; case HouseCode.E: return "E"; case HouseCode.F: return "F"; case HouseCode.G: return "G"; case HouseCode.H: return "H"; case HouseCode.I: return "I"; case HouseCode.J: return "J"; case HouseCode.K: return "K"; case HouseCode.L: return "L"; case HouseCode.M: return "M"; case HouseCode.N: return "N"; case HouseCode.O: return "O"; case HouseCode.P: return "P"; } throw (new ApplicationException("House Code out of range")); }
public X10AddressCommand(HouseCode houseCode, DeviceCode deviceCode) { this.House = houseCode; this.Device = deviceCode; }