Ejemplo n.º 1
0
 /// <summary>
 /// Creates an object based on the raw data
 /// received from Get IM Info call
 /// </summary>
 /// <param name="received">Should be 9 bytes</param>
 internal PlmInfo(Plm plm, byte[] received)
     : base(plm, new DeviceId(received[2], received[3], received[4]), received[5], received[6])
 {
     if (received == null) throw new ArgumentNullException("received");
     if (received.Length != 9) throw new ArgumentOutOfRangeException("received");
     this.FirmwareVersion = received[7];
 }
Ejemplo n.º 2
0
 internal PlmNetworkX10(Plm plm)
 {
     if (plm == null)
     {
         throw new ArgumentNullException("plm");
     }
     this.plm = plm;
 }
Ejemplo n.º 3
0
 internal PlmSetButton(Plm plm)
 {
     if (plm == null)
     {
         throw new ArgumentNullException("plm");
     }
     this.plm = plm;
 }
Ejemplo n.º 4
0
        internal PlmInfo getIMInfo(Plm plm)
        {
            var result = this.serialPortController.SendReceive(new byte[] { 0x02, 0x60 }, 9);

            assertReceived(result, 0, 0x02);
            assertReceived(result, 1, 0x60);
            assertACK(result, 8);
            return(new PlmInfo(plm, result));
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Creates an object based on the raw data
 /// received from Get IM Info call
 /// </summary>
 /// <param name="received">Should be 9 bytes</param>
 internal PlmInfo(Plm plm, byte[] received)
     : base(plm, new DeviceId(received[2], received[3], received[4]), received[5], received[6])
 {
     if (received == null)
     {
         throw new ArgumentNullException("received");
     }
     if (received.Length != 9)
     {
         throw new ArgumentOutOfRangeException("received");
     }
     this.FirmwareVersion = received[7];
 }
Ejemplo n.º 6
0
        internal static string DiscoverComPort()
        {
            string[] theSerialPortNames = System.IO.Ports.SerialPort.GetPortNames();
            foreach (var serialPort in theSerialPortNames)
            {
                using (var plm = new Plm(serialPort))
                {
                    plm.GetInfo();
                    if (!plm.Error)
                    {
                        return(serialPort);
                    }
                }
            }

            throw new Exception("No PLM was found.  Please make sure your PLM is plugged in to power and your serial/USB port.");
        }
 internal PlmNetworkX10(Plm plm)
 {
     if (plm == null) throw new ArgumentNullException("plm");
     this.plm = plm;
 }
            private DateTime lastSendTime = DateTime.MinValue; // have to delay sending between messages

            #endregion Fields

            #region Constructors

            internal HouseContext(Plm plm, string houseCode)
            {
                this.plm = plm;
                this.houseCode = houseCode;
            }
 internal PlmInfo getIMInfo(Plm plm)
 {
     var result = this.serialPortController.SendReceive(new byte[] { 0x02, 0x60 }, 9);
     assertReceived(result, 0, 0x02);
     assertReceived(result, 1, 0x60);
     assertACK(result, 8);
     return new PlmInfo(plm, result);
 }
Ejemplo n.º 10
0
        internal static string DiscoverComPort()
        {
            string[] theSerialPortNames = System.IO.Ports.SerialPort.GetPortNames();
              foreach (var serialPort in theSerialPortNames)
              {
            using (var plm = new Plm(serialPort))
            {
              plm.GetInfo();
              if (!plm.Error)
              {
                return serialPort;
              }
            }
              }

              throw new Exception("No PLM was found.  Please make sure your PLM is plugged in to power and your serial/USB port.");
        }
Ejemplo n.º 11
0
 public void Disconnect()
 {
     if (insteonPlm != null)
     {
         insteonPlm.OnError -= insteonPlm_HandleOnError;
         try { insteonPlm.Dispose(); } catch { }
         insteonPlm = null;
     }
     if (readerTask != null)
     {
         try { readerTask.Abort(); } catch { }
         readerTask = null;
     }
 }
Ejemplo n.º 12
0
        public bool Connect()
        {
            Disconnect();
            insteonPlm = new Plm(this.GetOption("Port").Value);
            insteonPlm.OnError += insteonPlm_HandleOnError;
            /* 

            // other events:

            insteonPlm.SetButton.PressedAndHeld
            insteonPlm.SetButton.ReleasedAfterHolding
            insteonPlm.SetButton.UserReset (SET Button Held During Power-up)

            insteonPlm.Network.StandardMessageReceived
                += new StandardMessageReceivedHandler((s, e) =>
            {
                Console.WriteLine("Message received: " + e.Description
                    + ", from " + e.PeerId.ToString());
            });


            // also see:
            insteonPlm.Network.X10.CommandReceived
            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;
        }
Ejemplo n.º 13
0
 internal PlmSetButton(Plm plm)
 {
     if (plm == null) throw new ArgumentNullException("plm");
     this.plm = plm;
 }
Ejemplo n.º 14
0
 /// <summary>
 /// Creates an object with all values zero
 /// </summary>
 internal PlmInfo(Plm plm)
     : base(plm, new DeviceId(0,0,0), 0, 0)
 {
 }
Ejemplo n.º 15
0
            private DateTime lastSendTime = DateTime.MinValue; // have to delay sending between messages

            internal HouseContext(Plm plm, string houseCode)
            {
                this.plm       = plm;
                this.houseCode = houseCode;
            }
Ejemplo n.º 16
0
 /// <summary>
 /// Creates an object with all values zero
 /// </summary>
 internal PlmInfo(Plm plm) : base(plm, new DeviceId(0, 0, 0), 0, 0)
 {
 }