lisai17@sina.com 2020-10-09 21:42:54 +08:00
parent 4692d04fff
commit 64ad813649
11 changed files with 25 additions and 22 deletions

View File

@ -41,7 +41,7 @@ public class InController extends Controller implements Runnable {
}
public void run() {
log.debug("开始 %s 流程", getWhich());
log.debug("开始 %s 流程 %s", getWhich(), supermarket_id);
deviceInit();
while (isRunning()) {
@ -108,7 +108,7 @@ public class InController extends Controller implements Runnable {
continue;
}
log.debug("%s 【%s】开始流程", getWhich(), pair.license);
log.debug("%s 【%s】开始流程 %s", getWhich(), pair.license, supermarket_id);
setCurrentLicense(pair.license); // 设定当前流程中的车辆
@ -179,6 +179,8 @@ public class InController extends Controller implements Runnable {
double weight = 0;
int tryCount = 0;
while (tryCount < 10 && !getResetFlow()) {
log.debug("第 %s 次,重 %s", tryCount, weight);
try {
if (!getScale().isConnected()) {
log.debug("%s 【%s】磅秤连接断开重连", getWhich(), pair.license);
@ -189,6 +191,9 @@ public class InController extends Controller implements Runnable {
if (weight > 0) {
log.debug("%s 【%s】称重结果【%s】", getWhich(), pair.license, weight);
break;
}else{
// 读数错误,断开连接,下次读取时重连
getScale().disconnect();
}
} catch (Exception e) {
getScale().disconnect();
@ -196,6 +201,7 @@ public class InController extends Controller implements Runnable {
log.error(e.getMessage(), e);
log.debug("%s 【%s】磅秤连接失败", getWhich(), pair.license);
}
tryCount++;
}

View File

@ -164,6 +164,8 @@ public class OutController extends Controller implements Runnable {
double weight = 0;
int tryCount = 0;
while (tryCount < 10 && !getResetFlow()) {
log.debug("第 %s 次,重 %s", tryCount, weight);
try {
if (!getScale().isConnected()) {
log.debug("%s 【%s】磅秤连接断开重连", getWhich(), pair.license);
@ -174,6 +176,9 @@ public class OutController extends Controller implements Runnable {
if (weight > 0) {
log.debug("%s 【%s】称重结果【%s】", getWhich(), pair.license, weight);
break;
}else{
// 读数错误,断开连接,下次读取时重连
getScale().disconnect();
}
} catch (Exception e) {
getScale().disconnect();
@ -181,6 +186,7 @@ public class OutController extends Controller implements Runnable {
log.error(e.getMessage(), e);
log.debug("%s 【%s】磅秤连接失败", getWhich(), pair.license);
}
tryCount++;
}

View File

@ -313,7 +313,7 @@ public class LEDThread extends Device implements Runnable {
public static void main(String[] args) {
try {
LEDThread led = new LEDThread("", "192.168.20.50", 5005);
LEDThread led = new LEDThread("", "192.168.20.52", 5005);
Thread thread = new Thread(led);
thread.setDaemon(true);
thread.start();

View File

@ -144,11 +144,6 @@ public class PLC extends Device {
void plcWrite(String address, byte data, byte[] framePreset) throws IOException {
lock.lock();
try {
if (!isConnected()) {
log.debug("PLC %s %s 未连接", getId(), getIp());
return;
}
if (addressTable.containsKey(address)) {
byte addr = addressTable.get(address);
byte[] frame = new byte[framePreset.length];
@ -172,11 +167,6 @@ public class PLC extends Device {
int plcRead() throws IOException {
lock.lock();
try {
if (!isConnected()) {
log.debug("PLC %s %s 未连接", getId(), getIp());
return -1;
}
InputStream in = socket.getInputStream();
if (in.available() >= 6) {
byte[] buf = new byte[6];
@ -199,11 +189,6 @@ public class PLC extends Device {
int plcClear() throws IOException {
lock.lock();
try {
if (!isConnected()) {
log.debug("PLC %s %s 未连接", getId(), getIp());
return -1;
}
InputStream inputStream = socket.getInputStream();
int available = inputStream.available();
byte[] buf = new byte[available];

View File

@ -1,5 +1,7 @@
package com.cowr.local.ssjygl.devicectrl.device;
import com.jfinal.log.Log;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
@ -10,6 +12,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
import java.util.stream.Collectors;
public class XiShuiScale extends AbsScale {
private static Log log = Log.getLog(XiShuiScale.class);
public XiShuiScale(String id, String ip, int port) {
super(id, ip, port);
}
@ -67,7 +70,7 @@ public class XiShuiScale extends AbsScale {
String weight = new String(Arrays.copyOfRange(buf, 4, 10));
if (!pattern.matcher(weight).matches() || weight.equals("000000")) {
// System.out.println("error:" + weight);
log.error("error weight: %s", weight);
if (errCount == 100) {
break;
@ -92,7 +95,7 @@ public class XiShuiScale extends AbsScale {
public static void main(String[] args) {
XiShuiScale s = new XiShuiScale("scale", "192.168.20.31", 10001);
XiShuiScale s = new XiShuiScale("scale", "192.168.20.30", 10001);
try {
boolean connect = s.connect();

View File

@ -319,6 +319,7 @@ public class Config extends JFinalConfig {
CliCacheData.SUP = Supermarket.dao.findById(configprop.getInt("current.supermarket_id"));
if (CliCacheData.SUP == null) {
System.out.println("没有获取到有效的砂站信息,检查配置是否正确");
log.error("没有获取到有效的砂站信息,检查配置是否正确");
try {

View File

@ -1,7 +1,7 @@
devMode=true
endpoint=oss-cn-shenzhen-internal.aliyuncs.com
endpoint=oss-cn-shenzhen.aliyuncs.com
#正式、测试的附件,都存入正式的 oss 中
bucketName=ssjygl-xsx-static
@ -15,7 +15,7 @@ socketserver.port=21002
socketio.port=12002
#当前部署本地程序的砂站id
current.supermarket_id=4
current.supermarket_id=6
#打印用到的配置信息
print.vendor=浠水县长投环保有限公司
@ -24,6 +24,8 @@ print.vendorTaxId=91421125MA49GYYK2B
#如果物流车辆入场重量大大超过皮重(>=10%),则认为是转运车辆
#2019-08-01 暂定 50%
weight.distinguish=0.5
#最大毛重不超过 49 吨,超过 49 吨不能上高速
weigh.max=49
#起步运输距离
start.trans.distance=5

Binary file not shown.