mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-11-03 17:50:21 +01:00
zmq: read simulator state from the shared TrainState registry
The zmq interface kept its own copy of the state field list, its own name table and its own packer. All three are now the shared registry, which resolves the same channel names and returns the same values, so the wire format is unchanged. New state exposed to external interfaces is added in one place from now on. The registry reports the raw velocity rather than zeroing it while the simulation is paused, and a symbol which doesn't apply to the current vehicle keeps its measurement and says so through its quality flag.
This commit is contained in:
@@ -2,45 +2,10 @@
|
||||
|
||||
#include <zmq_addon.hpp>
|
||||
#include "input/command.h"
|
||||
#include "hardware/registry/state_registry.h"
|
||||
|
||||
class zmq_input
|
||||
{
|
||||
enum class output_fields {
|
||||
shp,
|
||||
alerter,
|
||||
radio_stop,
|
||||
motor_resistors,
|
||||
line_breaker,
|
||||
motor_overload,
|
||||
motor_connectors,
|
||||
wheelslip,
|
||||
converter_overload,
|
||||
converter_off,
|
||||
compressor_overload,
|
||||
ventilator_overload,
|
||||
motor_overload_threshold,
|
||||
train_heating,
|
||||
cab,
|
||||
recorder_braking,
|
||||
recorder_power,
|
||||
alerter_sound,
|
||||
coupled_hv_voltage_relays,
|
||||
velocity,
|
||||
reservoir_pressure,
|
||||
pipe_pressure,
|
||||
brake_pressure,
|
||||
hv_voltage,
|
||||
hv_current_1,
|
||||
hv_current_2,
|
||||
hv_current_3,
|
||||
lv_voltage,
|
||||
distance,
|
||||
radio_channel,
|
||||
springbrake_active,
|
||||
time_month_of_era,
|
||||
time_minute_of_month,
|
||||
time_millisecond_of_day
|
||||
};
|
||||
|
||||
zmq::context_t ctx;
|
||||
std::optional<zmq::socket_t> sock;
|
||||
@@ -55,7 +20,8 @@ class zmq_input
|
||||
|
||||
struct peer_state {
|
||||
float update_interval;
|
||||
std::vector<output_fields> sopi_list;
|
||||
// symbols this peer subscribed to, resolved through the shared TrainState registry
|
||||
std::vector<hardware::state_descriptor const *> sopi_list;
|
||||
std::vector<std::tuple<input_type, user_command, user_command, bool>> sipo_list;;
|
||||
std::chrono::time_point<std::chrono::high_resolution_clock> last_update;
|
||||
};
|
||||
@@ -64,11 +30,9 @@ class zmq_input
|
||||
|
||||
float unpack_float(const zmq::message_t &);
|
||||
zmq::message_t pack_float(float f);
|
||||
zmq::message_t pack_field(output_fields f);
|
||||
|
||||
std::unordered_map<std::string, user_command> nametocommandmap;
|
||||
|
||||
static std::unordered_map<std::string, output_fields> output_fields_map;
|
||||
command_relay relay;
|
||||
|
||||
public:
|
||||
|
||||
Reference in New Issue
Block a user