#pragma once #include #include "command.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 sock; enum class input_type { none, toggle, // two commands, each mapped to one state; press event on state change impulse, // one command; press event when set, release when cleared value // one command; press event, value of specified byte passed as param1 }; struct peer_state { float update_interval; std::vector sopi_list; std::vector> sipo_list;; std::chrono::time_point last_update; }; std::map peers; 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 nametocommandmap; static std::unordered_map output_fields_map; command_relay relay; public: zmq_input(); void poll(); };