5#include "mechanism/pipe/ec_pipe_pdo.h"
6#include "mechanism/zmq/ec_zmq_pdo.h"
10 static const std::vector<std::string>name = {
"Motor_Current",
"Motor_Speed",
"Pressure1",
"Pressure2",
11 "temperature",
"MOSFET_temperature",
"motor_temperature",
12 "fault",
"rtt",
"op_idx_ack",
"aux"};
13 static const int pdo_size=11;
14 using pdo_t=std::tuple<float,float,float,float,
15 uint16_t,uint16_t,int16_t,
16 uint16_t,uint16_t,uint16_t,
float>;
18 inline bool make_vector_from_tuple(
const pdo_t &pdo_tuple,std::vector<T> &pdo_vector){
19 if(pdo_vector.size()!=pdo_size){
22 pdo_vector[0]=
static_cast<T
>(std::get<0>(pdo_tuple));
23 pdo_vector[1]=
static_cast<T
>(std::get<1>(pdo_tuple));
24 pdo_vector[2]=
static_cast<T
>(std::get<2>(pdo_tuple));
25 pdo_vector[3]=
static_cast<T
>(std::get<3>(pdo_tuple));
26 pdo_vector[4]=
static_cast<T
>(std::get<4>(pdo_tuple));
27 pdo_vector[5]=
static_cast<T
>(std::get<5>(pdo_tuple));
28 pdo_vector[6]=
static_cast<T
>(std::get<6>(pdo_tuple));
29 pdo_vector[7]=
static_cast<T
>(std::get<7>(pdo_tuple));
30 pdo_vector[8]=
static_cast<T
>(std::get<8>(pdo_tuple));
31 pdo_vector[9]=
static_cast<T
>(std::get<9>(pdo_tuple));
32 pdo_vector[10]=
static_cast<T
>(std::get<10>(pdo_tuple));
38 static const std::vector<std::string>name = {
"Pump_Target",
39 "pressure_P_gain",
"pressure_I_gain",
"pressure_D_gain",
"pressure_I_limit",
40 "fault_ack",
"SolenoidOut",
"ts",
"op_idx_aux",
"aux"};
41 static const int pdo_size=10;
42 using pdo_t=std::tuple<float,
43 float, float, float, float,
44 uint16_t,uint16_t,uint16_t,uint16_t,
float>;
46 inline bool make_vector_from_tuple(
const pdo_t &pdo_tuple,std::vector<T> &pdo_vector){
47 if(pdo_vector.size()!=pdo_size){
50 pdo_vector[0]=
static_cast<T
>(std::get<0>(pdo_tuple));
51 pdo_vector[1]=
static_cast<T
>(std::get<1>(pdo_tuple));
52 pdo_vector[2]=
static_cast<T
>(std::get<2>(pdo_tuple));
53 pdo_vector[3]=
static_cast<T
>(std::get<3>(pdo_tuple));
54 pdo_vector[4]=
static_cast<T
>(std::get<4>(pdo_tuple));
55 pdo_vector[5]=
static_cast<T
>(std::get<5>(pdo_tuple));
56 pdo_vector[6]=
static_cast<T
>(std::get<6>(pdo_tuple));
57 pdo_vector[7]=
static_cast<T
>(std::get<7>(pdo_tuple));
58 pdo_vector[8]=
static_cast<T
>(std::get<8>(pdo_tuple));
59 pdo_vector[9]=
static_cast<T
>(std::get<9>(pdo_tuple));
65class PumpPdo:
public T{
69 PumpPdo(
const std::string value,int32_t
id, uint32_t type);
76 PumpPdoRx::pdo_t rx_pdo{};
77 PumpPdoTx::pdo_t tx_pdo{};
78 bool init_rx_pdo=
false;
84inline void PumpPdo<T>::init_pb()
86 uint8_t pb_buf[MAX_PB_SIZE];
90 msg_size = T::pb_tx_pdos.ByteSizeLong();
91 T::pb_tx_pdos.SerializeToArray( (
void*)(pb_buf+
sizeof(msg_size)), msg_size);
95inline PumpPdo<T>::PumpPdo(
const std::string value,int32_t
id, uint32_t type):
104inline PumpPdo<T>::~PumpPdo()
111inline void PumpPdo<T>::get_from_pb()
113 std::get<0>(rx_pdo) = T::pb_rx_pdos.mutable_hyqhpu_rx_pdo()->motor_current();
114 std::get<1>(rx_pdo) = T::pb_rx_pdos.mutable_hyqhpu_rx_pdo()->motor_speed();
115 std::get<2>(rx_pdo) = T::pb_rx_pdos.mutable_hyqhpu_rx_pdo()->pressure1();
116 std::get<3>(rx_pdo) = T::pb_rx_pdos.mutable_hyqhpu_rx_pdo()->pressure2();
117 std::get<4>(rx_pdo) = T::pb_rx_pdos.mutable_hyqhpu_rx_pdo()->temperature();
118 std::get<5>(rx_pdo) = T::pb_rx_pdos.mutable_hyqhpu_rx_pdo()->mosfet_temperature();
119 std::get<6>(rx_pdo) = T::pb_rx_pdos.mutable_hyqhpu_rx_pdo()->motor_temperature();
120 std::get<7>(rx_pdo) = T::pb_rx_pdos.mutable_hyqhpu_rx_pdo()->fault();
121 std::get<8>(rx_pdo) = T::pb_rx_pdos.mutable_hyqhpu_rx_pdo()->rtt();
122 std::get<9>(rx_pdo) = T::pb_rx_pdos.mutable_hyqhpu_rx_pdo()->op_idx_ack();
123 std::get<10>(rx_pdo) = T::pb_rx_pdos.mutable_hyqhpu_rx_pdo()->aux();
131inline void PumpPdo<T>::set_to_pb()
133 set_pbHeader(T::pb_tx_pdos.mutable_header(), T::name, 0);
135 T::pb_tx_pdos.set_type(iit::advr::Ec_slave_pdo::TX_HYQ_HPU);
137 T::pb_tx_pdos.mutable_hyqhpu_tx_pdo()->set_pump_target(std::get<0>(tx_pdo));
138 T::pb_tx_pdos.mutable_hyqhpu_tx_pdo()->set_pressure_p_gain(std::get<1>(tx_pdo));
139 T::pb_tx_pdos.mutable_hyqhpu_tx_pdo()->set_pressure_i_gain(std::get<2>(tx_pdo));
140 T::pb_tx_pdos.mutable_hyqhpu_tx_pdo()->set_pressure_d_gain(std::get<3>(tx_pdo));
141 T::pb_tx_pdos.mutable_hyqhpu_tx_pdo()->set_pressure_i_limit(std::get<4>(tx_pdo));
142 T::pb_tx_pdos.mutable_hyqhpu_tx_pdo()->set_fault_ack(std::get<5>(tx_pdo));
143 T::pb_tx_pdos.mutable_hyqhpu_tx_pdo()->set_solenoidout(std::get<6>(tx_pdo));
144 T::pb_tx_pdos.mutable_hyqhpu_tx_pdo()->set_ts(std::get<7>(tx_pdo));
145 T::pb_tx_pdos.mutable_hyqhpu_tx_pdo()->set_op_idx_aux(std::get<8>(tx_pdo));
146 T::pb_tx_pdos.mutable_hyqhpu_tx_pdo()->set_aux(std::get<9>(tx_pdo));