/// <summary>
 /// Creates a SteeringModel.
 /// </summary>
 public static void CreateModel()
 {
     if (steeringModelIns != null)
     {
         throw new Exception("SteeringModel is already created");
     }
     steeringModelIns = new SteeringModel();
 }
Ejemplo n.º 2
0
 /// <summary>
 /// SteeringViewModel constructor.
 /// </summary>
 /// <param name="model">MetadataModel</param>
 public SteeringViewModel(SteeringModel model)
 {
     this.model = model;
     // when a property in SteeringModel changes, indicate it changed in SteeringViewModel as well
     model.PropertyChanged += delegate(Object sender, PropertyChangedEventArgs e)
     {
         NotifyPropertyChanged("VM" + e.PropertyName);
     };
 }
Ejemplo n.º 3
0
        /// <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();
        }