#ifndef __CONTROL_PROTO_COMMANDS__
#define __CONTROL_PROTO_COMMANDS__

#include <iostream>
#include <string>

#ifdef __cplusplus
#include <cstdint>
#define EXTERNC extern  "C"
#else
#include <stdint.h>
#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
