Example #1
0
        private static void CalculateCheckSumCommand(object sender, EventArgs e)
        {
            if (htxtSendData.Length == 0)
            {
                return;
            }

            string[] reslut        = CCommondMethod.StringToStringArray(htxtSendData.ToUpper(), 2);
            byte[]   btArySendData = CCommondMethod.StringArrayToByteArray(reslut, reslut.Length);

            byte btCheckData = reader.CheckValue(btArySendData);

            htxtCheckData = string.Format(" {0:X2}", btCheckData);
        }
Example #2
0
        private static void Connect()
        {
            string strException = string.Empty;
            string strComPort   = _Com_Port;
            int    nBaudrate    = Convert.ToInt32(_Boud_Rate);

            int nRet = reader.OpenCom(strComPort, nBaudrate, out strException);

            if (nRet != 0)
            {
                string strLog = "Connection failed, failure cause: " + strException;
                Logger(strLog);

                throw new Exception(strLog);
            }
            else
            {
                #region Set Function Default
                htxtSendData = "A0 04 FF A0 00";
                CalculateCheckSumCommand(null, EventArgs.Empty);
                string SendCommandStr = htxtSendData + htxtCheckData;

                string[] reslut        = CCommondMethod.StringToStringArray(SendCommandStr.ToUpper(), 2);
                byte[]   btArySendData = CCommondMethod.StringArrayToByteArray(reslut, reslut.Length);

                reader.SendMessage(btArySendData);
                #endregion Set Function Default

                string strLog = "Connect" + strComPort + "@" + nBaudrate.ToString();
                Logger(strLog);
                if (_Start_Read == "Start")
                {
                    try
                    {
                        strLog = "Started to read tags";
                        Logger(strLog);
                        m_curInventoryBuffer.ClearInventoryPar();
                        m_curInventoryBuffer.btRepeat = Convert.ToByte(repeatCommand);

                        m_curInventoryBuffer.bLoopCustomizedSession = false;
                        m_curInventoryBuffer.lAntenna.Add(0x00);
                        m_curInventoryBuffer.lAntenna.Add(0x01);
                        m_curInventoryBuffer.lAntenna.Add(0x02);
                        m_curInventoryBuffer.lAntenna.Add(0x03);
                        if (m_curInventoryBuffer.lAntenna.Count == 0)
                        {
                            Logger("One antenna must be selected");
                        }

                        m_bInventory = true;
                        m_curInventoryBuffer.bLoopInventory     = true;
                        m_curInventoryBuffer.bLoopInventoryReal = true;

                        m_nTotal = 0;

                        byte btWorkAntenna = m_curInventoryBuffer.lAntenna[m_curInventoryBuffer.nIndexAntenna];
                        reader.SetWorkAntenna(m_curSetting.btReadId, btWorkAntenna);
                        m_curSetting.btWorkAntenna = btWorkAntenna;


                        timerInventory.Enabled = true;
                        timerInventory.Enabled = true;
                    }
                    catch (Exception ex)
                    {
                        Logger(ex.Message);
                    }
                }
            }
        }