lzq 2025-10-20 13:09:41 +08:00
parent bc00d4c01c
commit 73872bb212
3 changed files with 15 additions and 5 deletions

View File

@ -1,6 +1,6 @@
{
"name": "鑫顺洁",
"delay": 0,
"delay": 60,
"daemon": true,
"httpSvr": {
"port": 11000
@ -94,7 +94,10 @@
{
"sn": "1",
"name": "地磅",
"delay": 5,
"sample": 20,
"retries": 30,
"weight": 200.0,
"port": "COM7",
"baudRate": 9600,
"byteSize": 8,
@ -114,6 +117,7 @@
{
"sn": "1",
"name": "摄像头",
"type": 0,
"ip": "192.168.1.206",
"port": 8000,
"username": "admin",

View File

@ -119,15 +119,15 @@ namespace zsy
/*status = 2;*/
LOGGER_INFO("正在称重...");
std::this_thread::sleep_for(std::chrono::milliseconds(1000));
if (config.delay > 0) std::this_thread::sleep_for(std::chrono::milliseconds(config.delay * 1000));
auto processor = static_cast<GenericPlatformScaleProcessor *>(serialPort->processor);
int count = 0;
while (processor->steady.load() < config.sample)
while (processor->steady.load() < config.sample || processor->weight.load() <= config.weight)
{
count++;
if (count >= 10)
if (count >= config.retries)
{
LOGGER_ERROR("称重失败,连续 {} 次未稳定", count);
LOGGER_ERROR("称重失败,连续 {} 次未稳定或磅重低于阈值 {} KG当前磅重{} KG", count, config.weight, processor->weight.load());
/*status = 1;*/
return 0.0;
}

View File

@ -8,7 +8,10 @@ namespace zsy
{
std::string sn;
std::string name;
uint8_t delay;
uint8_t sample;
uint8_t retries;
double weight;
std::string port;
uint32_t baudRate{9600};
uint8_t byteSize{8};
@ -20,7 +23,10 @@ namespace zsy
{
PARSE_JSON(sn, o.sn);
PARSE_JSON(name, o.name);
PARSE_JSON(delay, o.delay);
PARSE_JSON(sample, o.sample);
PARSE_JSON(retries, o.retries);
PARSE_JSON(weight, o.weight);
PARSE_JSON(port, o.port);
PARSE_JSON(baudRate, o.baudRate);
PARSE_JSON(byteSize, o.byteSize);