MotorControlModuleSDFM_TMS3.../Projects/EFC_Communication/UMLibrary/driver/ModbusAnalogWideOutput.hh
2024-06-07 11:12:56 +03:00

85 lines
1.8 KiB
C++
Raw 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.

/*
* ModbusAnalogWideOutput.hh
*
* Created on: 17 апр. 2023 г.
* Author: titov
*/
#ifndef UMLIBRARY_DRIVER_MODBUSANALOGWIDEOUTPUT_HH_
#define UMLIBRARY_DRIVER_MODBUSANALOGWIDEOUTPUT_HH_
#include <stdint.h>
#include "IModBus.hh"
namespace driver {
namespace modbus {
//!
class ModbusAnalogWideOutput {
typedef IModBusDispatch::Status Status;
const float coeff;
const float offset;
const float invalid;
float value;
bool format_signed;
float up_limit;
float down_limit;
bool update();
mutable uint16_t data[2];
struct Part : public IModBusDispatch {
uint16_t * data;
Status read( uint16_t & reg );
Status write( uint16_t reg );
Part( uint16_t * data ) : data(data) {}
};
struct PartUpdater : public Part {
ModbusAnalogWideOutput & self;
Status write( uint16_t reg );
PartUpdater( ModbusAnalogWideOutput & self, uint16_t * data ) : Part(data), self(self) {}
};
Part one;
PartUpdater two;
public:
//!Последовательность слов в регистрах
enum WordSequence {
HighFirstLowSecond, //!<Первый старший, второй младший.
LowFirstHighSecond //!<Первый младший, второй старший.
};
ModbusAnalogWideOutput( float coeff, float offset, float invalid, bool sign,
float initial, float up_limit, float down_limit , WordSequence sequnece );
//!Первый из пары регистров.
IModBusDispatch & first();
//!Второй из пары регистров.
IModBusDispatch & second();
const float & signal() const;
};
}
}
#endif /* UMLIBRARY_DRIVER_MODBUSANALOGWIDEOUTPUT_HH_ */