5#include "mechanism/pipe/ec_pipe_pdo.h"
6#include "mechanism/zmq/ec_zmq_pdo.h"
9 static const std::vector<std::string>name = {
"v_batt",
"v_load",
"i_load",
"temp_batt",
"temp_heatsink",
"temp_pcb",
"status",
"fault",
"op_idx_ack",
"aux"};
10 static const int pdo_size=10;
11 using pdo_t=std::tuple<float, float, float, float, float,float,uint16_t,uint16_t,uint16_t,float>;
13 inline bool make_vector_from_tuple(
const pdo_t &pdo_tuple,std::vector<T> &pdo_vector){
14 if(pdo_vector.size()!=pdo_size){
17 pdo_vector[0]=
static_cast<T
>(std::get<0>(pdo_tuple));
18 pdo_vector[1]=
static_cast<T
>(std::get<1>(pdo_tuple));
19 pdo_vector[2]=
static_cast<T
>(std::get<2>(pdo_tuple));
20 pdo_vector[3]=
static_cast<T
>(std::get<3>(pdo_tuple));
21 pdo_vector[4]=
static_cast<T
>(std::get<4>(pdo_tuple));
22 pdo_vector[5]=
static_cast<T
>(std::get<5>(pdo_tuple));
23 pdo_vector[6]=
static_cast<T
>(std::get<6>(pdo_tuple));
24 pdo_vector[7]=
static_cast<T
>(std::get<7>(pdo_tuple));
25 pdo_vector[8]=
static_cast<T
>(std::get<8>(pdo_tuple));
26 pdo_vector[9]=
static_cast<T
>(std::get<9>(pdo_tuple));
32 static const std::vector<std::string>name = {
"master_command",
"fault_ack",
"op_idx_aux",
"aux"};
33 static const int pdo_size=4;
34 using pdo_t=std::tuple<uint16_t,uint16_t,uint16_t,float>;
36 inline bool make_vector_from_tuple(
const pdo_t &pdo_tuple,std::vector<T> &pdo_vector){
37 if(pdo_vector.size()!=pdo_size){
40 pdo_vector[0]=
static_cast<T
>(std::get<0>(pdo_tuple));
41 pdo_vector[1]=
static_cast<T
>(std::get<1>(pdo_tuple));
42 pdo_vector[2]=
static_cast<T
>(std::get<2>(pdo_tuple));
43 pdo_vector[3]=
static_cast<T
>(std::get<3>(pdo_tuple));
49class PowPdo:
public T{
53 PowPdo(
const std::string value,int32_t
id, uint32_t type);
60 PowPdoRx::pdo_t rx_pdo{};
61 PowPdoTx::pdo_t tx_pdo{};
62 bool init_rx_pdo=
false;
68inline void PowPdo<T>::init_pb()
70 uint8_t pb_buf[MAX_PB_SIZE];
74 msg_size = T::pb_tx_pdos.ByteSizeLong();
75 T::pb_tx_pdos.SerializeToArray( (
void*)(pb_buf+
sizeof(msg_size)), msg_size);
79inline PowPdo<T>::PowPdo(
const std::string value,int32_t
id, uint32_t type):
88inline PowPdo<T>::~PowPdo()
94inline void PowPdo<T>::get_from_pb()
96 std::get<0>(rx_pdo)= T::pb_rx_pdos.mutable_powf28m36_rx_pdo()->v_batt();
97 std::get<1>(rx_pdo)= T::pb_rx_pdos.mutable_powf28m36_rx_pdo()->v_load();
98 std::get<2>(rx_pdo)= T::pb_rx_pdos.mutable_powf28m36_rx_pdo()->i_load();
99 std::get<3>(rx_pdo)= T::pb_rx_pdos.mutable_powf28m36_rx_pdo()->temp_batt();
100 std::get<4>(rx_pdo)= T::pb_rx_pdos.mutable_powf28m36_rx_pdo()->temp_heatsink();
101 std::get<5>(rx_pdo)= T::pb_rx_pdos.mutable_powf28m36_rx_pdo()->temp_pcb();
102 std::get<6>(rx_pdo)= T::pb_rx_pdos.mutable_powf28m36_rx_pdo()->status();
103 std::get<7>(rx_pdo)= T::pb_rx_pdos.mutable_powf28m36_rx_pdo()->fault();
104 std::get<8>(rx_pdo)= T::pb_rx_pdos.mutable_powf28m36_rx_pdo()->op_idx_ack();
105 std::get<9>(rx_pdo)= T::pb_rx_pdos.mutable_powf28m36_rx_pdo()->aux();
113inline void PowPdo<T>::set_to_pb()
115 set_pbHeader(T::pb_tx_pdos.mutable_header(), T::name, 0);
117 T::pb_tx_pdos.set_type(iit::advr::Ec_slave_pdo::TX_POW_F28M36);
118 T::pb_tx_pdos.mutable_powf28m36_tx_pdo()->set_master_command(std::get<0>(tx_pdo));
119 T::pb_tx_pdos.mutable_powf28m36_tx_pdo()->set_fault_ack(std::get<1>(tx_pdo));
120 T::pb_tx_pdos.mutable_powf28m36_tx_pdo()->set_op_idx_aux(std::get<2>(tx_pdo));
121 T::pb_tx_pdos.mutable_powf28m36_tx_pdo()->set_aux(std::get<3>(tx_pdo));