private void OnPositionRecieved(PositionData data) { if (this.PositionReceived != null) { this.PositionReceived(this, new PositionEventArgs(data)); } }
public void Write(PositionData data, long ticks) { writer.Write(ticks); writer.Write(data.X); writer.Write(data.Y); writer.Write(data.Z); writer.Write(data.Roll); writer.Write(data.Pitch); writer.Write(data.Yaw); }
void worker_DoWork(object sender, DoWorkEventArgs e) { while (!worker.CancellationPending) { if (locked) { continue; } locked = true; byte[] buffer = new byte[256]; this.tcpClient.Client.Receive(buffer); System.Text.UTF8Encoding encoding = new System.Text.UTF8Encoding(); string message = encoding.GetString(buffer).Trim(); //super super amazingly crappy 'parsing' of the string. Please don't ever use this. Just for testing quickly... if (message.Contains("$GPGGA")) { try { message = message.Substring(message.IndexOf("$GPGGA"), 61); GPGGAString data = NMEA.ProcessGPGGA(message); //at some point should integrate gyro/accelerometer to get pitch/yaw/roll information PositionData position = new PositionData(data.Longitude, data.Latitude, data.Altitude, 0, 0, 0); this.LastPosition = position; if (this.started) { this.OnPositionRecieved(position); } } catch (Exception ex) { } } locked = false; } }
void worker_DoWork(object sender, DoWorkEventArgs e) { while (!worker.CancellationPending) { if (locked) continue; locked = true; byte[] buffer = new byte[256]; this.tcpClient.Client.Receive(buffer); System.Text.UTF8Encoding encoding=new System.Text.UTF8Encoding(); string message = encoding.GetString(buffer).Trim(); //super super amazingly crappy 'parsing' of the string. Please don't ever use this. Just for testing quickly... if (message.Contains("$GPGGA")) { try { message = message.Substring(message.IndexOf("$GPGGA"), 61); GPGGAString data = NMEA.ProcessGPGGA(message); //at some point should integrate gyro/accelerometer to get pitch/yaw/roll information PositionData position = new PositionData(data.Longitude, data.Latitude, data.Altitude, 0, 0, 0); this.LastPosition = position; if (this.started) { this.OnPositionRecieved(position); } } catch (Exception ex) { } } locked = false; } }
public PositionEventArgs(PositionData position) { this.Position = position; }