public Gps(string gpsDeviceName, BaudRate baudRate) { this.GpsDeviceName = gpsDeviceName; NmeaParser = new NmeaParser(); this.State = new GpsState(); GpsDevice = new SerialDevice(gpsDeviceName, baudRate); GpsDevice.DataReceived += (sender, bytes) => { var nmeas = DeserializeMessages(bytes); nmeas.SetGpsState(ref State); var position = nmeas?.GetPosition(); if (position == null) { return; } Position = position; var args = new GpsUpdateEventArgs(Position, State, GpsDevice); OnGpsUpdate(this, args); }; }
protected virtual void OnGpsUpdate(Gps gps, GpsUpdateEventArgs args) { GpsUpdate?.Invoke(gps, args); }