Esempio n. 1
0
static void
Main()
{
  const Waypoints way_points;

  InterfaceBlackboard blackboard;
  blackboard.SetComputerSettings().SetDefaults();
  blackboard.SetComputerSettings().polar.glide_polar_task = GlidePolar(fixed(1));
  blackboard.SetUISettings().SetDefaults();

  TaskBehaviour task_behaviour;
  task_behaviour.SetDefaults();

  TaskManager task_manager(task_behaviour, way_points);
  task_manager.SetGlidePolar(blackboard.GetComputerSettings().polar.glide_polar_task);

  GlideComputerTaskEvents task_events;
  task_manager.SetTaskEvents(task_events);

  Airspaces airspace_database;

  ProtectedTaskManager protected_task_manager(task_manager,
                                              blackboard.GetComputerSettings().task);

  LoadFiles(airspace_database);

  const TaskFactoryType task_type_default =
    blackboard.GetComputerSettings().task.task_type_default;
  OrderedTask *task =
    protected_task_manager.TaskCreateDefault(&way_points, task_type_default);
  if (task != nullptr) {
    protected_task_manager.TaskCommit(*task);
    delete task;
  }

  GlideComputer glide_computer(way_points, airspace_database,
                               protected_task_manager,
                               task_events);
  glide_computer.ReadComputerSettings(blackboard.GetComputerSettings());
  glide_computer.SetTerrain(terrain);
  glide_computer.SetContestIncremental(false);
  glide_computer.Initialise();

  LoadReplay(replay, glide_computer, blackboard);
  delete replay;

  SingleWindow main_window;
  main_window.Create(_T("RunAnalysis"),
                     {640, 480});

  dlgAnalysisShowModal(main_window, *look, blackboard, glide_computer,
                       &protected_task_manager,
                       &airspace_database,
                       terrain);

  delete terrain;
}
Esempio n. 2
0
void
DemoReplayGlue::Start()
{
  ProtectedTaskManager::ExclusiveLease protected_task_manager(*task_manager);
  ProtectedTaskAccessor ta(protected_task_manager, fixed_zero);
  parms.realistic();
  parms.start_alt = device_blackboard->Basic().nav_altitude;
  DemoReplay::Start(ta, device_blackboard->Basic().location);

  // get wind from aircraft
  aircraft.GetState().wind = device_blackboard->Calculated().GetWindOrZero();
}
Esempio n. 3
0
bool
DemoReplayGlue::Update(NMEAInfo &data, fixed time_scale)
{
  if (!UpdateTime())
    return true;

  fixed floor_alt = fixed_300;
  if (device_blackboard->Calculated().terrain_valid) {
    floor_alt += device_blackboard->Calculated().terrain_altitude;
  }

  bool retval;

  {
    ProtectedTaskManager::ExclusiveLease protected_task_manager(*task_manager);
    TaskAccessor ta(protected_task_manager, floor_alt);
    retval = DemoReplay::Update(time_scale, ta);
  }

  const AircraftState &s = aircraft.GetState();

  data.clock = s.time;
  data.alive.Update(data.clock);
  data.ProvideTime(s.time);
  data.location = s.location;
  data.location_available.Update(data.clock);
  data.ground_speed = s.ground_speed;
  data.ground_speed_available.Update(data.clock);
  data.track = s.track;
  data.track_available.Update(data.clock);
  data.gps_altitude = s.altitude;
  data.gps_altitude_available.Update(data.clock);
  data.ProvidePressureAltitude(s.altitude);
  data.ProvideBaroAltitudeTrue(s.altitude);
  data.gps.real = false;
  data.gps.replay = true;
  data.gps.simulator = false;

  return retval;
}
Esempio n. 4
0
bool
DemoReplayGlue::Update()
{
  if (!enabled)
    return false;

  if (!UpdateTime())
    return true;

  fixed floor_alt = fixed_300;
  if (device_blackboard->Calculated().terrain_valid) {
    floor_alt += device_blackboard->Calculated().terrain_altitude;
  }

  ProtectedTaskManager::ExclusiveLease protected_task_manager(*task_manager);
  ProtectedTaskAccessor ta(protected_task_manager, floor_alt);
  bool retval = DemoReplay::Update(ta);

  const AircraftState s = aircraft.GetState();
  OnAdvance(s.location, s.ground_speed, s.track, s.altitude,
             s.altitude, s.time);

  return retval;
}
Esempio n. 5
0
int WINAPI
WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
#ifdef _WIN32_WCE
        LPWSTR lpCmdLine,
#else
        LPSTR lpCmdLine2,
#endif
        int nCmdShow)
#endif
{
#ifdef WIN32
  Args args(GetCommandLine(), "DRIVER FILE");
#else
  Args args(argc, argv, "DRIVER FILE");
#endif
  DebugReplay *replay = CreateDebugReplay(args);
  if (replay == NULL)
    return EXIT_FAILURE;

  args.ExpectEnd();

  InitialiseDataPath();
  Profile::SetFiles(_T(""));
  Profile::Load();

  const Waypoints way_points;

  InterfaceBlackboard blackboard;
  blackboard.SetComputerSettings().SetDefaults();

  GlideComputerTaskEvents task_events;
  TaskManager task_manager(way_points);
  task_manager.SetTaskEvents(task_events);

  Airspaces airspace_database;
  AirspaceWarningManager airspace_warning(airspace_database);

  ProtectedTaskManager protected_task_manager(task_manager,
                                              blackboard.GetComputerSettings().task);

  LoadFiles(airspace_database);

  GlideComputer glide_computer(way_points, airspace_database,
                               protected_task_manager,
                               task_events);
  glide_computer.SetTerrain(terrain);
  glide_computer.Initialise();
  glide_computer.ReadComputerSettings(blackboard.GetComputerSettings());

  ScreenGlobalInit screen_init;

  LoadReplay(replay, glide_computer, blackboard);
  delete replay;

#ifdef WIN32
  ResourceLoader::Init(hInstance);
#endif

  Layout::Initialize(640, 480);

  SingleWindow main_window;
  main_window.set(_T("STATIC"), _T("RunAnalysis"),
                  PixelRect{0, 0, 640, 480});

  Fonts::Initialize();

  dialog_settings.SetDefaults();

  Look *look = new Look();
  look->Initialise();
  look->InitialiseConfigured(blackboard.GetUISettings());

  SetXMLDialogLook(look->dialog);

  dialog_look = &look->dialog;

  main_window.show();

  dlgAnalysisShowModal(main_window, *look, blackboard, glide_computer,
                       &protected_task_manager,
                       &airspace_database,
                       terrain);

  delete look;
  Fonts::Deinitialize();

  delete terrain;

  DeinitialiseDataPath();

  return 0;
}