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

88 lines
2.0 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.

/*
* ModbusAnalogWideInput.hh
*
* Created on: 1 апр. 2023 г.
* Author: titov
*/
#ifndef UMLIBRARY_DRIVER_MODBUSANALOGWIDEINPUT_HH_
#define UMLIBRARY_DRIVER_MODBUSANALOGWIDEINPUT_HH_
#include <stdint.h>
#include "../systemic/ISignal.hh"
#include "IModBus.hh"
namespace driver {
namespace modbus {
//!
class ModbusAnalogWideInput {
typedef IModBusDispatch::Status Status;
systemic::ISignal & signal;
const bool format_signed; //!<Формат вывода.
float coeff;
float offset;
float up_limit;
float down_limit;
uint32_t nan_out_of_range; //!<Сопоставление для значения NAN сигнала.
bool extract();
uint16_t data[2];
struct Part : public IModBusDispatch {
const uint16_t * data;
Status read( uint16_t & reg );
Status write( uint16_t reg );
Part( const uint16_t * data ) : data(data) {}
};
struct PartShower : public Part {
ModbusAnalogWideInput & self;
Status read( uint16_t & reg );
PartShower( ModbusAnalogWideInput & self, const uint16_t * data ) : Part(data), self(self) {}
};
PartShower one;
Part two;
public:
//!Последовательность слов в регистрах
enum WordSequence {
HighFirstLowSecond, //!<Первый старший, второй младший.
LowFirstHighSecond //!<Первый младший, второй старший.
};
ModbusAnalogWideInput( systemic::ISignal & value, bool format_signed,
uint32_t nan_out_of_range,
float coeff, float offset,
float up_limit, float down_limit, WordSequence sequnece );
//!Первый из пары регистров.
IModBusDispatch & first();
//!Второй из пары регистров.
IModBusDispatch & second();
};
}
}
#endif /* UMLIBRARY_DRIVER_MODBUSANALOGWIDEINPUT_HH_ */