13#ifndef DDT_PUBLISHER_IMAGE1D_HPP
14#define DDT_PUBLISHER_IMAGE1D_HPP
21#include <ddt/ddtDataPublisher.hpp>
22#include <ddt/ddtEncDecBinaryxD.hpp>
23#include <ddt/ddtLogger.hpp>
25#include <boost/endian.hpp>
26#include <fmt/format.h>
44 static_assert(SI::ID.find_first_not_of(
"abcdefghijklmnopqrstuvwxyz_0123456789") ==
45 std::string_view::npos,
46 "DDT Publisher ID contains illegal characters!");
49 : m_logger(componentFramework::GetLogger(
"rtctk"))
51 , m_rtr_prefix_static(GetStaticRtrPrefix(
db_prefix))
52 , m_rtr_prefix_dynamic(GetDynamicRtrPrefix(
db_prefix))
54 , m_broker_endpoint(
"zpb.rr://127.0.0.1:5001") {
55 LOG4CPLUS_INFO(m_logger, fmt::format(
"Creating DdtPublisherImage1d '{}'", SI::ID));
71 m_meta_data.meta_data_base.bytes_per_pixel =
sizeof(
typename SI::PixelType);
72 m_meta_data.meta_data_base.number_dimensions = 1;
73 m_meta_data.meta_data_base.complete_flag =
true;
74 m_meta_data.meta_data_base.last_segment =
true;
81 m_meta_data.meta_data_base.byte_order_little_endian =
82 static_cast<bool>(boost::endian::order::native);
84 m_meta_data.meta_data_base.description = SI::ID;
86 if (
typeid(
typename SI::PixelType) ==
typeid(
uint8_t)) {
87 m_meta_data.meta_data_base.data_type = ddt::UINT8;
88 }
else if (
typeid(
typename SI::PixelType) ==
typeid(
int16_t)) {
89 m_meta_data.meta_data_base.data_type = ddt::SINT16;
90 }
else if (
typeid(
typename SI::PixelType) ==
typeid(
int32_t)) {
91 m_meta_data.meta_data_base.data_type = ddt::SINT32;
92 }
else if (
typeid(
typename SI::PixelType) ==
typeid(
float)) {
93 m_meta_data.meta_data_base.data_type = ddt::FLOAT32;
94 }
else if (
typeid(
typename SI::PixelType) ==
typeid(
double)) {
95 m_meta_data.meta_data_base.data_type = ddt::FLOAT64;
96 }
else if (
typeid(
typename SI::PixelType) ==
typeid(
uint16_t)) {
97 m_meta_data.meta_data_base.data_type = ddt::UINT16;
98 }
else if (
typeid(
typename SI::PixelType) ==
typeid(
uint32_t)) {
99 m_meta_data.meta_data_base.data_type = ddt::UINT32;
104 m_meta_data.array_dimensions = std::to_string(SI::WIDTH);
108 m_ddt_publisher = std::make_unique<ddt::DdtDataPublisher>(m_logger);
109 m_ddt_publisher->set_topic_id(m_enc_dec.get_topic_id());
115 m_ddt_publisher->RegisterPublisher(m_broker_endpoint, std::string(SI::ID),
false);
118 fmt::format(
"Failed to register DDT Publisher: {} against DDT Broker: {} "
119 "Check Broker URI, and ensure that Broker process is running.",
126 LOG4CPLUS_INFO(m_logger, fmt::format(
"Updating DdtPublisherImage1d::{}", SI::ID));
139 m_meta_data.meta_data_base.utc_timestamp = m_enc_dec.get_utc_timestamp();
140 m_enc_dec.Encode(m_meta_data);
141 std::vector<uint8_t> metadata = m_enc_dec.get_meta_data();
144 m_ddt_publisher->WriteData(
146 m_ddt_publisher->PublishData();
150 std::string GetStaticRtrPrefix(
const std::string&
db_prefix) {
152 temp.insert(
temp.find(
"/"),
"/static");
153 return "/" +
temp +
"/" + std::string(SI::ID);
156 std::string GetDynamicRtrPrefix(
const std::string&
db_prefix) {
158 temp.insert(
temp.find(
"/"),
"/dynamic");
159 return "/" +
temp +
"/" + std::string(SI::ID);
162 log4cplus::Logger& m_logger;
164 RuntimeRepoIf& m_rtr;
166 std::string m_rtr_prefix_static;
167 std::string m_rtr_prefix_dynamic;
177 std::string m_broker_endpoint;
192 std::unique_ptr<ddt::DdtDataPublisher> m_ddt_publisher;
This class provides a wrapper for a data point path.
Definition dataPointPath.hpp:74
T GetDataPoint(const DataPointPath &path) const
Fetches a datapoint from the repository.
Definition repositoryIf.ipp:1711
bool DataPointExists(const DataPointPath &path) const
Checks for the existence of a datapoint in the repository.
Definition repositoryIf.cpp:461
The RtctkException class is the base class for all Rtctk exceptions.
Definition exceptions.hpp:211
Base interface for all Runtime Configuration Repository adapters.
Definition runtimeRepoIf.hpp:27
Container class that holds services of any type.
Definition serviceContainer.hpp:39
The UnsupportedTypeException is thrown whenever an attempt is made to use an unsupported type in the ...
Definition exceptions.hpp:239
DDT Publisher class used to publish one-dimensional DDT streams.
Definition ddtPublisherImage1d.hpp:38
void Publish(uint32_t sample_id, const uint8_t *data_ptr, uint32_t elements)
Definition ddtPublisherImage1d.hpp:138
componentFramework::DataPointPath DataPointPath
Definition ddtPublisherImage1d.hpp:42
void Update()
Definition ddtPublisherImage1d.hpp:125
bool IsEnabled()
Definition ddtPublisherImage1d.hpp:134
SI StreamInfo
Definition ddtPublisherImage1d.hpp:40
DdtPublisherImage1d(const std::string &db_prefix, ServiceContainer &services)
Definition ddtPublisherImage1d.hpp:48
Provides macros and utilities for exception handling.
Logging Support Library based on log4cplus.
elt::mal::future< std::string > InjectReqRepEvent(StateMachineEngine &engine)
Definition malEventInjector.hpp:23
Definition businessLogic.cpp:24
Header file for RuntimeRepoIf, which defines the API for RuntimeRepoAdapters.
A container that can hold any type of service.