public bool Connect() { Disconnect(); insteonPlm = new Plm(this.GetOption("Port").Value); insteonPlm.OnError += insteonPlm_HandleOnError; /* * * //TODO: implement incoming events handling as well: * * insteonPlm.Network.StandardMessageReceived += new StandardMessageReceivedHandler((s, e) => * { * Console.WriteLine("Message received: " + e.Description + ", from " + e.PeerId.ToString()); + }); + + insteonPlm.Network.X10.CommandReceived += new X10CommandReceivedHandler((s, e) => + { + Console.WriteLine("X10 Command Received: House Code " + e.HouseCode + ", Command: " + e.Command.ToString()); + }); + + // TODO: also see: + + insteonPlm.SetButton.PressedAndHeld + insteonPlm.SetButton.ReleasedAfterHolding + insteonPlm.SetButton.UserReset (SET Button Held During Power-up) + insteonPlm.Network.SendStandardCommandToAddress ... + */ if (insteonPlm.Error) { Disconnect(); return(false); } // readerTask = new Thread(() => { while (insteonPlm != null) { insteonPlm.Receive(); System.Threading.Thread.Sleep(100); // wait 100 ms } }); readerTask.Start(); // if (InterfaceModulesChangedAction != null) { InterfaceModulesChangedAction(new InterfaceModulesChangedAction() { Domain = this.Domain }); } return(true); }
private void timerPLMreceive_Tick(object sender, EventArgs e) { powerlineModem.Receive(); }