public void SetFSPEC() { int DataIndex = 0; int FSpecIndex = 0; while (true) { var bits = new BitArray(new byte[] { _DataBlock[DataIndex] }); for (var i = 7; i >= 0; i--) { if (bits[i]) { FSPEC.Add(FSpecIndex, bits[i]); } FSpecIndex++; } //Remove the extenstion from field index FSPEC.Remove(FSpecIndex - 1); if (!bits[0]) { break; } DataIndex++; } String Binary = String.Empty; StringBuilder sbAvailableFields = new StringBuilder(); int LengthIndex = 0; foreach (int i in FSPEC.Keys) { Binary = Binary + (FSPEC[i] ? "1 " : "0 "); if (FSPEC[i]) { LengthIndex = LengthIndex + FieldMaping.FlightPlanRelatedData[i].FieldLength; sbAvailableFields.AppendLine( FieldMaping.FlightPlanRelatedData[i].Code + " - " + FieldMaping.FlightPlanRelatedData[i].Name + ", Length: " + FieldMaping.FlightPlanRelatedData[i].FieldLength + (FieldMaping.FlightPlanRelatedData[i].DynamicLength ? " (Dynamic)" : "") ); } } FieldLength = 1 + DataIndex + LengthIndex; //Console.WriteLine(Binary); //Console.WriteLine(sbAvailableFields.ToString()); }
public void SetFSPEC() { int FSpecIndex = 0; while (true) { var bits = new BitArray(new byte[] { _DataBlock[DataLength] }); for (var i = 7; i >= 0; i--) { if (bits[i]) { FSPEC.Add(FSpecIndex, bits[i]); } FSpecIndex++; } //Remove the extenstion from field index FSPEC.Remove(FSpecIndex - 1); if (!bits[0]) { break; } DataLength++; } /* * String Binary = String.Empty; * StringBuilder sbAvailableFields = new StringBuilder(); * int LengthIndex = 0; * foreach (int i in FSPEC.Keys) { * Binary = Binary + (FSPEC[i] ? "1 " : "0 "); * if (FSPEC[i]) { * LengthIndex = LengthIndex + FieldMaping.DataModel[i].FieldLength; * sbAvailableFields.AppendLine( * FieldMaping.DataModel[i].Code + " - " + FieldMaping.DataModel[i].Name + * ", Length: " + FieldMaping.DataModel[i].FieldLength + * (FieldMaping.DataModel[i].DynamicLength ? " (Dynamic)" : "") * ); * } * } * * Console.WriteLine(Binary); * Console.WriteLine(sbAvailableFields.ToString()); */ }