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

95 lines
2.2 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.

/*
* ModbusAnalogWideValue.hh
*
* Created on: 17 апр. 2023 г.
* Author: titov
*/
#ifndef UMLIBRARY_DRIVER_MODBUSANALOGWIDEVALUE_HH_
#define UMLIBRARY_DRIVER_MODBUSANALOGWIDEVALUE_HH_
#include <stdint.h>
#include "../systemic/IValueAsync.hpp"
#include "IModBus.hh"
namespace driver {
namespace modbus {
//!
class ModbusAnalogWideValue {
typedef IModBusDispatch::Status Status;
float write_coeff;
float write_offset;
float read_coeff;
float read_offset;
bool format_signed;
float up_limit;
float down_limit;
systemic::IValueType<float> & tech_value;
const uint32_t nan_out_of_range; //!< Сопоставление для значения NAN сигнала
bool extract();
bool update();
mutable uint16_t data[2];
struct PartShower : public IModBusDispatch {
ModbusAnalogWideValue & self;
uint16_t * const data;
Status read( uint16_t & reg );
Status write( uint16_t reg );
PartShower( ModbusAnalogWideValue & self, uint16_t * data ) : data(data), self(self) {}
};
struct PartUpdater : public IModBusDispatch {
ModbusAnalogWideValue & self;
uint16_t * const data;
Status read( uint16_t & reg );
Status write( uint16_t reg );
PartUpdater( ModbusAnalogWideValue & self, uint16_t * data ) : data(data), self(self) {}
};
PartShower one;
PartUpdater two;
public:
//!Последовательность слов в регистрах
enum WordSequence {
HighFirstLowSecond, //!<Первый старший, второй младший.
LowFirstHighSecond //!<Первый младший, второй старший.
};
ModbusAnalogWideValue( systemic::IValueType<float> & value,
float write_coeff, float write_offset, float read_coeff, float read_offset,
bool sign, float up_limit, float down_limit, uint32_t nan_register, WordSequence sequnece );
//!Первый из пары регистров.
IModBusDispatch & first();
//!Второй из пары регистров.
IModBusDispatch & second();
};
}
}
#endif /* UMLIBRARY_DRIVER_MODBUSANALOGWIDEVALUE_HH_ */