Пример #1
0
 /// <summary>
 /// Parses the received data
 /// Call it just before you use the data
 /// </summary>
 public void ParseData()
 {
     if (!_haveToParse)
     {
         return;
     }
     lock (this._parseBuffer) {
         _haveToParse = false;
         int i = 0;
         this.Roll = FastNumberParse.ParseFloat(this._parseBuffer, ref i);
         i++;
         this.Pitch = FastNumberParse.ParseFloat(this._parseBuffer, ref i);
         i++;
         this.Yaw = FastNumberParse.ParseFloat(this._parseBuffer, ref i);
         if (this._parseAnalogs)
         {
             // + ',AN:'
             i += AnalogsPree.Length;
             if (_applyOffsets)
             {
                 this.AnX = FastNumberParse.ParseInt(this._parseBuffer, ref i) - Offsets[0];
                 i++;
                 this.AnY = FastNumberParse.ParseInt(this._parseBuffer, ref i) - Offsets[1];
                 i++;
                 this.AnZ = FastNumberParse.ParseInt(this._parseBuffer, ref i) - Offsets[2];
                 i++;
                 this.AccX = FastNumberParse.ParseInt(this._parseBuffer, ref i) - Offsets[3];
                 i++;
                 this.AccY = FastNumberParse.ParseInt(this._parseBuffer, ref i) - Offsets[4];
                 i++;
                 this.AccZ = FastNumberParse.ParseInt(this._parseBuffer, ref i) - Offsets[5];
             }
             else
             {
                 this.AnX = FastNumberParse.ParseInt(this._parseBuffer, ref i);
                 i++;
                 this.AnY = FastNumberParse.ParseInt(this._parseBuffer, ref i);
                 i++;
                 this.AnZ = FastNumberParse.ParseInt(this._parseBuffer, ref i);
                 i++;
                 this.AccX = FastNumberParse.ParseInt(this._parseBuffer, ref i);
                 i++;
                 this.AccY = FastNumberParse.ParseInt(this._parseBuffer, ref i);
                 i++;
                 this.AccZ = FastNumberParse.ParseInt(this._parseBuffer, ref i);
             }
             i++;
             this.MagX = FastNumberParse.ParseInt(this._parseBuffer, ref i);
             i++;
             this.MagY = FastNumberParse.ParseInt(this._parseBuffer, ref i);
             i++;
             this.MagZ = FastNumberParse.ParseInt(this._parseBuffer, ref i);
         }
     }
 }
Пример #2
0
        private static void ParseOffset(out int offsetVar, char[] data)
        {
            int i = 0;

            offsetVar = FastNumberParse.ParseInt(data, ref i);
        }