58 lines
1.4 KiB
C++
58 lines
1.4 KiB
C++
/*
|
||
* 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_ */
|