protected void OnGSDataPacketReceived(object sender, PacketUpdatedEventArgs data) { Dispatcher.CurrentDispatcher.Invoke(() => { foreach (var key in LaunchArmed.KeyList) { key.IsEngaged = true; } }); }
private async void Log(object sender, PacketUpdatedEventArgs args) { try { // This text is added only once to the file. if (!File.Exists(_fileName)) using (var sw = File.CreateText(_fileName)) { await sw.WriteLineAsync(_header); await sw.WriteLineAsync(_packet.CSVHeader); } using (var sw = File.AppendText(_fileName)) { await sw.WriteLineAsync(_packet.CSVData); } } catch (Exception ex) { Console.WriteLine($@"File IO Error: {ex.Message}"); } }
protected void OnRocketDataPacketReceived(object sender, PacketUpdatedEventArgs data) { Application.Current.Dispatcher.Invoke(() => { var packet = (RocketDataPacket)data.Packet; IsConnected["Radio"].IsConnected = true; IsConnected["SDCard"].IsConnected = packet.SDCardConnected; LaunchArmed.IsRocketArmed = packet.LaunchedArmed; EventTimes.BackDrogueTime = packet.BackDrogueTime; EventTimes.BackMainTime = packet.BackMainTime; EventTimes.ElapsedTime = packet.ElapsedTime; EventTimes.LaunchTime = packet.LaunchTime; EventTimes.SelfDrogueBackTime = packet.SelfDrogueBackTime; EventTimes.SelfDroguePrimTime = packet.SelfDroguePrimTime; EventTimes.SelfMainBackTime = packet.SelfMainBackTime; EventTimes.SelfMainPrimTime = packet.SelfMainPrimTime; IsConnected["IMU"].IsConnected = packet.IMUConnected; if (packet.IMUConnected) { OrientationPosition.Acceleration = packet.Acceleration; OrientationPosition.Gyroscope = packet.GyroScope; OrientationPosition.Magnetometer = packet.Magnetometer; OrientationPosition.Euler = new[] { packet.Roll, packet.Pitch, packet.Yaw }; } IsConnected["Alt"].IsConnected = packet.AltConnected; if (packet.AltConnected) { OrientationPosition.Temperature = packet.Temperature; OrientationPosition.Pressure = packet.Pressure; OrientationPosition.AltASL = packet.AltAltitude; OrientationPosition.AltASLMax = packet.AltAltitudeMax; } IsConnected["GPS"].IsConnected = packet.GPSConnected; if (packet.GPSConnected) { OrientationPosition.GPSAltInit = packet.GPSAltitudeInit; OrientationPosition.Course = packet.Course; OrientationPosition.Latitude = packet.Latitude; OrientationPosition.Longitude = packet.Longitude; OrientationPosition.UTC = packet.UTC; } }); }