|
|
|
|
@ -309,6 +309,8 @@ extern std::string mqtt_topic_id;
|
|
|
|
|
|
|
|
|
|
void PublisherApp::run(std::shared_ptr<mqtt::async_client> dev)
|
|
|
|
|
{
|
|
|
|
|
std::map<std::string, std::string> print_msg;
|
|
|
|
|
|
|
|
|
|
while (!is_stopped())
|
|
|
|
|
{
|
|
|
|
|
//dds msg
|
|
|
|
|
@ -425,6 +427,51 @@ void PublisherApp::run(std::shared_ptr<mqtt::async_client> dev)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (!DdsMsgData::WeightInfoOk_queue_.empty())
|
|
|
|
|
{
|
|
|
|
|
WeighingSystem::WeightInfoOk info = std::move(DdsMsgData::WeightInfoOk_queue_.front());
|
|
|
|
|
DdsMsgData::WeightInfoOk_queue_.pop();
|
|
|
|
|
dds_lock.unlock();
|
|
|
|
|
|
|
|
|
|
auto formatFloat = [](float value) -> std::string
|
|
|
|
|
{
|
|
|
|
|
std::ostringstream oss;
|
|
|
|
|
oss << std::fixed << std::setprecision(2) << value;
|
|
|
|
|
return oss.str();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// if (info.IsPrintTicker() == true)
|
|
|
|
|
// {
|
|
|
|
|
print_msg.clear();
|
|
|
|
|
|
|
|
|
|
print_msg["Title"] = "过衡单";
|
|
|
|
|
print_msg["GrossDeviceID"] = std::to_string(info.GrossDeviceID());
|
|
|
|
|
print_msg["GrossDeviceName"] = info.GrossDeviceName();
|
|
|
|
|
print_msg["TareDeviceID"] = std::to_string(info.TareDeviceID());
|
|
|
|
|
print_msg["TareDeviceName"] = info.TareDeviceName();
|
|
|
|
|
print_msg["TitleCorp"] = info.EnterpriseName();
|
|
|
|
|
print_msg["CoalNumber"] = info.BillNumber();
|
|
|
|
|
print_msg["CarNumber"] = info.CarNumber();
|
|
|
|
|
print_msg["Supplier"] = info.Supplier();
|
|
|
|
|
print_msg["GoodsType"] = info.GoodsType();
|
|
|
|
|
print_msg["GrossWeight"] = formatFloat(info.GrossWeight());
|
|
|
|
|
print_msg["GrossTime"] = info.GrossTime();
|
|
|
|
|
print_msg["GrossOperater"] = info.GrossOperater();
|
|
|
|
|
print_msg["TareWeight"] = formatFloat(info.Tare());
|
|
|
|
|
print_msg["TareTime"] = info.TareTime();
|
|
|
|
|
print_msg["TareOperater"] = info.TareOperater();
|
|
|
|
|
print_msg["SuttleWeight"] = formatFloat(info.Suttle());
|
|
|
|
|
print_msg["duduction1"] = formatFloat(info.duduction1());
|
|
|
|
|
print_msg["duduction2"] = formatFloat(info.duduction2());
|
|
|
|
|
print_msg["duduction3"] = formatFloat(info.duduction3());
|
|
|
|
|
print_msg["INCoalYard"] = info.INCoalYard();
|
|
|
|
|
print_msg["OUTCoalYard"] = info.OutCoalYard();
|
|
|
|
|
print_msg["BatchNumber"] = info.BatchNumber();
|
|
|
|
|
print_msg["Warning"] = info.Warning();
|
|
|
|
|
print_msg["Tips"] = info.Tips();
|
|
|
|
|
print_msg["TicketType"] = info.TicketType();
|
|
|
|
|
// }
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
dds_lock.unlock();
|
|
|
|
|
@ -446,7 +493,7 @@ void PublisherApp::run(std::shared_ptr<mqtt::async_client> dev)
|
|
|
|
|
|
|
|
|
|
json cmd = json::parse(payload);
|
|
|
|
|
|
|
|
|
|
if (topic.find("barrier/frontup") != std::string::npos)
|
|
|
|
|
if (topic == ("pound/" + mqtt_topic_id + "/barrier/frontup"))
|
|
|
|
|
{
|
|
|
|
|
if (cmd["value"] == 1)
|
|
|
|
|
{
|
|
|
|
|
@ -455,7 +502,7 @@ void PublisherApp::run(std::shared_ptr<mqtt::async_client> dev)
|
|
|
|
|
bar_ctrl(ctrl);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (topic.find("barrier/frontdown") != std::string::npos)
|
|
|
|
|
else if (topic == ("pound/" + mqtt_topic_id + "/barrier/frontdown"))
|
|
|
|
|
{
|
|
|
|
|
if (cmd["value"] == 1)
|
|
|
|
|
{
|
|
|
|
|
@ -464,18 +511,28 @@ void PublisherApp::run(std::shared_ptr<mqtt::async_client> dev)
|
|
|
|
|
bar_ctrl(ctrl);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (topic.find("barrier/frontlock") != std::string::npos)
|
|
|
|
|
else if (topic == ("pound/" + mqtt_topic_id + "/barrier/frontlock"))
|
|
|
|
|
{
|
|
|
|
|
if (cmd["value"] == 1)
|
|
|
|
|
{
|
|
|
|
|
std::ofstream(getExeDir() / "frontbar.lock") << getpid();
|
|
|
|
|
std::ofstream(getExeDir() / "frontbar.lock");
|
|
|
|
|
std::string payload = "{\"value\": 1}";
|
|
|
|
|
auto mqtt_msg = mqtt::make_message("pound/" + std::string(mqtt_topic_id) + "/barrier/frontlockstatus", payload);
|
|
|
|
|
mqtt_msg->set_qos(0);
|
|
|
|
|
mqtt_msg->set_retained(true);
|
|
|
|
|
dev->publish(mqtt_msg);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
std::filesystem::remove(getExeDir() / "frontbar.lock");
|
|
|
|
|
std::string payload = "{\"value\": 0}";
|
|
|
|
|
auto mqtt_msg = mqtt::make_message("pound/" + std::string(mqtt_topic_id) + "/barrier/frontlockstatus", payload);
|
|
|
|
|
mqtt_msg->set_qos(0);
|
|
|
|
|
mqtt_msg->set_retained(true);
|
|
|
|
|
dev->publish(mqtt_msg);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (topic.find("light/frontsignal") != std::string::npos)
|
|
|
|
|
else if (topic == ("pound/" + mqtt_topic_id + "/light/frontsignal"))
|
|
|
|
|
{
|
|
|
|
|
if (cmd["value"] == 1)
|
|
|
|
|
{
|
|
|
|
|
@ -490,6 +547,10 @@ void PublisherApp::run(std::shared_ptr<mqtt::async_client> dev)
|
|
|
|
|
light_ctrl(ctrl);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (topic == ("pound/" + mqtt_topic_id + "/businessok/reprint"))
|
|
|
|
|
{
|
|
|
|
|
print_receipt(print_msg);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
|