добавил и отредактировал API от Дани
This commit is contained in:
parent
9502debfee
commit
d6851052b4
34
dependencies/control_system-dvbs-2/CMakeLists.txt
vendored
Normal file
34
dependencies/control_system-dvbs-2/CMakeLists.txt
vendored
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.20)
|
||||||
|
|
||||||
|
project(terminal-client-api)
|
||||||
|
|
||||||
|
set(CMAKE_CXX_STANDARD 17)
|
||||||
|
|
||||||
|
if (CMAKE_VERSION VERSION_LESS 3.2)
|
||||||
|
set(UPDATE_DISCONNECTED_IF_AVAILABLE "")
|
||||||
|
else()
|
||||||
|
set(UPDATE_DISCONNECTED_IF_AVAILABLE "UPDATE_DISCONNECTED 1")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
include(CheckCXXCompilerFlag)
|
||||||
|
set(CMAKE_CXX_FLAGS -fPIC)
|
||||||
|
|
||||||
|
set(default_build_type "Release")
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Werror")
|
||||||
|
set(CMAKE_CXX_FLAGS_DEBUG "-ggdb -O0 -fprofile-arcs -ftest-coverage")
|
||||||
|
set(CMAKE_CXX_FLAGS_RELEASE "-O2 -s -DNDEBUG ")
|
||||||
|
message(${CMAKE_CXX_FLAGS})
|
||||||
|
message("CMAKE_BUILD_TYPE: " ${CMAKE_BUILD_TYPE})
|
||||||
|
|
||||||
|
message(${CMAKE_CXX_FLAGS})
|
||||||
|
|
||||||
|
add_library(terminal-client-api SHARED
|
||||||
|
client/main.cpp
|
||||||
|
client/sock_client.cpp
|
||||||
|
client/system_client.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
find_package(Boost 1.53.0 COMPONENTS system log log_setup REQUIRED)
|
||||||
|
find_package(cereal REQUIRED)
|
||||||
|
target_link_libraries(terminal-client-api ${Boost_LIBRARIES} ${OPENSSL_LIBRARIES} cereal::cereal)
|
||||||
|
target_include_directories(terminal-client-api PRIVATE ${Boost_INCLUDE_DIR})
|
223
dependencies/control_system-dvbs-2/client/ControlProtoCInterface.h
vendored
Normal file
223
dependencies/control_system-dvbs-2/client/ControlProtoCInterface.h
vendored
Normal file
@ -0,0 +1,223 @@
|
|||||||
|
#ifndef __CONTROL_PROTO_COMMANDS__
|
||||||
|
#define __CONTROL_PROTO_COMMANDS__
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <iostream>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
#define EXTERNC extern "C"
|
||||||
|
#else
|
||||||
|
#define EXTERNC extern
|
||||||
|
#endif
|
||||||
|
|
||||||
|
typedef unsigned int TSID;
|
||||||
|
|
||||||
|
typedef enum CP_Res {
|
||||||
|
OK = 0,
|
||||||
|
TIMEOUT,
|
||||||
|
ERROR,
|
||||||
|
ABORT,
|
||||||
|
BUSY
|
||||||
|
} CP_Result;
|
||||||
|
|
||||||
|
typedef void (*CP_cmd_stdout_cb)(const char * str, uint32_t len);
|
||||||
|
|
||||||
|
/*
|
||||||
|
cb - callback for receive stdout of command
|
||||||
|
*/
|
||||||
|
EXTERNC void CP_SetCmdStdoutCallback(TSID sid, CP_cmd_stdout_cb cb);
|
||||||
|
/*
|
||||||
|
sid -- current session ID
|
||||||
|
*/
|
||||||
|
EXTERNC void CP_CmdAbort(TSID sid);
|
||||||
|
/*
|
||||||
|
host -- host name
|
||||||
|
user -- user name
|
||||||
|
pwd -- password hash
|
||||||
|
sid -- output session ID (used for all requests)
|
||||||
|
access -- output type of privilegies {admin|operator|...etc}
|
||||||
|
*/
|
||||||
|
EXTERNC CP_Result CP_Login(const char * user, const char * pwd, TSID * sid, unsigned int * access);
|
||||||
|
/*
|
||||||
|
sid -- current session ID
|
||||||
|
*/
|
||||||
|
EXTERNC CP_Result CP_Logout(TSID sid);
|
||||||
|
/*
|
||||||
|
sid -- current session ID
|
||||||
|
ip_address -- IP address of the host
|
||||||
|
packet_count -- count of packets to send
|
||||||
|
*/
|
||||||
|
EXTERNC CP_Result CP_GetDmaDebug(TSID sid, const char *command, std::string *val);
|
||||||
|
|
||||||
|
EXTERNC CP_Result CP_SetDemFreq(TSID sid, uint32_t freq);
|
||||||
|
|
||||||
|
EXTERNC CP_Result CP_GetDemFreq(TSID sid, uint32_t * freq);
|
||||||
|
|
||||||
|
EXTERNC CP_Result CP_SetDmaDebug(TSID sid, const char *command, std::string val);
|
||||||
|
|
||||||
|
EXTERNC CP_Result CP_Set10gConfig(TSID sid, const char *parameter, std::string val);
|
||||||
|
|
||||||
|
EXTERNC CP_Result CP_SetRollofBaudrate(TSID sid, double rollof,double baudrate);
|
||||||
|
|
||||||
|
//interfaces<TX1><TX2><RX1><RX2>
|
||||||
|
EXTERNC CP_Result CP_GetGain(TSID sid, const char *gain_interface, double *gain);
|
||||||
|
//interfaces<TX1><TX2><RX1><RX2>
|
||||||
|
EXTERNC CP_Result CP_SetGain(TSID sid, const char *gain_interface, double gain);
|
||||||
|
//interfaces<TX1><TX2><RX1><RX2>
|
||||||
|
EXTERNC CP_Result CP_RadioEnable(TSID sid, const char *radio_interface, bool on_of);
|
||||||
|
//interfaces<TX1><TX2><RX1><RX2>
|
||||||
|
/*
|
||||||
|
BOD -- baud_rate
|
||||||
|
SPREAD -- koef spread
|
||||||
|
LO -- lo frequency
|
||||||
|
*/
|
||||||
|
EXTERNC CP_Result CP_ModulatorParams(TSID sid, const char *modulator_param, uint32_t value);
|
||||||
|
|
||||||
|
EXTERNC CP_Result CP_GetModulatorParams(TSID sid, const char *modulator_param, uint32_t *value);
|
||||||
|
|
||||||
|
EXTERNC CP_Result CP_GetDemodulatorParams(TSID sid, const char *demodulator_param, uint32_t *value);
|
||||||
|
|
||||||
|
EXTERNC CP_Result CP_GetLevelDemod(TSID sid, const char * param ,double *value);
|
||||||
|
|
||||||
|
EXTERNC CP_Result CP_DemodulatorParams(TSID sid, const char *demodulator_param, uint32_t value);
|
||||||
|
|
||||||
|
EXTERNC CP_Result CP_SetLBQParams(TSID sid, const uint32_t &tick_ms, const uint32_t &bucket_size);
|
||||||
|
|
||||||
|
EXTERNC CP_Result CP_SetQoSParams(TSID sid, const std::string &type_node, const std::string & node);
|
||||||
|
|
||||||
|
EXTERNC CP_Result CP_GetQoSParams(TSID sid, const std::string &type_node, std::string * node);
|
||||||
|
|
||||||
|
struct ACM_parameters_serv_
|
||||||
|
{
|
||||||
|
double snr_treashold = 0;
|
||||||
|
double snr_treashold_acm = 0.5;
|
||||||
|
uint32_t period_pack = 15;
|
||||||
|
uint8_t max_modcod = 4;
|
||||||
|
uint8_t min_modcod = 4;
|
||||||
|
int max_attenuation = 0;
|
||||||
|
int min_attenuation = 0;
|
||||||
|
bool enable = false;
|
||||||
|
bool enable_auto_atten = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct DPDI_parmeters
|
||||||
|
{
|
||||||
|
uint8_t latitude_station_grad = 0;
|
||||||
|
uint8_t latitude_station_minute = 0;
|
||||||
|
uint8_t longitude_station_grad = 0;
|
||||||
|
uint8_t longitude_station_minute = 0;
|
||||||
|
uint8_t longitude_sattelite_grad = 0;
|
||||||
|
uint8_t longitude_sattelite_minute = 0;
|
||||||
|
bool is_delay_window = 0;
|
||||||
|
uint32_t max_delay = 1;
|
||||||
|
uint32_t min_delay = 0;
|
||||||
|
uint32_t freq_offset = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
EXTERNC CP_Result CP_SetAcmParams(TSID sid, ACM_parameters_serv_ acm_params);
|
||||||
|
EXTERNC CP_Result CP_GetAcmParams(TSID sid, ACM_parameters_serv_ *acm_params);
|
||||||
|
|
||||||
|
EXTERNC CP_Result CP_SetDpdiParams(TSID sid, DPDI_parmeters dpdi_params);
|
||||||
|
EXTERNC CP_Result CP_GetDpdiParams(TSID sid, DPDI_parmeters *dpdi_pars_get);
|
||||||
|
|
||||||
|
/*
|
||||||
|
PSV
|
||||||
|
PLV
|
||||||
|
PST
|
||||||
|
PLT
|
||||||
|
ADRVT
|
||||||
|
*/
|
||||||
|
EXTERNC CP_Result CP_ZynqParams(TSID sid, const char *zynq_param, double *value);
|
||||||
|
|
||||||
|
EXTERNC CP_Result CP_SetNetwork(TSID sid, const char *param_name, const char *val);
|
||||||
|
EXTERNC CP_Result CP_GetNetwork(TSID sid, const char *param_name, std::string *val);
|
||||||
|
/*
|
||||||
|
ip_address -- new IP address fot the host
|
||||||
|
*/
|
||||||
|
|
||||||
|
EXTERNC CP_Result CP_Ping(TSID sid, const char * ip_address, int packet_count);
|
||||||
|
/*
|
||||||
|
sid -- current session ID
|
||||||
|
ip_address -- IP address of the host
|
||||||
|
*/
|
||||||
|
EXTERNC CP_Result CP_Traceroute(TSID sid, const char * ip_address);
|
||||||
|
/*
|
||||||
|
sid -- current session ID
|
||||||
|
src -- {"running-config"|"startup-config"|host_address}
|
||||||
|
dst -- {"running-config"|"startup-config"|host_address}
|
||||||
|
NOTE:
|
||||||
|
src and dst both must be different
|
||||||
|
*/
|
||||||
|
EXTERNC CP_Result CP_Copy(TSID sid, const char * src, const char * dst);
|
||||||
|
/*
|
||||||
|
sid -- current session ID
|
||||||
|
interface -- {"all"|"sat0"|"gigabit"|"modulator"|"demodulator"}
|
||||||
|
output data goes to callback
|
||||||
|
*/
|
||||||
|
EXTERNC CP_Result CP_ShowInterface(TSID sid, const char * interface);
|
||||||
|
/*
|
||||||
|
sid -- current session ID
|
||||||
|
out_startup_config -- received information about startup config
|
||||||
|
*/
|
||||||
|
EXTERNC CP_Result CP_ShowStartupConfig(TSID sid, char ** out_startup_config);
|
||||||
|
/*
|
||||||
|
sid -- current session ID
|
||||||
|
interface -- {"all"|"sat0"|"gigabit"|"modulator"|"demodulator"}
|
||||||
|
out_startup_config -- received information about startup config
|
||||||
|
*/
|
||||||
|
EXTERNC CP_Result CP_ShowStartupConfigInterface(TSID sid, const char * interface, char ** out_startup_config);
|
||||||
|
|
||||||
|
// Demodulator
|
||||||
|
/*
|
||||||
|
sid -- current session ID
|
||||||
|
interface -- {"SAT"|"Ethernet"|"Loopback"}
|
||||||
|
rate -- symbol rate
|
||||||
|
*/
|
||||||
|
EXTERNC CP_Result CP_SetDemodSymrate(TSID sid, const char * interface, uint32_t rate);
|
||||||
|
/*
|
||||||
|
sid -- current session ID
|
||||||
|
interface -- {"SAT"|"Ethernet"|"Loopback"}
|
||||||
|
rate -- frequency value in Hertz
|
||||||
|
*/
|
||||||
|
EXTERNC CP_Result CP_SetDemodFrequency(TSID sid, const char * interface, uint32_t freq);
|
||||||
|
/*
|
||||||
|
sid -- current session ID
|
||||||
|
interface -- {"SAT"|"Ethernet"|"Loopback"}
|
||||||
|
mode -- {"on"|"off"|"auto"}
|
||||||
|
*/
|
||||||
|
EXTERNC CP_Result CP_SetDemodSpectrum(TSID sid, const char * interface, const char * mode);
|
||||||
|
/*
|
||||||
|
sid -- current session ID
|
||||||
|
interface -- {"SAT"|"Ethernet"|"Loopback"}
|
||||||
|
mode -- {"on"|"off"}
|
||||||
|
*/
|
||||||
|
EXTERNC CP_Result CP_SetDemodReference(TSID sid, const char * interface, const char * mode);
|
||||||
|
/*
|
||||||
|
sid -- current session ID
|
||||||
|
interface -- {"SAT"|"Ethernet"|"Loopback"}
|
||||||
|
rate -- frequency value in Hertz
|
||||||
|
*/
|
||||||
|
EXTERNC CP_Result CP_SetDemodSearch(TSID sid, const char * interface, uint32_t freq);
|
||||||
|
|
||||||
|
// Modulator
|
||||||
|
|
||||||
|
/*
|
||||||
|
sid -- current session ID
|
||||||
|
interface -- {"SAT"|"Ethernet"|"Loopback"}
|
||||||
|
rate -- symbol rate
|
||||||
|
*/
|
||||||
|
EXTERNC CP_Result CP_SetModSymrate(TSID sid, const char * interface, uint32_t rate);
|
||||||
|
/*
|
||||||
|
sid -- current session ID
|
||||||
|
interface -- {"SAT"|"Ethernet"|"Loopback"}
|
||||||
|
rate -- frequency value in Hertz
|
||||||
|
*/
|
||||||
|
EXTERNC CP_Result CP_SetModSymFrequency(TSID sid, const char * interface, uint32_t freq);
|
||||||
|
/*
|
||||||
|
sid -- current session ID
|
||||||
|
interface -- {"SAT"|"Ethernet"|"Loopback"}
|
||||||
|
mode -- {"on"|"off"}
|
||||||
|
*/
|
||||||
|
EXTERNC CP_Result CP_SetModReference(TSID sid, const char * interface, const char * mode);
|
||||||
|
#endif
|
1244
dependencies/control_system-dvbs-2/client/main.cpp
vendored
Normal file
1244
dependencies/control_system-dvbs-2/client/main.cpp
vendored
Normal file
File diff suppressed because it is too large
Load Diff
51
dependencies/control_system-dvbs-2/client/sock_client.cpp
vendored
Normal file
51
dependencies/control_system-dvbs-2/client/sock_client.cpp
vendored
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
#include "sock_client.h"
|
||||||
|
|
||||||
|
client::client(boost::asio::io_context & io_context, const std::string & unix_file, std::function<void(const std::vector<uint8_t>&)> func_cb)
|
||||||
|
: socket_(io_context)
|
||||||
|
, callback_func(func_cb)
|
||||||
|
{
|
||||||
|
socket_.async_connect(seq_packet::seqpacket_protocol::endpoint(unix_file),
|
||||||
|
std::bind(&client::handle_connect, this,
|
||||||
|
std::placeholders::_1));
|
||||||
|
}
|
||||||
|
|
||||||
|
client::~client()
|
||||||
|
{
|
||||||
|
do_close();
|
||||||
|
}
|
||||||
|
|
||||||
|
void client::write(const std::vector<uint8_t> & data)
|
||||||
|
{
|
||||||
|
boost::asio::write(socket_, boost::asio::buffer(data));
|
||||||
|
}
|
||||||
|
|
||||||
|
void client::do_close()
|
||||||
|
{
|
||||||
|
socket_.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
void client::start()
|
||||||
|
{
|
||||||
|
seq_packet::seqpacket_protocol::socket::message_flags in_flags { MSG_WAITALL };
|
||||||
|
socket_.async_receive(boost::asio::buffer(data_), in_flags,
|
||||||
|
std::bind(&client::handle_read, this,
|
||||||
|
std::placeholders::_1,
|
||||||
|
std::placeholders::_2));
|
||||||
|
}
|
||||||
|
|
||||||
|
void client::handle_connect(const boost::system::error_code & error)
|
||||||
|
{
|
||||||
|
if (!error)
|
||||||
|
start();
|
||||||
|
}
|
||||||
|
|
||||||
|
void client::handle_read(const boost::system::error_code & error, size_t bytes_transferred)
|
||||||
|
{
|
||||||
|
if (!error && callback_func && bytes_transferred)
|
||||||
|
{
|
||||||
|
callback_func(std::vector<uint8_t>(std::begin(data_), std::begin(data_) + bytes_transferred));
|
||||||
|
start();
|
||||||
|
}
|
||||||
|
//else
|
||||||
|
// do_close();
|
||||||
|
}
|
24
dependencies/control_system-dvbs-2/client/sock_client.h
vendored
Normal file
24
dependencies/control_system-dvbs-2/client/sock_client.h
vendored
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "../common/seq_packet.h"
|
||||||
|
|
||||||
|
class client
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
client(boost::asio::io_context & io_context, const std::string & unix_file, std::function<void(const std::vector<uint8_t>&)> func_cb = nullptr);
|
||||||
|
~client();
|
||||||
|
|
||||||
|
void write(const std::vector<uint8_t> & data);
|
||||||
|
void do_close();
|
||||||
|
|
||||||
|
private:
|
||||||
|
client(const client&) = delete;
|
||||||
|
const client& operator=(const client&) = delete;
|
||||||
|
|
||||||
|
seq_packet::seqpacket_protocol::socket socket_;
|
||||||
|
std::array<uint8_t, 2000> data_;
|
||||||
|
std::function<void(const std::vector<uint8_t>&)> callback_func;
|
||||||
|
|
||||||
|
void handle_connect(const boost::system::error_code & error);
|
||||||
|
void handle_read(const boost::system::error_code & error, size_t bytes_transferred);
|
||||||
|
void start();
|
||||||
|
};
|
755
dependencies/control_system-dvbs-2/client/system_client.cpp
vendored
Normal file
755
dependencies/control_system-dvbs-2/client/system_client.cpp
vendored
Normal file
@ -0,0 +1,755 @@
|
|||||||
|
#include "system_client.h"
|
||||||
|
|
||||||
|
system_client::system_client(const std::string & unix_file, std::function<void(const std::string&)> log_func)
|
||||||
|
: clt(io_context, unix_file, std::bind(&system_client::data_received, this, std::placeholders::_1))
|
||||||
|
, log(log_func)
|
||||||
|
, ctx_thread([&] { io_context.run(); } )
|
||||||
|
, cmd_id(0)
|
||||||
|
, current_state(state::connected)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
system_client::~system_client()
|
||||||
|
{
|
||||||
|
io_context.stop();
|
||||||
|
ctx_thread.join();
|
||||||
|
}
|
||||||
|
|
||||||
|
state system_client::get_current_state() const
|
||||||
|
{
|
||||||
|
return current_state;
|
||||||
|
}
|
||||||
|
|
||||||
|
response_type system_client::send_login_cmd(const std::string & username, const std::string & pass, access_rights & access)
|
||||||
|
{
|
||||||
|
std::scoped_lock lock(cmd_in_progress_mtx);
|
||||||
|
|
||||||
|
uint32_t curr_id { ++cmd_id };
|
||||||
|
|
||||||
|
cmd_header login_cmd_hdr { curr_id, cmd_type::login };
|
||||||
|
login_cmd log_req { username, pass };
|
||||||
|
send_to_socket(login_cmd_hdr, log_req);
|
||||||
|
|
||||||
|
std::any data_from_serv;
|
||||||
|
auto result = wait_for_response(curr_id, cmd_type::login, data_from_serv);
|
||||||
|
|
||||||
|
access = access_rights::not_allowed;
|
||||||
|
if (data_from_serv.has_value())
|
||||||
|
access = std::any_cast<access_rights>(data_from_serv);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
response_type system_client::send_copy_cmd(const fm::side_description & src, const fm::side_description & dst)
|
||||||
|
{
|
||||||
|
std::scoped_lock lock(cmd_in_progress_mtx);
|
||||||
|
|
||||||
|
uint32_t curr_id { ++cmd_id };
|
||||||
|
|
||||||
|
cmd_header copy_cmd_hdr { curr_id, cmd_type::copy };
|
||||||
|
copy_cmd copy_req { src, dst };
|
||||||
|
send_to_socket(copy_cmd_hdr, copy_req);
|
||||||
|
|
||||||
|
return wait_for_progressing_response(curr_id, cmd_type::copy);
|
||||||
|
}
|
||||||
|
|
||||||
|
response_type system_client::send_ping_cmd(const std::string & ip, size_t count)
|
||||||
|
{
|
||||||
|
std::scoped_lock lock(cmd_in_progress_mtx);
|
||||||
|
|
||||||
|
uint32_t curr_id { ++cmd_id };
|
||||||
|
|
||||||
|
cmd_header ping_cmd_hdr { curr_id, cmd_type::ping };
|
||||||
|
ping_cmd ping_req { ip, count };
|
||||||
|
send_to_socket(ping_cmd_hdr, ping_req);
|
||||||
|
|
||||||
|
return wait_for_progressing_response(curr_id, cmd_type::ping);
|
||||||
|
}
|
||||||
|
|
||||||
|
response_type system_client::send_traceroute_cmd(const std::string & ip)
|
||||||
|
{
|
||||||
|
std::scoped_lock lock(cmd_in_progress_mtx);
|
||||||
|
|
||||||
|
uint32_t curr_id { ++cmd_id };
|
||||||
|
|
||||||
|
cmd_header tracert_cmd_hdr { curr_id, cmd_type::tracert };
|
||||||
|
tracert_cmd tracert_req { ip };
|
||||||
|
send_to_socket(tracert_cmd_hdr, tracert_req);
|
||||||
|
|
||||||
|
return wait_for_progressing_response(curr_id, cmd_type::tracert);
|
||||||
|
}
|
||||||
|
|
||||||
|
response_type system_client::send_show_interface_cmd(const interface_value & interface)
|
||||||
|
{
|
||||||
|
std::scoped_lock lock(cmd_in_progress_mtx);
|
||||||
|
|
||||||
|
uint32_t curr_id { ++cmd_id };
|
||||||
|
|
||||||
|
cmd_header interface_cmd_hdr { curr_id, cmd_type::interface };
|
||||||
|
interface_cmd interface_req { interface };
|
||||||
|
send_to_socket(interface_cmd_hdr, interface_req);
|
||||||
|
|
||||||
|
return wait_for_progressing_response(curr_id, cmd_type::interface);
|
||||||
|
}
|
||||||
|
|
||||||
|
response_type system_client::wait_for_progressing_response(uint32_t c_id, const cmd_type & cmd_t)
|
||||||
|
{
|
||||||
|
auto result = response_type::in_progress;
|
||||||
|
while (result != response_type::ok && result != response_type::error && result != response_type::abort)
|
||||||
|
{
|
||||||
|
std::any data_from_serv;
|
||||||
|
result = wait_for_response(c_id, cmd_t, data_from_serv);
|
||||||
|
if (data_from_serv.has_value() && stdout_cb)
|
||||||
|
{
|
||||||
|
auto & text_bytes = std::any_cast<std::vector<uint8_t>&>(data_from_serv);
|
||||||
|
std::scoped_lock lock(cb_mtx);
|
||||||
|
stdout_cb(reinterpret_cast<char *>(text_bytes.data()), text_bytes.size());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (result == response_type::abort)
|
||||||
|
{
|
||||||
|
std::scoped_lock lock_1(responses_mtx);
|
||||||
|
responses.erase(c_id);
|
||||||
|
responses_data.erase(c_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
void system_client::abort()
|
||||||
|
{
|
||||||
|
send_abort(cmd_id);
|
||||||
|
process_response(cmd_id, response_type::abort, {});
|
||||||
|
}
|
||||||
|
|
||||||
|
void system_client::send_abort(uint32_t id)
|
||||||
|
{
|
||||||
|
std::stringstream s;
|
||||||
|
cmd_header abort_cmd { id, cmd_type::abort };
|
||||||
|
{
|
||||||
|
cereal::BinaryOutputArchive oarchive(s);
|
||||||
|
oarchive(abort_cmd);
|
||||||
|
}
|
||||||
|
std::vector<uint8_t> data((std::istream_iterator<uint8_t>(s)), std::istream_iterator<uint8_t>());
|
||||||
|
clt.write(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
response_type system_client::send_logout_cmd()
|
||||||
|
{
|
||||||
|
if (current_state != state::logged_in)
|
||||||
|
return response_type::error;
|
||||||
|
|
||||||
|
std::scoped_lock lock(cmd_in_progress_mtx);
|
||||||
|
|
||||||
|
uint32_t curr_id { cmd_id++ };
|
||||||
|
|
||||||
|
cmd_header logout_cmd_hdr { curr_id, cmd_type::exit };
|
||||||
|
std::stringstream s;
|
||||||
|
{
|
||||||
|
cereal::BinaryOutputArchive oarchive(s);
|
||||||
|
oarchive(logout_cmd_hdr);
|
||||||
|
}
|
||||||
|
std::vector<uint8_t> data((std::istream_iterator<uint8_t>(s)), std::istream_iterator<uint8_t>());
|
||||||
|
clt.write(data);
|
||||||
|
std::any data_from_serv;
|
||||||
|
return wait_for_response(curr_id, cmd_type::exit, data_from_serv);
|
||||||
|
}
|
||||||
|
|
||||||
|
response_type system_client::wait_for_response(uint32_t id, const cmd_type & type, std::any & data)
|
||||||
|
{
|
||||||
|
std::unique_lock<std::mutex> lock(responses_mtx);
|
||||||
|
cv_resp.wait(lock, [&] { return responses.find(id) != responses.end(); } );
|
||||||
|
|
||||||
|
auto result = std::move(responses[id].front());
|
||||||
|
data = std::move(responses_data[id].front());
|
||||||
|
|
||||||
|
responses[id].pop();
|
||||||
|
responses_data[id].pop();
|
||||||
|
|
||||||
|
if (result != response_type::abort && responses[id].empty())
|
||||||
|
{
|
||||||
|
responses.erase(id);
|
||||||
|
responses_data.erase(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (result == response_type::ok)
|
||||||
|
{
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case cmd_type::login:
|
||||||
|
{
|
||||||
|
current_state = state::logged_in;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case cmd_type::exit:
|
||||||
|
{
|
||||||
|
current_state = state::disconnected;
|
||||||
|
clt.do_close();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default: break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
void system_client::process_response(uint32_t id, response_type resp, std::any && data)
|
||||||
|
{
|
||||||
|
{
|
||||||
|
std::scoped_lock lock(responses_mtx);
|
||||||
|
if (responses.find(id) != responses.end() && responses[id].empty() && responses[id].front() == response_type::abort)
|
||||||
|
return;
|
||||||
|
|
||||||
|
responses[id].push(resp);
|
||||||
|
responses_data[id].push(std::move(data));
|
||||||
|
}
|
||||||
|
cv_resp.notify_all();
|
||||||
|
}
|
||||||
|
|
||||||
|
void system_client::data_received(const std::vector<uint8_t> & data)
|
||||||
|
{
|
||||||
|
std::stringstream ss;
|
||||||
|
std::copy(data.begin(), data.end(), std::ostream_iterator<uint8_t>(ss));
|
||||||
|
|
||||||
|
cereal::BinaryInputArchive iarchive(ss);
|
||||||
|
response_header cmd;
|
||||||
|
iarchive(cmd);
|
||||||
|
std::any data_from_serv;
|
||||||
|
|
||||||
|
switch (cmd.cmd)
|
||||||
|
{
|
||||||
|
case cmd_type::login:
|
||||||
|
{
|
||||||
|
if (cmd.rsp == response_type::ok)
|
||||||
|
{
|
||||||
|
access_rights access;
|
||||||
|
iarchive(access);
|
||||||
|
data_from_serv = access;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case cmd_type::ping:
|
||||||
|
case cmd_type::tracert:
|
||||||
|
case cmd_type::interface:
|
||||||
|
{
|
||||||
|
if (cmd.rsp == response_type::in_progress)
|
||||||
|
{
|
||||||
|
std::vector<uint8_t> data_rsp;
|
||||||
|
iarchive(data_rsp);
|
||||||
|
data_from_serv = std::move(data_rsp);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case cmd_type::get_demodulator_frequency:
|
||||||
|
{
|
||||||
|
if (cmd.rsp == response_type::ok)
|
||||||
|
{
|
||||||
|
uint32_t freq;
|
||||||
|
iarchive(freq);
|
||||||
|
data_from_serv = freq;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case cmd_type::get_gain_param:
|
||||||
|
{
|
||||||
|
if (cmd.rsp == response_type::ok)
|
||||||
|
{
|
||||||
|
double gain;
|
||||||
|
iarchive(gain);
|
||||||
|
data_from_serv = gain;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case cmd_type::zynq_param:
|
||||||
|
{
|
||||||
|
if (cmd.rsp == response_type::ok)
|
||||||
|
{
|
||||||
|
double value;
|
||||||
|
iarchive(value);
|
||||||
|
data_from_serv = value;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case cmd_type::get_demodulator_param:
|
||||||
|
{
|
||||||
|
if (cmd.rsp == response_type::ok)
|
||||||
|
{
|
||||||
|
uint32_t value;
|
||||||
|
iarchive(value);
|
||||||
|
data_from_serv = value;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case cmd_type::get_modulator_param:
|
||||||
|
{
|
||||||
|
if (cmd.rsp == response_type::ok)
|
||||||
|
{
|
||||||
|
uint32_t value;
|
||||||
|
iarchive(value);
|
||||||
|
data_from_serv = value;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case cmd_type::get_level_dmd:
|
||||||
|
{
|
||||||
|
if (cmd.rsp == response_type::ok)
|
||||||
|
{
|
||||||
|
double value;
|
||||||
|
iarchive(value);
|
||||||
|
data_from_serv = value;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case cmd_type::get_acm_params:
|
||||||
|
{
|
||||||
|
if(cmd.rsp == response_type::ok)
|
||||||
|
{
|
||||||
|
cmd_get_acm_param value;
|
||||||
|
iarchive(value);
|
||||||
|
data_from_serv = value;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case cmd_type::get_dma_debugg:
|
||||||
|
{
|
||||||
|
if (cmd.rsp == response_type::ok)
|
||||||
|
{
|
||||||
|
std::string value;
|
||||||
|
iarchive(value);
|
||||||
|
data_from_serv = value;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case cmd_type::get_params_dpdi:
|
||||||
|
{
|
||||||
|
if (cmd.rsp == response_type::ok)
|
||||||
|
{
|
||||||
|
dpdi_parameters value;
|
||||||
|
iarchive(value);
|
||||||
|
data_from_serv = value;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case cmd_type::get_network:
|
||||||
|
{
|
||||||
|
if (cmd.rsp == response_type::ok)
|
||||||
|
{
|
||||||
|
std::string value;
|
||||||
|
iarchive(value);
|
||||||
|
data_from_serv = value;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case cmd_type::get_qos_settings:
|
||||||
|
{
|
||||||
|
if (cmd.rsp == response_type::ok)
|
||||||
|
{
|
||||||
|
std::string value;
|
||||||
|
iarchive(value);
|
||||||
|
data_from_serv = value;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default: break;
|
||||||
|
}
|
||||||
|
|
||||||
|
process_response(cmd.id, cmd.rsp, std::move(data_from_serv));
|
||||||
|
}
|
||||||
|
|
||||||
|
void system_client::set_stdout_callback(std::function<void(const char *, uint32_t)> cb)
|
||||||
|
{
|
||||||
|
std::scoped_lock lock(cb_mtx);
|
||||||
|
stdout_cb = cb;
|
||||||
|
}
|
||||||
|
|
||||||
|
response_type system_client::send_set_dem_freq_cmd(uint32_t freq)
|
||||||
|
{
|
||||||
|
std::scoped_lock lock(cmd_in_progress_mtx);
|
||||||
|
|
||||||
|
uint32_t curr_id { ++cmd_id };
|
||||||
|
cmd_header set_dem_freq_cmd_hdr { curr_id, cmd_type::set_demodulator_frequency };
|
||||||
|
set_dem_freq_cmd freq_set { freq };
|
||||||
|
send_to_socket(set_dem_freq_cmd_hdr, freq_set);
|
||||||
|
|
||||||
|
std::any data_from_serv;
|
||||||
|
auto result = wait_for_response(curr_id, cmd_type::set_demodulator_frequency , data_from_serv);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
response_type system_client::send_get_dem_freq_cmd(uint32_t & freq)
|
||||||
|
{
|
||||||
|
std::scoped_lock lock(cmd_in_progress_mtx);
|
||||||
|
|
||||||
|
uint32_t curr_id { ++cmd_id };
|
||||||
|
|
||||||
|
cmd_header get_dem_freq_cmd_hdr { curr_id, cmd_type::get_demodulator_frequency };
|
||||||
|
send_to_socket(get_dem_freq_cmd_hdr);
|
||||||
|
|
||||||
|
std::any data_from_serv;
|
||||||
|
auto result = wait_for_response(curr_id, cmd_type::get_demodulator_frequency , data_from_serv);
|
||||||
|
if (data_from_serv.has_value())
|
||||||
|
freq = std::any_cast<uint32_t>(data_from_serv);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
response_type system_client::send_get_gain_param(const gain_value & interface_gain, double & gain)
|
||||||
|
{
|
||||||
|
std::scoped_lock lock(cmd_in_progress_mtx);
|
||||||
|
uint32_t curr_id { ++cmd_id };
|
||||||
|
|
||||||
|
cmd_header get_gain_cmd_hdr{curr_id,cmd_type::get_gain_param};
|
||||||
|
|
||||||
|
get_gain_par get_gain_cmd{interface_gain};
|
||||||
|
|
||||||
|
send_to_socket(get_gain_cmd_hdr,get_gain_cmd);
|
||||||
|
std::any data_from_serv;
|
||||||
|
auto result = wait_for_response(curr_id, cmd_type::get_gain_param , data_from_serv);
|
||||||
|
if (data_from_serv.has_value())
|
||||||
|
gain = std::any_cast<double>(data_from_serv);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
response_type system_client::send_get_demodulator_param(const getdemodulator_value & demod_val, uint32_t & value)
|
||||||
|
{
|
||||||
|
std::scoped_lock lock(cmd_in_progress_mtx);
|
||||||
|
uint32_t curr_id { ++cmd_id };
|
||||||
|
|
||||||
|
cmd_header get_demod_param{curr_id,cmd_type::get_demodulator_param};
|
||||||
|
|
||||||
|
cmd_get_demodulator_param get_dmd_param{demod_val, 0};
|
||||||
|
|
||||||
|
send_to_socket(get_demod_param,get_dmd_param);
|
||||||
|
std::any data_from_serv;
|
||||||
|
auto result = wait_for_response(curr_id, cmd_type::get_demodulator_param , data_from_serv);
|
||||||
|
if (data_from_serv.has_value())
|
||||||
|
value = std::any_cast<uint32_t>(data_from_serv);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
response_type system_client::send_get_modulator_param(const modulator_value & mod_val, uint32_t & value)
|
||||||
|
{
|
||||||
|
std::scoped_lock lock(cmd_in_progress_mtx);
|
||||||
|
uint32_t curr_id { ++cmd_id };
|
||||||
|
|
||||||
|
cmd_header get_mod_param{curr_id,cmd_type::get_modulator_param};
|
||||||
|
|
||||||
|
cmd_get_modulator_param cmd_get_mod_param{mod_val, 0};
|
||||||
|
|
||||||
|
send_to_socket(get_mod_param,cmd_get_mod_param);
|
||||||
|
std::any data_from_serv;
|
||||||
|
auto result = wait_for_response(curr_id, cmd_type::get_modulator_param , data_from_serv);
|
||||||
|
if (data_from_serv.has_value())
|
||||||
|
value = std::any_cast<uint32_t>(data_from_serv);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
response_type system_client::send_set_gain_param(const gain_value & interface_gain, double gain)
|
||||||
|
{
|
||||||
|
std::scoped_lock lock (cmd_in_progress_mtx);
|
||||||
|
uint32_t curr_id { ++cmd_id };
|
||||||
|
cmd_header set_gain_cmd_hdr{curr_id, cmd_type::set_gain_param};
|
||||||
|
|
||||||
|
set_gain_par set_gain_cmd{interface_gain, gain};
|
||||||
|
send_to_socket(set_gain_cmd_hdr,set_gain_cmd);
|
||||||
|
|
||||||
|
std::any data_from_serv;
|
||||||
|
auto result = wait_for_response(curr_id, cmd_type::set_gain_param , data_from_serv);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
response_type system_client::send_radio_enable(const cmd_radio & enable_choice, bool enbl_)
|
||||||
|
{
|
||||||
|
std::scoped_lock lock(cmd_in_progress_mtx);
|
||||||
|
uint32_t curr_id { ++cmd_id };
|
||||||
|
cmd_header radio_enable_cmd_hdr{curr_id, cmd_type::radio_on_of};
|
||||||
|
|
||||||
|
radio_enable radio_enable_cmd{enable_choice, enbl_};
|
||||||
|
send_to_socket(radio_enable_cmd_hdr, radio_enable_cmd);
|
||||||
|
|
||||||
|
std::any data_to_serv;
|
||||||
|
|
||||||
|
auto result = wait_for_response(curr_id, cmd_type::radio_on_of, data_to_serv);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
response_type system_client::send_set_demodulator_param(const demodulator_value & demod_val, uint32_t value)
|
||||||
|
{
|
||||||
|
std::scoped_lock lock(cmd_in_progress_mtx);
|
||||||
|
uint32_t curr_id { ++cmd_id };
|
||||||
|
cmd_header demodulator_cmd_hdr{curr_id, cmd_type::set_demodulator_param};
|
||||||
|
|
||||||
|
cmd_set_demodulator_param demodulator_cmd{demod_val, value};
|
||||||
|
send_to_socket(demodulator_cmd_hdr, demodulator_cmd);
|
||||||
|
|
||||||
|
std::any data_to_serv;
|
||||||
|
|
||||||
|
auto result = wait_for_response(curr_id, cmd_type::set_demodulator_param, data_to_serv);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
response_type system_client::send_modulator_param(const modulator_value & mod_val, uint32_t value)
|
||||||
|
{
|
||||||
|
std::scoped_lock lock(cmd_in_progress_mtx);
|
||||||
|
uint32_t curr_id { ++cmd_id };
|
||||||
|
cmd_header modulator_cmd_hdr{curr_id, cmd_type::modulator_param};
|
||||||
|
|
||||||
|
cmd_set_modulator_param modulator_cmd{mod_val, value};
|
||||||
|
send_to_socket(modulator_cmd_hdr, modulator_cmd);
|
||||||
|
|
||||||
|
std::any data_to_serv;
|
||||||
|
|
||||||
|
auto result = wait_for_response(curr_id, cmd_type::modulator_param, data_to_serv);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
response_type system_client::send_zynq_cmd(const zynq_value & zynq_val, double & value)
|
||||||
|
{
|
||||||
|
std::scoped_lock lock(cmd_in_progress_mtx);
|
||||||
|
uint32_t curr_id { ++cmd_id };
|
||||||
|
cmd_header zynq_cmd_hdr{curr_id, cmd_type::zynq_param};
|
||||||
|
|
||||||
|
cmd_zynq_param zynq_cmd{zynq_val};
|
||||||
|
send_to_socket(zynq_cmd_hdr, zynq_cmd);
|
||||||
|
|
||||||
|
std::any data_from_serv;
|
||||||
|
|
||||||
|
auto result = wait_for_response(curr_id, cmd_type::zynq_param, data_from_serv);
|
||||||
|
if (data_from_serv.has_value())
|
||||||
|
value = std::any_cast<double>(data_from_serv);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
response_type system_client::send_rollof_and_baudrate(double & rollof, double &baudrate)
|
||||||
|
{
|
||||||
|
std::scoped_lock lock(cmd_in_progress_mtx);
|
||||||
|
uint32_t curr_id { ++cmd_id };
|
||||||
|
cmd_header roll_baud_cmd_hdr{curr_id, cmd_type::set_baudrate_rollof_dmd};
|
||||||
|
cmd_set_rollof_and_demod cmd_roll_baud{baudrate, rollof};
|
||||||
|
send_to_socket(roll_baud_cmd_hdr, cmd_roll_baud);
|
||||||
|
|
||||||
|
std::any data_to_serv;
|
||||||
|
auto result = wait_for_response(curr_id, cmd_type::set_baudrate_rollof_dmd, data_to_serv);
|
||||||
|
return result;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
response_type system_client::send_get_dma_debug(const cmd_get_dma_debugg_enum & dma_debug, std::string &value)
|
||||||
|
{
|
||||||
|
std::scoped_lock lock(cmd_in_progress_mtx);
|
||||||
|
uint32_t curr_id { ++cmd_id };
|
||||||
|
cmd_header get_dma_debug_header{curr_id, cmd_type::get_dma_debugg};
|
||||||
|
|
||||||
|
cmd_get_dma_debug val_cmd{value, dma_debug};
|
||||||
|
send_to_socket(get_dma_debug_header, val_cmd);
|
||||||
|
|
||||||
|
std::any data_from_serv;
|
||||||
|
|
||||||
|
auto result = wait_for_response(curr_id, cmd_type::get_dma_debugg, data_from_serv);
|
||||||
|
if (data_from_serv.has_value())
|
||||||
|
value = std::any_cast<std::string>(data_from_serv);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
response_type system_client::send_get_level_dem(const cmd_level_dem & lvl_dem_val, double &value)
|
||||||
|
{
|
||||||
|
std::scoped_lock lock(cmd_in_progress_mtx);
|
||||||
|
uint32_t curr_id { ++cmd_id };
|
||||||
|
cmd_header snr_cmd_hdr{curr_id, cmd_type::get_level_dmd};
|
||||||
|
|
||||||
|
cmd_get_level_dem val_cmd{value, lvl_dem_val};
|
||||||
|
send_to_socket(snr_cmd_hdr, val_cmd);
|
||||||
|
|
||||||
|
std::any data_from_serv;
|
||||||
|
|
||||||
|
auto result = wait_for_response(curr_id, cmd_type::get_level_dmd, data_from_serv);
|
||||||
|
if (data_from_serv.has_value())
|
||||||
|
value = std::any_cast<double>(data_from_serv);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
response_type system_client::send_get_acm_params(cmd_get_acm_param &acm_params)
|
||||||
|
{
|
||||||
|
std::scoped_lock lock(cmd_in_progress_mtx);
|
||||||
|
uint32_t curr_id { ++cmd_id };
|
||||||
|
cmd_header cmd_acm_header{curr_id, cmd_type::get_acm_params};
|
||||||
|
|
||||||
|
send_to_socket(cmd_acm_header, acm_params);
|
||||||
|
|
||||||
|
std::any data_from_serv;
|
||||||
|
|
||||||
|
auto result = wait_for_response(curr_id, cmd_type::get_acm_params, data_from_serv);
|
||||||
|
if (data_from_serv.has_value())
|
||||||
|
acm_params = std::any_cast<cmd_get_acm_param>(data_from_serv);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
response_type system_client::send_set_qos_params(const std::string &node, const name_classes_qos & class_qos)
|
||||||
|
{
|
||||||
|
std::scoped_lock lock(cmd_in_progress_mtx);
|
||||||
|
uint32_t curr_id { ++cmd_id };
|
||||||
|
cmd_header cmd_qos_header{curr_id, cmd_type::set_qos_settings};
|
||||||
|
cmd_set_qos_settings qos_settings{node, class_qos};
|
||||||
|
|
||||||
|
send_to_socket(cmd_qos_header, qos_settings);
|
||||||
|
|
||||||
|
std::any data_to_serv;
|
||||||
|
|
||||||
|
auto result = wait_for_response(curr_id, cmd_type::set_qos_settings, data_to_serv);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
response_type system_client::send_get_qos_params(std::string &node, const name_classes_qos & class_qos)
|
||||||
|
{
|
||||||
|
std::scoped_lock lock(cmd_in_progress_mtx);
|
||||||
|
uint32_t curr_id { ++cmd_id };
|
||||||
|
cmd_header cmd_qos_header{curr_id, cmd_type::get_qos_settings};
|
||||||
|
cmd_get_qos_settings qos_settings{node, class_qos};
|
||||||
|
|
||||||
|
send_to_socket(cmd_qos_header, qos_settings);
|
||||||
|
|
||||||
|
std::any data_from_serv;
|
||||||
|
|
||||||
|
auto result = wait_for_response(curr_id, cmd_type::get_qos_settings, data_from_serv);
|
||||||
|
if (data_from_serv.has_value())
|
||||||
|
node = std::any_cast<std::string>(data_from_serv);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
response_type system_client::send_set_10g_config(const cmd_10g_config & _10g_config, std::string &value)
|
||||||
|
{
|
||||||
|
std::scoped_lock lock(cmd_in_progress_mtx);
|
||||||
|
uint32_t curr_id { ++cmd_id };
|
||||||
|
cmd_header _10g_config_header{curr_id, cmd_type::set_10g_config};
|
||||||
|
|
||||||
|
cmd_set_10g_config _10g_config_cmd{value, _10g_config};
|
||||||
|
send_to_socket(_10g_config_header, _10g_config_cmd);
|
||||||
|
|
||||||
|
std::any data_to_serv;
|
||||||
|
|
||||||
|
auto result = wait_for_response(curr_id, cmd_type::set_10g_config, data_to_serv);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
response_type system_client::send_set_dma_debug(const cmd_dma_debugg & dma_debugg, std::string &value)
|
||||||
|
{
|
||||||
|
std::scoped_lock lock(cmd_in_progress_mtx);
|
||||||
|
uint32_t curr_id { ++cmd_id };
|
||||||
|
cmd_header dma_debug_header{curr_id, cmd_type::set_dma_debugg};
|
||||||
|
|
||||||
|
cmd_set_dma_debug cmd_dma_debug{value, dma_debugg};
|
||||||
|
send_to_socket(dma_debug_header, cmd_dma_debug);
|
||||||
|
|
||||||
|
std::any data_to_serv;
|
||||||
|
|
||||||
|
auto result = wait_for_response(curr_id, cmd_type::set_dma_debugg, data_to_serv);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
response_type system_client::send_set_lbq_params(const uint32_t & tick_ms, const uint32_t & bucket_size)
|
||||||
|
{
|
||||||
|
std::scoped_lock lock(cmd_in_progress_mtx);
|
||||||
|
uint32_t curr_id { ++cmd_id };
|
||||||
|
cmd_header lbq_debug_header{curr_id, cmd_type::set_lbq_params};
|
||||||
|
|
||||||
|
cmd_lbq_params params{tick_ms, bucket_size};
|
||||||
|
|
||||||
|
send_to_socket(lbq_debug_header, params);
|
||||||
|
|
||||||
|
std::any data_to_serv;
|
||||||
|
|
||||||
|
auto result = wait_for_response(curr_id, cmd_type::set_lbq_params, data_to_serv);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
response_type system_client::send_set_acm_params(const ACM_parameters_serv &acm_params)
|
||||||
|
{
|
||||||
|
std::scoped_lock lock(cmd_in_progress_mtx);
|
||||||
|
uint32_t curr_id { ++cmd_id };
|
||||||
|
cmd_header cmd_acm_header{curr_id, cmd_type::set_acm_params};
|
||||||
|
|
||||||
|
cmd_set_acm_param cmd_set_acm{acm_params};
|
||||||
|
send_to_socket(cmd_acm_header, cmd_set_acm);
|
||||||
|
|
||||||
|
std::any data_to_serv;
|
||||||
|
|
||||||
|
auto result = wait_for_response(curr_id, cmd_type::set_acm_params, data_to_serv);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
response_type system_client::send_set_dpdi_params(dpdi_parameters &dpdi_params)
|
||||||
|
{
|
||||||
|
std::scoped_lock lock(cmd_in_progress_mtx);
|
||||||
|
uint32_t curr_id { ++cmd_id };
|
||||||
|
cmd_header cmd_dpdi_header{curr_id, cmd_type::set_params_dpdi};
|
||||||
|
|
||||||
|
dpdi_parameters cmd_set_dpdi{dpdi_params};
|
||||||
|
send_to_socket(cmd_dpdi_header, cmd_set_dpdi);
|
||||||
|
|
||||||
|
std::any data_to_serv;
|
||||||
|
|
||||||
|
auto result = wait_for_response(curr_id, cmd_type::set_params_dpdi, data_to_serv);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
response_type system_client::send_get_dpdi_params(dpdi_parameters &dpdi_params)
|
||||||
|
{
|
||||||
|
std::scoped_lock lock(cmd_in_progress_mtx);
|
||||||
|
uint32_t curr_id { ++cmd_id };
|
||||||
|
cmd_header cmd_dpdi_header{curr_id, cmd_type::get_params_dpdi};
|
||||||
|
|
||||||
|
send_to_socket(cmd_dpdi_header, dpdi_params);
|
||||||
|
|
||||||
|
std::any data_from_serv;
|
||||||
|
|
||||||
|
auto result = wait_for_response(curr_id, cmd_type::get_params_dpdi, data_from_serv);
|
||||||
|
if (data_from_serv.has_value())
|
||||||
|
dpdi_params = std::any_cast<dpdi_parameters>(data_from_serv);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
response_type system_client::send_network_settings(const network_value & cmd_netw, const std::string & value)
|
||||||
|
{
|
||||||
|
std::scoped_lock lock(cmd_in_progress_mtx);
|
||||||
|
uint32_t curr_id { ++cmd_id };
|
||||||
|
cmd_header network_cmd_hdr{curr_id, cmd_type::set_network};
|
||||||
|
cmd_set_network cmd_network{value, cmd_netw};
|
||||||
|
send_to_socket(network_cmd_hdr, cmd_network);
|
||||||
|
|
||||||
|
std::any data_to_serv;
|
||||||
|
auto result = wait_for_response(curr_id, cmd_type::set_network, data_to_serv);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
response_type system_client::send_get_network_settings(const network_value & cmd_netw, std::string & value)
|
||||||
|
{
|
||||||
|
std::scoped_lock lock(cmd_in_progress_mtx);
|
||||||
|
uint32_t curr_id { ++cmd_id };
|
||||||
|
cmd_header cmd_network_hdr{curr_id, cmd_type::get_network};
|
||||||
|
cmd_get_network cmd_network{value, cmd_netw};
|
||||||
|
send_to_socket(cmd_network_hdr, cmd_network);
|
||||||
|
|
||||||
|
std::any data_from_serv;
|
||||||
|
auto result = wait_for_response(curr_id, cmd_type::get_network, data_from_serv);
|
||||||
|
if (data_from_serv.has_value())
|
||||||
|
value = std::any_cast<std::string>(data_from_serv);
|
||||||
|
return result;
|
||||||
|
}
|
105
dependencies/control_system-dvbs-2/client/system_client.h
vendored
Normal file
105
dependencies/control_system-dvbs-2/client/system_client.h
vendored
Normal file
@ -0,0 +1,105 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <map>
|
||||||
|
#include <queue>
|
||||||
|
#include <any>
|
||||||
|
#include "sock_client.h"
|
||||||
|
#include "../common/protocol_commands.h"
|
||||||
|
|
||||||
|
enum class state
|
||||||
|
{
|
||||||
|
disconnected,
|
||||||
|
connected,
|
||||||
|
logged_in
|
||||||
|
};
|
||||||
|
|
||||||
|
class system_client
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
system_client(const std::string & unix_file, std::function<void(const std::string&)> log_func = nullptr);
|
||||||
|
~system_client();
|
||||||
|
|
||||||
|
state get_current_state() const;
|
||||||
|
|
||||||
|
response_type send_login_cmd (const std::string & username, const std::string & pass, access_rights & access);
|
||||||
|
response_type send_logout_cmd ();
|
||||||
|
response_type send_ping_cmd (const std::string & ip, size_t count);
|
||||||
|
response_type send_traceroute_cmd (const std::string & ip);
|
||||||
|
response_type send_show_interface_cmd(const interface_value & interface);
|
||||||
|
response_type send_copy_cmd (const fm::side_description & src, const fm::side_description & dst);
|
||||||
|
|
||||||
|
response_type send_set_dem_freq_cmd(uint32_t freq);
|
||||||
|
response_type send_get_dem_freq_cmd(uint32_t & freq);
|
||||||
|
|
||||||
|
response_type send_set_gain_param (const gain_value & interface_gain, double gain);
|
||||||
|
response_type send_get_gain_param (const gain_value & interface_gain, double & gain);
|
||||||
|
response_type send_radio_enable (const cmd_radio & enable_choice, bool enbl_);
|
||||||
|
response_type send_modulator_param(const modulator_value & mod_val, uint32_t value);
|
||||||
|
response_type send_get_modulator_param(const modulator_value & mod_val, uint32_t &value);
|
||||||
|
response_type send_set_demodulator_param(const demodulator_value & demod_val, uint32_t value);
|
||||||
|
response_type send_get_demodulator_param(const getdemodulator_value & demod_val, uint32_t &value);
|
||||||
|
response_type send_zynq_cmd(const zynq_value & zynq_val, double & value);
|
||||||
|
response_type send_network_settings(const network_value & cmd_netw, const std::string & value);
|
||||||
|
response_type send_get_network_settings(const network_value & cmd_netw, std::string & value);
|
||||||
|
response_type send_rollof_and_baudrate(double & rollof, double &baudrate);
|
||||||
|
response_type send_get_level_dem(const cmd_level_dem & lvl_dem_val, double &value);
|
||||||
|
response_type send_get_dma_debug(const cmd_get_dma_debugg_enum & dma_debug, std::string &value);
|
||||||
|
response_type send_set_10g_config(const cmd_10g_config & _10g_config, std::string &value);
|
||||||
|
response_type send_set_dma_debug(const cmd_dma_debugg & dma_debugg, std::string &value);
|
||||||
|
response_type send_set_acm_params(const ACM_parameters_serv &acm_params);
|
||||||
|
response_type send_get_acm_params(cmd_get_acm_param &acm_params);
|
||||||
|
|
||||||
|
response_type send_set_dpdi_params(dpdi_parameters &dpdi_params);
|
||||||
|
response_type send_get_dpdi_params(dpdi_parameters &dpdi_params);
|
||||||
|
|
||||||
|
response_type send_set_lbq_params(const uint32_t & tick_ms, const uint32_t & bucket_size);
|
||||||
|
|
||||||
|
response_type send_set_qos_params(const std::string &node, const name_classes_qos & class_qos);
|
||||||
|
response_type send_get_qos_params(std::string &node, const name_classes_qos & class_qos);
|
||||||
|
|
||||||
|
|
||||||
|
void set_stdout_callback(std::function<void(const char *, uint32_t)> cb);
|
||||||
|
void abort();
|
||||||
|
|
||||||
|
private:
|
||||||
|
system_client(const system_client&) = delete;
|
||||||
|
const system_client& operator=(const system_client&) = delete;
|
||||||
|
|
||||||
|
boost::asio::io_context io_context;
|
||||||
|
client clt;
|
||||||
|
std::function<void(const std::string&)> log;
|
||||||
|
std::thread ctx_thread;
|
||||||
|
std::atomic<uint32_t> cmd_id;
|
||||||
|
|
||||||
|
std::mutex cb_mtx;
|
||||||
|
std::function<void(const char *, uint32_t len)> stdout_cb;
|
||||||
|
|
||||||
|
std::mutex responses_mtx;
|
||||||
|
std::map<uint32_t, std::queue<response_type>> responses;
|
||||||
|
std::map<uint32_t, std::queue<std::any>> responses_data;
|
||||||
|
std::condition_variable cv_resp;
|
||||||
|
|
||||||
|
state current_state;
|
||||||
|
|
||||||
|
std::mutex cmd_in_progress_mtx;
|
||||||
|
|
||||||
|
response_type wait_for_response (uint32_t id, const cmd_type & type, std::any & data);
|
||||||
|
response_type wait_for_progressing_response(uint32_t c_id, const cmd_type & cmd_t);
|
||||||
|
void process_response (uint32_t id, response_type resp, std::any && data);
|
||||||
|
void data_received (const std::vector<uint8_t> & data);
|
||||||
|
void send_abort (uint32_t id);
|
||||||
|
|
||||||
|
template<typename... Args>
|
||||||
|
void send_to_socket(Args&&... args)
|
||||||
|
{
|
||||||
|
//TO-DO: need case for empty parameter pack?
|
||||||
|
std::stringstream s;
|
||||||
|
s << std::noskipws;
|
||||||
|
{
|
||||||
|
cereal::BinaryOutputArchive oarchive(s);
|
||||||
|
oarchive(std::forward<Args>(args)...);
|
||||||
|
}
|
||||||
|
std::vector<uint8_t> data((std::istream_iterator<uint8_t>(s)), std::istream_iterator<uint8_t>());
|
||||||
|
clt.write(data);
|
||||||
|
|
||||||
|
}
|
||||||
|
};
|
671
dependencies/control_system-dvbs-2/common/protocol_commands.h
vendored
Normal file
671
dependencies/control_system-dvbs-2/common/protocol_commands.h
vendored
Normal file
@ -0,0 +1,671 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <cereal/archives/binary.hpp>
|
||||||
|
#include <cereal/types/vector.hpp>
|
||||||
|
#include <cereal/types/string.hpp>
|
||||||
|
|
||||||
|
namespace fm
|
||||||
|
{
|
||||||
|
enum class side_type
|
||||||
|
{
|
||||||
|
local = 0,
|
||||||
|
tftp = 1,
|
||||||
|
config = 2
|
||||||
|
};
|
||||||
|
|
||||||
|
struct side_description
|
||||||
|
{
|
||||||
|
side_type s_type;
|
||||||
|
std::string filepath;
|
||||||
|
|
||||||
|
template<class Archive>
|
||||||
|
void serialize(Archive & archive)
|
||||||
|
{
|
||||||
|
archive(s_type, filepath);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
enum class cmd_dma_debugg
|
||||||
|
{
|
||||||
|
start = 0,
|
||||||
|
stop = 1,
|
||||||
|
reset = 2,
|
||||||
|
reinit = 3,
|
||||||
|
modcod = 4,
|
||||||
|
log_bool = 5,
|
||||||
|
data_mode = 6,
|
||||||
|
default_params = 7,
|
||||||
|
buc_voltage = 8,
|
||||||
|
lnb_voltage = 9,
|
||||||
|
_10mhz_tx = 10,
|
||||||
|
_10mhz_rx = 11,
|
||||||
|
powerdown_plata = 12,
|
||||||
|
_10MHz_out = 13,
|
||||||
|
current_state_tx = 14,
|
||||||
|
current_state_oib = 15,
|
||||||
|
save_config = 16,
|
||||||
|
begin_save_config = 17
|
||||||
|
};
|
||||||
|
|
||||||
|
enum class name_classes_qos
|
||||||
|
{
|
||||||
|
realtime1 = 0,
|
||||||
|
realtime2,
|
||||||
|
realtime3,
|
||||||
|
critical1,
|
||||||
|
critical2,
|
||||||
|
critical3,
|
||||||
|
cir,
|
||||||
|
pir,
|
||||||
|
wcr1,
|
||||||
|
wcr2,
|
||||||
|
wcr3,
|
||||||
|
enable,
|
||||||
|
ful_node
|
||||||
|
};
|
||||||
|
|
||||||
|
enum class cmd_get_dma_debugg_enum
|
||||||
|
{
|
||||||
|
speed_tx = 0,
|
||||||
|
speed_rx = 1,
|
||||||
|
modcod = 2,
|
||||||
|
drop_bad_rx = 3,
|
||||||
|
drop_full_rx = 4,
|
||||||
|
packet_ok_rx = 5,
|
||||||
|
packet_little_tx = 6,
|
||||||
|
packet_big_tx = 7,
|
||||||
|
bad_modcod_tx = 8,
|
||||||
|
bad_length_tx = 9,
|
||||||
|
reset_cnt_rx = 10,
|
||||||
|
data_mode = 11,
|
||||||
|
buc_voltage = 12,
|
||||||
|
lnb_voltage = 13,
|
||||||
|
_10mhz_tx = 14,
|
||||||
|
_10mhz_rx = 15,
|
||||||
|
powerdown_plata = 16,
|
||||||
|
_10MHz_out = 17,
|
||||||
|
current_state_tx = 18,
|
||||||
|
real_dpdi_shift = 19,
|
||||||
|
freq_error_offset = 20,
|
||||||
|
freq_fine_estimate = 21,
|
||||||
|
speed_tx_iface = 22,
|
||||||
|
speed_rx_iface = 23,
|
||||||
|
current_state_oib = 24,
|
||||||
|
ratio_signal_signal = 25,
|
||||||
|
status_init = 26
|
||||||
|
};
|
||||||
|
|
||||||
|
enum class cmd_10g_config
|
||||||
|
{
|
||||||
|
udp_payload_lenght = 0,
|
||||||
|
local_ip = 1,
|
||||||
|
dest_ip = 2,
|
||||||
|
gateway_ip = 3,
|
||||||
|
subnet_mask = 4,
|
||||||
|
udp_source_port = 5,
|
||||||
|
udp_dest_port = 6,
|
||||||
|
local_mac_31_0 = 7,
|
||||||
|
local_mac_32_47 = 8,
|
||||||
|
mtx_chan0 = 9,
|
||||||
|
mtx_chan1 = 10
|
||||||
|
};
|
||||||
|
|
||||||
|
enum class cmd_level_dem
|
||||||
|
{
|
||||||
|
//! ОСШ на входе
|
||||||
|
snr = 0,
|
||||||
|
//! RSSI на входе
|
||||||
|
rssi = 1,
|
||||||
|
sym_sync_lock = 2,
|
||||||
|
freq_search_lock = 3,
|
||||||
|
afc_lock = 4,
|
||||||
|
pkt_sync = 5,
|
||||||
|
phase_inv = 6,
|
||||||
|
afc_error = 7,
|
||||||
|
sym_error = 8,
|
||||||
|
fine_freq_error = 9,
|
||||||
|
crs_freq_error = 10,
|
||||||
|
gc_gain_aru = 11,
|
||||||
|
rollof = 12,
|
||||||
|
carrier_lock = 13,
|
||||||
|
filt_adapt_lock = 14,
|
||||||
|
snr_acm = 15,
|
||||||
|
modcod_tx = 16
|
||||||
|
};
|
||||||
|
|
||||||
|
enum class interface_value
|
||||||
|
{
|
||||||
|
all = 0,
|
||||||
|
sat0 = 1,
|
||||||
|
gigabit = 2,
|
||||||
|
modulator = 3,
|
||||||
|
demodulator = 4
|
||||||
|
};
|
||||||
|
|
||||||
|
enum class zynq_value
|
||||||
|
{
|
||||||
|
ps_volt = 0,
|
||||||
|
pl_volt = 1,
|
||||||
|
adrv_temp = 2,
|
||||||
|
pl_temp = 3,
|
||||||
|
ps_temp = 4,
|
||||||
|
adrv_temp2 = 5
|
||||||
|
};
|
||||||
|
|
||||||
|
enum class modulator_value
|
||||||
|
{
|
||||||
|
lo_freaquency = 0,
|
||||||
|
baud_rate = 1,
|
||||||
|
temp_treshold = 2,
|
||||||
|
mod_reset = 3,
|
||||||
|
modcod = 4,
|
||||||
|
rollof = 5,
|
||||||
|
mode_transmitt = 6,
|
||||||
|
if_overload = 7,
|
||||||
|
gold_seq = 8
|
||||||
|
};
|
||||||
|
|
||||||
|
enum class demodulator_value
|
||||||
|
{
|
||||||
|
lo_freaquency = 0,
|
||||||
|
baud_rate = 1,
|
||||||
|
freq_search = 2,
|
||||||
|
demod_reset = 3,
|
||||||
|
fec_frame_size = 4,
|
||||||
|
rvt = 5,
|
||||||
|
mode_gain_control = 6,
|
||||||
|
sig_min = 7,
|
||||||
|
sig_max = 8,
|
||||||
|
afc_rst = 9,
|
||||||
|
mode_demod = 10,
|
||||||
|
gold_seq = 11,
|
||||||
|
attitude_signals = 12,
|
||||||
|
is_reset_CinC = 13
|
||||||
|
};
|
||||||
|
enum class getdemodulator_value
|
||||||
|
{
|
||||||
|
lo_freaquency = 0,
|
||||||
|
baud_rate = 1,
|
||||||
|
dummy_counter = 2,
|
||||||
|
modcod = 3,
|
||||||
|
mode_gain_control = 4,
|
||||||
|
sig_min = 5,
|
||||||
|
sig_max = 6,
|
||||||
|
rvt = 7,
|
||||||
|
fec_size = 8,
|
||||||
|
mode_demod = 9,
|
||||||
|
cnt_bad_lock_cinc = 10,
|
||||||
|
gold_seq = 11,
|
||||||
|
attitude_signals = 12,
|
||||||
|
cnt_dem_time_sinc = 13,
|
||||||
|
cnt_dem_lock_afc = 14,
|
||||||
|
cnt_dem_sync_pack = 15,
|
||||||
|
cnt_dem_sinc_frec_corse = 16,
|
||||||
|
freq_lock_estimate = 17,
|
||||||
|
freq_fine_estimate = 18,
|
||||||
|
is_reset_CinC = 19,
|
||||||
|
type_pack = 20,
|
||||||
|
is_pilots = 21
|
||||||
|
};
|
||||||
|
|
||||||
|
enum class gain_value
|
||||||
|
{
|
||||||
|
tx1 = 0,
|
||||||
|
tx2 = 1,
|
||||||
|
rx1 = 2,
|
||||||
|
rx2 = 3,
|
||||||
|
txpwd = 4,
|
||||||
|
rxpwd = 5
|
||||||
|
};
|
||||||
|
|
||||||
|
enum class acm_value
|
||||||
|
{
|
||||||
|
enable = 0,
|
||||||
|
modcod_min = 1,
|
||||||
|
modcod_max = 2,
|
||||||
|
attenuation_min = 3,
|
||||||
|
attenuatin_max = 4,
|
||||||
|
required_snr = 5
|
||||||
|
};
|
||||||
|
|
||||||
|
enum class cmd_radio
|
||||||
|
{
|
||||||
|
tx1 = 0,
|
||||||
|
tx2 = 1,
|
||||||
|
rx1 = 2,
|
||||||
|
rx2 = 3,
|
||||||
|
global = 4,
|
||||||
|
global2 = 5
|
||||||
|
};
|
||||||
|
|
||||||
|
enum class network_value
|
||||||
|
{
|
||||||
|
network = 0,
|
||||||
|
mode_interface = 1,
|
||||||
|
version = 2,
|
||||||
|
mask = 3,
|
||||||
|
gateway = 4,
|
||||||
|
dhcp_on = 5,
|
||||||
|
dhcp_range = 6,
|
||||||
|
network_data = 7,
|
||||||
|
chip_id = 8,
|
||||||
|
serial = 9,
|
||||||
|
mac_eth0 = 10,
|
||||||
|
mac_eth1 = 11,
|
||||||
|
name_serv = 12,
|
||||||
|
network_debug_send = 13,
|
||||||
|
network_port_metric = 14,
|
||||||
|
network_port_data = 15,
|
||||||
|
periodic_send_metrics = 16,
|
||||||
|
if_debug_mode = 17
|
||||||
|
};
|
||||||
|
|
||||||
|
enum class cmd_type
|
||||||
|
{
|
||||||
|
login = 0,
|
||||||
|
exit = 1,
|
||||||
|
ping = 2,
|
||||||
|
tracert = 3,
|
||||||
|
interface = 4,
|
||||||
|
copy = 5,
|
||||||
|
abort = 6,
|
||||||
|
set_demodulator_frequency = 7,
|
||||||
|
get_demodulator_frequency = 8,
|
||||||
|
set_gain_param = 9,
|
||||||
|
get_gain_param = 10,
|
||||||
|
radio_on_of = 11,
|
||||||
|
modulator_param = 12,
|
||||||
|
zynq_param = 13,
|
||||||
|
set_demodulator_param = 14,
|
||||||
|
get_demodulator_param = 15,
|
||||||
|
get_modulator_param = 16,
|
||||||
|
set_network = 17,
|
||||||
|
get_level_dmd = 18,
|
||||||
|
set_10g_config = 19,
|
||||||
|
set_dma_debugg = 20,
|
||||||
|
get_dma_debugg = 21,
|
||||||
|
set_baudrate_rollof_dmd = 22,
|
||||||
|
set_acm_params = 23,
|
||||||
|
get_acm_params = 24,
|
||||||
|
set_params_dpdi = 25,
|
||||||
|
get_params_dpdi = 26,
|
||||||
|
get_network = 27,
|
||||||
|
set_qos_settings = 28,
|
||||||
|
get_qos_settings = 29,
|
||||||
|
set_lbq_params = 30
|
||||||
|
};
|
||||||
|
|
||||||
|
struct cmd_lbq_params
|
||||||
|
{
|
||||||
|
uint32_t tick_ms;
|
||||||
|
uint32_t bucket_size;
|
||||||
|
template<class Archive>
|
||||||
|
void serialize(Archive & archive)
|
||||||
|
{
|
||||||
|
archive(tick_ms, bucket_size);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
struct cmd_get_network
|
||||||
|
{
|
||||||
|
std::string network;
|
||||||
|
network_value net_val;
|
||||||
|
template<class Archive>
|
||||||
|
void serialize(Archive & archive)
|
||||||
|
{
|
||||||
|
archive(net_val, network);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
struct cmd_set_network
|
||||||
|
{
|
||||||
|
std::string network;
|
||||||
|
network_value net_val;
|
||||||
|
template<class Archive>
|
||||||
|
void serialize(Archive & archive)
|
||||||
|
{
|
||||||
|
archive(net_val, network);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
struct dpdi_parameters
|
||||||
|
{
|
||||||
|
uint8_t latitude_station_grad = 0;
|
||||||
|
uint8_t latitude_station_minute = 0;
|
||||||
|
uint8_t longitude_station_grad = 0;
|
||||||
|
uint8_t longitude_station_minute = 0;
|
||||||
|
uint8_t longitude_sattelite_grad = 0;
|
||||||
|
uint8_t longitude_sattelite_minute = 0;
|
||||||
|
bool is_delay_window = 0;
|
||||||
|
uint32_t max_delay = 1;
|
||||||
|
uint32_t min_delay = 0;
|
||||||
|
uint32_t freq_offset = 0;
|
||||||
|
template<class Archive>
|
||||||
|
void serialize(Archive & archive)
|
||||||
|
{
|
||||||
|
archive(latitude_station_grad, latitude_station_minute,
|
||||||
|
longitude_station_grad, longitude_station_minute,
|
||||||
|
longitude_sattelite_grad, longitude_sattelite_minute,
|
||||||
|
is_delay_window, max_delay, min_delay, freq_offset);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
struct ACM_parameters_serv
|
||||||
|
{
|
||||||
|
double snr_treashold = 0;
|
||||||
|
double snr_treashold_acm = 0.5;
|
||||||
|
uint32_t period_pack = 15;
|
||||||
|
uint8_t max_modcod = 4;
|
||||||
|
uint8_t min_modcod = 4;
|
||||||
|
int max_attenuation = 0;
|
||||||
|
int min_attenuation = 0;
|
||||||
|
bool enable = false;
|
||||||
|
bool enable_auto_atten = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct cmd_get_acm_param
|
||||||
|
{
|
||||||
|
double snr_treashold = 0;
|
||||||
|
double snr_treashold_acm = 0.5;
|
||||||
|
uint32_t period_pack = 15;
|
||||||
|
uint8_t max_modcod = 4;
|
||||||
|
uint8_t min_modcod = 4;
|
||||||
|
int max_attenuation = 0;
|
||||||
|
int min_attenuation = 0;
|
||||||
|
bool enable = false;
|
||||||
|
bool enable_auto_atten = false;
|
||||||
|
template<class Archive>
|
||||||
|
void serialize(Archive & archive)
|
||||||
|
{
|
||||||
|
archive(enable, max_attenuation, max_modcod, min_attenuation, min_modcod, snr_treashold, enable_auto_atten, snr_treashold_acm, period_pack);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
struct cmd_set_qos_settings
|
||||||
|
{
|
||||||
|
std::string node;
|
||||||
|
name_classes_qos class_qos;
|
||||||
|
template<class Archive>
|
||||||
|
void serialize(Archive & archive)
|
||||||
|
{
|
||||||
|
archive(node, class_qos);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
struct cmd_get_qos_settings
|
||||||
|
{
|
||||||
|
std::string node;
|
||||||
|
name_classes_qos class_qos;
|
||||||
|
template<class Archive>
|
||||||
|
void serialize(Archive & archive)
|
||||||
|
{
|
||||||
|
archive(node, class_qos);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
struct cmd_set_acm_param
|
||||||
|
{
|
||||||
|
ACM_parameters_serv acm_params;
|
||||||
|
template<class Archive>
|
||||||
|
void serialize(Archive & archive)
|
||||||
|
{
|
||||||
|
archive(acm_params.enable, acm_params.max_attenuation, acm_params.max_modcod, acm_params.min_attenuation, acm_params.min_modcod, acm_params.snr_treashold, acm_params.enable_auto_atten, acm_params.snr_treashold_acm, acm_params.period_pack);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
struct cmd_get_dma_debug
|
||||||
|
{
|
||||||
|
std::string value;
|
||||||
|
cmd_get_dma_debugg_enum dma_debugg;
|
||||||
|
template<class Archive>
|
||||||
|
void serialize(Archive & archive)
|
||||||
|
{
|
||||||
|
archive(dma_debugg, value);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
struct cmd_set_dma_debug
|
||||||
|
{
|
||||||
|
std::string value;
|
||||||
|
cmd_dma_debugg dma_debugg;
|
||||||
|
template<class Archive>
|
||||||
|
void serialize(Archive & archive)
|
||||||
|
{
|
||||||
|
archive(dma_debugg, value);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
struct cmd_set_10g_config
|
||||||
|
{
|
||||||
|
std::string value;
|
||||||
|
cmd_10g_config _10g_config;
|
||||||
|
template<class Archive>
|
||||||
|
void serialize(Archive & archive)
|
||||||
|
{
|
||||||
|
archive(_10g_config, value);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
struct cmd_get_level_dem
|
||||||
|
{
|
||||||
|
double value;
|
||||||
|
cmd_level_dem lvl_dem;
|
||||||
|
template<class Archive>
|
||||||
|
void serialize(Archive & archive)
|
||||||
|
{
|
||||||
|
archive(lvl_dem, value);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
struct cmd_zynq_param
|
||||||
|
{
|
||||||
|
zynq_value cmd_zynq;
|
||||||
|
template<class Archive>
|
||||||
|
void serialize(Archive & archive)
|
||||||
|
{
|
||||||
|
archive(cmd_zynq);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
struct radio_enable
|
||||||
|
{
|
||||||
|
cmd_radio cmd_radio_;
|
||||||
|
bool enbl;
|
||||||
|
template<class Archive>
|
||||||
|
void serialize(Archive & archive)
|
||||||
|
{
|
||||||
|
archive(cmd_radio_, enbl);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
struct cmd_set_modulator_param
|
||||||
|
{
|
||||||
|
modulator_value mod_val;
|
||||||
|
long long value;
|
||||||
|
|
||||||
|
template<class Archive>
|
||||||
|
void serialize(Archive & archive)
|
||||||
|
{
|
||||||
|
archive(mod_val,value);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
struct cmd_get_modulator_param
|
||||||
|
{
|
||||||
|
modulator_value mod_val;
|
||||||
|
uint32_t value;
|
||||||
|
|
||||||
|
template<class Archive>
|
||||||
|
void serialize(Archive & archive)
|
||||||
|
{
|
||||||
|
archive(mod_val,value);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
struct cmd_set_rollof_and_demod
|
||||||
|
{
|
||||||
|
double baudrate;
|
||||||
|
double rollof;
|
||||||
|
template<class Archive>
|
||||||
|
void serialize(Archive & archive)
|
||||||
|
{
|
||||||
|
archive(baudrate,rollof);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
struct cmd_set_demodulator_param
|
||||||
|
{
|
||||||
|
demodulator_value demod_val;
|
||||||
|
uint32_t value;
|
||||||
|
template<class Archive>
|
||||||
|
void serialize(Archive & archive)
|
||||||
|
{
|
||||||
|
archive(demod_val,value);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
struct cmd_get_demodulator_param
|
||||||
|
{
|
||||||
|
getdemodulator_value demod_val;
|
||||||
|
uint32_t value;
|
||||||
|
|
||||||
|
template<class Archive>
|
||||||
|
void serialize(Archive & archive)
|
||||||
|
{
|
||||||
|
archive(demod_val,value);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
struct set_gain_par
|
||||||
|
{
|
||||||
|
gain_value g_val;
|
||||||
|
double _gain;
|
||||||
|
|
||||||
|
template<class Archive>
|
||||||
|
void serialize(Archive & archive)
|
||||||
|
{
|
||||||
|
archive(g_val,_gain);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
struct get_gain_par
|
||||||
|
{
|
||||||
|
gain_value g_val;
|
||||||
|
template<class Archive>
|
||||||
|
void serialize(Archive & archive)
|
||||||
|
{
|
||||||
|
archive(g_val);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
struct set_dem_freq_cmd
|
||||||
|
{
|
||||||
|
uint32_t frequency;
|
||||||
|
template<class Archive>
|
||||||
|
void serialize(Archive & archive)
|
||||||
|
{
|
||||||
|
archive(frequency);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
enum class response_type
|
||||||
|
{
|
||||||
|
ok = 0,
|
||||||
|
error = 1,
|
||||||
|
in_progress = 3,
|
||||||
|
abort = 4,
|
||||||
|
busy = 5
|
||||||
|
};
|
||||||
|
|
||||||
|
enum class access_rights
|
||||||
|
{
|
||||||
|
not_allowed = 0,
|
||||||
|
user = 1,
|
||||||
|
admin = 2
|
||||||
|
};
|
||||||
|
|
||||||
|
struct cmd_header
|
||||||
|
{
|
||||||
|
uint32_t id;
|
||||||
|
cmd_type cmd;
|
||||||
|
|
||||||
|
template<class Archive>
|
||||||
|
void serialize(Archive & archive)
|
||||||
|
{
|
||||||
|
archive(id, cmd);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
struct login_cmd
|
||||||
|
{
|
||||||
|
std::string username;
|
||||||
|
std::string pass;
|
||||||
|
|
||||||
|
template<class Archive>
|
||||||
|
void serialize(Archive & archive)
|
||||||
|
{
|
||||||
|
archive(username, pass);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
struct ping_cmd
|
||||||
|
{
|
||||||
|
std::string ip_address;
|
||||||
|
size_t count;
|
||||||
|
|
||||||
|
template<class Archive>
|
||||||
|
void serialize(Archive & archive)
|
||||||
|
{
|
||||||
|
archive(ip_address, count);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
struct tracert_cmd
|
||||||
|
{
|
||||||
|
std::string ip_address;
|
||||||
|
|
||||||
|
template<class Archive>
|
||||||
|
void serialize(Archive & archive)
|
||||||
|
{
|
||||||
|
archive(ip_address);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
struct interface_cmd
|
||||||
|
{
|
||||||
|
interface_value val;
|
||||||
|
|
||||||
|
template<class Archive>
|
||||||
|
void serialize(Archive & archive)
|
||||||
|
{
|
||||||
|
archive(val);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
struct copy_cmd
|
||||||
|
{
|
||||||
|
fm::side_description src;
|
||||||
|
fm::side_description dst;
|
||||||
|
|
||||||
|
template<class Archive>
|
||||||
|
void serialize(Archive & archive)
|
||||||
|
{
|
||||||
|
archive(src, dst);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
struct response_header
|
||||||
|
{
|
||||||
|
uint32_t id;
|
||||||
|
cmd_type cmd;
|
||||||
|
response_type rsp;
|
||||||
|
|
||||||
|
template<class Archive>
|
||||||
|
void serialize(Archive & archive)
|
||||||
|
{
|
||||||
|
archive(id, cmd, rsp);
|
||||||
|
}
|
||||||
|
};
|
23
dependencies/control_system-dvbs-2/common/seq_packet.h
vendored
Normal file
23
dependencies/control_system-dvbs-2/common/seq_packet.h
vendored
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <boost/asio.hpp>
|
||||||
|
|
||||||
|
namespace seq_packet
|
||||||
|
{
|
||||||
|
using namespace boost::asio::local;
|
||||||
|
|
||||||
|
struct seqpacket_protocol
|
||||||
|
{
|
||||||
|
int type() const { return SOCK_SEQPACKET; }
|
||||||
|
int protocol() const { return 0; }
|
||||||
|
int family() const { return AF_UNIX; }
|
||||||
|
|
||||||
|
using endpoint = basic_endpoint<seqpacket_protocol>;
|
||||||
|
using socket = boost::asio::basic_stream_socket<seqpacket_protocol>;
|
||||||
|
using acceptor = boost::asio::basic_socket_acceptor<seqpacket_protocol>;
|
||||||
|
|
||||||
|
#if !defined(BOOST_ASIO_NO_IOSTREAM)
|
||||||
|
/// The UNIX domain iostream type.
|
||||||
|
typedef boost::asio::basic_socket_iostream<seqpacket_protocol> iostream;
|
||||||
|
#endif // !defined(BOOST_ASIO_NO_IOSTREAM)
|
||||||
|
};
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user