Example #1
0
        public new static MSG_RO_ACCESS_REPORT FromString(string str)
        {
            string val;

            XmlDocument xdoc = new XmlDocument();
            xdoc.LoadXml(str);
            XmlNode node = (XmlNode)xdoc.DocumentElement;

            MSG_RO_ACCESS_REPORT msg = new MSG_RO_ACCESS_REPORT();
            try { msg.MSG_ID = Convert.ToUInt32(XmlUtil.GetNodeAttrValue(node, "MessageID")); }
            catch { }


            try
            {

                XmlNodeList xnl = XmlUtil.GetXmlNodes(node, "TagReportData");
                if (null != xnl)
                {
                    if (xnl.Count != 0)
                    {
                        msg.TagReportData = new PARAM_TagReportData[xnl.Count];
                        for (int i = 0; i < xnl.Count; i++)
                            msg.TagReportData[i] = PARAM_TagReportData.FromXmlNode(xnl[i]);
                    }
                }

            }
            catch
            {
                //int i = 0;
            }

            try
            {

                XmlNodeList xnl = XmlUtil.GetXmlNodes(node, "RFSurveyReportData");
                if (null != xnl)
                {
                    if (xnl.Count != 0)
                    {
                        msg.RFSurveyReportData = new PARAM_RFSurveyReportData[xnl.Count];
                        for (int i = 0; i < xnl.Count; i++)
                            msg.RFSurveyReportData[i] = PARAM_RFSurveyReportData.FromXmlNode(xnl[i]);
                    }
                }

            }
            catch { }

            try
            {

                ArrayList xnl = XmlUtil.GetXmlNodeCustomChildren(node);
                if (null != xnl)
                {
                    if (xnl.Count != 0)
                    {
                        for (int i = 0; i < xnl.Count; i++)
                        {
                            ICustom_Parameter custom = CustomParamDecodeFactory.DecodeXmlNodeToCustomParameter((XmlNode)xnl[i]);
                            if (custom != null) msg.AddCustomParameter(custom);
                        }
                    }
                }

            }
            catch { }

            return msg;
        }
Example #2
0
        public new static MSG_RO_ACCESS_REPORT FromBitArray(ref BitArray bit_array, ref int cursor, int length)
        {
            if (cursor > length) return null;

            int field_len = 0;
            object obj_val;
            ArrayList param_list = new ArrayList();

            MSG_RO_ACCESS_REPORT obj = new MSG_RO_ACCESS_REPORT();

            int msg_type = 0;
            cursor += 6;
            msg_type = (int)(UInt64)Util.CalculateVal(ref bit_array, ref cursor, 10);

            if (msg_type != obj.msgType)
            {
                cursor -= 16;
                return null;
            }

            obj.msgLen = (UInt32)(UInt64)Util.CalculateVal(ref bit_array, ref cursor, 32);
            obj.msgID = (UInt32)(UInt64)Util.CalculateVal(ref bit_array, ref cursor, 32);


            param_list = new ArrayList();
            PARAM_TagReportData _param_TagReportData = PARAM_TagReportData.FromBitArray(ref bit_array, ref cursor, length);
            if (_param_TagReportData != null)
            {
                param_list.Add(_param_TagReportData);
                while ((_param_TagReportData = PARAM_TagReportData.FromBitArray(ref bit_array, ref cursor, length)) != null) param_list.Add(_param_TagReportData);
                if (param_list.Count > 0)
                {
                    obj.TagReportData = new PARAM_TagReportData[param_list.Count];
                    for (int i = 0; i < param_list.Count; i++)
                        obj.TagReportData[i] = (PARAM_TagReportData)param_list[i];
                }
            }

            param_list = new ArrayList();
            PARAM_RFSurveyReportData _param_RFSurveyReportData = PARAM_RFSurveyReportData.FromBitArray(ref bit_array, ref cursor, length);
            if (_param_RFSurveyReportData != null)
            {
                param_list.Add(_param_RFSurveyReportData);
                while ((_param_RFSurveyReportData = PARAM_RFSurveyReportData.FromBitArray(ref bit_array, ref cursor, length)) != null) param_list.Add(_param_RFSurveyReportData);
                if (param_list.Count > 0)
                {
                    obj.RFSurveyReportData = new PARAM_RFSurveyReportData[param_list.Count];
                    for (int i = 0; i < param_list.Count; i++)
                        obj.RFSurveyReportData[i] = (PARAM_RFSurveyReportData)param_list[i];
                }
            }

            ICustom_Parameter custom = CustomParamDecodeFactory.DecodeCustomParameter(ref bit_array, ref cursor, length);
            if (custom != null)
            {
                obj.Custom.Add(custom);
                while ((custom = CustomParamDecodeFactory.DecodeCustomParameter(ref bit_array, ref cursor, length)) != null) obj.Custom.Add(custom);
            }

            return obj;
        }
Example #3
0
        protected void TriggerRoAccessReport(MSG_RO_ACCESS_REPORT msg)
        {
            try
            {
                if (OnRoAccessReportReceived != null) OnRoAccessReportReceived(msg);
                if (OnEncapedRoAccessReportReceived != null)
                {
                    ENCAPED_RO_ACCESS_REPORT report = new ENCAPED_RO_ACCESS_REPORT();
                    report.reader = reader_name;
                    report.report = msg;

                    OnEncapedRoAccessReportReceived(report);
                }
            }
            catch { }
        }
Example #4
0
        private string ParseTag(MSG_RO_ACCESS_REPORT msg, string result, int i)
        {
            if (msg.TagReportData[i].EPCParameter.Count > 0)
            {
                string epcInfo = "";
                Type t = msg.TagReportData[i].EPCParameter[0].GetType();
                if (t.Name == "PARAM_EPC_96")
                    epcInfo = ((PARAM_EPC_96)(msg.TagReportData[i].EPCParameter[0])).EPC.ToHexString();
                else if (t.Name == "PARAM_EPCData")
                    epcInfo = ((PARAM_EPCData)(msg.TagReportData[i].EPCParameter[0])).EPC.ToHexString();
                else
                    throw new Exception("ParseTag method couldn't resolve EPC type");
 
                string time = (msg.TagReportData[i].LastSeenTimestampUTC).ToString();
                string count = (msg.TagReportData[i].TagSeenCount).ToString();
                string accessSpecID = (msg.TagReportData[i].AccessSpecID).ToString();
                string firstSeen = (msg.TagReportData[i].FirstSeenTimestampUTC).ToString();
                string lastSeen = (msg.TagReportData[i].LastSeenTimestampUTC).ToString();
                string rssi = (msg.TagReportData[i].PeakRSSI).ToString();
                string freq = (msg.TagReportData[i].ChannelIndex).ToString();

                result = null;
                //Tag newTag = BuildTag(epcInfo);

                // extract information
                count = getRelevantInfoFromXML(count, 1);
                //accessSpecID = getRelevantInfoFromXML(accessSpecID, 1);
                time = getRelevantInfoFromXML(time, 1);
                rssi = getRelevantInfoFromXML(rssi, 1);
                freq = getRelevantInfoFromXML(freq, 1);
                
                string accessResultData = "";
                if (accessSpecID != "0")
                {
                    for (int j = 0; j < msg.TagReportData[i].AccessCommandOpSpecResult.Length; j++)
                    {
                        result = msg.TagReportData[i].AccessCommandOpSpecResult[0].ToString();
                        // MessageBox.Show(result); - evil - just keeps popping up!
                        // extract access result
                        if (result != null && result.Contains("Success"))
                        {
                            Type t2 = msg.TagReportData[i].AccessCommandOpSpecResult[0].GetType();
                            if (t2.Name == "PARAM_C1G2ReadOpSpecResult")
                            {
                                PARAM_C1G2ReadOpSpecResult accessResult;
                                accessResult = ((PARAM_C1G2ReadOpSpecResult)(msg.TagReportData[i].AccessCommandOpSpecResult[0]));
                                string marker = "<ReadData>";
                                int start = result.IndexOf(marker);
                                int end = result.IndexOf("<", start + 1);
                                accessResultData = result.Substring(start + marker.Length, end - marker.Length - start);
                            }
                        }
                    }
                }

                // Pass all this information to the GUI in a MyTag object.
                MyTag newTag = new MyTag(epcInfo, time, count, firstSeen, lastSeen, accessResultData, rssi, freq);
                readerMgr.HandleTagReceived(newTag);

            }
            return result;
        }
Example #5
0
        public void UpdateROReport(MSG_RO_ACCESS_REPORT msg) 
        {
            if (msg.TagReportData == null)
            {
                readerMgr.HandleTagReceived(null);
                return;
            }

            string result = null;

            try
            {
                for (int i = 0; i < msg.TagReportData.Length; i++)
                {
                    result = ParseTag(msg, result, i);
                    //MessageBox.Show(result);
                }
            }
            catch (Exception ex)
            {
                WriteString(ex.Message);
            }
        }
Example #6
0
        //Thread myThread = new Thread(new ThreadStart(this.UpdateROReport));

        public void reader_OnRoAccessReportReceived(MSG_RO_ACCESS_REPORT msg)
        {
            delegateRoAccessReport del = UpdateROReport;
            del.BeginInvoke(msg, OnAsyncCallBack, null);
        }