#ifndef WEIGHUI_DDS_SUBSCRIBER_HPP #define WEIGHUI_DDS_SUBSCRIBER_HPP #include #include #include #include #include #include #include #include #include "WeighingDDSTypePubSubTypes.hpp" class DdsSubscriberApp : public eprosima::fastdds::dds::DataReaderListener { public: DdsSubscriberApp(const int& domain_id); virtual ~DdsSubscriberApp(); void on_data_available(eprosima::fastdds::dds::DataReader* reader) override; void on_subscription_matched( eprosima::fastdds::dds::DataReader* reader, const eprosima::fastdds::dds::SubscriptionMatchedStatus& info) override; void run(); void stop(); private: bool is_stopped(); std::shared_ptr factory_; eprosima::fastdds::dds::DomainParticipant* participant_; eprosima::fastdds::dds::Subscriber* subscriber_; eprosima::fastdds::dds::Topic* weightinfook_topic_; eprosima::fastdds::dds::DataReader* weightinfook_reader_; eprosima::fastdds::dds::TypeSupport weightinfook_type_; // WeightInfoError 主题订阅 (Warning 主题, 弹窗样式与 WeightInfoOk 完全一致) eprosima::fastdds::dds::Topic* weightinfoerror_topic_; eprosima::fastdds::dds::DataReader* weightinfoerror_reader_; eprosima::fastdds::dds::TypeSupport weightinfoerror_type_; eprosima::fastdds::dds::Topic* summary_topic_; eprosima::fastdds::dds::DataReader* summary_reader_; eprosima::fastdds::dds::TypeSupport summary_type_; // 实时重量 (weigh 程序发布) eprosima::fastdds::dds::Topic* scaleinfo_topic_; eprosima::fastdds::dds::DataReader* scaleinfo_reader_; eprosima::fastdds::dds::TypeSupport scaleinfo_type_; std::atomic stop_; uint32_t period_ms_ = 100; mutable std::mutex terminate_cv_mtx_; std::condition_variable terminate_cv_; }; #endif