Esempio n. 1
0
        public SampleResult(byte[] data)
        {
            Int16  int16Value  = 0;
            UInt32 uint32value = 0;
            Int32  int32value  = 0;
            int    idx         = 0;

            Valid = BitConverter.ToBoolean(data, idx);
            idx++;

            Error        = (ErrorCode)data[idx++];
            CalSignature = BitConverter.ToUInt16(data, idx);
            idx         += sizeof(UInt16);

            Status = data[idx++];

            PendingTimeLeft = BitConverter.ToUInt16(data, idx);
            idx            += sizeof(UInt16);

            int16Value    = BitConverter.ToInt16(data, idx);
            TempBeforeDep = (float)int16Value / 10.0f;
            idx          += sizeof(Int16);

            int16Value   = BitConverter.ToInt16(data, idx);
            TempAfterDep = (float)int16Value / 10.0f;
            idx         += sizeof(Int16);

            int16Value     = BitConverter.ToInt16(data, idx);
            TempAfterAssay = (float)int16Value / 10.0f;
            idx           += sizeof(Int16);

            int16Value = BitConverter.ToInt16(data, idx);
            TempAvg    = (float)int16Value / 10.0f;
            idx       += sizeof(Int16);

            LowerMinimum = BitConverter.ToUInt16(data, idx);
            idx         += sizeof(UInt16);

            UpperMinimum = BitConverter.ToUInt16(data, idx);
            idx         += sizeof(UInt16);

            Slope = BitConverter.ToInt16(data, idx);
            idx  += sizeof(Int16);

            SWCscaled = BitConverter.ToUInt16(data, idx);
            idx      += sizeof(UInt16);

            int32value = BitConverter.ToInt32(data, idx);
            Timestamp  = UnixTime.FromUnixTime(int32value);
            idx       += sizeof(Int32);

            SWCValue = BitConverter.ToUInt32(data, idx);
            idx     += sizeof(UInt32);

            TempCorrected = BitConverter.ToUInt32(data, idx);
            idx          += sizeof(UInt32);

            BLLCorrected = BitConverter.ToUInt32(data, idx);
            idx         += sizeof(UInt32);


            uint32value = BitConverter.ToUInt32(data, idx);
            if (uint32value != LOW_LEAD && uint32value != HIGH_LEAD)
            {
                Result = (float)uint32value / (float)10.0;
            }
            else
            {
                Result = uint32value;
            }

            idx += sizeof(UInt32);

            Transmitted = BitConverter.ToBoolean(data, idx);
            idx++;

            int nullIdx = FindFirstNullByte(data, idx, SAMPLE_ID_LEN);

            if (nullIdx > 0)
            {
                SampleID = Encoding.ASCII.GetString(data, idx, nullIdx);
            }
            idx += SAMPLE_ID_LEN;

            LotCode = Encoding.ASCII.GetString(data, idx, LOTCODE_LEN - 1);
        }
Esempio n. 2
0
 public TimeMessage(DateTime dt)
 {
     RtcTime = UnixTime.ToUnixTime(dt);
     UpdateChipData(dt);
 }