MotorControlModuleSDFM_TMS3.../Projects/EFC_Application/UMLibrary/driver/BinaryDataRecycler.hh

45 lines
1.2 KiB
C++

/*
* BinaryDataRecycler.hh
*
* Created on: 8 îêò. 2022 ã.
* Author: titov
*/
#ifndef UMLIBRARY_DRIVER_BINARYDATARECYCLER_HH_
#define UMLIBRARY_DRIVER_BINARYDATARECYCLER_HH_
#include "../systemic/IProcess.hh"
#include "../communication/format/BinaryDataPublisher.hh"
#include <memory_resource>
#include <vector>
#include <mutex>
namespace driver {
//!Ìîäóëü îòëîæåííîé îáðàáîòêè áèíàðíûõ äàííûõ.
class BinaryDataRecycler : public communication::ISubscriberRegistrator,
public communication::IBinaryDataSubscriber,
public systemic::IProcess {
public:
BinaryDataRecycler( std::pmr::memory_resource * memory_resource, std::size_t bit_len );
void addSubscriber( std::size_t bit_address, std::size_t bit_len, communication::IBinaryDataSubscriber * subscriber ) override;
void read( const void * data, std::size_t size ) override;
void process() override;
private:
communication::format::BinaryDataPublisher subscribers; //!Àáîíåíò.
std::vector< char, std::pmr::polymorphic_allocator<char> > buffer;
const std::size_t bitsize;
std::mutex buffer_lock;
bool updated;
};
}
#endif /* UMLIBRARY_DRIVER_BINARYDATARECYCLER_HH_ */