コード例 #1
0
ファイル: Form2.cs プロジェクト: niceukulele/ProjectForZou
        private bool initPr9000()
        {
            string strException = string.Empty;
            string strComPort = conf.PR9000Port;
            //int nBaudrate = Convert.ToInt32(cmbBaudrate.Text);
            int nBaudrate = 19200;
            pr9000 = new PR9000();
            pr9000.AnalyCallback = analyData;
            int nRet = pr9000.OpenCom(strComPort, out strException);
            if (nRet != 0)
            {
                string strLog = "连接读卡器失败,失败原因: " + strException;
                WriteLog(logRichText, strLog, 1);
                writeLog(strLog);
                m_readerIsNormal = true;
                //buttonInv.Enabled = false;
                return false;
            }
            else
            {
                string strLog = "连接读卡器 " + strComPort + "@" + nBaudrate.ToString();
                WriteLog(logRichText, strLog, 0);
                writeLog(strLog);
            }

            return true;
        }
コード例 #2
0
ファイル: Form2.cs プロジェクト: niceukulele/ProjectForZou
        void analyData(PR9000.CALLBACK_MSG_TYPE msgType, byte arg, byte[] payload)
        {
            string strLog = "";
            switch (msgType)
            {
                case PR9000.CALLBACK_MSG_TYPE.POWER_ON:
                    if (arg == 0)
                    {
                        pr9000.setPowerOnState(true);
                        strLog = "PR9000 power on ok";
                    }
                    else
                    {
                        pr9000.setPowerOnState(false);
                        strLog = "PR9000 power on fail";
                    }
                    //WriteLog(logRichText, strLog, 0);
                    break;
                case PR9000.CALLBACK_MSG_TYPE.START_INV:
                    if (arg == 0)
                    {
                        pr9000.setInvState(true);
                        strLog = "PR9000 start INV";
                        //WriteLog(logRichText, strLog, 0);
                    }

                    break;
                case PR9000.CALLBACK_MSG_TYPE.STOP_INV:
                    if (arg == 0)
                    {
                        pr9000.setInvState(false);
                        strLog = "PR9000 stop INV";
                        //WriteLog(logRichText, strLog, 0);
                    }
                    break;
                case PR9000.CALLBACK_MSG_TYPE.EPC:
                    //strLog = "EPC:" + CCommondMethod.ByteArrayToString(payload, 0, payload.Length);
                    if (!inUploadSession)
                    {
                        if (payload[2] == 0x23 && payload[3] == 0x23 && payload[4] == 0x55)
                        {
                            inUploadSession = true;
                            disablePr9000Inv();
                            //verify the epc is stuff
                            strLog = "识别到人员标签";
                            WriteLog(logRichText, strLog, 0);
                            writeLog(strLog);
                            //remove CRC first
                            stuffEpc = CCommondMethod.ByteArrayToStringNoBlank(payload, 0, payload.Length-2);
                            writeLog("Stuff Epc:" + stuffEpc);
                            epcIndex = 0;
                            EpcCollections[epcIndex] = stuffEpc;
                            epcIndex++;
                            //m_invBuffer.collectEpc(stuffEpc);
                            //string tmpEpc = CCommondMethod.ByteArrayToStringNoBlank(payload, 2, payload.Length - 4);
                            //remove 0x3000 head
                            string tmpEpc = stuffEpc.Substring(4, stuffEpc.Length - 4);
                            //writeLog("temp Epc:" + stuffEpc);
                            pr9000.ClearCom();
                            if (sc.checkUsrInfo(tmpEpc) == 0)
                            {
                                updateUserInfo();
                            }
                            startCollectDocEpc();
                            //wb modify

                        }
                    }
                    //WriteLog(logRichText, strLog, 0);
                    break;
                case PR9000.CALLBACK_MSG_TYPE.INV_FINISH:
                    strLog = "Inventory finish";
                    //WriteLog(logRichText, strLog, 0);
                    if (isContinuous)
                    {
                        enablePr9000CtsInv();
                    }
                    else
                    {
                        disablePr9000CtsInv();
                    }
                    break;
                default:
                    break;
            }
        }