void CaptureFormKeyUp(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.ShiftKey) { fixMode = FixMode.None; } }
/// <summary> /// This method is used to "fix" the mouse coordinates when keeping shift/ctrl pressed /// </summary> /// <param name="currentMouse"></param> /// <returns></returns> private Point FixMouseCoordinates(Point currentMouse) { switch (_fixMode) { case FixMode.Initiated: if (_previousMousePos.X != currentMouse.X) { _fixMode = FixMode.Vertical; } else if (_previousMousePos.Y != currentMouse.Y) { _fixMode = FixMode.Horizontal; } break; case FixMode.Vertical: currentMouse = new Point(currentMouse.X, _previousMousePos.Y); break; case FixMode.Horizontal: currentMouse = new Point(_previousMousePos.X, currentMouse.Y); break; } _previousMousePos = currentMouse; return(currentMouse); }
public void FixGongFaData(int gongFaID, FixMode gongFaFixMode, object value) { if (gongFaFixData.TryGetValue(gongFaID, out Dictionary <int, string> data)) { string oldValue; int index = (int)gongFaFixMode; bool flag = data.TryGetValue(index, out oldValue); switch (gongFaFixMode) { case FixMode.发挥上限上升: { if (flag) { data[index] = (int.Parse(oldValue) + Convert.ToInt32(value)).ToString(); } else { data[index] = Convert.ToInt32(value).ToString(); } break; } } } else { gongFaFixData.Add(gongFaID, new Dictionary <int, string>()); FixGongFaData(gongFaID, gongFaFixMode, value); } }
/// <summary> /// Corrects this classes properties after the base sentence was changed. /// </summary> private new void SetPropertiesFromSentence() { // Cache the sentence words string[] words = Words; int wordCount = words.Length; FixMode = ParseFixMode(0); FixMethod = ParseFixMethod(1, true); if (wordCount >= 3) { // The sentence supports up to 12 satellites _fixedSatellites = new List <Satellite>(12); // Get each satellite PRN number int count = wordCount < 14 ? wordCount : 14; for (int index = 2; index < count; index++) { // add the satellite if word isn't empty if (words[index].Length != 0) { _fixedSatellites.Add(new Satellite(int.Parse(words[index], NmeaCultureInfo))); } } } PositionDilutionOfPrecision = ParseDilution(14); // Set overall dilution of precision HorizontalDilutionOfPrecision = ParseDilution(15); // Set horizontal dilution of precision VerticalDilutionOfPrecision = ParseDilution(16); // Set vertical dilution of precision }
public static bool CheckKeyUpForFixing(Keys keys) { if (keys == Keys.ShiftKey) { fixMode = FixMode.None; return true; } return false; }
/// <summary> /// Deserializes command /// </summary> /// <param name="talkedId"></param> /// <param name="parts"></param> internal RMC(string talkedId, string[] parts) : base(talkedId) { if (!string.IsNullOrWhiteSpace(parts[8])) { DateTime = System.DateTime.ParseExact(parts[8], DATETIME_DDMMYY, DateTimeFormatInfo.InvariantInfo, DateTimeStyles.AssumeUniversal | DateTimeStyles.AdjustToUniversal); } if (!string.IsNullOrWhiteSpace(parts[8])) { DateTime time; /* * * if ( * !System.DateTime.TryParseExact(parts[0], HHMMSSfff, DateTimeFormatInfo.InvariantInfo, DateTimeStyles.AssumeUniversal | DateTimeStyles.AdjustToUniversal, out time)) * { * time = System.DateTime.ParseExact(parts[0], HHMMSS, DateTimeFormatInfo.InvariantInfo, * DateTimeStyles.AssumeUniversal | DateTimeStyles.AdjustToUniversal); * } */ try { time = System.DateTime.ParseExact(parts[0], DATETIME_HHMMSSfff, DateTimeFormatInfo.InvariantInfo, DateTimeStyles.AssumeUniversal | DateTimeStyles.AdjustToUniversal); } catch (FormatException) { time = System.DateTime.ParseExact(parts[0], DATETIME_HHMMSS, DateTimeFormatInfo.InvariantInfo, DateTimeStyles.AssumeUniversal | DateTimeStyles.AdjustToUniversal); } DateTime = DateTime?.Add(time.TimeOfDay) ?? time; } Status = MessageFormatting.ParseOneLetterEnumByValue <Flag>(parts[1]); Position = new Position(parts[2], parts[3], parts[4], parts[5]); SOG = float.Parse(parts[6]); TMG = !string.IsNullOrWhiteSpace(parts[7]) ? new TrueMessageCompassValue(double.Parse(parts[7])) : null; if (!string.IsNullOrWhiteSpace(parts[9])) { MagneticVariation = float.Parse(parts[9]); } if (!string.IsNullOrWhiteSpace(parts[10])) { MagneticVariationDirection = MessageFormatting.ParseOneLetterEnumByValue <EastWest>(parts[10]); } if (parts.Length > 11 && !string.IsNullOrWhiteSpace(parts[11])) { Mode = MessageFormatting.ParseOneLetterEnumByValue <FixMode>(parts[11]); } }
public static bool CheckKeyUpForFixing(Keys keys) { if (keys == Keys.ShiftKey) { fixMode = FixMode.None; return(true); } return(false); }
public static bool CheckKeyDownForFixing(Keys keys) { if (keys == Keys.ShiftKey) { if (fixMode == FixMode.None) { fixMode = FixMode.Initiated; return true; } } return false; }
public static bool CheckKeyDownForFixing(Keys keys) { if (keys == Keys.ShiftKey) { if (fixMode == FixMode.None) { fixMode = FixMode.Initiated; return(true); } } return(false); }
/// <summary> /// Handle the key up event /// </summary> /// <param name="sender">object</param> /// <param name="keyEventArgs">KeyEventArgs</param> private void CaptureFormKeyUp(object sender, KeyEventArgs keyEventArgs) { switch (keyEventArgs.KeyCode) { case Keys.ShiftKey: _fixMode = FixMode.None; break; case Keys.ControlKey: _isCtrlPressed = false; break; } }
public static string ToString(FixMode fixMode) { switch (fixMode) { case FixMode.Manual: return("M"); case FixMode.Automatic: return("A"); default: return(""); } }
public static string FixModeString(FixMode value) { switch (value) { case FixMode.Auto: return("Auto"); case FixMode.Manual: return("Manual"); default: return("Unknown"); } }
public override void Empty() { base.Empty(); Operating = OperatingMode.Unknown; Fix = FixMode.Unknown; PositionDilutionOfPrecision = 0.0D; HorizontalDilutionOfPrecision = 0.0D; VerticalDilutionOfPrecision = 0.0D; for (int index = 0; index < Satellites.Length; index++) { Satellites[index] = 0; } }
public static Point FixMouseCoordinates(Point currentMouse) { if (fixMode == FixMode.Initiated) { if (previousMousePos.X != currentMouse.X) { fixMode = FixMode.Vertical; } else if (previousMousePos.Y != currentMouse.Y) { fixMode = FixMode.Horizontal; } } else if (fixMode == FixMode.Vertical) { currentMouse = new Point(currentMouse.X, previousMousePos.Y); } else if (fixMode == FixMode.Horizontal) { currentMouse = new Point(previousMousePos.X, currentMouse.Y); } previousMousePos = currentMouse; return currentMouse; }
void CaptureFormKeyDown(object sender, KeyEventArgs e) { // Check fixmode if (e.KeyCode == Keys.ShiftKey) { if (fixMode == FixMode.None) { fixMode = FixMode.Initiated; return; } } if (e.KeyCode == Keys.Escape) { DialogResult = DialogResult.Cancel; } else if (e.KeyCode == Keys.M) { // Toggle mouse cursor capture.CursorVisible = !capture.CursorVisible; pictureBox.Invalidate(); } else if (e.KeyCode == Keys.V && conf.isExperimentalFeatureEnabled("Video")) { capture.CaptureDetails.CaptureMode = CaptureMode.Video; pictureBox.Invalidate(); } else if (e.KeyCode == Keys.Space) { switch (captureMode) { case CaptureMode.Region: captureMode = CaptureMode.Window; break; case CaptureMode.Window: captureMode = CaptureMode.Region; break; } pictureBox.Invalidate(); selectedCaptureWindow = null; PictureBoxMouseMove(this, new MouseEventArgs(MouseButtons.None, 0, Cursor.Position.X, Cursor.Position.Y, 0)); } else if (e.KeyCode == Keys.Return && captureMode == CaptureMode.Window) { DialogResult = DialogResult.OK; } }
protected Emulator(string name) { _Name = name; // Create new buffers for reading and writing _ReadBuffer = new List <byte>(_DefaultReadBufferSize); _WriteBuffer = new List <byte>(_DefaultWriteBufferSize); // Initialize simulated values _ReadDataAvailableWaitHandle = new ManualResetEvent(false); _WriteDataAvailableWaitHandle = new ManualResetEvent(false); _EmulationIntervalWaitHandle = new ManualResetEvent(false); // Default timeouts for reading and writing _ReadTimeout = _DefaultReadTimeout; _WriteTimeout = _DefaultWriteTimeout; // Simulated values _seed = new Random(); _UtcDateTime = DateTime.UtcNow; _CurrentPosition = Positioning.Position.Empty; _Altitude = Distance.FromFeet(1000); _Route = new List <Position>(); _Satellites = new List <Satellite>(); _FixQuality = FixQuality.GpsFix; _FixMode = FixMode.Automatic; _FixMethod = FixMethod.Fix3D; _FixStatus = FixStatus.Fix; _HorizontalDop = DilutionOfPrecision.Good; _VerticalDop = DilutionOfPrecision.Good; _MeanDop = DilutionOfPrecision.Good; _Speed = Speed.FromStatuteMilesPerHour(20); _speedLow = Speed.FromKilometersPerSecond(10).Value; _speedHigh = Speed.FromKilometersPerSecond(25).Value; _Bearing = Azimuth.Southwest; _bearingStart = _seed.NextDouble() * 360; _bearingArc = 10; }
public static Point FixMouseCoordinates(Point currentMouse) { if (_fixMode == FixMode.Initiated) { if (_previousMousePos.X != currentMouse.X) { _fixMode = FixMode.Vertical; } else if (_previousMousePos.Y != currentMouse.Y) { _fixMode = FixMode.Horizontal; } } else if (_fixMode == FixMode.Vertical) { currentMouse = new Point(currentMouse.X, _previousMousePos.Y); } else if (_fixMode == FixMode.Horizontal) { currentMouse = new Point(_previousMousePos.X, currentMouse.Y); } _previousMousePos = currentMouse; return(currentMouse); }
/// <summary> /// This method is used to "fix" the mouse coordinates when keeping shift/ctrl pressed /// </summary> /// <param name="currentMouse"></param> /// <returns></returns> private Point FixMouseCoordinates(Point currentMouse) { if (fixMode == FixMode.Initiated) { if (previousMousePos.X != currentMouse.X) { fixMode = FixMode.Vertical; } else if (previousMousePos.Y != currentMouse.Y) { fixMode = FixMode.Horizontal; } } else if (fixMode == FixMode.Vertical) { currentMouse = new Point(currentMouse.X, previousMousePos.Y); } else if (fixMode == FixMode.Horizontal) { currentMouse = new Point(previousMousePos.X, currentMouse.Y); } previousMousePos = currentMouse; return(currentMouse); }
/// <summary> /// Creates a new GpgsaSentence /// </summary> /// <param name="fixMode">The fix mode.</param> /// <param name="fixMethod">The fix method.</param> /// <param name="satellites">The satellites.</param> /// <param name="positionDilutionOfPrecision">The position dilution of precision.</param> /// <param name="horizontalDilutionOfPrecision">The horizontal dilution of precision.</param> /// <param name="verticalDilutionOfPrecision">The vertical dilution of precision.</param> public GpgsaSentence(FixMode fixMode, FixMethod fixMethod, IEnumerable <Satellite> satellites, DilutionOfPrecision positionDilutionOfPrecision, DilutionOfPrecision horizontalDilutionOfPrecision, DilutionOfPrecision verticalDilutionOfPrecision) { // Use a string builder to create the sentence text StringBuilder builder = new StringBuilder(128); // Append the command word builder.Append("$GPGSA"); builder.Append(','); switch (fixMode) { case FixMode.Automatic: builder.Append("A"); break; default: builder.Append("M"); break; } builder.Append(','); switch (fixMethod) { case FixMethod.Fix2D: builder.Append("2"); break; case FixMethod.Fix3D: builder.Append("3"); break; default: builder.Append("1"); break; } builder.Append(','); #region Fixed satellites /* A comma-delimited list of satellites involved in a fix. Up to 12 satellites can be serialized. * This one concerns me, because while the limit is 12, ever more satellites are being launched. * Should we just serialize everything?? */ // Get a count of satellites to write, up to 123. We'll scrub the list to ensure only fixed satellites are written int fixedSatellitesWritten = 0; foreach (Satellite item in satellites) { // Is it fixed? if (item.IsFixed) { // Yes. It cannot have babies builder.Append(item.PseudorandomNumber.ToString(NmeaCultureInfo)); // Append a comma builder.Append(","); // Update the count fixedSatellitesWritten++; // If we're at 12, that's the limit. Stop here if (fixedSatellitesWritten == 12) { break; } } } // If we wrote less than 12 satellites, write commas for the remainder for (int index = 0; index < 12 - fixedSatellitesWritten; index++) { builder.Append(","); } #endregion Fixed satellites // NOTE: Commas have been written at this point // Position Dilution of Precision builder.Append(positionDilutionOfPrecision.Value.ToString(NmeaCultureInfo)); builder.Append(","); // Horizontal Dilution of Precision builder.Append(horizontalDilutionOfPrecision.Value.ToString(NmeaCultureInfo)); builder.Append(","); // Vertical Dilution of Precision builder.Append(verticalDilutionOfPrecision.Value.ToString(NmeaCultureInfo)); // Set this object's sentence Sentence = builder.ToString(); SetPropertiesFromSentence(); // Finally, append the checksum AppendChecksum(); }
/// <summary> /// Creates a new instance with the specified fix method. /// </summary> /// <param name="fixMode">A value from the <strong>FixMode</strong> enumeration.</param> /// <remarks></remarks> public FixModeEventArgs(FixMode fixMode) { _FixMode = fixMode; }
/// <summary> /// Updates the fix mode to the specified value. /// </summary> /// <param name="value">The value.</param> protected virtual void SetFixMode(FixMode value) { // If the new value is the same or it's invalid, ignore it if (value == _fixMode || value == FixMode.Unknown) return; // Set the new value _fixMode = value; // And notify if (FixModeChanged != null) FixModeChanged(this, new FixModeEventArgs(_fixMode)); }
/// <summary> /// Handle the key down event /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void CaptureFormKeyDown(object sender, KeyEventArgs e) { var step = _isCtrlPressed ? 10 : 1; switch (e.KeyCode) { case Keys.Up: Cursor.Position = new Point(Cursor.Position.X, Cursor.Position.Y - step); break; case Keys.Down: Cursor.Position = new Point(Cursor.Position.X, Cursor.Position.Y + step); break; case Keys.Left: Cursor.Position = new Point(Cursor.Position.X - step, Cursor.Position.Y); break; case Keys.Right: Cursor.Position = new Point(Cursor.Position.X + step, Cursor.Position.Y); break; case Keys.ShiftKey: // Fixmode if (_fixMode == FixMode.None) { _fixMode = FixMode.Initiated; } break; case Keys.ControlKey: _isCtrlPressed = true; break; case Keys.Escape: // Cancel DialogResult = DialogResult.Cancel; break; case Keys.M: // Toggle mouse cursor _capture.CursorVisible = !_capture.CursorVisible; Invalidate(); break; //// TODO: Enable when the screen capture code works reliable //case Keys.V: // // Video // if (capture.CaptureDetails.CaptureMode != CaptureMode.Video) { // capture.CaptureDetails.CaptureMode = CaptureMode.Video; // } else { // capture.CaptureDetails.CaptureMode = captureMode; // } // Invalidate(); // break; case Keys.Z: if (UsedCaptureMode == CaptureMode.Region) { // Toggle zoom Conf.ZoomerEnabled = !Conf.ZoomerEnabled; InitializeZoomer(Conf.ZoomerEnabled); Invalidate(); } break; case Keys.D: if (UsedCaptureMode == CaptureMode.Window) { // Toggle debug _showDebugInfo = !_showDebugInfo; Invalidate(); } break; case Keys.Space: // Toggle capture mode switch (UsedCaptureMode) { case CaptureMode.Region: // Set the window capture mode UsedCaptureMode = CaptureMode.Window; // "Fade out" Zoom InitializeZoomer(false); // "Fade in" window _windowAnimator = new RectangleAnimator(new NativeRect(_cursorPos, NativeSize.Empty), _captureRect, FramesForMillis(700), EasingTypes.Quintic, EasingModes.EaseOut); _captureRect = Rectangle.Empty; Invalidate(); break; case CaptureMode.Window: // Set the region capture mode UsedCaptureMode = CaptureMode.Region; // "Fade out" window _windowAnimator.ChangeDestination(new NativeRect(_cursorPos, NativeSize.Empty), FramesForMillis(700)); // Fade in zoom InitializeZoomer(Conf.ZoomerEnabled); _captureRect = Rectangle.Empty; Invalidate(); break; } SelectedCaptureWindow = null; OnMouseMove(this, new MouseEventArgs(MouseButtons.None, 0, Cursor.Position.X, Cursor.Position.Y, 0)); break; case Keys.Return: // Confirm if (UsedCaptureMode == CaptureMode.Window) { DialogResult = DialogResult.OK; } else if (!_mouseDown) { StartSelecting(); } else { FinishSelecting(); } break; case Keys.F: ToFront = !ToFront; TopMost = !TopMost; break; } }
/// <summary> /// This packet provides a list of satellites used for position or time-only fixes by the GPS /// receiver. The packet also provides the dilution of precision values PDOP, HDOP, VDOP and TDOP /// of that set and provides the current mode (automatic or manual, 3-D or 2-D, Over-Determined Clock /// mode, etc.). This packet has variable length equal to (17 + nsvs) where "nsvs" is the /// number of satellites used in the solution. If an SV is rejected for use by the T-RAIM /// algorithm then the SV PRN value will be negative. /// /// PDOP = positional DOP /// HDOP = horizontal DOP /// VDOP = vertical DOP /// TDOP = temporal DOP /// /// Note: The GPS receiver sends this packet in response to packet 0x24 or automatically. /// </summary> private void sat_list(TsipPacket tp) { byte mode, count, dimension; dimension = mode = count = tp.GetNextByte(); dimension &= 0x07; // fix dimension is in first 3 bits mode &= 0x08; // mode is in bit 3 mode >>= 3; count >>= 4; // tracked sat count in upper 4 bits //Debug.Print(":0x6D (Satellite List count = {0})", count); positional_dop = Helpers.FloatToFixPrecision(tp.GetNextSingle()); horizontal_dop = Helpers.FloatToFixPrecision(tp.GetNextSingle()); vertical_dop = Helpers.FloatToFixPrecision(tp.GetNextSingle()); temporal_dop = Helpers.FloatToFixPrecision(tp.GetNextSingle()); fix_dimension = Helpers.ByteToFixDimension(dimension); fix_mode = Helpers.ByteToFixMode(mode); for (int i = 0; i < 32; i++) // clear current tracking flags Satellites[i].UsedInFix = false; for (int i = 0; i < count; i++) { bool used = true; byte prn = tp.GetNextByte(); if ((prn & 0x80) == 0x80) // satellite is tracked but is not used in fix { used = false; prn &= 0x7F; } prn--; if (prn > 31) continue; // disregard bogus data Satellites[prn].Tracked = true; Satellites[prn].UsedInFix = used; } }
void CaptureFormKeyUp(object sender, KeyEventArgs e) { switch(e.KeyCode) { case Keys.ShiftKey: _fixMode = FixMode.None; break; case Keys.ControlKey: _isCtrlPressed = false; break; } }
void CaptureFormKeyUp(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.ShiftKey) { fixMode = FixMode.None; } }
public override bool Parse(Sentence sentence) { /* ** GSA - GPS DOP and Active Satellites ** ** 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 ** | | | | | | | | | | | | | | | | | | ** $--GSA,a,x,xx,xx,xx,xx,xx,xx,xx,xx,xx,xx,xx,xx,x.x,x.x,x.x*hh<CR><LF> ** ** Field Number: ** 1) Operating Mode, A = Automatic, M = Manual ** 2) Fix Mode, 1 = Fix not available, 2 = 2D, 3 = 3D ** 3) Satellite PRN #1 ** 4) Satellite PRN #2 ** 5) Satellite PRN #3 ** 6) Satellite PRN #4 ** 7) Satellite PRN #5 ** 8) Satellite PRN #6 ** 9) Satellite PRN #7 ** 10) Satellite PRN #8 ** 11) Satellite PRN #9 ** 12) Satellite PRN #10 ** 13) Satellite PRN #11 ** 14) Satellite PRN #12 ** 15) PDOP ** 16) HDOP ** 17) VDOP ** 18) Checksum */ /* ** First we check the checksum... */ if (sentence.IsChecksumBad() == Boolean.True) { Empty(); return(false); } string field = sentence.Field(1); if (field == "A") { Operating = OperatingMode.Automatic; } else if (field == "M") { Operating = OperatingMode.Manual; } else { Operating = OperatingMode.Unknown; } int index = sentence.Integer(2); switch (index) { case 1: Fix = FixMode.Unavailable; break; case 2: Fix = FixMode.TwoDimensional; break; case 3: Fix = FixMode.ThreeDimensional; break; default: Fix = FixMode.Unknown; break; } index = 0; while (index < 12) { Satellites[index] = sentence.Integer(index + 3); index++; } PositionDilutionOfPrecision = sentence.Double(15); HorizontalDilutionOfPrecision = sentence.Double(16); VerticalDilutionOfPrecision = sentence.Double(17); return(true); }
/// <summary> /// OnSentanceChanged event handler /// </summary> protected override void OnSentenceChanged() { base.OnSentenceChanged(); // Cache the sentence words string[] words = Words; int wordCount = words.Length; /* * Garmin produces several embedded GPS systems. They are easy to setup because Garmin provides a nice utility for uploading configuration data to the GPS. You first load the utility to a PC. Connect the PC to the GPS through one of the serial ports. The utility will check each baud rate until it communicates with the GPS. The common configuration parameters are output sentences from the GPS unit, the communication baud rate with a host, and the required pulse per second. Each sentence is preceded with a ‘$’ symbol and ends with a line-feed character. At one sentence per second, the following is out put in four seconds: $PGRMF, 223, 424798, 041203, 215945, 13, 0000.0000, N, 00000.0000, W, A, 2, 0, 62, 2, 1*3B $PGRMF, 223, 424799, 041203, 215946, 13, 00000.0000, N, 00000.0000, W, A, 2, 0, 62, 2, 1*39 $PGRMF, 223, 424800, 041203, 215947, 13, 00000.0000, N, 00000.0000, W, A, 2, 0, 62, 2, 1*34 $PGRMF, 223, 424801, 041203, 215948, 13, 00000.0000, N, 00000.0000, W, A, 2, 0, 62, 2, 1*35 The sentence is proprietary to the Garmin GPS Global Positioning System and is translated below. $PGRMF <1>GPS Week Number(0-1023) <2>GPS Seconds (0 - 604799) <3>UTC Date of position fix, ddmmyy format <4>UTC time of position fix, hhmmss format <5>GPS leap second count <6>Latitude, ddmm.mmmm format (leading zeros transmitted) <7>Latitude hemisphere N or S <8>Longitude, ddmm.mmmm format (leading zeros transmitted) <9>Longitude hemisphere N or S <10>Mode M = Manual, A automatic <11>Fix type 0 = No Fix, 1 = 2D Fix, 2 = 3D fix <12>Speed over ground, 0 to 359 degrees true <13>Course over ground, 0 to 9 (rounded to nearest intvalue) <14>Time dilution of precision, 0 to 9 (rnded nearest int val) <15>Time dilution of precision, 0 to 9 (rnded nearest int val) *hh <CR><LF> */ // TODO: Convert GPS week number/seconds to UTC date/time // Do we have enough words to parse the fix status? if (wordCount >= 4 && words[2].Length != 0 && words[3].Length != 0) { // Build a UTC date/time object. _utcDateTime = new DateTime( int.Parse(words[2].Substring(4, 2), NmeaCultureInfo) + 2000, // Year int.Parse(words[2].Substring(2, 2), NmeaCultureInfo), // Month int.Parse(words[2].Substring(0, 2), NmeaCultureInfo), // Day int.Parse(words[3].Substring(0, 2), NmeaCultureInfo), // Hour int.Parse(words[3].Substring(2, 2), NmeaCultureInfo), // Minute int.Parse(words[3].Substring(4, 2), NmeaCultureInfo), // Second DateTimeKind.Utc); } #region Position // Can we parse the latitude and longitude? if (wordCount >= 8 && words[5].Length != 0 && words[6].Length != 0 && words[7].Length != 0 && words[8].Length != 0) { #region Parse the latitude string latitudeWord = words[5]; int latitudeHours = int.Parse(latitudeWord.Substring(0, 2), NmeaCultureInfo); double latitudeDecimalMinutes = double.Parse(latitudeWord.Substring(2), NmeaCultureInfo); LatitudeHemisphere latitudeHemisphere = words[6].Equals("N", StringComparison.Ordinal) ? LatitudeHemisphere.North : LatitudeHemisphere.South; #endregion Parse the latitude #region Parse the longitude string longitudeWord = words[7]; int longitudeHours = int.Parse(longitudeWord.Substring(0, 3), NmeaCultureInfo); double longitudeDecimalMinutes = double.Parse(longitudeWord.Substring(3), NmeaCultureInfo); LongitudeHemisphere longitudeHemisphere = words[8].Equals("E", StringComparison.Ordinal) ? LongitudeHemisphere.East : LongitudeHemisphere.West; #endregion Parse the longitude #region Build a Position from the latitude and longitude _position = new Position( new Latitude(latitudeHours, latitudeDecimalMinutes, latitudeHemisphere), new Longitude(longitudeHours, longitudeDecimalMinutes, longitudeHemisphere)); #endregion Build a Position from the latitude and longitude } else { _position = Position.Invalid; } #endregion Position #region Fix Mode if (wordCount >= 9 && words[9].Length != 0) { _fixMode = words[9] == "A" ? FixMode.Automatic : FixMode.Manual; } else { _fixMode = FixMode.Unknown; } #endregion Fix Mode #region Fix Quality // Do we have enough data for fix quality? if (wordCount >= 10 && words[10].Length != 0) { switch (int.Parse(words[10], NmeaCultureInfo)) { case 0: _fixQuality = FixQuality.NoFix; break; case 1: _fixQuality = FixQuality.GpsFix; break; case 2: _fixQuality = FixQuality.DifferentialGpsFix; break; case 3: _fixQuality = FixQuality.PulsePerSecond; break; case 4: _fixQuality = FixQuality.FixedRealTimeKinematic; break; case 5: _fixQuality = FixQuality.FloatRealTimeKinematic; break; case 6: _fixQuality = FixQuality.Estimated; break; case 7: _fixQuality = FixQuality.ManualInput; break; case 8: _fixQuality = FixQuality.Simulated; break; default: _fixQuality = FixQuality.Unknown; break; } } else { // This fix quality is invalid _fixQuality = FixQuality.Unknown; } #endregion Fix Quality #region Bearing // Do we have enough data for fix quality? if (wordCount >= 13 && words[12].Length != 0) { _bearing = new Azimuth(words[12], NmeaCultureInfo); } else { _bearing = Azimuth.Invalid; } #endregion Bearing #region Speed // Do we have enough data for fix quality? if (wordCount >= 12 && words[11].Length != 0) { _speed = Speed.FromKilometersPerHour(double.Parse(words[11], NmeaCultureInfo)); } else { _speed = Speed.Invalid; } #endregion Speed #region Position Dilution of Precision // Do we have enough data for fix quality? if (wordCount >= 13 && words[13].Length != 0) { _positionDop = new DilutionOfPrecision(float.Parse(words[13], NmeaCultureInfo)); } else { _positionDop = DilutionOfPrecision.Invalid; } #endregion Position Dilution of Precision }
/// <summary> /// Handle the key down event /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void CaptureFormKeyDown(object sender, KeyEventArgs e) { switch (e.KeyCode) { case Keys.Up: Cursor.Position = new Point(Cursor.Position.X, Cursor.Position.Y - 1); break; case Keys.Down: Cursor.Position = new Point(Cursor.Position.X, Cursor.Position.Y + 1); break; case Keys.Left: Cursor.Position = new Point(Cursor.Position.X - 1, Cursor.Position.Y); break; case Keys.Right: Cursor.Position = new Point(Cursor.Position.X + 1, Cursor.Position.Y); break; case Keys.ShiftKey: // Fixmode if (fixMode == FixMode.None) { fixMode = FixMode.Initiated; return; } break; case Keys.Escape: // Cancel DialogResult = DialogResult.Cancel; break; case Keys.M: // Toggle mouse cursor capture.CursorVisible = !capture.CursorVisible; Invalidate(); break; //// TODO: Enable when the screen capture code works reliable //case Keys.V: // // Video // if (capture.CaptureDetails.CaptureMode != CaptureMode.Video) { // capture.CaptureDetails.CaptureMode = CaptureMode.Video; // } else { // capture.CaptureDetails.CaptureMode = captureMode; // } // Invalidate(); // break; case Keys.Z: if (captureMode == CaptureMode.Region) { // Toggle zoom conf.ZoomerEnabled = !conf.ZoomerEnabled; InitializeZoomer(conf.ZoomerEnabled); Invalidate(); } break; case Keys.Space: // Toggle capture mode switch (captureMode) { case CaptureMode.Region: // Set the window capture mode captureMode = CaptureMode.Window; // "Fade out" Zoom InitializeZoomer(false); // "Fade in" window windowAnimator = new RectangleAnimator(new Rectangle(cursorPos, Size.Empty), captureRect, FramesForMillis(700), EasingType.Quintic, EasingMode.EaseOut); captureRect = Rectangle.Empty; Invalidate(); break; case CaptureMode.Window: // Set the region capture mode captureMode = CaptureMode.Region; // "Fade out" window windowAnimator.ChangeDestination(new Rectangle(cursorPos, Size.Empty), FramesForMillis(700)); // Fade in zoom InitializeZoomer(conf.ZoomerEnabled); captureRect = Rectangle.Empty; Invalidate(); break; } selectedCaptureWindow = null; OnMouseMove(this, new MouseEventArgs(MouseButtons.None, 0, Cursor.Position.X, Cursor.Position.Y, 0)); break; case Keys.Return: // Confirm if (captureMode == CaptureMode.Window) { DialogResult = DialogResult.OK; } break; } }
/// <summary> /// This method is used to "fix" the mouse coordinates when keeping shift/ctrl pressed /// </summary> /// <param name="currentMouse"></param> /// <returns></returns> private Point FixMouseCoordinates(Point currentMouse) { if (_fixMode == FixMode.Initiated) { if (_previousMousePos.X != currentMouse.X) { _fixMode = FixMode.Vertical; } else if (_previousMousePos.Y != currentMouse.Y) { _fixMode = FixMode.Horizontal; } } else if (_fixMode == FixMode.Vertical) { currentMouse = new Point(currentMouse.X, _previousMousePos.Y); } else if (_fixMode == FixMode.Horizontal) { currentMouse = new Point(_previousMousePos.X, currentMouse.Y); } _previousMousePos = currentMouse; return currentMouse; }
/// <inheritdoc /> protected override void SetIndexValue(int idx, ReadOnlySpan <char> val) { switch (idx) { case 0: SelectionMode = GetSelectionMode(val); break; case 1: Mode = GetFixMode(val); break; case 2: Sat1Id = GetInteger(val); break; case 3: Sat2Id = GetInteger(val); break; case 4: Sat3Id = GetInteger(val); break; case 5: Sat4Id = GetInteger(val); break; case 6: Sat5Id = GetInteger(val); break; case 7: Sat6Id = GetInteger(val); break; case 8: Sat7Id = GetInteger(val); break; case 9: Sat8Id = GetInteger(val); break; case 10: Sat9Id = GetInteger(val); break; case 11: Sat10Id = GetInteger(val); break; case 12: Sat11Id = GetInteger(val); break; case 13: Sat12Id = GetInteger(val); break; case 14: PDOPMeters = GetDouble(val); break; case 15: HDOPMeters = GetDouble(val); break; case 16: VDOPMeters = GetDouble(val); break; } }
/// <summary> /// Called when [sentence changed]. /// </summary> protected override void OnSentenceChanged() { // First, process the basic info for the sentence base.OnSentenceChanged(); // Cache the sentence words string[] words = Words; int wordCount = words.Length; #region Fix mode if (wordCount >= 1 && words[0].Length != 0) { switch (words[0]) { case "A": _fixMode = FixMode.Automatic; break; case "M": _fixMode = FixMode.Manual; break; default: _fixMode = FixMode.Unknown; break; } } else { _fixMode = FixMode.Unknown; } #endregion Fix mode #region Fix method // Get the fix quality information if (wordCount >= 2 && words[1].Length != 0) { switch (words[1]) { case "1": _fixMethod = FixMethod.NoFix; break; case "2": _fixMethod = FixMethod.Fix2D; break; case "3": _fixMethod = FixMethod.Fix3D; break; default: _fixMethod = FixMethod.Unknown; break; } } else { _fixMethod = FixMethod.Unknown; } #endregion Fix method #region Fixed satellites if (wordCount >= 3) { // The sentence supports up to 12 satellites _fixedSatellites = new List <Satellite>(12); // Get each satellite PRN number int count = wordCount < 14 ? wordCount : 14; for (int index = 2; index < count; index++) { // Is the word empty? if (words[index].Length != 0) { // No. Add a satellite _fixedSatellites.Add( // We'll only have an empty object for now new Satellite(int.Parse(words[index], NmeaCultureInfo))); } } } #endregion Fixed satellites #region Dilution of Precision // Set overall dilution of precision if (wordCount >= 15 && words[14].Length != 0) { _positionDop = new DilutionOfPrecision(float.Parse(words[14], NmeaCultureInfo)); } else { _positionDop = DilutionOfPrecision.Invalid; } // Set horizontal dilution of precision if (wordCount >= 16 && words[15].Length != 0) { _horizontalDop = new DilutionOfPrecision(float.Parse(words[15], NmeaCultureInfo)); } else { _horizontalDop = DilutionOfPrecision.Invalid; } // Set vertical dilution of precision if (wordCount >= 17 && words[16].Length != 0) { _verticalDop = new DilutionOfPrecision(float.Parse(words[16], NmeaCultureInfo)); } else { _verticalDop = DilutionOfPrecision.Invalid; } #endregion Dilution of Precision }
protected override void OnSentenceChanged() { // First, process the basic info for the sentence base.OnSentenceChanged(); // Cache the sentence words string[] words = base.Words; int wordCount = words.Length; #region Fix mode if (wordCount >= 1 && words[0].Length != 0) { switch (words[0]) { case "A": _FixMode = FixMode.Automatic; break; case "M": _FixMode = FixMode.Manual; break; default: _FixMode = FixMode.Unknown; break; } } else { _FixMode = FixMode.Unknown; } #endregion #region Fix method // Get the fix quality information if (wordCount >= 2 && words[1].Length != 0) { switch (words[1]) { case "1": _FixMethod = FixMethod.NoFix; break; case "2": _FixMethod = FixMethod.Fix2D; break; case "3": _FixMethod = FixMethod.Fix3D; break; default: _FixMethod = FixMethod.Unknown; break; } } else { _FixMethod = FixMethod.Unknown; } #endregion #region Fixed satellites if (wordCount >= 3) { // The sentence supports up to 12 satellites _FixedSatellites = new List<Satellite>(12); // Get each satellite PRN number int count = wordCount < 14 ? wordCount : 14; for (int index = 2; index < count; index++) // Is the word empty? if (words[index].Length != 0) // No. Add a satellite _FixedSatellites.Add( // We'll only have an empty object for now new Satellite(int.Parse(words[index], NmeaCultureInfo))); } #endregion #region Dilution of Precision // Set overall dilution of precision if (wordCount >= 15 && words[14].Length != 0) _PositionDop = new DilutionOfPrecision(float.Parse(words[14], NmeaCultureInfo)); else _PositionDop = DilutionOfPrecision.Invalid; // Set horizontal dilution of precision if (wordCount >= 16 && words[15].Length != 0) _HorizontalDop = new DilutionOfPrecision(float.Parse(words[15], NmeaCultureInfo)); else _HorizontalDop = DilutionOfPrecision.Invalid; // Set vertical dilution of precision if (wordCount >= 17 && words[16].Length != 0) _VerticalDop = new DilutionOfPrecision(float.Parse(words[16], NmeaCultureInfo)); else _VerticalDop = DilutionOfPrecision.Invalid; #endregion }
/// <summary> /// Creates a new instance with the specified fix method. /// </summary> /// <param name="fixMode">A value from the <strong>FixMode</strong> enumeration.</param> /// <remarks></remarks> public FixModeEventArgs(FixMode fixMode) { _FixMode = fixMode; }
/// <summary> /// Handle the key down event /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void CaptureFormKeyDown(object sender, KeyEventArgs e) { int step = _isCtrlPressed ? 10 : 1; switch (e.KeyCode) { case Keys.Up: Cursor.Position = new Point(Cursor.Position.X, Cursor.Position.Y - step); break; case Keys.Down: Cursor.Position = new Point(Cursor.Position.X, Cursor.Position.Y + step); break; case Keys.Left: Cursor.Position = new Point(Cursor.Position.X - step, Cursor.Position.Y); break; case Keys.Right: Cursor.Position = new Point(Cursor.Position.X + step, Cursor.Position.Y); break; case Keys.ShiftKey: // Fixmode if (_fixMode == FixMode.None) { _fixMode = FixMode.Initiated; } break; case Keys.ControlKey: _isCtrlPressed = true; break; case Keys.Escape: // Cancel DialogResult = DialogResult.Cancel; break; case Keys.M: // Toggle mouse cursor _capture.CursorVisible = !_capture.CursorVisible; Invalidate(); break; //// TODO: Enable when the screen capture code works reliable //case Keys.V: // // Video // if (capture.CaptureDetails.CaptureMode != CaptureMode.Video) { // capture.CaptureDetails.CaptureMode = CaptureMode.Video; // } else { // capture.CaptureDetails.CaptureMode = captureMode; // } // Invalidate(); // break; case Keys.Z: if (_captureMode == CaptureMode.Region) { // Toggle zoom Conf.ZoomerEnabled = !Conf.ZoomerEnabled; InitializeZoomer(Conf.ZoomerEnabled); Invalidate(); } break; case Keys.Space: // Toggle capture mode switch (_captureMode) { case CaptureMode.Region: // Set the window capture mode _captureMode = CaptureMode.Window; // "Fade out" Zoom InitializeZoomer(false); // "Fade in" window _windowAnimator = new RectangleAnimator(new Rectangle(_cursorPos, Size.Empty), _captureRect, FramesForMillis(700), EasingType.Quintic, EasingMode.EaseOut); _captureRect = Rectangle.Empty; Invalidate(); break; case CaptureMode.Window: // Set the region capture mode _captureMode = CaptureMode.Region; // "Fade out" window _windowAnimator.ChangeDestination(new Rectangle(_cursorPos, Size.Empty), FramesForMillis(700)); // Fade in zoom InitializeZoomer(Conf.ZoomerEnabled); _captureRect = Rectangle.Empty; Invalidate(); break; } _selectedCaptureWindow = null; OnMouseMove(this, new MouseEventArgs(MouseButtons.None, 0, Cursor.Position.X, Cursor.Position.Y, 0)); break; case Keys.Return: // Confirm if (_captureMode == CaptureMode.Window) { DialogResult = DialogResult.OK; } else if (!_mouseDown) { HandleMouseDown(); } else if (_mouseDown) { HandleMouseUp(); } break; } }
public GpgsaSentence(FixMode fixMode, FixMethod fixMethod, IList<Satellite> satellites, DilutionOfPrecision positionDilutionOfPrecision, DilutionOfPrecision horizontalDilutionOfPrecision, DilutionOfPrecision verticalDilutionOfPrecision) { // Use a string builder to create the sentence text StringBuilder builder = new StringBuilder(128); // Append the command word builder.Append("$GPGSA"); // Append a comma builder.Append(','); #region Append the fix method switch (_FixMode) { case FixMode.Automatic: builder.Append("A"); break; default: builder.Append("M"); break; } #endregion // Append a comma builder.Append(','); #region Append the fix method switch (_FixMethod) { case FixMethod.Fix2D: builder.Append("2"); break; case FixMethod.Fix3D: builder.Append("3"); break; default: builder.Append("1"); break; } #endregion // Append a comma builder.Append(','); #region Fixed satellites /* A comma-delimited list of satellites involved in a fix. Up to 12 satellites can be serialized. * This one concerns me, because while the limit is 12, ever more satellites are being launched. * Should we just serialize everything?? */ // Get a count of satellites to write, up to 123. We'll scrub the list to ensure only fixed satellites are written int fixedSatellitesWritten = 0; for(int index = 0; index < satellites.Count; index++) { // Get the satellite Satellite item = satellites[index]; // Is it fixed? if(item.IsFixed) { // Yes. It cannot have babies builder.Append(item.PseudorandomNumber.ToString(NmeaCultureInfo)); // Append a comma builder.Append(","); // Update the count fixedSatellitesWritten++; // If we're at 12, that's the limit. Stop here if(fixedSatellitesWritten == 12) break; } } // If we wrote less than 12 satellites, write commas for the remainder for(int index = 0; index < 12 - fixedSatellitesWritten; index++) builder.Append(","); #endregion // NOTE: Commas have been written at this point // Position Dilution of Precision builder.Append(positionDilutionOfPrecision.Value.ToString(NmeaCultureInfo)); // Append a comma builder.Append(","); // Horizontal Dilution of Precision builder.Append(horizontalDilutionOfPrecision.Value.ToString(NmeaCultureInfo)); // Append a comma builder.Append(","); // Vertical Dilution of Precision builder.Append(verticalDilutionOfPrecision.Value.ToString(NmeaCultureInfo)); // Set this object's sentence SetSentence(builder.ToString()); // Finally, append the checksum AppendChecksum(); }
void CaptureFormKeyDown(object sender, KeyEventArgs e) { // Check fixmode if (e.KeyCode == Keys.ShiftKey) { if (fixMode == FixMode.None) { fixMode = FixMode.Initiated; return; } } if (e.KeyCode == Keys.Escape) { DialogResult = DialogResult.Cancel; } else if (e.KeyCode == Keys.M) { // Toggle mouse cursor capture.CursorVisible = !capture.CursorVisible; pictureBox.Invalidate(); } else if (e.KeyCode == Keys.V && conf.isExperimentalFeatureEnabled("Video")) { capture.CaptureDetails.CaptureMode = CaptureMode.Video; pictureBox.Invalidate(); } else if (e.KeyCode == Keys.Space) { switch (captureMode) { case CaptureMode.Region: captureMode = CaptureMode.Window; break; case CaptureMode.Window: captureMode = CaptureMode.Region; break; } pictureBox.Invalidate(); selectedCaptureWindow = null; PictureBoxMouseMove(this, new MouseEventArgs(MouseButtons.None, 0, Cursor.Position.X, Cursor.Position.Y, 0)); } else if (e.KeyCode == Keys.Return && captureMode == CaptureMode.Window) { DialogResult = DialogResult.OK; } }
protected Emulator(string name) { _Name = name; // Create new buffers for reading and writing _ReadBuffer = new List<byte>(_DefaultReadBufferSize); _WriteBuffer = new List<byte>(_DefaultWriteBufferSize); // Initialize simulated values _ReadDataAvailableWaitHandle = new ManualResetEvent(false); _WriteDataAvailableWaitHandle = new ManualResetEvent(false); _EmulationIntervalWaitHandle = new ManualResetEvent(false); // Default timeouts for reading and writing _ReadTimeout = _DefaultReadTimeout; _WriteTimeout = _DefaultWriteTimeout; // Simulated values _seed = new Random(); _UtcDateTime = DateTime.UtcNow; _CurrentPosition = GeoFramework.Position.Empty; _Altitude = Distance.FromFeet(1000); _Route = new List<Position>(); _Satellites = new List<Satellite>(); _FixQuality = FixQuality.GpsFix; _FixMode = FixMode.Automatic; _FixMethod = FixMethod.Fix3D; _FixStatus = FixStatus.Fix; _HorizontalDop = DilutionOfPrecision.Good; _VerticalDop = DilutionOfPrecision.Good; _MeanDop = DilutionOfPrecision.Good; _Speed = Speed.FromStatuteMilesPerHour(20); _speedLow = Speed.FromKilometersPerSecond(10).Value; _speedHigh = Speed.FromKilometersPerSecond(25).Value; _Bearing = Azimuth.Southwest; _bearingStart = _seed.NextDouble() * 360; _bearingArc = 10; }
/// <summary> /// OnSentanceChanged event handler /// </summary> protected override void OnSentenceChanged() { base.OnSentenceChanged(); // Cache the sentence words string[] words = Words; int wordCount = words.Length; /* * Garmin produces several embedded GPS systems. They are easy to setup because Garmin provides a nice utility for uploading configuration data to the GPS. You first load the utility to a PC. Connect the PC to the GPS through one of the serial ports. The utility will check each baud rate until it communicates with the GPS. * * The common configuration parameters are output sentences from the GPS unit, the communication baud rate with a host, and the required pulse per second. * * Each sentence is preceded with a ‘$’ symbol and ends with a line-feed character. At one sentence per second, the following is out put in four seconds: * * $PGRMF, 223, 424798, 041203, 215945, 13, 0000.0000, N, 00000.0000, W, A, 2, 0, 62, 2, 1*3B * $PGRMF, 223, 424799, 041203, 215946, 13, 00000.0000, N, 00000.0000, W, A, 2, 0, 62, 2, 1*39 * $PGRMF, 223, 424800, 041203, 215947, 13, 00000.0000, N, 00000.0000, W, A, 2, 0, 62, 2, 1*34 * $PGRMF, 223, 424801, 041203, 215948, 13, 00000.0000, N, 00000.0000, W, A, 2, 0, 62, 2, 1*35 * * The sentence is proprietary to the Garmin GPS Global Positioning System and is translated below. * * $PGRMF * <1>GPS Week Number(0-1023) * <2>GPS Seconds (0 - 604799) * <3>UTC Date of position fix, ddmmyy format * <4>UTC time of position fix, hhmmss format * <5>GPS leap second count * <6>Latitude, ddmm.mmmm format (leading zeros transmitted) * <7>Latitude hemisphere N or S * <8>Longitude, ddmm.mmmm format (leading zeros transmitted) * <9>Longitude hemisphere N or S * <10>Mode M = Manual, A automatic * <11>Fix type 0 = No Fix, 1 = 2D Fix, 2 = 3D fix * <12>Speed over ground, 0 to 359 degrees true * <13>Course over ground, 0 to 9 (rounded to nearest intvalue) * <14>Time dilution of precision, 0 to 9 (rnded nearest int val) * <15>Time dilution of precision, 0 to 9 (rnded nearest int val) * hh <CR><LF> */ // TODO: Convert GPS week number/seconds to UTC date/time // Do we have enough words to parse the fix status? if (wordCount >= 4 && words[2].Length != 0 && words[3].Length != 0) { // Build a UTC date/time object. _utcDateTime = new DateTime( int.Parse(words[2].Substring(4, 2), NmeaCultureInfo) + 2000, // Year int.Parse(words[2].Substring(2, 2), NmeaCultureInfo), // Month int.Parse(words[2].Substring(0, 2), NmeaCultureInfo), // Day int.Parse(words[3].Substring(0, 2), NmeaCultureInfo), // Hour int.Parse(words[3].Substring(2, 2), NmeaCultureInfo), // Minute int.Parse(words[3].Substring(4, 2), NmeaCultureInfo), // Second DateTimeKind.Utc); } #region Position // Can we parse the latitude and longitude? if (wordCount >= 8 && words[5].Length != 0 && words[6].Length != 0 && words[7].Length != 0 && words[8].Length != 0) { #region Parse the latitude string latitudeWord = words[5]; int latitudeHours = int.Parse(latitudeWord.Substring(0, 2), NmeaCultureInfo); double latitudeDecimalMinutes = double.Parse(latitudeWord.Substring(2), NmeaCultureInfo); LatitudeHemisphere latitudeHemisphere = words[6].Equals("N", StringComparison.Ordinal) ? LatitudeHemisphere.North : LatitudeHemisphere.South; #endregion Parse the latitude #region Parse the longitude string longitudeWord = words[7]; int longitudeHours = int.Parse(longitudeWord.Substring(0, 3), NmeaCultureInfo); double longitudeDecimalMinutes = double.Parse(longitudeWord.Substring(3), NmeaCultureInfo); LongitudeHemisphere longitudeHemisphere = words[8].Equals("E", StringComparison.Ordinal) ? LongitudeHemisphere.East : LongitudeHemisphere.West; #endregion Parse the longitude #region Build a Position from the latitude and longitude _position = new Position( new Latitude(latitudeHours, latitudeDecimalMinutes, latitudeHemisphere), new Longitude(longitudeHours, longitudeDecimalMinutes, longitudeHemisphere)); #endregion Build a Position from the latitude and longitude } else { _position = Position.Invalid; } #endregion Position #region Fix Mode if (wordCount >= 9 && words[9].Length != 0) { _fixMode = words[9] == "A" ? FixMode.Automatic : FixMode.Manual; } else { _fixMode = FixMode.Unknown; } #endregion Fix Mode #region Fix Quality // Do we have enough data for fix quality? if (wordCount >= 10 && words[10].Length != 0) { switch (int.Parse(words[10], NmeaCultureInfo)) { case 0: _fixQuality = FixQuality.NoFix; break; case 1: _fixQuality = FixQuality.GpsFix; break; case 2: _fixQuality = FixQuality.DifferentialGpsFix; break; case 3: _fixQuality = FixQuality.PulsePerSecond; break; case 4: _fixQuality = FixQuality.FixedRealTimeKinematic; break; case 5: _fixQuality = FixQuality.FloatRealTimeKinematic; break; case 6: _fixQuality = FixQuality.Estimated; break; case 7: _fixQuality = FixQuality.ManualInput; break; case 8: _fixQuality = FixQuality.Simulated; break; default: _fixQuality = FixQuality.Unknown; break; } } else { // This fix quality is invalid _fixQuality = FixQuality.Unknown; } #endregion Fix Quality #region Bearing // Do we have enough data for fix quality? if (wordCount >= 13 && words[12].Length != 0) { _bearing = new Azimuth(words[12], NmeaCultureInfo); } else { _bearing = Azimuth.Invalid; } #endregion Bearing #region Speed // Do we have enough data for fix quality? if (wordCount >= 12 && words[11].Length != 0) { _speed = Speed.FromKilometersPerHour(double.Parse(words[11], NmeaCultureInfo)); } else { _speed = Speed.Invalid; } #endregion Speed #region Position Dilution of Precision // Do we have enough data for fix quality? if (wordCount >= 13 && words[13].Length != 0) { _positionDop = new DilutionOfPrecision(float.Parse(words[13], NmeaCultureInfo)); } else { _positionDop = DilutionOfPrecision.Invalid; } #endregion Position Dilution of Precision }