/* * BinaryCrcCheck.hh * * Created on: 21 мая 2023 г. * Author: titov */ #ifndef UMLIBRARY_DRIVER_BINARYCRCCHECK_HH_ #define UMLIBRARY_DRIVER_BINARYCRCCHECK_HH_ #include "../communication/IBinaryDataSubscriber.hh" #include "../communication/format/BinaryHelpers.hh" #include "../common/ICrcUnit.hpp" #include #include #include namespace driver { //!Модуль проверки контрольной суммы бинарных данных. class BinaryCrcCheck : public communication::IBinaryDataSubscriber { public: BinaryCrcCheck( common::crc::ICrcUnit::CrcCalcualtor calculator, communication::IBinaryDataSubscriber & protected_data, std::size_t crc_bit_address, std::size_t crc_bit_len, std::size_t data_bit_address, std::size_t data_bit_len, std::pmr::memory_resource * memory_resource ); void read( const void * data, std::size_t size ); const bool & error() const; private: std::vector< char, std::pmr::polymorphic_allocator > buffer_data; communication::IBinaryDataSubscriber & protected_data; common::crc::ICrcUnit::CrcCalcualtor calculator; communication::format::bits::Extractor extract_crc; communication::format::bits::Extractor extract_data; char * temp_data_buffer; std::size_t data_octet_size; std::size_t data_byte_size; bool crc_mismatch; }; } #endif /* UMLIBRARY_DRIVER_BINARYCRCCHECK_HH_ */