66 lines
2.6 KiB
C++
66 lines
2.6 KiB
C++
#pragma once
|
|
|
|
#include "fgc/Config.h"
|
|
|
|
#include <memory>
|
|
#include <functional>
|
|
#include <optional>
|
|
#include <string>
|
|
|
|
namespace fgc {
|
|
|
|
// Command-line / runtime options that override config at launch.
|
|
struct RuntimeOptions {
|
|
// Whether to home and which mode to start in are NOT here: they are config.ini
|
|
// [Startup] home / mode (AppConfig::startup), so the boot service needs no flags.
|
|
// Start anyway when hardware.ini declares something this rig does not have.
|
|
// Field triage only: it overrides [Features] strict_presence, and the log
|
|
// says so in those words so it cannot become the normal way to run a tower.
|
|
bool degraded = false;
|
|
|
|
// Tri-state feature overrides (unset => use the config value).
|
|
std::optional<bool> use_mqtt;
|
|
std::optional<bool> mock_camera;
|
|
std::optional<bool> mock_camera_full; // --mock-camera-full: tower-size 12-bit frames
|
|
std::optional<bool> mock_serial;
|
|
std::optional<bool> mock_env; // implies [Features] enable_env
|
|
std::optional<bool> use_tui; // --tui / --no-tui; unset => [UI] enable_tui
|
|
|
|
std::string log_level; // empty => default
|
|
std::string trace_categories; // comma list (serial,mqtt,camera,control,all); empty => unset
|
|
std::string config_path; // resolved config.ini path (to save calibration back); empty => none
|
|
// The log file being written now (it rotates), for the dashboard's LOG title.
|
|
// Unset => no log file.
|
|
std::function<std::string()> log_file;
|
|
|
|
// --test: run this one self-test selection (the words after `test` at the
|
|
// console, e.g. "hardware" or "hardware motor") once the motor link is up,
|
|
// then exit with its verdict. Empty => normal operation. For scripts - the
|
|
// installer above all - which need an answer, not a dashboard. A --test run
|
|
// ignores [Startup]: it neither homes nor leaves manual.
|
|
std::string run_test;
|
|
};
|
|
|
|
// Exit codes of a --test run, beside main()'s 1 (config), 2 (lock) and
|
|
// Application's 3 (declared hardware missing).
|
|
constexpr int kExitTestFail = 4; // the test ran and failed
|
|
constexpr int kExitTestNotRun = 5; // the test could not start; the log says why
|
|
|
|
// Owns the component lifecycle and the control loop. Builds the concrete
|
|
// motor controller, control channel and camera source from config + options
|
|
// (real or mock), wires them to the ImagePipeline and CaptureScheduler, and
|
|
// runs until "exit" / SIGINT.
|
|
class Application {
|
|
public:
|
|
Application(AppConfig config, RuntimeOptions options);
|
|
~Application();
|
|
|
|
int run();
|
|
|
|
private:
|
|
struct Impl;
|
|
std::unique_ptr<Impl> impl_;
|
|
};
|
|
|
|
} // namespace fgc
|