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

58 lines
1.4 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.

/*
* HipAnalogValue.h
*
* Created on: 20 февр. 2020 г.
* Author: user
*/
#ifndef UMLIBRARY_COMMUNICATION_HIPERFACE_HIPANALOGVALUE_H_
#define UMLIBRARY_COMMUNICATION_HIPERFACE_HIPANALOGVALUE_H_
#include "../../math/math_inc.hh"
#include "../../driver/HiperfaceNetworkDriver.hh"
namespace communication {
namespace hiperface {
class HipAnalogValue {
private:
driver::HiperfaceNetworkDriver & hip_driver;
struct AnalogValue {
unsigned char channel = 0x48;
unsigned char rec_data[3];
driver::MessageControl message_control = {
.address = 0,
.code = 0x44,
.send_data_size = 1,
.send_data = &channel,
.rec_data_size = 3,
.rec_data = rec_data,
.timeout_ms = 5,
.ans_ready_flag = false,
.result = driver::OK
};
} mutable request;
public:
unsigned long getAnalogValue() const;
bool sendRequest() { return hip_driver.send( &request.message_control ); }
bool isAnswerReady() const { return request.message_control.ans_ready_flag; }
bool isOk() const { return request.message_control.result == driver::OK; }
HipAnalogValue( driver::HiperfaceNetworkDriver & hip_driver, unsigned short address);
};
} /* namespace hiperface */
} /* namespace communication */
#endif /* UMLIBRARY_COMMUNICATION_HIPERFACE_HIPANALOGVALUE_H_ */