internal void DataUpdate(SensorDataEntry value)
 {
     lock (mCurrentDataLock)
     {
         this.mCurrentData = value;
     }
 }
 /// <summary>
 /// Prints a data entry to the log
 /// </summary>
 /// <param name="dataEntry">The entry to print</param>
 private void printDataEntry(SensorDataEntry dataEntry)
 {
     try
     {
         string output = dataEntry.ToString();
         Logger.Info("Sensor {0} data: {1}", mID, output);
     }
     catch (Exception e)
     {
         Logger.Error("Sensor {0} string printing exception: {1}", mID, e.Message);
     }
 }
        /// <summary>
        ///  Packs a data entry struct along with sequence and timestamp
        /// </summary>
        /// <param name="orientation">orientation angle</param>
        /// <param name="accel">accelerometer vector</param>
        /// <param name="mag">magnetometer vector</param>
        /// <param name="gyro">gyroscope vector</param>
        /// <returns></returns>
        private SensorDataEntry prepareEntry(Matrix4 orientation, Vector3 accel, Vector3 mag, Vector3 gyro, Vector3 ypr)
        {
            SensorDataEntry newEntry = new SensorDataEntry();

            newEntry.orientation    = orientation;
            newEntry.yawpitchroll   = ypr;
            newEntry.accelerometer  = accel;
            newEntry.magnetometer   = mag;
            newEntry.gyroscope      = gyro;
            newEntry.sequenceNumber = mSequenceNum++;
            newEntry.timeStamp      = DateTime.Now;
            newEntry.id             = String.Copy(mID);
            return(newEntry);
        }
        public void addDataEntry(SensorDataEntry newData)
        {
            /*
             * mDataBuffer[ mBufferIndex++ ] = newData;
             *
             *
             * if( mBufferIndex == MAX_BUFFER_INDEX )
             * {
             *
             *  Matrix4 sum = new Matrix4();
             *  for( int i = 0; i < MAX_BUFFER_INDEX; i++ )
             *  {
             *      sum.Row0 += mDataBuffer[ i ].orientation.Row0;
             *      sum.Row1 += mDataBuffer[ i ].orientation.Row1;
             *      sum.Row2 += mDataBuffer[ i ].orientation.Row2;
             *      sum.Row3 += mDataBuffer[ i ].orientation.Row3;
             *
             *  }
             *
             *
             *  sum.Row0 /= (float)MAX_BUFFER_INDEX;
             *  sum.Row1 /= ( float ) MAX_BUFFER_INDEX;
             *  sum.Row2 /= ( float ) MAX_BUFFER_INDEX;
             *  sum.Row3 /= ( float ) MAX_BUFFER_INDEX;
             *
             *
             *  newData.orientation = sum;
             *
             *  Vector3 vSum = new Vector3();
             *
             *  for( int i = 0; i < MAX_BUFFER_INDEX; i++ )
             *  {
             *      vSum += mDataBuffer[ i ].accelerometer;
             *  }
             *
             *  vSum /= ( float ) MAX_BUFFER_INDEX;
             *
             *
             *  newData.accelerometer = vSum;
             *
             *  mBufferIndex = 0;
             */
            /** Call the event to notify and listeners */
            DataReceivedEventArgs dataEventArgs = new DataReceivedEventArgs(mID, newData);

            OnDataReceived(dataEventArgs);
            /*}*/
        }
 internal void DataUpdate(SensorDataEntry value)
 {
     lock (mCurrentDataLock)
     {
         this.mCurrentData = value;
     }
 }
 public DataReceivedEventArgs(string id, SensorDataEntry data)
 {
     mID   = id;
     mData = data;
 }
 public DataReceivedEventArgs( string id, SensorDataEntry data)
 {
     mID = id;
     mData = data;
 }
 /// <summary>
 /// Prints a data entry to the log
 /// </summary>
 /// <param name="dataEntry">The entry to print</param>
 private void printDataEntry( SensorDataEntry dataEntry )
 {
     try
     {
         string output = dataEntry.ToString();
         Logger.Info( "Sensor {0} data: {1}", mID, output );
     }
     catch( Exception e)
     {
         Logger.Error( "Sensor {0} string printing exception: {1}", mID, e.Message );
     }
 }
 /// <summary>
 ///  Packs a data entry struct along with sequence and timestamp
 /// </summary>
 /// <param name="orientation">orientation angle</param>
 /// <param name="accel">accelerometer vector</param>
 /// <param name="mag">magnetometer vector</param>
 /// <param name="gyro">gyroscope vector</param>
 /// <returns></returns>
 private SensorDataEntry prepareEntry( Matrix4 orientation, Vector3 accel, Vector3 mag, Vector3 gyro, Vector3 ypr )
 {
     SensorDataEntry newEntry = new SensorDataEntry();
     newEntry.orientation = orientation;
     newEntry.yawpitchroll = ypr;
     newEntry.accelerometer = accel;
     newEntry.magnetometer = mag;
     newEntry.gyroscope = gyro;
     newEntry.sequenceNumber = mSequenceNum++;
     newEntry.timeStamp = DateTime.Now;
     newEntry.id = String.Copy( mID );
     return newEntry;
 }
        public void addDataEntry( SensorDataEntry newData )
        {
            /*
            mDataBuffer[ mBufferIndex++ ] = newData;

            if( mBufferIndex == MAX_BUFFER_INDEX )
            {

                Matrix4 sum = new Matrix4();
                for( int i = 0; i < MAX_BUFFER_INDEX; i++ )
                {
                    sum.Row0 += mDataBuffer[ i ].orientation.Row0;
                    sum.Row1 += mDataBuffer[ i ].orientation.Row1;
                    sum.Row2 += mDataBuffer[ i ].orientation.Row2;
                    sum.Row3 += mDataBuffer[ i ].orientation.Row3;

                }

                sum.Row0 /= (float)MAX_BUFFER_INDEX;
                sum.Row1 /= ( float ) MAX_BUFFER_INDEX;
                sum.Row2 /= ( float ) MAX_BUFFER_INDEX;
                sum.Row3 /= ( float ) MAX_BUFFER_INDEX;

                newData.orientation = sum;

                Vector3 vSum = new Vector3();

                for( int i = 0; i < MAX_BUFFER_INDEX; i++ )
                {
                    vSum += mDataBuffer[ i ].accelerometer;
                }

                vSum /= ( float ) MAX_BUFFER_INDEX;

                newData.accelerometer = vSum;

                mBufferIndex = 0;
             */
                /** Call the event to notify and listeners */
                DataReceivedEventArgs dataEventArgs = new DataReceivedEventArgs( mID, newData );
                OnDataReceived( dataEventArgs );
            /*}*/
        }