master
parent
bc00d4c01c
commit
73872bb212
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "鑫顺洁",
|
"name": "鑫顺洁",
|
||||||
"delay": 0,
|
"delay": 60,
|
||||||
"daemon": true,
|
"daemon": true,
|
||||||
"httpSvr": {
|
"httpSvr": {
|
||||||
"port": 11000
|
"port": 11000
|
||||||
|
|
@ -94,7 +94,10 @@
|
||||||
{
|
{
|
||||||
"sn": "1",
|
"sn": "1",
|
||||||
"name": "地磅",
|
"name": "地磅",
|
||||||
|
"delay": 5,
|
||||||
"sample": 20,
|
"sample": 20,
|
||||||
|
"retries": 30,
|
||||||
|
"weight": 200.0,
|
||||||
"port": "COM7",
|
"port": "COM7",
|
||||||
"baudRate": 9600,
|
"baudRate": 9600,
|
||||||
"byteSize": 8,
|
"byteSize": 8,
|
||||||
|
|
@ -114,6 +117,7 @@
|
||||||
{
|
{
|
||||||
"sn": "1",
|
"sn": "1",
|
||||||
"name": "摄像头",
|
"name": "摄像头",
|
||||||
|
"type": 0,
|
||||||
"ip": "192.168.1.206",
|
"ip": "192.168.1.206",
|
||||||
"port": 8000,
|
"port": 8000,
|
||||||
"username": "admin",
|
"username": "admin",
|
||||||
|
|
|
||||||
|
|
@ -119,15 +119,15 @@ namespace zsy
|
||||||
|
|
||||||
/*status = 2;*/
|
/*status = 2;*/
|
||||||
LOGGER_INFO("正在称重...");
|
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);
|
auto processor = static_cast<GenericPlatformScaleProcessor *>(serialPort->processor);
|
||||||
int count = 0;
|
int count = 0;
|
||||||
while (processor->steady.load() < config.sample)
|
while (processor->steady.load() < config.sample || processor->weight.load() <= config.weight)
|
||||||
{
|
{
|
||||||
count++;
|
count++;
|
||||||
if (count >= 10)
|
if (count >= config.retries)
|
||||||
{
|
{
|
||||||
LOGGER_ERROR("称重失败,连续 {} 次未稳定", count);
|
LOGGER_ERROR("称重失败,连续 {} 次未稳定或磅重低于阈值 {} KG,当前磅重:{} KG", count, config.weight, processor->weight.load());
|
||||||
/*status = 1;*/
|
/*status = 1;*/
|
||||||
return 0.0;
|
return 0.0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,10 @@ namespace zsy
|
||||||
{
|
{
|
||||||
std::string sn;
|
std::string sn;
|
||||||
std::string name;
|
std::string name;
|
||||||
|
uint8_t delay;
|
||||||
uint8_t sample;
|
uint8_t sample;
|
||||||
|
uint8_t retries;
|
||||||
|
double weight;
|
||||||
std::string port;
|
std::string port;
|
||||||
uint32_t baudRate{9600};
|
uint32_t baudRate{9600};
|
||||||
uint8_t byteSize{8};
|
uint8_t byteSize{8};
|
||||||
|
|
@ -20,7 +23,10 @@ namespace zsy
|
||||||
{
|
{
|
||||||
PARSE_JSON(sn, o.sn);
|
PARSE_JSON(sn, o.sn);
|
||||||
PARSE_JSON(name, o.name);
|
PARSE_JSON(name, o.name);
|
||||||
|
PARSE_JSON(delay, o.delay);
|
||||||
PARSE_JSON(sample, o.sample);
|
PARSE_JSON(sample, o.sample);
|
||||||
|
PARSE_JSON(retries, o.retries);
|
||||||
|
PARSE_JSON(weight, o.weight);
|
||||||
PARSE_JSON(port, o.port);
|
PARSE_JSON(port, o.port);
|
||||||
PARSE_JSON(baudRate, o.baudRate);
|
PARSE_JSON(baudRate, o.baudRate);
|
||||||
PARSE_JSON(byteSize, o.byteSize);
|
PARSE_JSON(byteSize, o.byteSize);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue