You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

42 lines
1.9 KiB
Java

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

package com.example.pdaplccontrol;
final class PlcConfig {
// 参数集中放置,现场地址变化时只改这里。
static final String PLC_IP = "192.168.11.1";
static final int RACK = 0;
static final int SLOT = 1;
static final int DB_NUMBER = 49;
static final int LINE_NUMBER_OFFSET = 32;
static final int WEIGHT_KG_OFFSET = 34;
static final int WORD_BYTE_LENGTH = 2;
static final int MONITOR_START_OFFSET = LINE_NUMBER_OFFSET;
static final int MONITOR_BYTE_LENGTH = WEIGHT_KG_OFFSET + WORD_BYTE_LENGTH - MONITOR_START_OFFSET;
// 监控常规轮询间隔5000毫秒。设为 5 秒是为了降低 PDA 与 PLC 的网络交互负荷。
static final int MONITOR_INTERVAL_MILLIS = 5000;
// 监控发生第一次读取失败时的退避重试延迟2000毫秒。初次失败快速重试以规避偶发抖动。
static final int MONITOR_FIRST_FAILURE_RETRY_MILLIS = 2000;
// 监控发生第二次读取失败时的退避重试延迟3000毫秒
static final int MONITOR_SECOND_FAILURE_RETRY_MILLIS = 3000;
// 监控发生多次连续失败时的最大退避延迟5000毫秒。防止网络彻底断开时高频请求占用设备连接资源。
static final int MONITOR_MAX_FAILURE_RETRY_MILLIS = 5000;
// 判定通讯异常的连续失败次数阈值。达到 3 次失败才报错,避免网络偶发丢包导致界面闪红。
static final int MONITOR_FAILURE_THRESHOLD = 3;
// 判定通讯数据失效的兜底时间阈值15秒。用于防止由于其他原因导致的监控界面数据僵死、长期未刷新的情况。
static final long MONITOR_STALE_THRESHOLD_MILLIS = 15000L;
static final int MIN_LINE_NUMBER = 10;
static final int MAX_LINE_NUMBER = 18;
static final int MIN_WEIGHT_KG = 0;
static final int MAX_WEIGHT_KG = 30;
private PlcConfig() {
}
}