mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-10-28 21:37:31 +01:00
hardware protocol v2.1: device log, diagnostic routines, manual links
Three additions, all driven from the simulator debug panel. DEVICE_LOG lets a controller send text lines; they reach the simulator log and a per connection view in the panel which keeps the last 64 of them. Diagnostic routines: a controller lists the procedures it offers, the operator picks one from a drop down and starts it, and the controller reports progress and the result. While a routine runs the controller can ask the simulator to show a message box with its own text and buttons and gets back which one was pressed, which is what a valve or gauge calibration needs. The message box appears whether the debug panel is open or not. Links can now be disconnected and reconnected by hand: disconnecting closes the serial port so the controller can be reprogrammed, and the session is rebuilt from scratch on reconnect. Ports which appear while the simulation runs can be picked from a refreshed list, given a baud rate and added as a new controller, so the manager now starts even with no uart2 entries in eu07.ini.
This commit is contained in:
@@ -11,6 +11,7 @@ http://mozilla.org/MPL/2.0/.
|
||||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "hardware/protocol/protocol_defs.h"
|
||||
|
||||
@@ -89,6 +90,39 @@ struct device_diagnostics
|
||||
std::string firmware_build;
|
||||
};
|
||||
|
||||
// one text line sent by the device
|
||||
struct device_log_entry
|
||||
{
|
||||
log_severity severity = log_severity::info;
|
||||
std::uint32_t device_uptime_ms = 0;
|
||||
std::string text;
|
||||
};
|
||||
|
||||
// a diagnostic routine the device offers, listed in the debug panel
|
||||
struct diagnostic_function
|
||||
{
|
||||
std::uint8_t id = 0;
|
||||
std::string name;
|
||||
};
|
||||
|
||||
// progress of the routine currently running on the device
|
||||
struct diagnostic_report
|
||||
{
|
||||
diagnostic_state state = diagnostic_state::idle;
|
||||
std::uint8_t function = 0;
|
||||
std::uint8_t progress = 0;
|
||||
std::string message;
|
||||
};
|
||||
|
||||
// a message box the device asked the simulator to show
|
||||
struct diagnostic_prompt
|
||||
{
|
||||
bool active = false;
|
||||
std::uint32_t id = 0;
|
||||
std::string text;
|
||||
std::vector<std::string> options;
|
||||
};
|
||||
|
||||
// everything the debug panel needs about one connection, copied out once per frame
|
||||
struct link_report
|
||||
{
|
||||
@@ -106,9 +140,17 @@ struct link_report
|
||||
std::size_t handles = 0;
|
||||
std::size_t subscriptions = 0;
|
||||
std::size_t frame_size = 0;
|
||||
// false when the link was switched off from the debug panel, which releases the port
|
||||
bool enabled = true;
|
||||
// index of the link, as the manager knows it
|
||||
std::size_t index = 0;
|
||||
transport_diagnostics transport;
|
||||
protocol_diagnostics protocol;
|
||||
device_diagnostics device;
|
||||
std::vector<diagnostic_function> functions;
|
||||
diagnostic_report diagnostic;
|
||||
diagnostic_prompt prompt;
|
||||
std::vector<device_log_entry> log;
|
||||
};
|
||||
|
||||
} // namespace hardware
|
||||
|
||||
Reference in New Issue
Block a user