3#include <uwebsockets/App.h>
5#include <BS_thread_pool.hpp>
31class MonitoringManager;
32class ProcedureManager;
53 std::function<std::expected<void, std::string>(std::string driver, std::string adapter)>;
59 using GetLogFn = std::function<std::vector<std::string>()>;
67 using RefreshCertFn = std::function<std::expected<void, std::string>()>;
94 std::function<std::expected<mm::net::Response, std::string>(
const std::string& body)>;
142 std::string
corsOrigin{
"https://motion-master.synapticon.com"};
195 std::vector<mm::api::RegisterRoutesFn> routeModules_;
196 std::atomic<bool> running_{
false};
198 std::atomic<uWS::Loop*> loop_{
nullptr};
199 std::atomic<uWS::SSLApp*> app_{
nullptr};
201 std::promise<bool> listenResult_;
205 std::atomic<bool> stopping_{
false};
242 BS::light_thread_pool pool_{32};
HTTPS REST API server.
Definition http_server.h:43
std::function< std::expected< void, std::string >(uint32_t periodUs)> SetGameLoopPeriodFn
Callback type for PUT /api/game-loop.
Definition http_server.h:85
std::function< mm::auto_tuning::Status()> AutoTuningStatusFn
Callback type for GET /api/auto-tuning.
Definition http_server.h:101
~HttpServer()
Destructor. Calls stop() if the server is still running.
Definition http_server.cc:383
std::function< std::expected< mm::net::Response, std::string >(const std::string &body)> AutoTuningRunFn
Callback type for POST /api/auto-tuning/run and GET /api/auto-tuning/swagger.yml.
Definition http_server.h:94
std::function< std::expected< void, std::string >(std::string driver, std::string adapter)> InitDeviceManagerFn
Callback type for POST /api/init.
Definition http_server.h:53
void addRoutes(mm::api::RegisterRoutesFn module)
Registers a route plug-in to be wired in when the server starts.
Definition http_server.cc:391
std::function< mm::node::EniCollectorOptions()> EniOptionsFn
Supplies the three things an ENI needs that no device can answer for: the master's name,...
Definition http_server.h:116
std::function< std::vector< std::string >()> GetLogFn
Callback type for GET /api/log.
Definition http_server.h:59
std::function< std::expected< void, std::string >()> RefreshCertFn
Callback type for POST /api/cert/refresh.
Definition http_server.h:67
void stop()
Stops the server, closes the listen socket, and joins the thread.
Definition http_server.cc:410
std::function< GameLoopHealth()> GetGameLoopHealthFn
Callback type for GET /api/game-loop.
Definition http_server.h:75
std::function< std::expected< mm::net::Response, std::string >()> AutoTuningSpecFn
Callback type for GET /api/auto-tuning/swagger.yml.
Definition http_server.h:107
bool start()
Starts the server background thread and begins accepting connections.
Definition http_server.cc:399
A flat, user-writable file store rooted at Motion Master's per-user cache directory.
Definition user_cache.h:65
Owns the fieldbus driver and node collection, and drives PDO exchange.
Definition device_manager.h:287
Owns the active monitorings and turns each into a lossless stream of recorded rows.
Definition monitoring_manager.h:62
Runs off-RT command-and-wait procedures and remembers how each one went.
Definition procedure_manager.h:121
A blocking HTTP client for the calls Motion Master makes out.
std::function< void(Router &router, const RouteContext &ctx)> RegisterRoutesFn
A route plug-in: registers its routes on the HTTP app.
Definition web_api.h:77
Definition http_server.h:25
Definition bus_health_source.h:7
Routes whose handlers cannot block the event loop, because they do not run on it.
What Motion Master knows about its auto-tuning process, as a client can read it.
The whole config file. Top-level keys map to these members.
Definition config.h:197
Snapshot of game-loop real-time health for the GET /api/game-loop diagnostic endpoint....
Definition game_loop.h:15
Server configuration.
Definition http_server.h:119
AutoTuningRunFn runAutoTuning
Handler for POST /api/auto-tuning/run; forwards a call.
Definition http_server.h:136
AutoTuningStatusFn autoTuningStatus
Handler for GET /api/auto-tuning; the startup snapshot.
Definition http_server.h:138
RefreshCertFn refreshCert
Handler for POST /api/cert/refresh; fetches+installs a cert.
Definition http_server.h:131
GetGameLoopHealthFn getGameLoopHealth
Handler for GET /api/game-loop; RT loop health snapshot.
Definition http_server.h:133
GetLogFn getLog
Handler for GET /api/log; returns buffered log entries.
Definition http_server.h:130
std::string startedConfig
Serialized JSON of the boot config; served at GET /api/config.
Definition http_server.h:127
std::string version
Application version string served at GET /api/version.
Definition http_server.h:125
AutoTuningSpecFn autoTuningSpec
Handler for GET /api/auto-tuning/swagger.yml.
Definition http_server.h:139
std::string bindAddress
Local address to bind. Loopback serves only this machine; "0.0.0.0" serves the network.
Definition http_server.h:121
InitDeviceManagerFn initDeviceManager
Handler for POST /api/init; required for API-driven init.
Definition http_server.h:129
uint16_t port
TCP port to listen on (TLS).
Definition http_server.h:122
std::string certFile
Path to the TLS certificate (PEM).
Definition http_server.h:123
EniOptionsFn eniOptions
Definition http_server.h:140
std::string keyFile
Path to the TLS private key (PEM).
Definition http_server.h:124
std::string corsOrigin
Value sent in Access-Control-Allow-Origin. Defaults to the production PWA origin.
Definition http_server.h:142
SetGameLoopPeriodFn setGameLoopPeriod
Handler for PUT /api/game-loop; retimes the RT loop.
Definition http_server.h:135
The state of the auto-tuning process, reported by GET /api/auto-tuning.
Definition status.h:22
What an ENI needs that no device can answer for.
Definition eni_collector.h:19