Skip to content

Commit

Permalink
Rename back to clock, because that term is used in many other places.
Browse files Browse the repository at this point in the history
  • Loading branch information
KerstinKeller committed Jan 30, 2025
1 parent 6b476f7 commit cf38d1f
Show file tree
Hide file tree
Showing 9 changed files with 45 additions and 42 deletions.
2 changes: 1 addition & 1 deletion app/rec/rec_client_core/src/frame.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ namespace eCAL
, ecal_receive_time_(receive_time)
, system_receive_time_(system_receive_time)
, topic_name_(topic_name)
, clock_(callback_data->send_counter)
, clock_(callback_data->send_clock)
, id_(0) // TODO: We don't receive ids any more. We shoud probably adapt the frame class here.
{
data_.reserve(callback_data->buffer_size);
Expand Down
71 changes: 37 additions & 34 deletions ecal/core/include/ecal/pubsub/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,13 @@

namespace eCAL
{
/**
* @brief A struct which uniquely identifies anybody producing or consuming topics, e.g. a CPublisher or a CSubscriber.
**/
struct STopicId
{
SEntityId topic_id;
std::string topic_name;
SEntityId topic_id; //!< The unique id of the topic
std::string topic_name; //!< The topics name (on which matching is performed in the pub/sub case)

bool operator==(const STopicId& other) const
{
Expand All @@ -61,63 +64,63 @@ namespace eCAL
**/
struct SReceiveCallbackData
{
const void* buffer = nullptr; //!< payload buffer
const void* buffer = nullptr; //!< payload buffer, containing the sent data
size_t buffer_size = 0; //!< payload buffer size
int64_t send_timestamp = 0; //!< publisher send time in µs
uint64_t send_counter = 0; //!< publisher send counter. Each publisher increases the counter by one, every time a message is sent. It can be used to detect message drops.
int64_t send_timestamp = 0; //!< publisher send timestamp in µs
uint64_t send_clock = 0; //!< publisher send clock. Each publisher increases the counter by one, every time a message is sent. It can be used to detect message drops.
};

/**
* @brief eCAL subscriber event callback type.
**/
enum class eSubscriberEvent
* @brief eCAL publisher event callback type.
**/
enum class ePublisherEvent
{
none = 0,
connected = 1,
disconnected = 2,
dropped = 3
connected = 1, //!< a new subscriber has been connected to the publisher
disconnected = 2, //!< a previously connected subscriber has been disconnected from this publisher
dropped = 3 //!< some subscriber has missed a message that was sent by this publisher
};

inline std::string to_string(eSubscriberEvent event_) {
inline std::string to_string(ePublisherEvent event_) {
switch (event_) {
case eSubscriberEvent::none: return "NONE";
case eSubscriberEvent::connected: return "CONNECTED";
case eSubscriberEvent::disconnected: return "DISCONNECTED";
case eSubscriberEvent::dropped: return "DROPPED";
default: return "Unknown";
case ePublisherEvent::none: return "NONE";
case ePublisherEvent::connected: return "CONNECTED";
case ePublisherEvent::disconnected: return "DISCONNECTED";
case ePublisherEvent::dropped: return "DROPPED";
default: return "Unknown";
}
}

/**
* @brief eCAL publisher event callback type.
**/
enum class ePublisherEvent
* @brief eCAL subscriber event callback type.
**/
enum class eSubscriberEvent
{
none = 0,
connected = 1,
disconnected = 2,
dropped = 3
connected = 1, //!< a new publisher has been connected to the subscriber
disconnected = 2, //!< a previously connected publisher has been disconnected from this subscriber
dropped = 3 //!< a message coming from a publisher has been dropped, e.g. the subscriber has missed it
};

inline std::string to_string(ePublisherEvent event_) {
inline std::string to_string(eSubscriberEvent event_) {
switch (event_) {
case ePublisherEvent::none: return "NONE";
case ePublisherEvent::connected: return "CONNECTED";
case ePublisherEvent::disconnected: return "DISCONNECTED";
case ePublisherEvent::dropped: return "DROPPED";
default: return "Unknown";
case eSubscriberEvent::none: return "NONE";
case eSubscriberEvent::connected: return "CONNECTED";
case eSubscriberEvent::disconnected: return "DISCONNECTED";
case eSubscriberEvent::dropped: return "DROPPED";
default: return "Unknown";
}
}

/**
* @brief Receive callback function type with topic id and data struct. The topic id contains the topic name, the process
* name, the host name and a uniques topic identifier.
* @brief Receive callback function type. A user can register this callback type with a subscriber, and this callback will be triggered when the user receives any data.
*
* @param topic_id_ The topic id struct of the received message.
* @param data_type_info_ Topic data type information (encoding, type, descriptor).
* @param publisher_id_ The topic id of the publisher that has sent the data which is now being received.
* @param data_type_info_ Topic metadata, as set by the publisher (encoding, type, descriptor).
* This can be used to validate that the received data can be properly interpreted by the subscriber.
* @param data_ Data struct containing payload, timestamp and publication clock.
**/
using ReceiveCallbackT = std::function<void(const STopicId& topic_id_, const SDataTypeInformation& data_type_info_, const SReceiveCallbackData& data_)>;
using ReceiveCallbackT = std::function<void(const STopicId& publisher_id_, const SDataTypeInformation& data_type_info_, const SReceiveCallbackData& data_)>;

/**
* @brief eCAL publisher event callback struct.
Expand Down
2 changes: 1 addition & 1 deletion ecal/core/src/pubsub/ecal_subscriber_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ namespace eCAL
cb_data.buffer = static_cast<const void*>(payload_);
cb_data.buffer_size = long(size_);
cb_data.send_timestamp = time_;
cb_data.send_counter = clock_;
cb_data.send_clock = clock_;

STopicId topic_id;
topic_id.topic_name = topic_info_.topic_name;
Expand Down
2 changes: 1 addition & 1 deletion ecal/core/src/v5/pubsub/ecal_subscriber.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ namespace eCAL
v5_callback_data.size = static_cast<long>(v6_callback_data.buffer_size);
v5_callback_data.id = 0; // v6 callbacks do not communicate this data any more, hence it is always set to 0.
v5_callback_data.time = v6_callback_data.send_timestamp;
v5_callback_data.clock = v6_callback_data.send_counter;
v5_callback_data.clock = v6_callback_data.send_clock;
callback_(topic_id_.topic_name.c_str(), &v5_callback_data);
};
return AddReceiveCallback(v6_callback);
Expand Down
2 changes: 1 addition & 1 deletion ecal/samples/cpp/benchmarks/perftool/src/subscriber.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ void Subscriber::callback(const eCAL::SReceiveCallbackData& data_)
message_info.local_receive_time = std::chrono::steady_clock::now();
message_info.ecal_receive_time = eCAL::Time::ecal_clock::now();
message_info.ecal_send_time = eCAL::Time::ecal_clock::time_point(std::chrono::microseconds(data_.send_timestamp));
message_info.ecal_counter = data_.send_counter;
message_info.ecal_counter = data_.send_clock;
message_info.size_bytes = data_.buffer_size;

std::chrono::steady_clock::duration time_to_waste_this_iteration(time_to_waste_);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ void OnReceive(const eCAL::STopicId& /*topic_id_*/, const eCAL::SDataTypeInforma
std::cout << "----------------------------------------------" << std::endl;
std::cout << " Size : " << data_.buffer_size << std::endl;
std::cout << " Time : " << data_.send_timestamp << std::endl;
std::cout << " Counter : " << data_.send_counter << std::endl;
std::cout << " Clock : " << data_.send_clock << std::endl;
std::cout << std::endl;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ void OnReceive(const eCAL::STopicId& /*topic_id_*/, const eCAL::SDataTypeInforma
std::cout << "------------------------------------" << std::endl;
std::cout << " Size : " << data_.buffer_size << std::endl;
std::cout << " Time : " << data_.send_timestamp << std::endl;
std::cout << " Counter : " << data_.send_counter << std::endl;
std::cout << " Clock : " << data_.send_clock << std::endl;
std::cout << std::endl;
std::cout << "------------------------------------" << std::endl;
std::cout << "SSimpleStruct :" << std::endl;
Expand Down
2 changes: 1 addition & 1 deletion serialization/common/core/include/ecal/msg/dynamic.h
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ namespace eCAL
try
{
auto msg = m_deserializer.Deserialize(data_.buffer, data_.buffer_size, topic_info_);
fn_callback(topic_id_, msg, data_.send_timestamp, data_.send_counter);
fn_callback(topic_id_, msg, data_.send_timestamp, data_.send_clock);
}
catch (const DynamicReflectionException& e)
{
Expand Down
2 changes: 1 addition & 1 deletion serialization/common/core/include/ecal/msg/subscriber.h
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ namespace eCAL
// In the future, I would like to get m_datatype_info from the ReceiveBuffer function!
if (m_deserializer.Deserialize(msg, data_.buffer, data_.buffer_size))
{
(fn_callback)(topic_id_, msg, data_.send_timestamp, data_.send_counter);
(fn_callback)(topic_id_, msg, data_.send_timestamp, data_.send_clock);
}
}

Expand Down

0 comments on commit cf38d1f

Please sign in to comment.