Example #1
0
 private void xL_XplReConfigDone(object sender)
 {
     try
     {
         if (mComPort != Int32.Parse(xL.ConfigItems["comport"].Item))
         {
             //the COM port changed
             if (x10!=null) x10.Dispose();
             x10 = X10Comm.Instance;
             InitCM11();
         }
     }
     catch (Exception ex)
     {
         EventLog.WriteEntry("Illegal COM-port value.\n" + ex.Message);
     }
 }
Example #2
0
        protected override void OnStart(string[] args)
        {
            x10 = X10Comm.Instance;

            xPL_Base.xPLErrorEventLog = EventLog;
            try
            {
                // Recreate device from settings
                xL = new xPLDevice(Properties.Settings.Default.strDeviceState, false);
            }
            catch
            {
                // recreate failed, so create a new one
                xL = new xPLDevice();
                xL.Configurable = true;
                xL.VendorID = VENDORID;
                xL.DeviceID = DEVICEID;
                xL.InstanceIDType = xPL_Base.InstanceCreation.Randomized;

                xL.ConfigItems.Add("comport", "1", xPL_Base.xPLConfigTypes.xReconf, 1);
            }

            //receive Configuration Done notification
            xL.xPLConfigDone += new xPLDevice.xPLConfigDoneEventHandler(xL_XplConfigDone);
            xL.xPLReConfigDone += new xPLDevice.xPLReConfigDoneEventHandler(xL_XplReConfigDone);
            xL.xPLMessageReceived += new xPLDevice.xPLMessageReceivedEventHandler(xL_XplMessageReceived);
            // If config was already done, startup COM port
            if (xL.Configured == true)
            {
                xL_XplConfigDone(null);
            }
            // Startup xPL Communications
            xL.Enable();
        }
Example #3
0
 protected override void OnStop()
 {
     try
     {
         Properties.Settings.Default.strDeviceState = xL.GetState("1.0");
         x10.Dispose();
         x10 = null;
         xL.Dispose();
         xL = null;
     }
     catch (Exception ex)
     {
         EventLog.WriteEntry("Unexpected error: " + ex.Message, EventLogEntryType.Error);
     }
 }