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

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

/*
* 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_ */