Esempio n. 1
0
        public RTRegsForm(NurApi hApi, RT0005Tag tag)
        {
            InitializeComponent();

            mTag = tag;
            hNur = hApi;

            hNur.DisconnectedEvent += new EventHandler <NurApi.NurEventArgs>(hNur_DisconnectedEvent);

            ReadRegs();
        }
Esempio n. 2
0
        void FindThread()
        {
            int  scanRound;
            bool possiblyFound;

            NurApi.TriggerReadData rd;
            byte[]     epc;
            NurApi.Tag theTag;
            byte[]     testData;

            int startTime, execTime;

            startTime = 0;

            possiblyFound = false;
            mTag          = null;

            execTime = 0;
            epc      = null;

            mAsyncUpdate = false;
            ControlState(TagLabel, STATE_RUN, "Scanning...");
            ControlEnable(ScanBtn, false);
            ControlEnable(AntennaBtn, false);
            HandleBinStateGroup(true, NO_TAG, NOT_LOGGING);

            mAsyncUpdate = true;
            ProgressInit(ScanProgress, 0, mTryCount, 1);

            for (scanRound = 0; scanRound < mTryCount && !possiblyFound; scanRound++)
            {
                ProgressStep(ScanProgress);
                try
                {
                    startTime = System.Environment.TickCount;
                    rd        = hNur.ScanSingle(500);
                    execTime  = System.Environment.TickCount - startTime;

                    epc = new byte[rd.epcLen];
                    System.Array.Copy(rd.epc, epc, rd.epcLen);

                    ControlState(TagLabel, STATE_RUN, "Verify...");

                    testData = hNur.ReadTagByEPC(mPassword, mSecured, epc, NurApi.BANK_PASSWD, RTConst.PASSWD_EXTRA_ADDR, RTConst.NR_PASSWD_EXTRA_BYTES);

                    /* Guess that this is OK tag. */
                    possiblyFound = (testData != null && testData.Length == RTConst.NR_PASSWD_EXTRA_BYTES);
                    if (possiblyFound)
                    {
                        theTag      = new NurApi.Tag();
                        theTag.hApi = hNur;
                        theTag.epc  = new byte[rd.epcLen];
                        System.Array.Copy(rd.epc, theTag.epc, rd.epcLen);

                        theTag.antennaId = (byte)rd.antennaID;
                        theTag.channel   = 0;
                        theTag.frequency = 0;                           // Huh.

                        mTag = new RT0005Tag(hNur, theTag);

                        mTag.ProgressEvent += new EventHandler <RTProgressEvent>(mTag_ProgressEvent);
                    }
                }
                catch (Exception e)
                {
                    if (e is NurApiException && ((NurApiException)e).error == NurApiErrors.NUR_ERROR_TR_NOT_CONNECTED)
                    {
                        break;
                    }

                    if (execTime < 500)
                    {
                        System.Threading.Thread.Sleep(500 - execTime);
                    }

                    ControlState(TagLabel, STATE_RUN, "Scanning...");
                }
            }

            while (scanRound < mTryCount)
            {
                scanRound++;
                ProgressStep(ScanProgress);
            }

            mBusy = false;

            ControlEnable(ScanBtn, hNur.IsConnected());
            ControlEnable(AntennaBtn, hNur.IsConnected());

            ProgressInit(ScanProgress, 0, mTryCount, 1);

            mScanThread = null;

            TempTagReady(possiblyFound, epc);
        }