Example #1
0
        /// <summary>
        /// 消息发送和数据处理
        /// </summary>
        /// <param name="clientConn"></param>
        /// <param name="com"></param>
        /// <returns></returns>
        private static int DealComData(SerialPort clientConn, string com, out bool isGetSuccess)
        {
            isGetSuccess = true;

            try
            {
                byte[] TxData = { 0xA1 };
                clientConn.Write(TxData, 0, 1);
            }
            catch (Exception ex)
            {
                LogUtils.Error(ex.ToString());
                isGetSuccess = false;
            }

            if (isGetSuccess)
            {
                ManualResetEvent manualResetEvent = new ManualResetEvent(false);
                manualEvents.Add(manualResetEvent);
                DelegateGetMsg delegateGetMsg = new DelegateGetMsg(com, clientConn, manualResetEvent);
                // 订阅标签上报事件
                clientConn.DataReceived += new SerialDataReceivedEventHandler(delegateGetMsg.OnDataReceivedLock);
                //返回收集结果
                return(delegateGetMsg.GetDelegateMsg());
            }
            else
            {
                return(0);
            }
        }
Example #2
0
        /// <summary>
        /// 消息发送和数据处理
        /// </summary>
        /// <param name="clientConn"></param>
        /// <param name="com"></param>
        /// <returns></returns>
        private static HashSet <string> DealComData(GClient clientConn, string com, out bool isGetSuccess)
        {
            /// mutex互斥锁,用于人为阻塞当前线程
            ManualResetEvent manualResetEvent = new ManualResetEvent(false);

            manualEvents.Add(manualResetEvent);

            DelegateGetMsg delegateGetMsg = new DelegateGetMsg(com, clientConn, manualResetEvent);

            // 订阅标签上报事件
            clientConn.OnEncapedTagEpcLog  += new delegateEncapedTagEpcLog(delegateGetMsg.OnEncapedTagEpcLog);
            clientConn.OnEncapedTagEpcOver += new delegateEncapedTagEpcOver(delegateGetMsg.OnEncapedTagEpcOver);

            //停止指令,空闲态
            SendSynBaseStopMsg(clientConn, out isGetSuccess);

            //功率配置, 将 4 个天线功率都设置为 30dBm.
            SendSynBaseSetPowerMsg(clientConn, out isGetSuccess);

            //4个天线读卡, 读取EPC数据区以及TID数据区
            SendSynBaseInventoryEpcMsg(clientConn, out isGetSuccess);

            //返回收集结果
            return(delegateGetMsg.GetDelegateMsg());

            //停止指令,空闲态
            //SendSynBaseStopMsg(clientConn);
        }