Exemple #1
0
        public eReturn ParseAndPackRecodedData(byte[] buffer, DeviceData recordedData)
        {
            eReturn eReturn;

            if (buffer.Length != 6)
            {
                eReturn = eReturn.BUFFER_LENGTH_NOT_PROPER;
            }
            else
            {
                byte[] parseByte1 = new byte[2]
                {
                    buffer[0],
                    buffer[1]
                };
                byte[] parseByte2 = new byte[2]
                {
                    buffer[1],
                    buffer[2]
                };
                byte[] parseByte3 = new byte[2]
                {
                    buffer[3],
                    buffer[4]
                };
                byte[] parseByte4 = new byte[2]
                {
                    buffer[4],
                    buffer[5]
                };
                byte parseByte5 = buffer[5];
                CalibrationInformation calibrationInformation = new CalibrationInformation();
                calibrationInformation.Xgain   = recordedData.ObjCalibInfo.Xgain;
                calibrationInformation.Xoffset = recordedData.ObjCalibInfo.Xoffset;
                calibrationInformation.Ygain   = recordedData.ObjCalibInfo.Ygain;
                calibrationInformation.Yoffset = recordedData.ObjCalibInfo.Yoffset;
                calibrationInformation.Zgain   = recordedData.ObjCalibInfo.Zgain;
                calibrationInformation.Zoffset = recordedData.ObjCalibInfo.Zoffset;
                calibrationInformation.Volts   = recordedData.ObjCalibInfo.Volts;
                calibrationInformation.Lux     = recordedData.ObjCalibInfo.Lux;
                float  accXaxis     = (float)this.ParseAccXaxis(parseByte1);
                float  accYaxis     = (float)this.ParseAccYaxis(parseByte2);
                float  accZaxis     = (float)this.ParseAccZaxis(parseByte3);
                ushort lightMeter   = this.ParseLightMeter(parseByte4);
                string buttonStatus = this.ParseButtonStatus(parseByte5);
                float  num1         = recordedData.CalibrateXAxis(accXaxis);
                recordedData.ObjRecordedData.ArrXaxis.Add(num1);
                float num2 = recordedData.CalibrateYAxis(accYaxis);
                recordedData.ObjRecordedData.ArrYaxis.Add(num2);
                float num3 = recordedData.CalibrateZAxis(accZaxis);
                recordedData.ObjRecordedData.ArrZaxis.Add(num3);
                ushort num4 = (int)calibrationInformation.Volts != 0 ? (ushort)((uint)lightMeter * (uint)calibrationInformation.Lux / (uint)calibrationInformation.Volts) : (ushort)0;
                recordedData.ObjRecordedData.ArrLightMeter.Add(num4);
                recordedData.ObjRecordedData.ArrButtonStatus.Add(buttonStatus);
                eReturn = eReturn.SUCCESS;
            }
            return(eReturn);
        }
 public DeviceData()
 {
     this.m_ObjDeviceInfo = new DeviceSettingsInfo();
     //this.m_ObjSubjectInfo = new SubjectInfo();
     //this.m_ObjTrialInfo = new TrialInfo();
     this.m_ObjRecordedData     = new RecordedData();
     this.m_ObjCalibInfo        = new CalibrationInformation();
     this.m_ObjDeviceStatusInfo = new DeviceStatusInfo();
 }
Exemple #3
0
 public eReturn ParseAndPackGetCalibInfo(byte[] buffer, CalibrationInformation calib)
 {
     if (buffer.Length != 28)
     {
         return(eReturn.BUFFER_LENGTH_NOT_PROPER);
     }
     byte[] numArray1 = new byte[2] {
         buffer[1], buffer[0]
     };
     byte[] numArray2 = new byte[2] {
         buffer[3], buffer[2]
     };
     byte[] numArray3 = new byte[2] {
         buffer[5], buffer[4]
     };
     byte[] numArray4 = new byte[2] {
         buffer[7], buffer[6]
     };
     byte[] numArray5 = new byte[2] {
         buffer[9], buffer[8]
     };
     byte[] numArray6 = new byte[2]
     {
         buffer[11],
         buffer[10]
     };
     byte[] numArray7 = new byte[2]
     {
         buffer[13],
         buffer[12]
     };
     byte[] numArray8 = new byte[2]
     {
         buffer[15],
         buffer[14]
     };
     byte[] numArray9 = new byte[2]
     {
         buffer[17],
         buffer[16]
     };
     byte[] bytes = new byte[10];
     for (int index = 0; index < 10; ++index)
     {
         bytes[index] = buffer[index + 18];
     }
     try
     {
         calib.Xgain = BitConverter.ToInt16(numArray1, 0);
         Console.WriteLine("XGAIN" + calib.Xgain);
         calib.Xoffset            = BitConverter.ToInt16(numArray2, 0);
         calib.Ygain              = BitConverter.ToInt16(numArray3, 0);
         calib.Yoffset            = BitConverter.ToInt16(numArray4, 0);
         calib.Zgain              = BitConverter.ToInt16(numArray5, 0);
         calib.Zoffset            = BitConverter.ToInt16(numArray6, 0);
         calib.Volts              = BitConverter.ToInt16(numArray7, 0);
         calib.Lux                = BitConverter.ToInt16(numArray8, 0);
         calib.ClockOffset        = BitConverter.ToInt16(numArray9, 0);
         calib.DeviceElectronicID = Encoding.ASCII.GetString(bytes);
         return(eReturn.SUCCESS);
     }
     catch
     {
         return(eReturn.FAILURE);
     }
 }