MotorControlModuleSDFM_TMS3.../Projects/EFC_Application/UMLibrary/communication/hiperface/HipStatus.hh

60 lines
1.5 KiB
C++

/*
* HipStatus.h
*
* Created on: 20 ôåâð. 2020 ã.
* Author: user
*/
#ifndef UMLIBRARY_COMMUNICATION_HIPERFACE_HIPSTATUS_H_
#define UMLIBRARY_COMMUNICATION_HIPERFACE_HIPSTATUS_H_
#include "../../driver/HiperfaceNetworkDriver.hh"
namespace communication {
namespace hiperface {
class HipStatusClient {
private:
driver::HiperfaceNetworkDriver & hip_driver;
struct HipStatus {
unsigned char status;
driver::MessageControl message_control = {
.address = 0,
.code = 0x50,
.send_data_size = 0,
.send_data = nullptr,
.rec_data_size = 1,
.rec_data = &status,
.timeout_ms = 5,
.ans_ready_flag = false,
.result = driver::OK
};
} request;
public:
enum Severity {
critical,
major,
minor,
unknown
};
static unsigned short getErroLevel(unsigned short error_code) { return unknown; }
unsigned short getErrorCode() const { return request.status; }
bool sendRequest() { return hip_driver.send( &request.message_control ); }
bool isAnswerReady() const { return request.message_control.ans_ready_flag; }
HipStatusClient( driver::HiperfaceNetworkDriver & hip_driver, unsigned short address );
};
} /* namespace hiperface */
} /* namespace communication */
#endif /* UMLIBRARY_COMMUNICATION_HIPERFACE_HIPSTATUS_H_ */