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

45 lines
1.5 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.

/*
* SerialPacketReaderInitializer.cpp
*
* Created on: 17 дек. 2021 г.
* Author: titov
*/
#include "SerialPacketReader.hh"
#include "../../communication/IBinaryDataSubscriber.hh"
#include "../../driver/SerialPacketReader.hh"
bool application::board::SerialPacketReader::input( Environment & env ) {
return grab( memory_resource, env.rholder.getShared<std::pmr::memory_resource>( links.data_memory ) ) and
grab( serial_port, env.rholder.getShared<peripheral::ISerialPort>( links.serial_port ) ) and
grab( binary_data, env.rholder.getShared<communication::IBinaryDataSubscriber>( links.binary_data ) );
}
void application::board::SerialPacketReader::build( Environment & env ) {
typedef ::driver::SerialPacketReader SPR;
std::size_t bitsize = config.bit_size;
bool need_reverse = config.data_reverse;
SPR * spr = memories::instance_object<SPR>( env.static_data_ma, *serial_port, *binary_data, memory_resource, bitsize, need_reverse );
systemic::ProcScheduler::ProcessParameter proc = {
.priority = params.priority,
.period = params.period, .phase = params.phase,
.controlled = false
};
env.scheduler.registerProcess( params.processor_id, *spr,
proc );
}
application::board::SerialPacketReader::SerialPacketReader( const Links & links, const Setting & config, const configuration::ProcessConfig & proc) :
links(links), config(config), params(proc) {}