/* Get the current measurement setup from the tag. */
        private MeasurementSetup MeasurementSetupExchange(uint password, bool secured)
        {
            MeasurementSetup theSetup = new MeasurementSetup();
            BitBuffer        bb;

            NurApi.CustomExchangeParams   xch;
            NurApi.CustomExchangeResponse resp;
            uint tmp;
            int  respLen;

            /* Build the command. */
            bb = BuildCommand(CMD_GET_MEAS_SETUP, null);
            //xch = BuildDefault(bb, 0, false, false);
            xch = BuildDefault(bb, GETMEAS_RESP_LEN, false, false);

            resp    = hApi.CustomExchangeSingulated(password, secured, NurApi.BANK_EPC, 32, epc.Length * 8, epc, xch);
            respLen = resp.tagBytes.Length;

            if (resp.error != NurApiErrors.NUR_NO_ERROR || respLen != GETMEAS_RESP_BYTES)
            {
                hApi.ULog("Get setup error: " + resp.error + ", len = " + respLen + ".");
                if (respLen >= MIN_ERROR_RESP_LENGTH)
                {
                    InterpretedException("Measurement setup", resp);
                }
                DoException("Measurement setup", resp);
            }

            theSetup.startTime = ExtractStartTime(resp.tagBytes);
            theSetup.limits    = ExtractLogLimits(resp.tagBytes);
            theSetup.form      = ExtractLoggingForm(resp.tagBytes);

            theSetup.roll     = IsMaskBitSet(resp.tagBytes[MEAS_OFFSET_MODE], LM_MEAS_ROLL_BIT);
            theSetup.interval = GetBitsBigEndian(resp.tagBytes, BytesToBits(MEAS_OFFSET_INTVAL), BytesToBits(MEAS_SZ_INTVAL));

            theSetup.battChkEn  = IsMaskBitSet(resp.tagBytes[MEAS_OFFSET_MODE], LM_MEAS_BATTCHK_BIT);
            theSetup.tempSensEn = IsMaskBitSet(resp.tagBytes[MEAS_OFFSET_MODE], LM_MEAS_TEMPSENS_BIT);
            theSetup.ext1En     = IsMaskBitSet(resp.tagBytes[MEAS_OFFSET_MODE], LM_MEAS_EXT1_BIT);
            theSetup.ext2En     = IsMaskBitSet(resp.tagBytes[MEAS_OFFSET_MODE], LM_MEAS_EXT2_BIT);

            tmp   = resp.tagBytes[MEAS_OFFSET_DELAY];
            tmp <<= 8;
            tmp  |= resp.tagBytes[MEAS_OFFSET_DELAY + 1];

            theSetup.delayModeExt = IsMaskBitSet(tmp, LM_MEAS_DLYMODE_BIT);
            theSetup.irqTimerEn   = IsMaskBitSet(tmp, LM_MEAS_IRQTME_EN_BIT);
            theSetup.delayTime    = (ushort)((tmp >> LM_MEAS_DLY_LSH) & LM_MEAS_DLY_MASKVAL);

            tmp   = resp.tagBytes[MEAS_OFFSET_APPDATA];
            tmp <<= 8;
            tmp  |= resp.tagBytes[MEAS_OFFSET_APPDATA + 1];

            theSetup.appDataWords  = ((tmp >> LM_MEAS_APPDATA_LSH) & LM_MEAS_APPDATA_MASKVAL);
            theSetup.brokenWordPtr = (tmp & LM_MEAS_BROKEN_MASK);

            return(theSetup);
        }
Esempio n. 2
0
        private void MeasSetupComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            // Get the measurementsetup ID from the combo box
            int MeasSetupID = CommonFunctions.GetListItemIDfromComboBox(MeasSetupComboBox);

            // Read the measurementsetup from the database
            measSetup = mPMObj.ReadMeasurementSetupfromDatabase(MeasSetupID);

            // Additionally alter the measurementsetup if needed
            measSetup.SubFrameRegion = new Rectangle(0, 0, 0, 0); // maximizes subframe

            // Update the fixed exposure value
            FixedExposureNumber.Value = (decimal)measSetup.FixedExposureTime[1];
        }