Beispiel #1
0
        /// <summary>
        /// Compose two 32-bit unsigned integer parameters from the shelf life specification.
        /// </summary>
        /// <param name="slp">The shelf life parameters, <see cref="ShelfLifeParam"/>.</param>.
        /// <returns>An 32-bit unsigned integer array representing the tag required air parameters.</returns>
        /// <exception cref="ApplicationException">Thrown when tag responded with an error or the tag's response length was invalid.</exception>
        /// <exception cref="NurApiException">Exception is thrown when communication error occured with the tag or module.</exception>
        public uint [] ComposeShelfLifeParams(ShelfLifeParam slp)
        {
            uint [] ret = new uint[] { 0, 0 };
            uint    tmp;

            tmp   = slp.maxTemp & 0xFF;
            tmp <<= 8;
            tmp  |= slp.minTemp & 0xFF;
            tmp <<= 8;
            tmp  |= slp.normTemp & 0xFF;
            tmp <<= 8;
            tmp  |= slp.actEnergy & 0xFF;

            ret[0] = tmp;

            tmp   = slp.initLife & SL_INITLIFE_MASKVAL;
            tmp <<= SL_INITTEMP_BITS;

            tmp  |= (slp.initTemp & SL_INITTEMP_MASKVAL);
            tmp <<= SL_SENSID_LSH;

            tmp |= (slp.slSensId & SL_SENSID_MASKVAL);

            /* One-bit params. */
            tmp <<= 1;
            tmp  |= (uint)(slp.negSlEn ? 1 : 0);
            tmp <<= 1;
            tmp  |= (uint)(slp.slAlgEn ? 1 : 0);
            tmp <<= 2;                  // RFU bits

            ret[1] = tmp;

            return(ret);
        }
Beispiel #2
0
        /// <summary>
        /// Get the shelf life paraeter from the log state information.
        /// Used in getting the <see cref="ShelfLife"/>.
        /// </summary>
        /// <param name="lsi">The log state information from the tag.</param>
        /// <returns>Extracted shelf life parameter, <see cref="ShelfLifeParam"/>.</returns>
        /// <exception cref="ApplicationException">Exception thrown when the log state does not contain the shelf life information.</exception>
        public ShelfLifeParam ExtractShelfLifeResp(LogStateInfo lsi)
        {
            if (!lsi.hasShelfLife)
            {
                throw new ApplicationException("ExtractShelfLifeReponse: no shelf life present.");
            }

            ShelfLifeParam slp = new ShelfLifeParam();

            slp.actEnergy    = lsi.shelfLife.actEnergy;
            slp.curShelfLife = lsi.shelfLife.curShelfLife;
            slp.initLife     = lsi.shelfLife.initLife;
            slp.initTemp     = lsi.shelfLife.initTemp;
            slp.maxTemp      = lsi.shelfLife.maxTemp;
            slp.minTemp      = lsi.shelfLife.minTemp;
            slp.negSlEn      = lsi.shelfLife.negSlEn;
            slp.normTemp     = lsi.shelfLife.normTemp;
            slp.slAlgEn      = lsi.shelfLife.slAlgEn;
            slp.slSensId     = lsi.shelfLife.slSensId;

            return(slp);
        }