Ejemplo n.º 1
0
        void initializeXPL()
        {
            xL = new XplListener(VENDORID, DEVICEID);

            //definition of the configuration items
            xL.ConfigItems.Define("showsecs", mShowSecs.ToString());
            xL.ConfigItems.Define("fadeinmsecs", mFadeInMSecs.ToString());
            xL.ConfigItems.Define("fadeoutmsecs", mFadeOutMSecs.ToString());
            xL.ConfigItems.Define("usefading", mUseFading.ToString());
            xL.ConfigItems.Define("appfilter", 16);   //multi-valued

            //default filter value
            xL.Filters.Add(new XplListener.XplFilter(XplMessageTypes.Any, "*", "*", "*", "log", "basic"));

            //possibly show also msgs not intended for us
            xL.Filters.MatchTarget = false;

            //prepare to receive events
            xL.XplConfigDone       += new XplListener.XplConfigDoneEventHandler(xL_XplConfigDone);
            xL.XplJoinedxPLNetwork += new XplListener.XplJoinedxPLNetworkEventHandler(xL_XplJoinedxPLNetwork);
            xL.XplReConfigDone     += new XplListener.XplReConfigDoneEventHandler(xL_XplReConfigDone);
            xL.XplMessageReceived  += new XplListener.XplMessageReceivedEventHandler(xL_XplMessageReceived);

            //connect to the xpl network
            xL.Listen();
        }
Ejemplo n.º 2
0
 public void Initialize()
 {
     if (this._IsDisabled)
     {
         Log.Info("xPL_Connector.Initialize(): DRIVER DISABLED!");
     }
     else
     {
         this._lines[0] = string.Empty;
         this._lines[1] = string.Empty;
         Log.Info("xPL_Connector.Initialize(): called");
         this.Listener = new XplListener(this.mVendorID + "-" + this.mDeviceID, 1);
         Log.Info("xPL_Connector.Initialize(): waiting to join xPL network. (Awaiting config = {0})",
                  new object[] { this.Listener.AwaitingConfiguration });
         if (this.Listener.AwaitingConfiguration)
         {
             this.Listener.ConfigItems.Add("newconf", "", xplConfigTypes.xReconf);
             this.Listener.ConfigItems.Add("interval", "", xplConfigTypes.xOption);
         }
         this.Listener.XplMessageReceived +=
             new XplListener.XplMessageReceivedEventHandler(this.Listener_XplMessageReceived);
         this.Listener.XplJoinedxPLNetwork +=
             new XplListener.XplJoinedxPLNetworkEventHandler(this.Listener_XplJoinedxPLNetwork);
         this.Listener.Listen();
         int num = 0x7530;
         while (!this.Listener.JoinedxPLNetwork)
         {
             Log.Info("xPL_Connector.Initialize(): waiting to join the xPL network");
             Thread.Sleep(100);
             num -= 100;
             if (num < 0)
             {
                 break;
             }
         }
         if (!this.Listener.JoinedxPLNetwork)
         {
             Log.Info("xPL_Connector.Initialize(): Could NOT join the xPL network");
         }
         else
         {
             this._IsConnected = true;
         }
         if (this._IsConnected)
         {
             AdvancedSettings.OnSettingsChanged +=
                 new AdvancedSettings.OnSettingsChangedHandler(this.AdvancedSettings_OnSettingsChanged);
             this.Clear();
         }
         this.mInstanceID = this.Listener.InstanceName;
         Log.Info("xPL_Connector.Initialize(): completed");
     }
 }
Ejemplo n.º 3
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);
     }
 }
Ejemplo n.º 4
0
        public void Send(IPEndPoint ep)
        {
            Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);

            socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.Broadcast, 1);
            string ipString = XplListener.sListenOnIP();

            if (!ipString.Equals("ANY_LOCAL"))
            {
                IPEndPoint localEP = new IPEndPoint(IPAddress.Parse(ipString), 0);
                socket.Bind(localEP);
            }
            socket.SendTo(Encoding.ASCII.GetBytes(this.XPL_Raw), ep);
            socket.Close();
        }
Ejemplo n.º 5
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();
        }
Ejemplo n.º 6
0
        protected override void OnStart(string[] args)
        {
            MsgCache    = new XplMsg[MSGCACHESIZE];
            MsgCacheIn  = new DateTime[MSGCACHESIZE];
            MsgCacheIdx = 0;
            xL          = new XplListener(VENDORID, DEVICEID, EventLog);

            xL.ConfigItems.Define("loglen", DEFAULTLOGSIZE.ToString());
            xL.ConfigItems.Define("lpath", @"c:\temp\");
            xL.ConfigItems.Define("xml", "log.xml");
            xL.ConfigItems.Define("xsl", "log.xsl");
            xL.ConfigItems.Define("out", "log.htm");
            xL.ConfigItems.Define("appfilter", 16);   //multi-valued

            xL.Filters.Add(new XplListener.XplFilter(XplMessageTypes.Trigger, "*", "*", "*", "log", "basic"));

            //log also msgs not intended for us
            xL.Filters.MatchTarget = false;

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

            //receive reconfiguration done
            xL.XplReConfigDone += new xpllib.XplListener.XplReConfigDoneEventHandler(xL_XplReConfigDone);

            //start listening
            xL.XplMessageReceived += new xpllib.XplListener.XplMessageReceivedEventHandler(xL_XplMessageReceived);
            xL.Listen();

            if (!xL.AwaitingConfiguration)
            {
                EventLog.WriteEntry(DEVICEID + " started logging to " + mPath + mXML, EventLogEntryType.Information);
            }
            else
            {
                EventLog.WriteEntry(DEVICEID + " started, awaiting configuration", EventLogEntryType.Information);
            }
        }
Ejemplo n.º 7
0
 private void xL_XplReConfigDone(XplListener.XplLoadStateEventArgs e)
 {
     CheckConfig();
 }
Ejemplo n.º 8
0
        protected override void OnStart(string[] args)
        {
            MsgCache = new XplMsg[MSGCACHESIZE];
            MsgCacheIn = new DateTime[MSGCACHESIZE];
            MsgCacheIdx = 0;
            xL = new XplListener(VENDORID, DEVICEID, EventLog);

            xL.ConfigItems.Define("loglen", DEFAULTLOGSIZE.ToString());
            xL.ConfigItems.Define("lpath", @"c:\temp\");
            xL.ConfigItems.Define("xml", "log.xml");
            xL.ConfigItems.Define("xsl", "log.xsl");
            xL.ConfigItems.Define("out", "log.htm");
            xL.ConfigItems.Define("appfilter", 16);   //multi-valued

            xL.Filters.Add(new XplListener.XplFilter(XplMessageTypes.Trigger, "*", "*", "*", "log", "basic"));

            //log also msgs not intended for us
            xL.Filters.MatchTarget = false;

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

            //receive reconfiguration done
            xL.XplReConfigDone += new xpllib.XplListener.XplReConfigDoneEventHandler(xL_XplReConfigDone);

            //start listening
            xL.XplMessageReceived += new xpllib.XplListener.XplMessageReceivedEventHandler(xL_XplMessageReceived);
            xL.Listen();

            if (!xL.AwaitingConfiguration)
                EventLog.WriteEntry(DEVICEID + " started logging to " + mPath + mXML, EventLogEntryType.Information);
            else
                EventLog.WriteEntry(DEVICEID + " started, awaiting configuration", EventLogEntryType.Information);
        }
Ejemplo n.º 9
0
        private void xL_XplMessageReceived(object sender, XplListener.XplEventArgs e)
        {
            try
            {
                //maybe it should be ignored
                if ((mFilterApps.Count > 0)
                    && (mFilterApps.ContainsKey(e.XplMsg.SourceVendor + "." + e.XplMsg.SourceDevice)))
                {
                    string lvls = (string)mFilterApps[e.XplMsg.SourceVendor + "." + e.XplMsg.SourceDevice];
                    bool foundKey = false;
                    bool foundMatch = false;
                    foreach (XplMsg.KeyValuePair kv in e.XplMsg.KeyValues)
                    {
                        if(lvls.IndexOf(kv.Key + "=") >=0)
                        {
                            foundKey = true;
                            if (lvls.IndexOf(kv.Key + "=" + kv.Value.ToLower()) >= 0)
                            {
                                foundMatch = true;
                                break;
                            }
                        }
                    }

                    if (foundKey && !foundMatch)
                        return;
                }

                string title = "";
                string txt = "";
                int level = 0;
                int delay = mShowSecs;
                string othertxt = "";
                bool isOsdBasic = ((e.XplMsg.Type.ToLower() == "osd") && (e.XplMsg.Class.ToLower() == "basic"));

                foreach (XplMsg.KeyValuePair kv in e.XplMsg.KeyValues)
                    {

                    switch (kv.Key.ToLower())
                    {
                        case "title":
                            title = kv.Value;
                            break;

                        case "type":
                            switch (kv.Value.ToLower())
                            {
                                case "err": level = 2;
                                    break;
                                case "wrn": level = 1;
                                    break;
                                case "inf": level = 0;
                                    break;
                                default:
                                    othertxt += kv.Key + "=" + kv.Value + "\n";
                                    level = 0;
                                    break;
                            }
                            break;

                        case "text":
                            txt += kv.Value + "\n";
                            break;

                        case "delay":
                            if (!Int32.TryParse(kv.Value, out delay))
                                delay = mShowSecs;
                            break;

                        case "command":
                            if (!isOsdBasic)
                                othertxt += kv.Key + "=" + kv.Value + "\n";
                            break;

                        case "row":
                            if (!isOsdBasic)
                                othertxt += kv.Key + "=" + kv.Value + "\n";
                            break;

                        case "column":
                            if (!isOsdBasic)
                                othertxt += kv.Key + "=" + kv.Value + "\n";
                            break;

                        default:
                            othertxt += kv.Key + "=" + kv.Value + "\n";
                            break;
                    }
                }

                if (title.Length == 0)
                    title = "xPL message (" + e.XplMsg.Class + "." + e.XplMsg.Type + ")";

                if (othertxt.Length > 0)
                    if (txt.Length > 0)
                        txt += "\n" + othertxt;
                    else
                        txt = othertxt;

                ShowMsg(title, txt, level, delay);
            }
            catch (Exception ex)
            {
                //MessageBox.Show(ex.Message);
                eventLog.WriteEntry("Unable to show balloon: " + ex.Message, EventLogEntryType.Error);
            }
        }
Ejemplo n.º 10
0
        void initializeXPL()
        {
            xL = new XplListener(VENDORID, DEVICEID);

            //definition of the configuration items
            xL.ConfigItems.Define("showsecs", mShowSecs.ToString());
            xL.ConfigItems.Define("fadeinmsecs", mFadeInMSecs.ToString());
            xL.ConfigItems.Define("fadeoutmsecs", mFadeOutMSecs.ToString());
            xL.ConfigItems.Define("usefading", mUseFading.ToString());
            xL.ConfigItems.Define("appfilter", 16);   //multi-valued

            //default filter value
            xL.Filters.Add(new XplListener.XplFilter(XplMessageTypes.Any, "*", "*", "*", "log", "basic"));

            //possibly show also msgs not intended for us
            xL.Filters.MatchTarget = false;

            //prepare to receive events
            xL.XplConfigDone += new XplListener.XplConfigDoneEventHandler(xL_XplConfigDone);
            xL.XplJoinedxPLNetwork += new XplListener.XplJoinedxPLNetworkEventHandler(xL_XplJoinedxPLNetwork);
            xL.XplReConfigDone += new XplListener.XplReConfigDoneEventHandler(xL_XplReConfigDone);
            xL.XplMessageReceived += new XplListener.XplMessageReceivedEventHandler(xL_XplMessageReceived);

            //connect to the xpl network
            xL.Listen();
        }