Example #1
0
        public void parseRecords(string str, StateObject state)
        {
            if (str.StartsWith("cmd=evtNtf"))
            {
                //cmd=evtNtf&batchEnd=yes
                if (str.Contains("batchEnd=yes"))
                {
                    saveToLogVerbose("BatchEnd Found");
                    OnTagListEvent(new TagListEventArgs(state.list));
                    state.list.Clear();
                    OnBatchEnd(new BatchEndEventArgs(DateTime.Now.ToString()));
                    return;
                }

                //cmd=evtNtf&evt_id=TagfoundAction&msg=invenDisabled&trig=irNotfound&time=1175329956
                if (str.Contains("msg="))
                {
                    INVENTORY_NTF_INFO info = new INVENTORY_NTF_INFO();
                    string[] Invkeys = str.Split('&');
                    foreach (string s in Invkeys)
                    {
                        if (s.StartsWith("evt_id=", StringComparison.OrdinalIgnoreCase))
                        {
                            info.id = s.Substring(7);
                        }
                        else if (s.StartsWith("msg=", StringComparison.OrdinalIgnoreCase))
                        {
                            info.msg = s.Substring(4);
                        }
                        else if (s.StartsWith("trig=", StringComparison.OrdinalIgnoreCase))
                        {
                            info.trigger = s.Substring(5);
                        }
                        else if (s.StartsWith("time=", StringComparison.OrdinalIgnoreCase))
                        {
                            info.time = s.Substring(5);
                        }
                    }
                    saveToLogVerbose(String.Format("{0} {1} Found", info.id, info.msg));
                    OnInventory(new InventoryEventArgs(info));
                    return;
                }

                //cmd=evtNtf&evt_id=DemoEvent&src_ip=192.168.25.249&ant=Antenna1&cp_id=Capture Point 1&idx=B1&tag_id=100000000000000000000004&rssi=-48&time=1173077508
                TAG intag = new TAG();
                string[] keys = str.Split('&');
                foreach (string s in keys)
                {
                    if (s.StartsWith("evt_id=", StringComparison.OrdinalIgnoreCase))
                    {
                        intag.EventId = s.Substring(7);
                    }
                    else if (s.StartsWith("src_ip=", StringComparison.OrdinalIgnoreCase))
                    {
                        intag.ServerIp = s.Substring(7);
                    }
                    else if (s.StartsWith("ant=", StringComparison.OrdinalIgnoreCase))
                    {
                        intag.Antenna = s.Substring(4);
                    }
                    else if (s.StartsWith("cp_id=", StringComparison.OrdinalIgnoreCase))
                    {
                        intag.CapturePointId = s.Substring(6);
                    }
                    else if (s.StartsWith("idx=", StringComparison.OrdinalIgnoreCase))
                    {
                        if (s.Length > 5)
                        {
                            intag.Index = s.Substring(5);
                            intag.session = s.Substring(4, 1);
                        }
                    }
                    else if (s.StartsWith("tag_id=", StringComparison.OrdinalIgnoreCase))
                    {
                        intag.TagOrigId = s.Substring(7);
                    }
                    else if (s.StartsWith("rssi=", StringComparison.OrdinalIgnoreCase))
                    {
                        double.TryParse(s.Substring(5), out intag.RSSI);
                    }
                    else if (s.StartsWith("time=", StringComparison.OrdinalIgnoreCase))
                    {
                        Int32.TryParse(s.Substring(5), out intag.Time);
                    }
                    else if (s.StartsWith("cnt=", StringComparison.OrdinalIgnoreCase))
                    {
                        Int32.TryParse(s.Substring(4), out intag.count);
                    }
                    else if (s.StartsWith("bank0=", StringComparison.OrdinalIgnoreCase))
                    {
                        intag.Bank0 = s.Substring(6);
                    }
                    else if (s.StartsWith("bank2=", StringComparison.OrdinalIgnoreCase))
                    {
                        intag.Bank2 = s.Substring(6);
                    }
                    else if (s.StartsWith("bank3=", StringComparison.OrdinalIgnoreCase))
                    {
                        intag.Bank3 = s.Substring(6);
                    }

                }
                intag.ApiTimeStampUTC = DateTime.UtcNow;
                OnTagReceiveEvent(new TagReceiveEventArgs(intag));
                state.list.Add(intag);
            }
            else if (str.StartsWith("cmd=blog"))
            {
                //cmd=blogNtf&dataEnd=yes
                if (str.Contains("dataEnd=yes"))
                {
                    saveToLogVerbose("DataEnd Found");
                    OnDataEnd(new DataEndEventArgs(DateTime.Now.ToString()));
                    return;
                }
                //cmd=blogNtf&evt_id=DemoEvent&src_ip=192.168.25.249&ant=Antenna1&cp_id=Capture Point 1&idx=C31&tag_id=000000000000000000000006&rssi=-49&time=1173076720
            }
            else if (str.StartsWith("cmd=errNtf"))
            {
                //cmd=errNtf&status=buffer overflow&time=1173076720
                string status = null;
                string time = null;

                string[] keys = str.Split('&');
                foreach (string s in keys)
                {
                    if (s.StartsWith("status=", StringComparison.OrdinalIgnoreCase))
                    {
                        if (s.Length > 7)
                            status = s.Substring(7);
                    }
                    else if (s.StartsWith("time=", StringComparison.OrdinalIgnoreCase))
                    {
                        if (s.Length > 5)
                            time = s.Substring(5);
                    }
                }
                if (status.Equals("buffer overflow", StringComparison.OrdinalIgnoreCase))
                {
                    saveToLogVerbose("BufferOverflow Found");
                    OnBufferOverflowEvent(new BufferOverflowEventArgs(time));
                    return;
                }
            }
            else if (str.StartsWith("cmd=antNtf"))
            {
                //cmd=antNtf&mismatch=1234&time=1173076720
                string port = null;
                string time = null;

                string[] keys = str.Split('&');
                foreach (string s in keys)
                {
                    if (s.StartsWith("mismatch=", StringComparison.OrdinalIgnoreCase))
                    {
                        if (s.Length > 9)
                            port = s.Substring(9);
                    }
                    else if (s.StartsWith("time=", StringComparison.OrdinalIgnoreCase))
                    {
                        if (s.Length > 5)
                            time = s.Substring(5);
                    }
                }
                saveToLogVerbose("AntennaNtf Found");
                OnAntennaEvent(new AntennaEventArgs(port, time));
            }
        }
Example #2
0
 public InventoryEventArgs(INVENTORY_NTF_INFO o)
 {
     info = (object)o;
 }