/// <summary> /// Creates a MetadataModel. /// </summary> public static void CreateModel() { if (metadataModelIns != null) { throw new Exception("MetadataModel is already created"); } metadataModelIns = new MetadataModel(); }
/// <summary> /// MetadataViewModel constructor. /// </summary> /// <param name="model">MetadataModel</param> public MetadataViewModel(MetadataModel model) { this.model = model; // when a property in MetadataModel changes, indicate it changed in MetadataViewModel as well model.PropertyChanged += delegate(Object sender, PropertyChangedEventArgs e) { NotifyPropertyChanged("VM" + e.PropertyName); }; }
/// <summary> /// Runs the flight on Flight Gear based on the given CSV file. /// </summary> /// <param name="PathCSV">path of the CSV file with the flight data</param> public void Start(string PathCSV) { new Thread(delegate() { Metadata.MetadataModel metaModel = Metadata.MetadataModel.Instance; Steering.SteeringModel steeringModel = Steering.SteeringModel.Instance; Player.PlayerModel playerModel = Player.PlayerModel.Instance; Speedometer.SpeedometerModel speedometerModel = Speedometer.SpeedometerModel.Instance; Altimeter.AltimeterModel altimeterModel = Altimeter.AltimeterModel.Instance; while (!shouldStop) { // send a line from the CSV to FG this.telnetClient.Write(dataModel.getLineByIndex(dataModel.CurrentLineIndex)); // store each value from the current line in MetadataModel properties metaModel.Altitude = dataModel.getValueByKeyAndTime(Properties.Settings.Default.altimeter, dataModel.CurrentLineIndex); metaModel.AirSpeed = dataModel.getValueByKeyAndTime(Properties.Settings.Default.airspeed, dataModel.CurrentLineIndex); metaModel.Heading = dataModel.getValueByKeyAndTime("heading-deg", dataModel.CurrentLineIndex); metaModel.Pitch = dataModel.getValueByKeyAndTime("pitch-deg", dataModel.CurrentLineIndex); metaModel.Roll = dataModel.getValueByKeyAndTime("roll-deg", dataModel.CurrentLineIndex); metaModel.SideSlip = dataModel.getValueByKeyAndTime("side-slip-deg", dataModel.CurrentLineIndex); // store each value from the current line in SteeringModel properties steeringModel.Throttle = dataModel.getValueByKeyAndTime("throttle_0", dataModel.CurrentLineIndex); steeringModel.Rudder = dataModel.getValueByKeyAndTime("rudder", dataModel.CurrentLineIndex); steeringModel.Elevator = dataModel.getValueByKeyAndTime("elevator", dataModel.CurrentLineIndex); steeringModel.Aileron = dataModel.getValueByKeyAndTime("aileron_0", dataModel.CurrentLineIndex); speedometerModel.AirSpeed = dataModel.getValueByKeyAndTime(Properties.Settings.Default.airspeed, dataModel.CurrentLineIndex); speedometerModel.SpeedometerAngle = speedometerModel.calculateSpeedometerAngle(speedometerModel.AirSpeed); altimeterModel.Altimeter = dataModel.getValueByKeyAndTime(Properties.Settings.Default.altimeter, dataModel.CurrentLineIndex); // read another line from the data model playerModel.DataModel.moveNextLine(); // play in 10 Hz: Thread.Sleep(playerModel.PlayingSpeed); } }).Start(); }