1. 新增DEBUG打印模块信息。

main
baocm 8 months ago
parent 8e289d3246
commit 223cd03653

@ -44,17 +44,20 @@ target_link_libraries(System_lib fastcdr fastdds)
# )
# Core Application.
set(PROGRAM_MODULE "Core")
add_executable(Core
core/main.cxx
core/Publisher.cxx
core/Subscriber.cxx
)
target_compile_definitions(Core PRIVATE PROGRAM_MODULE_NAME="${PROGRAM_MODULE}")
target_include_directories(Core PRIVATE core)
target_link_libraries(Core fastcdr fastdds
System_lib
)
# GateCtrl Application.
set(PROGRAM_MODULE "GateCtrl")
add_executable(GateCtrl
gatectrl/main.cxx
gatectrl/Publisher.cxx
@ -62,6 +65,7 @@ add_executable(GateCtrl
gatectrl/MsgHandler.cxx
common/CanMsgHandler.cxx
)
target_compile_definitions(GateCtrl PRIVATE PROGRAM_MODULE_NAME="${PROGRAM_MODULE}")
target_include_directories(GateCtrl PRIVATE gatectrl)
target_link_libraries(GateCtrl fastcdr fastdds
System_lib
@ -81,18 +85,21 @@ target_link_libraries(GateCtrl fastcdr fastdds
# )
# HttpServer Application.
set(PROGRAM_MODULE "HttpServer")
add_executable(HttpServer
httpserver/main.cxx
httpserver/Publisher.cxx
httpserver/Subscriber.cxx
httpserver/httpserver.cxx
)
target_compile_definitions(HttpServer PRIVATE PROGRAM_MODULE_NAME="${PROGRAM_MODULE}")
target_include_directories(HttpServer PRIVATE httpserver)
target_link_libraries(HttpServer fastcdr fastdds
System_lib
)
# Print Application.
set(PROGRAM_MODULE "Print")
add_executable(Print
print/main.cxx
print/Publisher.cxx
@ -101,12 +108,14 @@ add_executable(Print
common/SerialMsgHandler.cxx
lib/strcode.cpp
)
target_compile_definitions(Print PRIVATE PROGRAM_MODULE_NAME="${PROGRAM_MODULE}")
target_include_directories(Print PRIVATE print)
target_link_libraries(Print fastcdr fastdds
System_lib
)
# Weigh Application.
set(PROGRAM_MODULE "Weigh")
add_executable(Weigh
weigh/main.cxx
weigh/Publisher.cxx
@ -115,17 +124,20 @@ add_executable(Weigh
weigh/WeightStabilityDetector.cxx
common/SerialMsgHandler.cxx
)
target_compile_definitions(Weigh PRIVATE PROGRAM_MODULE_NAME="${PROGRAM_MODULE}")
target_include_directories(Weigh PRIVATE weigh)
target_link_libraries(Weigh fastcdr fastdds
System_lib
)
# MqttDds Application.
set(PROGRAM_MODULE "MqttDds")
add_executable(MqttDds
mqttdds/main.cxx
mqttdds/Publisher.cxx
mqttdds/Subscriber.cxx
)
target_compile_definitions(MqttDds PRIVATE PROGRAM_MODULE_NAME="${PROGRAM_MODULE}")
target_include_directories(MqttDds PRIVATE mqttdds)
target_link_libraries(MqttDds fastcdr fastdds
System_lib PahoMqttCpp::paho-mqttpp3

@ -0,0 +1,11 @@
#pragma once
#include <iostream>
// 使用CMake定义的模块名
#ifndef PROGRAM_MODULE_NAME
#define PROGRAM_MODULE_NAME "DefaultApp"
#endif
// 使用CMake设置的模块名
#define DEBUG(...) std::cout << "[" << PROGRAM_MODULE_NAME << "] " << __VA_ARGS__ << std::endl

@ -35,6 +35,7 @@
#include "SystemPubSubTypes.hpp"
#include "msg.hpp"
#include "DEBUG.hpp"
using namespace eprosima::fastdds::dds;
@ -219,7 +220,7 @@ void PublisherApp::on_publication_matched(
std::lock_guard<std::mutex> lock(mutex_);
matched_ = info.current_count;
}
std::cout << writer->get_topic()->get_name() << " Publisher matched." << std::endl;
DEBUG(writer->get_topic()->get_name() << " Publisher matched.");
cv_.notify_one();
}
else if (info.current_count_change == -1)
@ -228,12 +229,11 @@ void PublisherApp::on_publication_matched(
std::lock_guard<std::mutex> lock(mutex_);
matched_ = info.current_count;
}
std::cout << writer->get_topic()->get_name() << " Publisher unmatched." << std::endl;
DEBUG(writer->get_topic()->get_name() << " Publisher unmatched.");
}
else
{
std::cout << info.current_count_change
<< " is not a valid value for PublicationMatchedStatus current count change" << std::endl;
DEBUG(info.current_count_change << " is not a valid value for PublicationMatchedStatus current count change");
}
}
@ -273,7 +273,7 @@ bool PublisherApp::bar_ctrl(const std::map<std::string, std::string>& ctrl)
}
}
std::cout << "send bar ctrl cmd" << std::endl;
DEBUG("send bar ctrl cmd");
bar_writer_->write(&cmd);
return true;
@ -311,7 +311,7 @@ bool PublisherApp::light_ctrl(const std::map<std::string, std::string>& ctrl)
}
}
std::cout << "send light ctrl cmd" << std::endl;
DEBUG("send light ctrl cmd");
light_writer_->write(&cmd);
return true;
@ -325,7 +325,7 @@ bool PublisherApp::print_receipt(const std::map<std::string, std::string>& msg)
for (auto &m : req.msg())
{
std::cout << "first: " << m.first << " second: " << m.second << std::endl;
DEBUG("first: " << m.first << " second: " << m.second);
}
print_writer_->write(&req);
@ -350,8 +350,8 @@ void PublisherApp::run()
DdsMsgData::LicenseSnapUpdate_queue_.pop();
dds_lock.unlock();
std::cout << "车牌: " << info.License() << std::endl;
std::cout << "类型: " << info.NewTag() << std::endl;
DEBUG("车牌: " << info.License());
DEBUG("类型: " << info.NewTag());
if (license_no == "")
{
@ -364,11 +364,11 @@ void PublisherApp::run()
DdsMsgData::ScaleInfo_queue_.pop();
dds_lock.unlock();
std::cout << "有车: " << info.HasVehicle() << std::endl;
std::cout << "稳定: " << info.WeightOK() << std::endl;
std::cout << "设备状态: " << info.State() << std::endl;
std::cout << "实时重量: " << info.Value() << std::endl;
std::cout << "稳定重量: " << info.StableValue() << std::endl;
DEBUG("有车: " << info.HasVehicle());
DEBUG("稳定: " << info.WeightOK());
DEBUG("设备状态: " << info.State());
DEBUG("实时重量: " << info.Value());
DEBUG("稳定重量: " << info.StableValue());
if (info.WeightOK() == 1)
{
@ -391,8 +391,8 @@ void PublisherApp::run()
DdsMsgData::BarUpdate_queue_.pop();
dds_lock.unlock();
std::cout << "前拦车器状态: " << info.FrontBarState() << std::endl;
std::cout << "后拦车器状态: " << info.BackBarState() << std::endl;
DEBUG("前拦车器状态: " << info.FrontBarState());
DEBUG("后拦车器状态: " << info.BackBarState());
}
else if (!DdsMsgData::LightsUpdate_queue_.empty())
{
@ -400,8 +400,8 @@ void PublisherApp::run()
DdsMsgData::LightsUpdate_queue_.pop();
dds_lock.unlock();
std::cout << "前红绿灯状态: " << info.FrontLEDState() << std::endl;
std::cout << "后红绿灯状态: " << info.BackLEDState() << std::endl;
DEBUG("前红绿灯状态: " << info.FrontLEDState());
DEBUG("后红绿灯状态: " << info.BackLEDState());
}
else if (!DdsMsgData::InfraredUpdate_queue_.empty())
{
@ -409,8 +409,8 @@ void PublisherApp::run()
DdsMsgData::InfraredUpdate_queue_.pop();
dds_lock.unlock();
std::cout << "前红外对射状态: " << info.FrontResistanceSignal() << std::endl;
std::cout << "后红外对射状态: " << info.BackResistanceSignal() << std::endl;
DEBUG("前红外对射状态: " << info.FrontResistanceSignal());
DEBUG("后红外对射状态: " << info.BackResistanceSignal());
}
else if (!DdsMsgData::WeightInfoOk_queue_.empty())
{
@ -474,7 +474,7 @@ void PublisherApp::run()
{
if ((stable_weight != 0) && (license_no != ""))
{
std::cout << "send summary" << std::endl;
DEBUG("send summary");
WeighingSystem::SummaryUpdate info;
info.License() = license_no;
info.StableValue() = stable_weight;

@ -35,6 +35,7 @@
#include "SystemPubSubTypes.hpp"
#include "msg.hpp"
#include "DEBUG.hpp"
using namespace eprosima::fastdds::dds;
@ -336,16 +337,15 @@ void SubscriberApp::on_subscription_matched(
{
if (info.current_count_change == 1)
{
std::cout << reader->get_topicdescription()->get_name() << " Subscriber matched." << std::endl;
DEBUG(reader->get_topicdescription()->get_name() << " Subscriber matched.");
}
else if (info.current_count_change == -1)
{
std::cout << reader->get_topicdescription()->get_name() << " Subscriber unmatched." << std::endl;
DEBUG(reader->get_topicdescription()->get_name() << " Subscriber unmatched.");
}
else
{
std::cout << info.current_count_change
<< " is not a valid value for SubscriptionMatchedStatus current count change" << std::endl;
DEBUG(info.current_count_change << " is not a valid value for SubscriptionMatchedStatus current count change");
}
}
@ -354,7 +354,7 @@ void SubscriberApp::on_data_available(
{
SampleInfo info;
std::string topic_name = reader->get_topicdescription()->get_name();
std::cout << topic_name << std::endl;
DEBUG(topic_name << " Topic receviced.");
if (topic_name == "BarUpdate")
{

@ -31,8 +31,8 @@
#include "Subscriber.hpp"
#include "Publisher.hpp"
#include "mqtt/async_client.h"
#include "msg.hpp"
#include "DEBUG.hpp"
#define VERSION "v1.0"
@ -80,7 +80,6 @@ int main(int argc, char** argv)
auto ret = EXIT_SUCCESS;
std::shared_ptr<SubscriberApp> sub;
std::shared_ptr<PublisherApp> pub;
std::shared_ptr<mqtt::async_client> dev = nullptr;
int domain_id = 0;
@ -89,7 +88,6 @@ int main(int argc, char** argv)
if (strcmp(argv[i], "--domain") == 0 && i + 1 < argc)
{
domain_id = atoi(argv[++i]);
mqtt_id = std::string("core_") + std::string(argv[i]);
}
else if (strcmp(argv[i], "--version") == 0)
{
@ -123,7 +121,7 @@ int main(int argc, char** argv)
std::thread sub_thread(&SubscriberApp::run, sub);
std::thread pub_thread(&PublisherApp::run, pub);
std::cout << "Program is running. Please press Ctrl+C to stop at any time." << std::endl;
DEBUG("Program is running. Please press Ctrl+C to stop at any time.");
stop_handler = [&](int signum)
{

@ -5,6 +5,7 @@
#include <unistd.h>
#include <sys/ioctl.h>
#include "MsgHandler.hpp"
#include "DEBUG.hpp"
MsgHandler::MsgHandler() : fd(-1)
{
@ -218,15 +219,15 @@ int MsgHandler::ParseDeviceMsg(std::vector<uint8_t>& data)
switch(data[1])
{
case 0x50:
std::cout << "can gpio open success" << std::endl;
DEBUG("can gpio open success");
ret = 0;
break;
case 0x51:
std::cout << "can gpio write success" << std::endl;
DEBUG("can gpio write success");
break;
ret = 0;
case 0x52:
std::cout << "gpio change" << std::endl;
DEBUG("gpio change");
for (auto &p : this->iomap.imap)
{
p.second.second = data[p.second.first+2];

@ -37,6 +37,7 @@
#include "msg.hpp"
#include "MsgHandler.hpp"
#include "DEBUG.hpp"
using namespace eprosima::fastdds::dds;
@ -190,7 +191,7 @@ void PublisherApp::on_publication_matched(
std::lock_guard<std::mutex> lock(mutex_);
matched_ = info.current_count;
}
std::cout << writer->get_topic()->get_name() << " Publisher matched." << std::endl;
DEBUG(writer->get_topic()->get_name() << " Publisher matched.");
cv_.notify_one();
}
else if (info.current_count_change == -1)
@ -199,12 +200,11 @@ void PublisherApp::on_publication_matched(
std::lock_guard<std::mutex> lock(mutex_);
matched_ = info.current_count;
}
std::cout << writer->get_topic()->get_name() << " Publisher unmatched." << std::endl;
DEBUG(writer->get_topic()->get_name() << " Publisher unmatched.");
}
else
{
std::cout << info.current_count_change
<< " is not a valid value for PublicationMatchedStatus current count change" << std::endl;
DEBUG(info.current_count_change << " is not a valid value for PublicationMatchedStatus current count change");
}
}

@ -35,6 +35,7 @@
#include "SystemPubSubTypes.hpp"
#include "msg.hpp"
#include "DEBUG.hpp"
using namespace eprosima::fastdds::dds;
@ -150,16 +151,15 @@ void SubscriberApp::on_subscription_matched(
{
if (info.current_count_change == 1)
{
std::cout << reader->get_topicdescription()->get_name() << " Subscriber matched." << std::endl;
DEBUG(reader->get_topicdescription()->get_name() << " Subscriber matched.");
}
else if (info.current_count_change == -1)
{
std::cout << reader->get_topicdescription()->get_name() << " Subscriber unmatched." << std::endl;
DEBUG(reader->get_topicdescription()->get_name() << " Subscriber unmatched.");
}
else
{
std::cout << info.current_count_change
<< " is not a valid value for SubscriptionMatchedStatus current count change" << std::endl;
DEBUG(info.current_count_change << " is not a valid value for SubscriptionMatchedStatus current count change");
}
}
@ -168,7 +168,7 @@ void SubscriberApp::on_data_available(
{
SampleInfo info;
std::string topic_name = reader->get_topicdescription()->get_name();
std::cout << topic_name << std::endl;
DEBUG(topic_name << " Topic receviced.");
if (topic_name == "BarCommandUpdate")
{

@ -32,6 +32,7 @@
#include "Publisher.hpp"
#include "CanMsgHandler.hpp"
#include "msg.hpp"
#include "DEBUG.hpp"
#define VERSION "v1.0"
@ -153,7 +154,7 @@ int main(int argc, char** argv)
std::thread sub_thread(&SubscriberApp::run, sub, dev);
std::thread pub_thread(&PublisherApp::run, pub, dev);
std::cout << "Program is running. Please press Ctrl+C to stop at any time." << std::endl;
DEBUG("Program is running. Please press Ctrl+C to stop at any time.");
stop_handler = [&](int signum)
{

@ -35,6 +35,7 @@
#include "SystemPubSubTypes.hpp"
#include "json.hpp"
#include "DEBUG.hpp"
using json = nlohmann::json;
using namespace eprosima::fastdds::dds;
@ -127,7 +128,7 @@ void PublisherApp::on_publication_matched(
std::lock_guard<std::mutex> lock(mutex_);
matched_ = info.current_count;
}
std::cout << writer->get_topic()->get_name() << " Publisher matched." << std::endl;
DEBUG(writer->get_topic()->get_name() << " Publisher matched.");
cv_.notify_one();
}
else if (info.current_count_change == -1)
@ -136,12 +137,11 @@ void PublisherApp::on_publication_matched(
std::lock_guard<std::mutex> lock(mutex_);
matched_ = info.current_count;
}
std::cout << writer->get_topic()->get_name() << " Publisher unmatched." << std::endl;
DEBUG(writer->get_topic()->get_name() << " Publisher unmatched.");
}
else
{
std::cout << info.current_count_change
<< " is not a valid value for PublicationMatchedStatus current count change" << std::endl;
DEBUG(info.current_count_change << " is not a valid value for PublicationMatchedStatus current count change");
}
}
@ -155,7 +155,7 @@ void PublisherApp::run(std::shared_ptr<HTTPServer> handler)
if (handler->PostMsg.empty() != true)
{
json j = json::parse(handler->PostMsg);
std::cout << "车牌: " << j["AlarmInfoPlate"]["result"]["PlateResult"]["license"] << std::endl;
DEBUG("车牌: " << j["AlarmInfoPlate"]["result"]["PlateResult"]["license"]);
WeighingSystem::LicenseSnapUpdate info;
info.License() = j["AlarmInfoPlate"]["result"]["PlateResult"]["license"];

@ -34,6 +34,7 @@
#include "SystemPubSubTypes.hpp"
#include "DEBUG.hpp"
using namespace eprosima::fastdds::dds;
SubscriberApp::SubscriberApp(
@ -111,16 +112,15 @@ void SubscriberApp::on_subscription_matched(
{
if (info.current_count_change == 1)
{
std::cout << reader->get_topicdescription()->get_name() << " Subscriber matched." << std::endl;
DEBUG(reader->get_topicdescription()->get_name() << " Subscriber matched.");
}
else if (info.current_count_change == -1)
{
std::cout << reader->get_topicdescription()->get_name() << " Subscriber unmatched." << std::endl;
DEBUG(reader->get_topicdescription()->get_name() << " Subscriber unmatched.");
}
else
{
std::cout << info.current_count_change
<< " is not a valid value for SubscriptionMatchedStatus current count change" << std::endl;
DEBUG(info.current_count_change << " is not a valid value for SubscriptionMatchedStatus current count change");
}
}
@ -129,6 +129,8 @@ void SubscriberApp::on_data_available(
{
WeighingSystem::LicenseSnapUpdate sample_;
SampleInfo info;
std::string topic_name = reader->get_topicdescription()->get_name();
DEBUG(topic_name << " Topic receviced.");
while ((!is_stopped()) && (RETCODE_OK == reader->take_next_sample(&sample_, &info)))
{
if ((info.instance_state == ALIVE_INSTANCE_STATE) && info.valid_data)

@ -32,6 +32,7 @@
#include "Publisher.hpp"
#include "httpserver.hpp"
#include "DEBUG.hpp"
#define VERSION "v1.0.0"
@ -121,7 +122,7 @@ int main(int argc, char** argv)
std::thread pub_thread(&PublisherApp::run, pub, dev);
std::cout << "Program is running. Please press Ctrl+C to stop at any time." << std::endl;
DEBUG("Program is running. Please press Ctrl+C to stop at any time.");
stop_handler = [&](int signum)
{

@ -36,6 +36,7 @@
#include "SystemPubSubTypes.hpp"
#include "json.hpp"
#include "msg.hpp"
#include "DEBUG.hpp"
using namespace eprosima::fastdds::dds;
using json = nlohmann::json;
@ -221,7 +222,7 @@ void PublisherApp::on_publication_matched(
std::lock_guard<std::mutex> lock(mutex_);
matched_ = info.current_count;
}
std::cout << writer->get_topic()->get_name() << " Publisher matched." << std::endl;
DEBUG(writer->get_topic()->get_name() << " Publisher matched.");
cv_.notify_one();
}
else if (info.current_count_change == -1)
@ -230,12 +231,11 @@ void PublisherApp::on_publication_matched(
std::lock_guard<std::mutex> lock(mutex_);
matched_ = info.current_count;
}
std::cout << writer->get_topic()->get_name() << " Publisher unmatched." << std::endl;
DEBUG(writer->get_topic()->get_name() << " Publisher unmatched.");
}
else
{
std::cout << info.current_count_change
<< " is not a valid value for PublicationMatchedStatus current count change" << std::endl;
DEBUG(info.current_count_change << " is not a valid value for PublicationMatchedStatus current count change");
}
}
@ -275,7 +275,7 @@ bool PublisherApp::bar_ctrl(const std::map<std::string, std::string>& ctrl)
}
}
std::cout << "send bar ctrl cmd" << std::endl;
DEBUG("send bar ctrl cmd");
bar_writer_->write(&cmd);
return true;
@ -313,7 +313,7 @@ bool PublisherApp::light_ctrl(const std::map<std::string, std::string>& ctrl)
}
}
std::cout << "send light ctrl cmd" << std::endl;
DEBUG("send light ctrl cmd");
light_writer_->write(&cmd);
return true;
@ -327,7 +327,7 @@ bool PublisherApp::print_receipt(const std::map<std::string, std::string>& msg)
for (auto &m : req.msg())
{
std::cout << "first: " << m.first << " second: " << m.second << std::endl;
DEBUG("first: " << m.first << " second: " << m.second);
}
print_writer_->write(&req);
@ -349,8 +349,8 @@ void PublisherApp::run(std::shared_ptr<mqtt::async_client> dev)
DdsMsgData::LicenseSnapUpdate_queue_.pop();
dds_lock.unlock();
// std::cout << "车牌: " << info.License() << std::endl;
// std::cout << "类型: " << info.NewTag() << std::endl;
// DEBUG("车牌: " << info.License());
// DEBUG("类型: " << info.NewTag());
}
else if (!DdsMsgData::ScaleInfo_queue_.empty())
{
@ -358,11 +358,11 @@ void PublisherApp::run(std::shared_ptr<mqtt::async_client> dev)
DdsMsgData::ScaleInfo_queue_.pop();
dds_lock.unlock();
// std::cout << "有车: " << info.HasVehicle() << std::endl;
// std::cout << "稳定: " << info.WeightOK() << std::endl;
// std::cout << "设备状态: " << info.State() << std::endl;
// std::cout << "实时重量: " << info.Value() << std::endl;
// std::cout << "稳定重量: " << info.StableValue() << std::endl;
// DEBUG("有车: " << info.HasVehicle());
// DEBUG("稳定: " << info.WeightOK());
// DEBUG("设备状态: " << info.State());
// DEBUG("实时重量: " << info.Value());
// DEBUG("稳定重量: " << info.StableValue());
}
else if (!DdsMsgData::BarUpdate_queue_.empty())
{
@ -370,8 +370,8 @@ void PublisherApp::run(std::shared_ptr<mqtt::async_client> dev)
DdsMsgData::BarUpdate_queue_.pop();
dds_lock.unlock();
// std::cout << "前拦车器状态: " << info.FrontBarState() << std::endl;
// std::cout << "后拦车器状态: " << info.BackBarState() << std::endl;
// DEBUG("前拦车器状态: " << info.FrontBarState());
// DEBUG("后拦车器状态: " << info.BackBarState());
if (dev != nullptr)
{
@ -394,8 +394,8 @@ void PublisherApp::run(std::shared_ptr<mqtt::async_client> dev)
DdsMsgData::LightsUpdate_queue_.pop();
dds_lock.unlock();
// std::cout << "前红绿灯状态: " << info.FrontLEDState() << std::endl;
// std::cout << "后红绿灯状态: " << info.BackLEDState() << std::endl;
// DEBUG("前红绿灯状态: " << info.FrontLEDState());
// DEBUG("后红绿灯状态: " << info.BackLEDState());
if (dev != nullptr)
{
@ -418,8 +418,8 @@ void PublisherApp::run(std::shared_ptr<mqtt::async_client> dev)
DdsMsgData::InfraredUpdate_queue_.pop();
dds_lock.unlock();
// std::cout << "前红外对射状态: " << info.FrontResistanceSignal() << std::endl;
// std::cout << "后红外对射状态: " << info.BackResistanceSignal() << std::endl;
// DEBUG("前红外对射状态: " << info.FrontResistanceSignal());
// DEBUG("后红外对射状态: " << info.BackResistanceSignal());
if (dev != nullptr)
{

@ -35,6 +35,7 @@
#include "SystemPubSubTypes.hpp"
#include "msg.hpp"
#include "DEBUG.hpp"
using namespace eprosima::fastdds::dds;
@ -274,16 +275,15 @@ void SubscriberApp::on_subscription_matched(
{
if (info.current_count_change == 1)
{
std::cout << reader->get_topicdescription()->get_name() << " Subscriber matched." << std::endl;
DEBUG(reader->get_topicdescription()->get_name() << " Subscriber matched.");
}
else if (info.current_count_change == -1)
{
std::cout << reader->get_topicdescription()->get_name() << " Subscriber unmatched." << std::endl;
DEBUG(reader->get_topicdescription()->get_name() << " Subscriber unmatched.");
}
else
{
std::cout << info.current_count_change
<< " is not a valid value for SubscriptionMatchedStatus current count change" << std::endl;
DEBUG(info.current_count_change << " is not a valid value for SubscriptionMatchedStatus current count change");
}
}
@ -292,7 +292,7 @@ void SubscriberApp::on_data_available(
{
SampleInfo info;
std::string topic_name = reader->get_topicdescription()->get_name();
std::cout << topic_name << std::endl;
DEBUG(topic_name << " Topic receviced.");
if (topic_name == "BarUpdate")
{

@ -33,6 +33,7 @@
#include "mqtt/async_client.h"
#include "msg.hpp"
#include "DEBUG.hpp"
#define VERSION "v1.0"
@ -220,7 +221,7 @@ int main(int argc, char** argv)
std::thread sub_thread(&SubscriberApp::run, sub, dev);
std::thread pub_thread(&PublisherApp::run, pub, dev);
std::cout << "Program is running. Please press Ctrl+C to stop at any time." << std::endl;
DEBUG("Program is running. Please press Ctrl+C to stop at any time.");
stop_handler = [&](int signum)
{

@ -37,6 +37,7 @@
#include "msg.hpp"
#include "MsgHandler.hpp"
#include "DEBUG.hpp"
using namespace eprosima::fastdds::dds;
@ -122,7 +123,7 @@ void PublisherApp::on_publication_matched(
std::lock_guard<std::mutex> lock(mutex_);
matched_ = info.current_count;
}
std::cout << writer->get_topic()->get_name() << " Publisher matched." << std::endl;
DEBUG(writer->get_topic()->get_name() << " Publisher matched.");
cv_.notify_one();
}
else if (info.current_count_change == -1)
@ -131,12 +132,11 @@ void PublisherApp::on_publication_matched(
std::lock_guard<std::mutex> lock(mutex_);
matched_ = info.current_count;
}
std::cout << writer->get_topic()->get_name() << " Publisher unmatched." << std::endl;
DEBUG(writer->get_topic()->get_name() << " Publisher unmatched.");
}
else
{
std::cout << info.current_count_change
<< " is not a valid value for PublicationMatchedStatus current count change" << std::endl;
DEBUG(info.current_count_change << " is not a valid value for PublicationMatchedStatus current count change");
}
}
@ -153,13 +153,12 @@ void PublisherApp::run(std::shared_ptr<MsgHandler> handler)
MsgData::PrintReq_queue_.pop();
lock.unlock();
std::cout << "index: " << req.index() << std::endl;
handler->HandleDdsMsg(req.msg());
InternalSystem::PrintRsp rsp;
rsp.index() = req.index();
rsp.msg() = "success";
writer_->write(&rsp);
// InternalSystem::PrintRsp rsp;
// rsp.index() = req.index();
// rsp.msg() = "success";
// writer_->write(&rsp);
}
else
{

@ -35,6 +35,7 @@
#include "SystemPubSubTypes.hpp"
#include "msg.hpp"
#include "DEBUG.hpp"
using namespace eprosima::fastdds::dds;
@ -113,16 +114,15 @@ void SubscriberApp::on_subscription_matched(
{
if (info.current_count_change == 1)
{
std::cout << reader->get_topicdescription()->get_name() << " Subscriber matched." << std::endl;
DEBUG(reader->get_topicdescription()->get_name() << " Subscriber matched.");
}
else if (info.current_count_change == -1)
{
std::cout << reader->get_topicdescription()->get_name() << " Subscriber unmatched." << std::endl;
DEBUG(reader->get_topicdescription()->get_name() << " Subscriber unmatched.");
}
else
{
std::cout << info.current_count_change
<< " is not a valid value for SubscriptionMatchedStatus current count change" << std::endl;
DEBUG(info.current_count_change << " is not a valid value for SubscriptionMatchedStatus current count change");
}
}
@ -131,7 +131,7 @@ void SubscriberApp::on_data_available(
{
SampleInfo info;
std::string topic_name = reader->get_topicdescription()->get_name();
std::cout << topic_name << std::endl;
DEBUG(topic_name << " Topic receviced.");
if (topic_name == "PrintReq")
{

@ -32,6 +32,7 @@
#include "Publisher.hpp"
#include "SerialMsgHandler.hpp"
#include "msg.hpp"
#include "DEBUG.hpp"
#define VERSION "v1.0"
@ -145,7 +146,7 @@ int main(int argc, char** argv)
std::thread pub_thread(&PublisherApp::run, pub, dev);
std::cout << "Program is running. Please press Ctrl+C to stop at any time." << std::endl;
DEBUG("Program is running. Please press Ctrl+C to stop at any time.");
stop_handler = [&](int signum)
{

@ -38,6 +38,7 @@
#include "msg.hpp"
#include "MsgHandler.hpp"
#include "WeightStabilityDetector.hpp"
#include "DEBUG.hpp"
using namespace eprosima::fastdds::dds;
@ -129,7 +130,7 @@ void PublisherApp::on_publication_matched(
std::lock_guard<std::mutex> lock(mutex_);
matched_ = info.current_count;
}
std::cout << writer->get_topic()->get_name() << " Publisher matched." << std::endl;
DEBUG(writer->get_topic()->get_name() << " Publisher matched.");
cv_.notify_one();
}
else if (info.current_count_change == -1)
@ -138,12 +139,11 @@ void PublisherApp::on_publication_matched(
std::lock_guard<std::mutex> lock(mutex_);
matched_ = info.current_count;
}
std::cout << writer->get_topic()->get_name() << " Publisher unmatched." << std::endl;
DEBUG(writer->get_topic()->get_name() << " Publisher unmatched.");
}
else
{
std::cout << info.current_count_change
<< " is not a valid value for PublicationMatchedStatus current count change" << std::endl;
DEBUG(info.current_count_change << " is not a valid value for PublicationMatchedStatus current count change");
}
}
@ -252,7 +252,7 @@ void PublisherApp::run(std::shared_ptr<MsgHandler> handler)
info.WeightOK() = 1;
info.Value() = weight/1000;
info.StableValue() = weight/1000;
std::cout << "STABLE WEIGHT: " << detector.getStableWeight() << " kg" << std::endl;
DEBUG("STABLE WEIGHT: " << detector.getStableWeight() << " kg");
}
else
{

@ -35,6 +35,7 @@
#include "SystemPubSubTypes.hpp"
#include "msg.hpp"
#include "DEBUG.hpp"
using namespace eprosima::fastdds::dds;
@ -119,16 +120,15 @@ void SubscriberApp::on_subscription_matched(
{
if (info.current_count_change == 1)
{
std::cout << reader->get_topicdescription()->get_name() << " Subscriber matched." << std::endl;
DEBUG(reader->get_topicdescription()->get_name() << " Subscriber matched.");
}
else if (info.current_count_change == -1)
{
std::cout << reader->get_topicdescription()->get_name() << " Subscriber unmatched." << std::endl;
DEBUG(reader->get_topicdescription()->get_name() << " Subscriber unmatched.");
}
else
{
std::cout << info.current_count_change
<< " is not a valid value for SubscriptionMatchedStatus current count change" << std::endl;
DEBUG(info.current_count_change << " is not a valid value for SubscriptionMatchedStatus current count change");
}
}
@ -137,7 +137,7 @@ void SubscriberApp::on_data_available(
{
SampleInfo info;
std::string topic_name = reader->get_topicdescription()->get_name();
std::cout << topic_name << std::endl;
DEBUG(topic_name << " Topic receviced.");
if (topic_name == "ScaleCommand")
{

@ -32,6 +32,7 @@
#include "Publisher.hpp"
#include "SerialMsgHandler.hpp"
#include "msg.hpp"
#include "DEBUG.hpp"
#define VERSION "v1.0"
@ -152,7 +153,7 @@ int main(int argc, char** argv)
std::thread pub_thread(&PublisherApp::run, pub, dev);
std::cout << "Program is running. Please press Ctrl+C to stop at any time." << std::endl;
DEBUG("Program is running. Please press Ctrl+C to stop at any time.");
stop_handler = [&](int signum)
{

Loading…
Cancel
Save