1. 创建led显示程序。

main
baocm 8 months ago
parent 39c2050e8f
commit 2e6c1a3385

@ -103,6 +103,19 @@ target_link_libraries(HttpServer fastcdr fastdds
System_lib
)
# Led Application.
link_directories(${CMAKE_CURRENT_SOURCE_DIR}/lib)
set(PROGRAM_MODULE "Led")
add_executable(Led
led/main.cxx
led/Subscriber.cxx
)
target_compile_definitions(Led PRIVATE PROGRAM_MODULE="${PROGRAM_MODULE}" PROGRAM_VERSION="${PROGRAM_VERSION}")
target_include_directories(Led PRIVATE led)
target_link_libraries(Led fastcdr fastdds
System_lib fun
)
# Print Application.
set(PROGRAM_MODULE "Print")
add_executable(Print

@ -0,0 +1,269 @@
// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima).
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/*!
* @file Subscriber.cxx
* This file contains the implementation of the subscriber functions.
*
* This file was generated by the tool fastddsgen.
*/
#include "Subscriber.hpp"
#include <condition_variable>
#include <stdexcept>
#include <fastdds/dds/core/status/SubscriptionMatchedStatus.hpp>
#include <fastdds/dds/domain/DomainParticipantFactory.hpp>
#include <fastdds/dds/subscriber/DataReader.hpp>
#include <fastdds/dds/subscriber/qos/DataReaderQos.hpp>
#include <fastdds/dds/subscriber/qos/SubscriberQos.hpp>
#include <fastdds/dds/subscriber/SampleInfo.hpp>
#include <fastdds/dds/subscriber/Subscriber.hpp>
#include "SystemPubSubTypes.hpp"
#include "msg.hpp"
#include "DEBUG.hpp"
using namespace eprosima::fastdds::dds;
SubscriberApp::SubscriberApp(
const int& domain_id)
: factory_(nullptr)
, participant_(nullptr)
, subscriber_(nullptr)
, scaleinfo_topic_(nullptr)
, scaleinfo_reader_(nullptr)
, scaleinfo_type_(new WeighingSystem::ScaleInfoPubSubType())
, weightinfook_topic_(nullptr)
, weightinfook_reader_(nullptr)
, weightinfook_type_(new WeighingSystem::WeightInfoOkPubSubType())
, weightinfoerror_topic_(nullptr)
, weightinfoerror_reader_(nullptr)
, weightinfoerror_type_(new WeighingSystem::WeightInfoErrorPubSubType())
, samples_received_(0)
, stop_(false)
{
// Create the participant
DomainParticipantQos pqos = PARTICIPANT_QOS_DEFAULT;
pqos.name("LedDisplay_sub_participant");
pqos.wire_protocol().builtin.discovery_config.leaseDuration = Duration_t(60, 0);
pqos.wire_protocol().builtin.discovery_config.leaseDuration_announcementperiod = Duration_t(30, 0);
factory_ = DomainParticipantFactory::get_shared_instance();
participant_ = factory_->create_participant(domain_id, pqos, nullptr, StatusMask::none());
if (participant_ == nullptr)
{
throw std::runtime_error("LedDisplay Participant initialization failed");
}
// Register the type
scaleinfo_type_.register_type(participant_);
weightinfook_type_.register_type(participant_);
weightinfoerror_type_.register_type(participant_);
// Create the subscriber
SubscriberQos sub_qos = SUBSCRIBER_QOS_DEFAULT;
participant_->get_default_subscriber_qos(sub_qos);
subscriber_ = participant_->create_subscriber(sub_qos, nullptr, StatusMask::none());
if (subscriber_ == nullptr)
{
throw std::runtime_error("LedDisplay Subscriber initialization failed");
}
// Create the topic
TopicQos topic_qos = TOPIC_QOS_DEFAULT;
participant_->get_default_topic_qos(topic_qos);
scaleinfo_topic_ = participant_->create_topic("ScaleInfo", scaleinfo_type_.get_type_name(), topic_qos);
if (scaleinfo_topic_ == nullptr)
{
throw std::runtime_error("WeighingSystem::ScaleInfo Topic initialization failed");
}
// Create the reader
DataReaderQos reader_qos = DATAREADER_QOS_DEFAULT;
subscriber_->get_default_datareader_qos(reader_qos);
reader_qos.reliability().kind = ReliabilityQosPolicyKind::RELIABLE_RELIABILITY_QOS;
reader_qos.reliability().max_blocking_time = Duration_t(1, 0);
reader_qos.durability().kind = DurabilityQosPolicyKind::VOLATILE_DURABILITY_QOS;
reader_qos.history().kind = HistoryQosPolicyKind::KEEP_LAST_HISTORY_QOS;
reader_qos.history().depth = 1;
reader_qos.resource_limits().max_samples = 200;
reader_qos.resource_limits().max_instances = 1;
reader_qos.resource_limits().max_samples_per_instance = 100;
reader_qos.data_sharing().off();
scaleinfo_reader_ = subscriber_->create_datareader(scaleinfo_topic_, reader_qos, this, StatusMask::all());
if (scaleinfo_reader_ == nullptr)
{
throw std::runtime_error("WeighingSystem::ScaleInfo DataReader initialization failed");
}
// Create the topic
topic_qos = TOPIC_QOS_DEFAULT;
participant_->get_default_topic_qos(topic_qos);
weightinfook_topic_ = participant_->create_topic("WeightInfoOk", weightinfook_type_.get_type_name(), topic_qos);
if (weightinfook_topic_ == nullptr)
{
throw std::runtime_error("WeighingSystem::WeightInfoOk Topic initialization failed");
}
// Create the reader
reader_qos = DATAREADER_QOS_DEFAULT;
subscriber_->get_default_datareader_qos(reader_qos);
reader_qos.reliability().kind = ReliabilityQosPolicyKind::RELIABLE_RELIABILITY_QOS;
reader_qos.reliability().max_blocking_time = Duration_t(1, 0);
reader_qos.durability().kind = DurabilityQosPolicyKind::VOLATILE_DURABILITY_QOS;
reader_qos.history().kind = HistoryQosPolicyKind::KEEP_LAST_HISTORY_QOS;
reader_qos.history().depth = 1;
reader_qos.resource_limits().max_samples = 200;
reader_qos.resource_limits().max_instances = 1;
reader_qos.resource_limits().max_samples_per_instance = 100;
reader_qos.data_sharing().off();
weightinfook_reader_ = subscriber_->create_datareader(weightinfook_topic_, reader_qos, this, StatusMask::all());
if (weightinfook_reader_ == nullptr)
{
throw std::runtime_error("WeighingSystem::WeightInfoOk DataReader initialization failed");
}
// Create the topic
topic_qos = TOPIC_QOS_DEFAULT;
participant_->get_default_topic_qos(topic_qos);
weightinfoerror_topic_ = participant_->create_topic("WeightInfoError", weightinfoerror_type_.get_type_name(), topic_qos);
if (weightinfoerror_topic_ == nullptr)
{
throw std::runtime_error("WeighingSystem::WeightInfoError Topic initialization failed");
}
// Create the reader
reader_qos = DATAREADER_QOS_DEFAULT;
subscriber_->get_default_datareader_qos(reader_qos);
reader_qos.reliability().kind = ReliabilityQosPolicyKind::RELIABLE_RELIABILITY_QOS;
reader_qos.reliability().max_blocking_time = Duration_t(1, 0);
reader_qos.durability().kind = DurabilityQosPolicyKind::VOLATILE_DURABILITY_QOS;
reader_qos.history().kind = HistoryQosPolicyKind::KEEP_LAST_HISTORY_QOS;
reader_qos.history().depth = 1;
reader_qos.resource_limits().max_samples = 200;
reader_qos.resource_limits().max_instances = 1;
reader_qos.resource_limits().max_samples_per_instance = 100;
reader_qos.data_sharing().off();
weightinfoerror_reader_ = subscriber_->create_datareader(weightinfoerror_topic_, reader_qos, this, StatusMask::all());
if (weightinfoerror_reader_ == nullptr)
{
throw std::runtime_error("WeighingSystem::WeightInfoError DataReader initialization failed");
}
}
SubscriberApp::~SubscriberApp()
{
if (nullptr != participant_)
{
// Delete DDS entities contained within the DomainParticipant
participant_->delete_contained_entities();
// Delete DomainParticipant
factory_->delete_participant(participant_);
}
}
void SubscriberApp::on_subscription_matched(
DataReader* reader,
const SubscriptionMatchedStatus& info)
{
if (info.current_count_change == 1)
{
DEBUG(reader->get_topicdescription()->get_name() << " Subscriber matched.");
}
else if (info.current_count_change == -1)
{
DEBUG(reader->get_topicdescription()->get_name() << " Subscriber unmatched.");
}
else
{
DEBUG(info.current_count_change << " is not a valid value for SubscriptionMatchedStatus current count change");
}
}
void SubscriberApp::on_data_available(
DataReader* reader)
{
SampleInfo info;
std::string topic_name = reader->get_topicdescription()->get_name();
DEBUG(topic_name << " Topic receviced.");
if (topic_name == "WeightInfoOk")
{
WeighingSystem::WeightInfoOk sample_;
while ((!is_stopped()) && (RETCODE_OK == reader->take_next_sample(&sample_, &info)))
{
if ((info.instance_state == ALIVE_INSTANCE_STATE) && info.valid_data)
{
{
std::unique_lock<std::mutex> lock(DdsMsgData::queue_cv_mtx_);
DdsMsgData::WeightInfoOk_queue_.push(std::move(sample_));
lock.unlock();
}
}
}
}
else if (topic_name == "WeightInfoError")
{
WeighingSystem::WeightInfoError sample_;
while ((!is_stopped()) && (RETCODE_OK == reader->take_next_sample(&sample_, &info)))
{
if ((info.instance_state == ALIVE_INSTANCE_STATE) && info.valid_data)
{
{
std::unique_lock<std::mutex> lock(DdsMsgData::queue_cv_mtx_);
DdsMsgData::WeightInfoError_queue_.push(std::move(sample_));
lock.unlock();
}
}
}
}
else if (topic_name == "ScaleInfo")
{
WeighingSystem::ScaleInfo sample_;
while ((!is_stopped()) && (RETCODE_OK == reader->take_next_sample(&sample_, &info)))
{
if ((info.instance_state == ALIVE_INSTANCE_STATE) && info.valid_data)
{
{
std::unique_lock<std::mutex> lock(DdsMsgData::queue_cv_mtx_);
DdsMsgData::ScaleInfo_queue_.push(std::move(sample_));
lock.unlock();
}
}
}
}
}
void SubscriberApp::run()
{
std::unique_lock<std::mutex> lck(terminate_cv_mtx_);
terminate_cv_.wait(lck, [this]
{
return is_stopped();
});
}
bool SubscriberApp::is_stopped()
{
return stop_.load();
}
void SubscriberApp::stop()
{
stop_.store(true);
terminate_cv_.notify_all();
}

@ -0,0 +1,81 @@
// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima).
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/*!
* @file SubscriberApp.hpp
* This header file contains the declaration of the subscriber functions.
*
* This file was generated by the tool fastddsgen.
*/
#ifndef FAST_DDS_GENERATED__SUBSCRIBERAPP_HPP
#define FAST_DDS_GENERATED__SUBSCRIBERAPP_HPP
#include <condition_variable>
#include <fastdds/dds/domain/DomainParticipant.hpp>
#include <fastdds/dds/domain/DomainParticipantFactory.hpp>
#include <fastdds/dds/subscriber/DataReaderListener.hpp>
#include <fastdds/dds/topic/TypeSupport.hpp>
#include "System.hpp"
class SubscriberApp : public eprosima::fastdds::dds::DataReaderListener
{
public:
SubscriberApp(
const int& domain_id);
virtual ~SubscriberApp();
//! Subscription callback
void on_data_available(
eprosima::fastdds::dds::DataReader* reader) override;
//! Subscriber matched method
void on_subscription_matched(
eprosima::fastdds::dds::DataReader* reader,
const eprosima::fastdds::dds::SubscriptionMatchedStatus& info) override;
//! Run subscriber
void run();
//! Trigger the end of execution
void stop();
private:
//! Return the current state of execution
bool is_stopped();
std::shared_ptr<eprosima::fastdds::dds::DomainParticipantFactory> factory_;
eprosima::fastdds::dds::DomainParticipant* participant_;
eprosima::fastdds::dds::Subscriber* subscriber_;
eprosima::fastdds::dds::Topic* scaleinfo_topic_;
eprosima::fastdds::dds::DataReader* scaleinfo_reader_;
eprosima::fastdds::dds::TypeSupport scaleinfo_type_;
eprosima::fastdds::dds::Topic* weightinfook_topic_;
eprosima::fastdds::dds::DataReader* weightinfook_reader_;
eprosima::fastdds::dds::TypeSupport weightinfook_type_;
eprosima::fastdds::dds::Topic* weightinfoerror_topic_;
eprosima::fastdds::dds::DataReader* weightinfoerror_reader_;
eprosima::fastdds::dds::TypeSupport weightinfoerror_type_;
uint16_t samples_received_;
std::atomic<bool> stop_;
mutable std::mutex terminate_cv_mtx_;
std::condition_variable terminate_cv_;
};
#endif // FAST_DDS_GENERATED__SUBSCRIBERAPP_HPP

File diff suppressed because it is too large Load Diff

@ -0,0 +1,366 @@
// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima).
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/*!
* @file main.cxx
* This file acts as a main entry point to the application.
*
* This file was generated by the tool fastddsgen.
*/
#include <csignal>
#include <cstring>
#include <functional>
#include <iostream>
#include <stdexcept>
#include <thread>
#include <queue>
#include <fastdds/dds/log/Log.hpp>
#include "Subscriber.hpp"
#include "msg.hpp"
#include "DEBUG.hpp"
#include "YQNetCom.h"
using eprosima::fastdds::dds::Log;
std::function<void(int)> stop_handler;
void signal_handler(
int signum)
{
stop_handler(signum);
}
std::string parse_signal(
const int& signum)
{
switch (signum)
{
case SIGINT:
return "SIGINT";
case SIGTERM:
return "SIGTERM";
#ifndef _WIN32
case SIGQUIT:
return "SIGQUIT";
case SIGHUP:
return "SIGHUP";
#endif // _WIN32
default:
return "UNKNOWN SIGNAL";
}
}
static const std::string base64_chars =
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"abcdefghijklmnopqrstuvwxyz"
"0123456789+/";
static inline bool is_base64(unsigned char c) {
return (isalnum(c) || (c == '+') || (c == '/'));
}
std::string base64_encode(const std::string &input)
{
std::string ret;
int i = 0;
int j = 0;
unsigned char char_array_3[3];
unsigned char char_array_4[4];
size_t in_len = input.size();
const char *bytes_to_encode = input.c_str();
while (in_len--)
{
char_array_3[i++] = *(bytes_to_encode++);
if (i == 3)
{
char_array_4[0] = (char_array_3[0] & 0xfc) >> 2;
char_array_4[1] = ((char_array_3[0] & 0x03) << 4) + ((char_array_3[1] & 0xf0) >> 4);
char_array_4[2] = ((char_array_3[1] & 0x0f) << 2) + ((char_array_3[2] & 0xc0) >> 6);
char_array_4[3] = char_array_3[2] & 0x3f;
for (i = 0; i < 4; i++)
{
ret += base64_chars[char_array_4[i]];
}
i = 0;
}
}
if (i)
{
for (j = i; j < 3; j++)
{
char_array_3[j] = '\0';
}
char_array_4[0] = (char_array_3[0] & 0xfc) >> 2;
char_array_4[1] = ((char_array_3[0] & 0x03) << 4) + ((char_array_3[1] & 0xf0) >> 4);
char_array_4[2] = ((char_array_3[1] & 0x0f) << 2) + ((char_array_3[2] & 0xc0) >> 6);
for (j = 0; j < i + 1; j++)
{
ret += base64_chars[char_array_4[j]];
}
while (i++ < 3)
{
ret += '=';
}
}
return ret;
}
void send_text(std::string ip_addr, int port, std::string text)
{
char *user_name = "guest", *user_pwd = "guest";
int dynamic_type = 1;
int display_effects = 0;
int display_speed = 16;
int stay_time = 10;
int gif_flag = 0;
char *bg_color = "0xff000000";
char *color = "0xffffffff";
char *font_attributes = "normal";
char *font = "SimSun";
char *align_h = "0";
char *align_v = "0";
char *ali = "";
int err;
std::vector<char> ip(ip_addr.begin(), ip_addr.end());
ip.push_back('\0');
std::string encoded_str = base64_encode(text);
std::vector<char> wcstring(encoded_str.begin(), encoded_str.end());
wcstring.push_back('\0');
int b = check_time(ip.data(), port, user_name, user_pwd);
DEBUG("check_time==" << b);
unsigned long play_list = create_playlist(128, 128, 8280);
printf("create_playlist: %p\n", play_list);
char *program_name = "program_0";
unsigned long program = create_program(program_name, bg_color);
printf("create_program: %p\n", program);
unsigned long dynamic_area = create_dynamic();
printf("create_dynamic: %p\n", dynamic_area);
err = add_dynamic_unit(dynamic_area, dynamic_type, display_effects, display_speed, stay_time, wcstring.data(), gif_flag, bg_color, 14, font, color, font_attributes, align_h, align_v, 0, 0, 0, "", "", 0);
DEBUG("add_dynamic_unit:" << err);
err = add_dynamic(program, dynamic_area, 0, 0, 0, 128, 128, ali, 0, ali, 100);
DEBUG("add_dynamic:" << err);
delete_dynamic(dynamic_area);
err = add_program_in_playlist(play_list, program, 0, 10, ali, ali, ali, ali, 127);
DEBUG("add_program_in_playlist:" << err);
err = update_dynamic_small(ip.data(), port, user_name, user_pwd, play_list, "", 1, 0);
if (err != 0)
{
DEBUG(ip.data() << "update_dynamic_small:" << err);
}
delete_playlist(play_list);
}
void send_default(std::string ip_addr, int port)
{
char *user_name = "guest", *user_pwd = "guest";
int dynamic_type = 1;
int display_effects = 0;
int display_speed = 16;
int stay_time = 10;
int gif_flag = 0;
char *bg_color = "0xff000000";
char *color = "0xffffffff";
char *font_attributes = "normal";
char *font = "SimSun";
char *align_h = "0";
char *align_v = "0";
char *ali = "";
int err;
std::vector<char> ip(ip_addr.begin(), ip_addr.end());
ip.push_back('\0');
std::string wcstring = "led.txt";
int b = check_time(ip.data(), port, user_name, user_pwd);
DEBUG("check_time==" << b);
unsigned long play_list = create_playlist(128, 128, 8280);
printf("create_playlist: %p\n", play_list);
char *program_name = "program_0";
unsigned long program = create_program(program_name, bg_color);
printf("create_program: %p\n", program);
unsigned long dynamic_area = create_dynamic();
printf("create_dynamic: %p\n", dynamic_area);
err = add_dynamic_unit(dynamic_area, dynamic_type, display_effects, display_speed, stay_time, wcstring.data(), gif_flag, bg_color, 14, font, color, font_attributes, align_h, align_v, 0, 0, 0, "", "", 0);
DEBUG("add_dynamic_unit:" << err);
err = add_dynamic(program, dynamic_area, 0, 0, 0, 128, 128, ali, 0, ali, 100);
DEBUG("add_dynamic:" << err);
delete_dynamic(dynamic_area);
err = add_program_in_playlist(play_list, program, 0, 10, ali, ali, ali, ali, 127);
DEBUG("add_program_in_playlist:" << err);
err = update_dynamic(ip.data(), port, user_name, user_pwd, play_list, "", 1, 0);
if (err != 0)
{
DEBUG(ip.data() << "update_dynamic:" << err);
}
delete_playlist(play_list);
}
std::queue<WeighingSystem::ScaleInfo> DdsMsgData::ScaleInfo_queue_;
std::queue<WeighingSystem::WeightInfoOk> DdsMsgData::WeightInfoOk_queue_;
std::queue<WeighingSystem::WeightInfoError> DdsMsgData::WeightInfoError_queue_;
std::mutex DdsMsgData::queue_cv_mtx_;
std::atomic<bool> running(true);
int main(int argc, char** argv)
{
auto ret = EXIT_SUCCESS;
std::shared_ptr<SubscriberApp> sub;
int domain_id = 0;
int port = 80;
std::string addr = "192.168.1.100";
uint8_t clear_led = 1;
for (int i = 1; i < argc; i++)
{
if (strcmp(argv[i], "--domain") == 0 && i + 1 < argc)
{
domain_id = atoi(argv[++i]);
}
else if (strcmp(argv[i], "--addr") == 0 && i + 1 < argc)
{
addr = argv[++i];
}
else if (strcmp(argv[i], "--port") == 0 && i + 1 < argc)
{
port = atoi(argv[++i]);
}
else if (strcmp(argv[i], "--version") == 0)
{
std::cout << "Vesrion: " << PROGRAM_VERSION << "\n";
return EXIT_SUCCESS;
}
else if (strcmp(argv[i], "--help") == 0)
{
std::cout << "Usage: [options]\n"
<< "Options:\n"
<< " --domain Set domain ID\n"
<< " --addr Set led addr (e.g., 192.168.1.1)\n"
<< " --port Set port name (e.g., 80)\n"
<< " --version Show software Version\n"
<< " --help Show this help message\n";
return EXIT_SUCCESS;
}
else
{
std::cerr << "Unknown option: " << argv[i] << "\n";
std::cout << "Usage: [options]\n"
<< "Options:\n"
<< " --domain Set domain ID\n"
<< " --addr Set led addr (e.g., 192.168.1.1)\n"
<< " --port Set port name (e.g., 80)\n"
<< " --version Show software Version\n"
<< " --help Show this help message\n";
return EXIT_FAILURE;
}
}
sub = std::make_shared<SubscriberApp>(domain_id);
DEBUG("Program is running. Please press Ctrl+C to stop at any time.");
auto formatFloat = [](float value) -> std::string
{
std::ostringstream oss;
oss << std::fixed << std::setprecision(2) << value;
return oss.str();
};
send_default(addr, port);
while(running.load())
{
std::unique_lock<std::mutex> lock(DdsMsgData::queue_cv_mtx_, std::try_to_lock);
if (lock.owns_lock())
{
if(!DdsMsgData::WeightInfoOk_queue_.empty())
{
WeighingSystem::WeightInfoOk info = std::move(DdsMsgData::WeightInfoOk_queue_.front());
DdsMsgData::WeightInfoOk_queue_.pop();
lock.unlock();
send_text(addr, port, info.Warning());
clear_led = 0;
}
else if (!DdsMsgData::WeightInfoError_queue_.empty())
{
WeighingSystem::WeightInfoError info = std::move(DdsMsgData::WeightInfoError_queue_.front());
DdsMsgData::WeightInfoError_queue_.pop();
lock.unlock();
send_text(addr, port, info.Warning());
clear_led = 0;
}
else if (!DdsMsgData::ScaleInfo_queue_.empty())
{
WeighingSystem::ScaleInfo info = std::move(DdsMsgData::ScaleInfo_queue_.front());
DdsMsgData::ScaleInfo_queue_.pop();
lock.unlock();
if (info.HasVehicle() == false)
{
if (clear_led == 0)
{
send_default(addr, port);
clear_led = 1;
}
}
}
else
{
lock.unlock();
}
}
std::this_thread::sleep_for(std::chrono::milliseconds(100));
}
stop_handler = [&](int signum)
{
std::cout << "\n" << parse_signal(signum) << " received, stopping " << argv[1]
<< " execution." << std::endl;
running.store(false);
};
signal(SIGINT, signal_handler);
signal(SIGTERM, signal_handler);
#ifndef _WIN32
signal(SIGQUIT, signal_handler);
signal(SIGHUP, signal_handler);
#endif // _WIN32
Log::Reset();
return ret;
}

@ -0,0 +1,16 @@
#ifndef _MSG_HPP_
#define _MSG_HPP_
#include <queue>
#include <mutex>
#include "System.hpp"
class DdsMsgData {
public:
static std::queue<WeighingSystem::ScaleInfo> ScaleInfo_queue_;
static std::queue<WeighingSystem::WeightInfoOk> WeightInfoOk_queue_;
static std::queue<WeighingSystem::WeightInfoError> WeightInfoError_queue_;
static std::mutex queue_cv_mtx_;
};
#endif

Binary file not shown.
Loading…
Cancel
Save