internal InsteonDevice(InsteonNetwork network, InsteonAddress address, InsteonIdentity identity) { this.network = network; Address = address; Identity = identity; ackTimer = new Timer(PendingCommandTimerCallback, null, Timeout.Infinite, Constants.deviceAckTimeout); }
public void VerifyInsteonNetworkTest() { network = new InsteonNetwork(); var connected = network.TryConnect(); Assert.IsTrue(connected); Assert.IsTrue(network.VerifyConnection()); network.Close(); }
public void SimpleConnectAnySerialPortTest() { network = new InsteonNetwork(); var connected = network.TryConnect(); Assert.IsTrue(connected); Assert.AreEqual(network.Connection.Address.Value, InsteonAddress.Parse(ConfigurationManager.AppSettings["plmIdentityTest"]).Value); network.Close(); }
public void TearDown() { if (network != null && network.IsConnected) { network.Close(); } network = null; }
private byte[] sentMessage; // bytes of last sent message, used to match the echo public InsteonMessenger(InsteonNetwork network) { if (network == null) { throw new ArgumentNullException(nameof(network)); } this.network = network; bridge = new InsteonNetworkBridge(this); ControllerProperties = new Dictionary <PropertyKey, int>(); }
private byte[] sentMessage; // bytes of last sent message, used to match the echo public InsteonMessenger(InsteonNetwork network) { if (network == null) { throw new ArgumentNullException(nameof(network)); } this.network = network; bridge = new InsteonNetworkBridge(this); ControllerProperties = new Dictionary<PropertyKey, int>(); }
public void SimpleConnectKnownSerialPortTest() { InsteonConnection connection; Assert.IsTrue(InsteonConnection.TryParse(insteonSource, out connection)); network = new InsteonNetwork(); var connected = network.TryConnect(connection); Assert.IsTrue(connected); Assert.AreEqual(connection.Address.Value, InsteonAddress.Parse(ConfigurationManager.AppSettings["plmIdentityTest"]).Value); network.Close(); }
public void TestNetworkConnection() { var network = new InsteonNetwork(); var connections = network.GetAvailableNetworkConnections(true); foreach (var connection in connections) { if (!network.IsConnected) { network.Connect(connection); } } }
public void TestSerialConnection() { var network = new InsteonNetwork(); var connections = network.GetAvailableSerialConnections(); foreach (var connection in connections) { if (!network.IsConnected) { network.Connect(connection); } Assert.IsTrue(network.IsConnected); } }
public void GetLinksTest() { network = new InsteonNetwork(); var connected = network.TryConnect(); Assert.IsTrue(connected); var links = network.Controller.GetDeviceLinkRecords(); foreach (var link in links) { Console.WriteLine(link.Address + ":" + link.RecordType); } Assert.IsNotEmpty(links); network.Close(); }
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); }
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)); }
public InsteonManager(string insteonSource) { logger.Debug("Creating insteon manager"); InsteonConnection iConnection; if (InsteonConnection.TryParse(insteonSource, out iConnection)) { logger.DebugFormat("Parsed InsteonConnection to {0}", iConnection.ToString()); Connection = iConnection; } else { throw new Exception("Could not create Insteon Connection type from " + insteonSource); } Network = new InsteonNetwork { AutoAdd = true }; }
public void GetLinkIdentityTest() { network = new InsteonNetwork(); var connected = network.TryConnect(); Assert.IsTrue(connected); var links = network.Controller.GetDeviceLinkRecords(); Assert.IsNotEmpty(links); var insteonAddresses = links.Select(l => l.Address).Distinct(); foreach (var insteonAddress in insteonAddresses) { if (network.Devices.ContainsKey(insteonAddress)) { continue; } InsteonIdentity?id; if (network.Controller.TryGetLinkIdentity(insteonAddress, out id)) { if (id != null) { var d = network.Devices.Add(insteonAddress, id.Value); } } else { Console.WriteLine("Possibly a battery powered device."); } } network.Close(); }
internal PowerLincUsbModem(InsteonNetwork network, InsteonAddress address, InsteonIdentity identity) : base(network, address, identity) { }
public void Initalize() { Trace.TraceInformation("Connecting to Insteon..."); this.insteonNetwork = new InsteonNetwork(); this.insteonNetwork.Close(); this.insteonNetwork.AutoAdd = true; this.insteonNetwork.Connect(new InsteonConnection(InsteonConnectionType.Serial, this.usbSerial)); if (!this.insteonNetwork.IsConnected) { Trace.TraceError("Cannot connect to Insteon."); } this.insteonNetwork.Controller.DeviceLinked += (o, d) => { Trace.TraceInformation("DeviceLinked: {0}", d.Device.Address.ToString()); this.insteonNetwork.Controller.CancelLinkMode(); }; this.insteonNetwork.Controller.DeviceLinkTimeout += (o, d) => { Trace.TraceWarning("DeviceLinkTimeout"); this.insteonNetwork.Controller.CancelLinkMode(); }; this.insteonNetwork.Controller.DeviceUnlinked += (o, d) => { Trace.TraceInformation("DeviceUnlinked: {0}", d.Device.Address.ToString()); this.insteonNetwork.Controller.CancelLinkMode(); }; //InsteonDeviceLinkRecord[] knownLinks; //this.insteonNetwork.Controller.TryGetLinks(out knownLinks); foreach (var device in this.settings.Devices) { var d = this.insteonNetwork.Devices.Add(InsteonAddress.Parse(device.ID), new InsteonIdentity()); d.DeviceCommandTimeout += (o, data) => { Trace.TraceWarning("Device command timeout. Device: " + data.Device.Address); }; d.DeviceIdentified += (o, data) => { Trace.TraceInformation("Device identified. Device: " + data.Device.Address); }; d.DeviceStatusChanged += (o, data) => { Trace.TraceInformation("Device status changed. Device: " + data.Device.Address + ", Status: " + data.DeviceStatus); foreach (var dev in this.settings.Devices) { if (data.Device.Address.Value == InsteonAddress.Parse(dev.ID).Value) { switch (data.DeviceStatus) { case InsteonDeviceStatus.Brighten: case InsteonDeviceStatus.Dim: case InsteonDeviceStatus.FastOn: case InsteonDeviceStatus.On: dev.State = "On"; dev.Level = 255; break; case InsteonDeviceStatus.FastOff: case InsteonDeviceStatus.Off: dev.State = "Off"; dev.Level = 0; break; default: dev.State = "Unknown"; dev.Level = 0; break; } break; } } }; deviceList.Add(d); //d.Command(InsteonDeviceCommands.StatusRequest); } //if (this.insteonNetwork.Controller.TryGetLinks(out knownLinks)) //{ // foreach (var link in knownLinks) // { // this.debugOutput.DebugInformation("Adding device id {0}", link.Address); // var d = this.insteonNetwork.Devices.Add(link.Address, new InsteonIdentity()); // d.DeviceCommandTimeout += // (o, data) => // { // this.debugOutput.DebugInformation("Device command timeout. Device: " + data.Device.Address); // }; // d.DeviceIdentified += // (o, data) => // { // this.debugOutput.DebugInformation("Device identified. Device: " + data.Device.Address); // }; // d.DeviceStatusChanged += // (o, data) => // { // this.debugOutput.DebugInformation("Device status changed. Device: " + data.Device.Address + ", Status: " + data.DeviceStatus); // foreach (var de in this.settings.Devices) // if (GetInsteonDevice(de.ID) != null) // { // de.State = data.DeviceStatus == InsteonDeviceStatus.On ? "On" : "Off"; // de.Level = (byte)(data.DeviceStatus == InsteonDeviceStatus.On ? 255 : 0); // break; // } // }; // //d.Command(InsteonDeviceCommands.StatusRequest); // } //} //else //{ // this.debugOutput.DebugError("Cannot get links"); //} }
internal IoLinc(InsteonNetwork network, InsteonAddress address, InsteonIdentity identity) : base(network, address, identity) { }
internal MiniRemote(InsteonNetwork network, InsteonAddress address, InsteonIdentity identity, int buttonCount) : base(network, address, identity) { NumberOfButtons = buttonCount; }
internal LeakSensor(InsteonNetwork network, InsteonAddress address, InsteonIdentity identity) : base(network, address, identity) { }
internal InsteonDeviceList(InsteonNetwork network) { this.network = network; }
internal MotionSensor(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) { }
public NetworkService(InsteonNetwork insteonNetwork) { Network = insteonNetwork; }