public void Integration_test_AllLinkDatabase() { using (var plm = new Plm()) { var database = plm.GetAllLinkDatabase(); Assert.IsFalse(plm.Error); Assert.IsNotNull(database); foreach (var record in database.Records) { Debug.Print("Device Id: {0}", record.DeviceId); DeviceBase device; if (plm.Network.TryConnectToDevice(record.DeviceId, out device)) { Debug.Print("\tAll Link Database"); foreach (var subRecord in device.GetAllLinkDatabase().Records) { Debug.Print("\t\tDevice ID: {0}", subRecord.DeviceId); } if (!device.AllLinkDatabase.Records.Any()) { Debug.Print("\t\tNot paired with any devices!"); } Debug.Print("\tPeer Device Category: {0}", device.DeviceCategory); Debug.Print("\tPeer Device Subcategory: {0}", device.DeviceSubcategory); } else { Debug.Print("\tFailed to connect to device!"); } } } }
private void testDeviceCategory(byte deviceCategory, string name) { var serialPortController = MockRepository.GenerateStub<ISerialPortController>(); var plm = new Plm(serialPortController); var test = buildObjectForTest(plm, 0, 0, 0, deviceCategory, 0, 0); Assert.AreEqual(name, test.DeviceCategory); }
public static DeviceBase BuildDevice(Plm plm, byte[] idRequestResponse) { if (idRequestResponse == null) throw new ArgumentNullException("idRequestResponse"); var deviceId = DeviceMessage.DeviceMessageOriginator(idRequestResponse); byte category = deviceCategory(idRequestResponse); byte subcategory = deviceSubcategory(idRequestResponse); switch (category) { case 0x00: return new GeneralizedController(plm, deviceId, category, subcategory); case 0x01: return new DimmableLightingControl(plm, deviceId, category, subcategory); case 0x02: return new SwitchedLightingControl(plm, deviceId, category, subcategory); case 0x03: return new NetworkBridge(plm, deviceId, category, subcategory); case 0x04: return new IrrigationControl(plm, deviceId, category, subcategory); case 0x05: return new ClimateControl(plm, deviceId, category, subcategory); case 0x06: return new PoolAndSpaControl(plm, deviceId, category, subcategory); case 0x07: return new SensorsActuators(plm, deviceId, category, subcategory); case 0x08: return new HomeEntertainmentControl(plm, deviceId, category, subcategory); case 0x09: return new EnergyManagement(plm, deviceId, category, subcategory); case 0x0A: return new BuiltInApplianceControl(plm, deviceId, category, subcategory); case 0x0B: return new PlumbingControl(plm, deviceId, category, subcategory); case 0x0C: return new CommunicationControl(plm, deviceId, category, subcategory); case 0x0D: return new ComputerControl(plm, deviceId, category, subcategory); case 0x0E: return new WindowCoveringControl(plm, deviceId, category, subcategory); case 0x0F: return new AccessControl(plm, deviceId, category, subcategory); case 0x10: return new SecurityHealthOrSafetyControl(plm, deviceId, category, subcategory); case 0x11: return new SurveillanceControl(plm, deviceId, category, subcategory); case 0x12: return new AutomotiveControl(plm, deviceId, category, subcategory); case 0x13: return new PetCareControl(plm, deviceId, category, subcategory); case 0x14: return new Toy(plm, deviceId, category, subcategory); case 0x15: return new TimekeepingControl(plm, deviceId, category, subcategory); case 0x16: return new HolidayControl(plm, deviceId, category, subcategory); default: return new DeviceBase(plm, deviceId, category, subcategory); } }
public EndTile(Point position, Elec elec, Mech mech, Plm plm, bool isEndTile) : base(position.X, position.Y) { this.IsEndTile = isEndTile; this.Electrical = elec; this.Mechanical = mech; this.Plumbing = plm; }
public EndTile(int x, int y, Elec elec = Elec.positive, Mech mech = Mech.jagged, Plm plm = Plm.open) : base(x, y) { this.IsEndTile = true; this.Electrical = elec; this.Mechanical = mech; this.Plumbing = plm; }
internal DeviceBase(Plm plm, DeviceId deviceId, byte deviceCategory, byte deviceSubcategory) { this.plm = plm; this.deviceId = deviceId; this.DeviceCategoryCode = deviceCategory; this.DeviceSubcategoryCode = deviceSubcategory; }
public static T BuildDeviceForTest <T>(byte deviceCategory, byte deviceSubcategory, ISerialPortController serialPortController, byte peerIdHi, byte peerIdMiddle, byte peerIdLo) where T : DeviceBase { const byte PEER_FIRMWARE = 0x00; const byte MSG_FLAGS = Constants.MSG_FLAGS_BROADCAST; var plm = new Plm(serialPortController); byte[] idRequestResponse = new byte[] { 0x02, 0x50, peerIdHi, peerIdMiddle, peerIdLo, deviceCategory, deviceSubcategory, PEER_FIRMWARE, MSG_FLAGS, 0x01, 0xFF }; return(DeviceFactory.BuildDevice(plm, idRequestResponse) as T); }
internal PoolAndSpaControl(Plm plm, DeviceId deviceId, byte deviceCategory, byte deviceSubcategory) : base(plm, deviceId, deviceCategory, deviceSubcategory) { }
internal CommunicationControl(Plm plm, DeviceId deviceId, byte deviceCategory, byte deviceSubcategory) : base(plm, deviceId, deviceCategory, deviceSubcategory) { }
internal SecurityHealthOrSafetyControl(Plm plm, DeviceId deviceId, byte deviceCategory, byte deviceSubcategory) : base(plm, deviceId, deviceCategory, deviceSubcategory) { }
internal NetworkBridge(Plm plm, DeviceId deviceId, byte deviceCategory, byte deviceSubcategory) : base(plm, deviceId, deviceCategory, deviceSubcategory) { }
internal SwitchedLightingControl(Plm plm, DeviceId deviceId, byte deviceCategory, byte deviceSubcategory) : base(plm, deviceId, deviceCategory, deviceSubcategory) { }
internal ClimateControl(Plm plm, DeviceId deviceId, byte deviceCategory, byte deviceSubcategory) : base(plm, deviceId, deviceCategory, deviceSubcategory) { }
internal HomeEntertainmentControl(Plm plm, DeviceId deviceId, byte deviceCategory, byte deviceSubcategory) : base(plm, deviceId, deviceCategory, deviceSubcategory) { }
internal ComputerControl(Plm plm, DeviceId deviceId, byte deviceCategory, byte deviceSubcategory) : base(plm, deviceId, deviceCategory, deviceSubcategory) { }
internal AutomotiveControl(Plm plm, DeviceId deviceId, byte deviceCategory, byte deviceSubcategory) : base(plm, deviceId, deviceCategory, deviceSubcategory) { }
internal SurveillanceControl(Plm plm, DeviceId deviceId, byte deviceCategory, byte deviceSubcategory) : base(plm, deviceId, deviceCategory, deviceSubcategory) { }
public void Integration_test_GetInfo() { using (var plm = new Plm()) { var info = plm.GetInfo(); Assert.IsFalse(plm.Error); Assert.AreNotEqual(0, info.DeviceCategoryCode); Assert.AreNotEqual(0, info.DeviceSubcategoryCode); Assert.AreNotEqual(0, info.FirmwareVersion); Assert.AreEqual("Network Bridges", info.DeviceCategory); const string pattern = "PowerLinc - (Serial|USB) \\(Dual Band\\) \\[2413[SU]\\]"; Assert.IsTrue(new Regex(pattern).IsMatch(info.DeviceSubcategory)); } }
public void Integration_test_Network() { // This test requires a device at peerId attached to your Insteon Network // If you don't have one, just disable or disregard this test. using (var plm = new Plm()) { DeviceBase device; Assert.IsTrue(plm.Network .TryConnectToDevice(peerId, out device)); Assert.IsNotNull(device); Assert.AreEqual(peerId, device.DeviceId); Debug.Print("Network integration test - Peer Device info:"); Debug.Print("Device Id: {0}", device.DeviceId.ToString()); Debug.Print("Peer Device Category: {0}", device.DeviceCategory); Debug.Print("Peer Device Subcategory: {0}", device.DeviceSubcategory); // test Ping Assert.IsTrue(device.Ping()); // Device category-specific integration testing if (device is LightingControl) { Integration_test_LightingDevice(device as LightingControl); } } }
public void Integration_test_LED() { using (var plm = new Plm()) { plm.Led .EnableManualControl() .TurnOn(); Assert.IsTrue(plm.GetConfiguration().ManualLedControl); Thread.Sleep(250); plm.Led .TurnOff() .DisableManualControl(); Assert.IsFalse(plm.GetConfiguration().ManualLedControl); Assert.IsFalse(plm.Error); } }
internal WindowCoveringControl(Plm plm, DeviceId deviceId, byte deviceCategory, byte deviceSubcategory) : base(plm, deviceId, deviceCategory, deviceSubcategory) { }
internal SensorsActuators(Plm plm, DeviceId deviceId, byte deviceCategory, byte deviceSubcategory) : base(plm, deviceId, deviceCategory, deviceSubcategory) { }
internal EnergyManagement(Plm plm, DeviceId deviceId, byte deviceCategory, byte deviceSubcategory) : base(plm, deviceId, deviceCategory, deviceSubcategory) { }
internal BuiltInApplianceControl(Plm plm, DeviceId deviceId, byte deviceCategory, byte deviceSubcategory) : base(plm, deviceId, deviceCategory, deviceSubcategory) { }
private static PlmInfo buildObjectForTest(Plm plm, byte idHi, byte idMiddle, byte idLo, byte deviceCategory, byte deviceSubcategory, byte firmwareRevision) { return new PlmInfo(plm, new byte[] { 0, 0, idHi, idMiddle, idLo, deviceCategory, deviceSubcategory, firmwareRevision, 0 }); }
internal TimekeepingControl(Plm plm, DeviceId deviceId, byte deviceCategory, byte deviceSubcategory) : base(plm, deviceId, deviceCategory, deviceSubcategory) { }
internal Toy(Plm plm, DeviceId deviceId, byte deviceCategory, byte deviceSubcategory) : base(plm, deviceId, deviceCategory, deviceSubcategory) { }
internal GeneralizedController(Plm plm, DeviceId deviceId, byte deviceCategory, byte deviceSubcategory) : base(plm, deviceId, deviceCategory, deviceSubcategory) { }
internal DimmableLightingControl(Plm plm, DeviceId deviceId, byte deviceCategory, byte deviceSubcategory) : base(plm, deviceId, deviceCategory, deviceSubcategory) { }
public void ToggleTile(MouseEventArgs e) { MouseButtons mouseButton = e.Button; int direction = 0; if (mouseButton.Equals(MouseButtons.Left) == true) { direction = 1; } if (mouseButton.Equals(MouseButtons.Right) == true) { direction = -1; } int current; int next; Array allValues; switch (Program.puzzleType) { case Program.PuzzleType.Elec: current = (int)Electrical; allValues = Enum.GetValues(typeof(Elec)); next = current + direction; if (next < 0) { next += allValues.Length; } next %= allValues.Length; Electrical = (Elec)allValues.GetValue(next); break; case Program.PuzzleType.Mech: current = (int)Mechanical; allValues = Enum.GetValues(typeof(Mech)); next = current + direction; if (next < 0) { next += allValues.Length; } next %= allValues.Length; Mechanical = (Mech)allValues.GetValue(next); break; case Program.PuzzleType.Plm: current = (int)Plumbing; allValues = Enum.GetValues(typeof(Plm)); next = current + direction; if (next < 0) { next += allValues.Length; } next %= allValues.Length; Plumbing = (Plm)allValues.GetValue(next); break; } }
public DimmableKeyPadLightingControl(Plm plm, DeviceId deviceId, byte category, byte subcategory) : base(plm, deviceId, category, subcategory) { }
public SwitchedKeyPadLightingControl(Plm plm, DeviceId deviceId, byte category, byte subcategory) : base(plm, deviceId, category, subcategory) { }