MotorControlModuleSDFM_TMS3.../Projects/EFC_Communication/UMLibrary/communication/hiperface/HipStatus.hh
2024-06-07 11:12:56 +03:00

60 lines
1.5 KiB
C++
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*
* 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_ */