Beispiel #1
0
        /// <summary>
        /// 4个天线读卡, 读取EPC数据区以及TID数据区
        /// </summary>
        /// <param name="clientConn">连接</param>
        private static void SendSynBaseInventoryEpcMsg(GClient clientConn, out bool isGetSuccess)
        {
            // 4个天线读卡, 读取EPC数据区以及TID数据区
            MsgBaseInventoryEpc msgBaseInventoryEpc = new MsgBaseInventoryEpc
            {
                AntennaEnable = (eAntennaNo._1 | eAntennaNo._2 | eAntennaNo._3 | eAntennaNo._4),
                InventoryMode = (byte)eInventoryMode.Single,
                // tid参数
                ReadTid = new ParamEpcReadTid()
            };

            msgBaseInventoryEpc.ReadTid.Mode = (byte)eParamTidMode.Auto;
            msgBaseInventoryEpc.ReadTid.Len  = 6;
            clientConn.SendSynMsg(msgBaseInventoryEpc);
            if (0 == msgBaseInventoryEpc.RtCode)
            {
                isGetSuccess = true;
                LogUtils.Debug("Inventory epc successful.");
            }
            else
            {
                LogUtils.Debug("Inventory epc error.");
                isGetSuccess = false;
            }
        }
Beispiel #2
0
        /// <summary>
        /// 功率配置, 将4个天线功率都设置为30dBm.
        /// </summary>
        /// <param name="clientConn">连接</param>
        private static void SendSynBaseSetPowerMsg(GClient clientConn, out bool isGetSuccess)
        {
            // 功率配置, 将4个天线功率都设置为30dBm.
            MsgBaseSetPower msgBaseSetPower = new MsgBaseSetPower
            {
                DicPower = new Dictionary <byte, byte>()
                {
                    { 1, 30 },
                    { 2, 30 },
                    { 3, 30 },
                    { 4, 30 }
                }
            };

            clientConn.SendSynMsg(msgBaseSetPower);
            if (0 == msgBaseSetPower.RtCode)
            {
                LogUtils.Debug("Power configuration successful.");
                isGetSuccess = true;
            }
            else
            {
                LogUtils.Debug("Power configuration error.");
                isGetSuccess = false;
            }
        }
Beispiel #3
0
        /// <summary>
        /// 停止指令,空闲态(当读写器处于读卡状态时,所有配置消息将无法发送,必须发送停止指令)
        /// </summary>
        /// <param name="clientConn">连接</param>
        private static void SendSynBaseStopMsg(GClient clientConn, out bool isGetSuccess)
        {
            // 停止指令,空闲态
            MsgBaseStop msgBaseStop = new MsgBaseStop();

            clientConn.SendSynMsg(msgBaseStop);
            if (0 == msgBaseStop.RtCode)
            {
                isGetSuccess = true;
                LogUtils.Debug("Stop successful.");
            }
            else
            {
                LogUtils.Debug("Stop error.");
                isGetSuccess = false;
            }
        }
Beispiel #4
0
        public static void TestRFID(object sender, ElapsedEventArgs elapsed)
        {
            GClient clientConn = new GClient();

            //COM1  主柜rfid串口
            //COM4  副柜rfid串口
            if (clientConn.OpenSerial("COM1:115200", 3000, out eConnectionAttemptEventStatusType status))
            //if (clientConn.OpenTcp("192.168.1.168:8160", 3000, out status))
            {
                // 订阅标签上报事件
                clientConn.OnEncapedTagEpcLog  += new delegateEncapedTagEpcLog(OnEncapedTagEpcLog);
                clientConn.OnEncapedTagEpcOver += new delegateEncapedTagEpcOver(OnEncapedTagEpcOver);

                // 停止指令,空闲态
                MsgBaseStop msgBaseStop = new MsgBaseStop();
                clientConn.SendSynMsg(msgBaseStop);
                if (0 == msgBaseStop.RtCode)
                {
                    LogUtils.Debug("Stop successful.");
                }
                else
                {
                    LogUtils.Debug("Stop error.");
                }

                // 功率配置, 将4个天线功率都设置为30dBm.
                MsgBaseSetPower msgBaseSetPower = new MsgBaseSetPower
                {
                    DicPower = new Dictionary <byte, byte>()
                    {
                        { 1, 30 },
                        { 2, 30 },
                        { 3, 30 },
                        { 4, 30 }
                    }
                };
                clientConn.SendSynMsg(msgBaseSetPower);
                if (0 == msgBaseSetPower.RtCode)
                {
                    LogUtils.Debug("Power configuration successful.");
                }
                else
                {
                    LogUtils.Debug("Power configuration error.");
                }
                LogUtils.Debug("Enter any character to start reading the tag.");
                Console.ReadKey();

                // 4个天线读卡, 读取EPC数据区以及TID数据区
                MsgBaseInventoryEpc msgBaseInventoryEpc = new MsgBaseInventoryEpc
                {
                    AntennaEnable = (uint)(eAntennaNo._1 | eAntennaNo._2 | eAntennaNo._3 | eAntennaNo._4),
                    InventoryMode = (byte)eInventoryMode.Inventory,
                    // tid参数
                    ReadTid = new ParamEpcReadTid()
                };
                msgBaseInventoryEpc.ReadTid.Mode = (byte)eParamTidMode.Auto;
                msgBaseInventoryEpc.ReadTid.Len  = 6;
                clientConn.SendSynMsg(msgBaseInventoryEpc);
                if (0 == msgBaseInventoryEpc.RtCode)
                {
                    LogUtils.Debug("Inventory epc successful.");
                }
                else
                {
                    LogUtils.Debug("Inventory epc error.");
                }
                Console.ReadKey();

                // 停止读卡,空闲态
                clientConn.SendSynMsg(msgBaseStop);
                if (0 == msgBaseStop.RtCode)
                {
                    LogUtils.Debug("Stop successful.");
                }
                else
                {
                    LogUtils.Debug("Stop error.");
                }
            }
            else
            {
                LogUtils.Debug("Connect failure.");
            }
            Console.ReadKey();
            clientConn.Close();
        }