Esempio n. 1
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();
        }
Esempio n. 2
0
 protected override void OnStop()
 {
     try
     {
         x10.Dispose();
         x10 = null;
         xL.Dispose();
         xL = null;
     }
     catch (Exception ex)
     {
         EventLog.WriteEntry("Unexpected error: " + ex.Message, EventLogEntryType.Error);
     }
 }
Esempio n. 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);
     }
 }
Esempio n. 4
0
        protected override void OnStart(string[] args)
        {
            x10 = X10Comm.Instance;

            xL = new XplListener(VENDORID, DEVICEID, EventLog);

            xL.ConfigItems.Define("comport", "1");
            xL.Filters.Add(new XplListener.XplFilter(xpllib.XplMessageTypes.Command, "*", "*", "*", "x10", "*"));

            //receive Configuration Done notification
            xL.XplConfigDone   += new xpllib.XplListener.XplConfigDoneEventHandler(xL_XplConfigDone);
            xL.XplReConfigDone += new xpllib.XplListener.XplReConfigDoneEventHandler(xL_XplReConfigDone);

            //listen
            xL.XplMessageReceived += new xpllib.XplListener.XplMessageReceivedEventHandler(xL_XplMessageReceived);
            xL.Listen();
        }
Esempio n. 5
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);
     }
 }