MotorControlModuleSDFM_TMS3.../Projects/EFC_Communication/UMLibrary/application/drivers/ModbusRtu.hh
2024-06-07 11:12:56 +03:00

68 lines
2.1 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.

/*
* ModBusRtuSetup.hh
*
* Created on: 30 июн. 2020 г.
* Author: s.maksimenko
*/
#ifndef UMLIBRARY_APPLICATION_DRIVERS_MODBUSRTU_HH_
#define UMLIBRARY_APPLICATION_DRIVERS_MODBUSRTUSETUP_HH_
#include <memory_resource>
#include "../ISetupStep.hh"
#include "../../peripheral/IUartPort.hh"
#include "../../systemic/ISignal.hh"
#include "../../systemic/IStatus.hh"
namespace application {
namespace drivers {
//!Драйвер протокола обмена Modbus RTU.
class ModbusRtu : public ISetupStep {
typedef systemic::ISignal ISignal;
typedef systemic::IStatus IStatus;
peripheral::IUartPort* mpPort = nullptr;
std::pmr::memory_resource * mpMemRes = nullptr;
ISignal * mpSigAddrModBus = nullptr;
IStatus * mpStsAddrValid = nullptr;
public:
bool input ( Environment & env );
void build ( Environment & env );
struct Links {
/* Input links */
Environment::Id uart; //!<Порт Modbus.
Environment::SignalId address; //!<Адрес на шине Modbus RTU.
Environment::StatusId enable; //!<Разрешение присвоения адреса.
Environment::Id memory; //!<Cистемный идентификатор аллокатора памяти
/* Output links */
Environment::Id modbus_rtu; //!<Протокол Modbus RTU.
Environment::Id crc_error; //!<Ошибка контрольной суммы.
Environment::Id incorrect_request; //!<Некорректный запрос.
Environment::Id packet_counter; //!<Счетчик пакетов.
};
struct Setting {
uint16_t address; //!<Адрес на шине MODBUS (если == 0 то адрес определяется links.sigAddr)
};
const Links & links;
const Setting & cfg;
const configuration::ProcessConfig & params;
ModbusRtu( const Links &, const Setting &, const configuration::ProcessConfig & );
};
}// namespace drivers
}// namespace application
#endif /* UMLIBRARY_APPLICATION_DRIVERS_MODBUSRTU_HH_ */