dev
parent
f54734c197
commit
5bfea9b517
|
|
@ -59,47 +59,51 @@ public class KeLiScale extends AbsScale {
|
||||||
ArrayList<String> list = new ArrayList<>();
|
ArrayList<String> list = new ArrayList<>();
|
||||||
AtomicBoolean run = new AtomicBoolean(true);
|
AtomicBoolean run = new AtomicBoolean(true);
|
||||||
|
|
||||||
InputStream inputStream = socket.getInputStream();
|
try (InputStream inputStream = socket.getInputStream()) {
|
||||||
byte[] clearBuf = new byte[inputStream.available()];
|
byte[] clearBuf = new byte[inputStream.available()];
|
||||||
inputStream.read(clearBuf);
|
inputStream.read(clearBuf);
|
||||||
int errCount = 0;
|
int errCount = 0;
|
||||||
|
|
||||||
while (run.get() && list.size() < 15) {
|
while (run.get() && list.size() < 15) {
|
||||||
long st = System.currentTimeMillis();
|
long st = System.currentTimeMillis();
|
||||||
|
|
||||||
byte[] buf = new byte[DATA_LENGTH];
|
byte[] buf = new byte[DATA_LENGTH];
|
||||||
int read = inputStream.read(buf);
|
int read = inputStream.read(buf);
|
||||||
|
|
||||||
if (read != DATA_LENGTH && errCount < 10) {
|
if (read != DATA_LENGTH && errCount < 10) {
|
||||||
errCount++;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
String weight = new String(Arrays.copyOfRange(buf, DATA_FROM, DATA_TO));
|
|
||||||
|
|
||||||
if (!pattern.matcher(weight).matches() || weight.equals("000000")) {
|
|
||||||
// System.out.println("error:" + weight);
|
|
||||||
|
|
||||||
if (errCount == 100) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
errCount++;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
if (Long.parseLong(weight) > 100000) {
|
|
||||||
errCount++;
|
errCount++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
|
||||||
log.error(e.getMessage(), e);
|
String weight = new String(Arrays.copyOfRange(buf, DATA_FROM, DATA_TO));
|
||||||
}
|
|
||||||
|
if (!pattern.matcher(weight).matches() || weight.equals("000000")) {
|
||||||
|
// System.out.println("error:" + weight);
|
||||||
|
|
||||||
|
if (errCount == 100) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
errCount++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (Long.parseLong(weight) > 100000) {
|
||||||
|
errCount++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.getMessage(), e);
|
||||||
|
}
|
||||||
|
|
||||||
// System.out.println("读一次耗时:" + (System.currentTimeMillis() - st) + ", " + Double.parseDouble(flip(weight)));
|
// System.out.println("读一次耗时:" + (System.currentTimeMillis() - st) + ", " + Double.parseDouble(flip(weight)));
|
||||||
list.add(weight);
|
list.add(weight);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.getMessage(), e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
String max = "0";
|
String max = "0";
|
||||||
if (list.size() > 0) {
|
if (list.size() > 0) {
|
||||||
Map<String, Long> collect = list.stream().collect(
|
Map<String, Long> collect = list.stream().collect(
|
||||||
|
|
|
||||||
|
|
@ -52,47 +52,51 @@ public class XiShuiScale extends AbsScale {
|
||||||
ArrayList<String> list = new ArrayList<>();
|
ArrayList<String> list = new ArrayList<>();
|
||||||
AtomicBoolean run = new AtomicBoolean(true);
|
AtomicBoolean run = new AtomicBoolean(true);
|
||||||
|
|
||||||
InputStream inputStream = socket.getInputStream();
|
try (InputStream inputStream = socket.getInputStream()) {
|
||||||
byte[] clearBuf = new byte[inputStream.available()];
|
byte[] clearBuf = new byte[inputStream.available()];
|
||||||
inputStream.read(clearBuf);
|
inputStream.read(clearBuf);
|
||||||
int errCount = 0;
|
int errCount = 0;
|
||||||
|
|
||||||
while (run.get() && list.size() < 15) {
|
while (run.get() && list.size() < 15) {
|
||||||
// long st = System.currentTimeMillis();
|
// long st = System.currentTimeMillis();
|
||||||
|
|
||||||
byte[] buf = new byte[18];
|
byte[] buf = new byte[18];
|
||||||
int read = inputStream.read(buf);
|
int read = inputStream.read(buf);
|
||||||
|
|
||||||
if (read != 18 && errCount < 10) {
|
if (read != 18 && errCount < 10) {
|
||||||
errCount++;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
String weight = new String(Arrays.copyOfRange(buf, 4, 10));
|
|
||||||
|
|
||||||
if (!pattern.matcher(weight).matches() || weight.equals("000000")) {
|
|
||||||
// log.error("error weight: %s", weight);
|
|
||||||
|
|
||||||
if (errCount == 100) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
errCount++;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
if (Long.parseLong(weight) > 100000) {
|
|
||||||
errCount++;
|
errCount++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
|
||||||
log.error(e.getMessage(), e);
|
String weight = new String(Arrays.copyOfRange(buf, 4, 10));
|
||||||
}
|
|
||||||
|
if (!pattern.matcher(weight).matches() || weight.equals("000000")) {
|
||||||
|
// log.error("error weight: %s", weight);
|
||||||
|
|
||||||
|
if (errCount == 100) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
errCount++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (Long.parseLong(weight) > 100000) {
|
||||||
|
errCount++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.getMessage(), e);
|
||||||
|
}
|
||||||
|
|
||||||
// System.out.println("读一次耗时:" + (System.currentTimeMillis() - st) + ", " + Double.parseDouble(flip(weight)));
|
// System.out.println("读一次耗时:" + (System.currentTimeMillis() - st) + ", " + Double.parseDouble(flip(weight)));
|
||||||
list.add(weight);
|
list.add(weight);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.getMessage(), e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
String max = "0";
|
String max = "0";
|
||||||
if (list.size() > 0) {
|
if (list.size() > 0) {
|
||||||
Map<String, Long> collect = list.stream().collect(
|
Map<String, Long> collect = list.stream().collect(
|
||||||
|
|
|
||||||
|
|
@ -55,44 +55,47 @@ public class YaoHuaScale extends AbsScale {
|
||||||
ArrayList<String> list = new ArrayList<>();
|
ArrayList<String> list = new ArrayList<>();
|
||||||
AtomicBoolean run = new AtomicBoolean(true);
|
AtomicBoolean run = new AtomicBoolean(true);
|
||||||
|
|
||||||
InputStream inputStream = socket.getInputStream();
|
try (InputStream inputStream = socket.getInputStream()) {
|
||||||
byte[] clearBuf = new byte[inputStream.available()];
|
byte[] clearBuf = new byte[inputStream.available()];
|
||||||
inputStream.read(clearBuf);
|
inputStream.read(clearBuf);
|
||||||
int errCount = 0;
|
int errCount = 0;
|
||||||
|
|
||||||
while (run.get() && list.size() < 15) {
|
while (run.get() && list.size() < 15) {
|
||||||
long st = System.currentTimeMillis();
|
long st = System.currentTimeMillis();
|
||||||
|
|
||||||
byte[] buf = new byte[12];
|
byte[] buf = new byte[12];
|
||||||
int read = inputStream.read(buf);
|
int read = inputStream.read(buf);
|
||||||
|
|
||||||
if (read != 18 && errCount < 10) {
|
if (read != 18 && errCount < 10) {
|
||||||
errCount++;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
String weight = new String(Arrays.copyOfRange(buf, 2, 8));
|
|
||||||
|
|
||||||
if (!pattern.matcher(weight).matches() || weight.equals("000000")) {
|
|
||||||
// System.out.println("error:" + weight);
|
|
||||||
|
|
||||||
if (errCount == 100) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
errCount++;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
if (Long.parseLong(weight) > 100000) {
|
|
||||||
errCount++;
|
errCount++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
|
||||||
log.error(e.getMessage(), e);
|
String weight = new String(Arrays.copyOfRange(buf, 2, 8));
|
||||||
}
|
|
||||||
|
if (!pattern.matcher(weight).matches() || weight.equals("000000")) {
|
||||||
|
// System.out.println("error:" + weight);
|
||||||
|
|
||||||
|
if (errCount == 100) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
errCount++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
if (Long.parseLong(weight) > 100000) {
|
||||||
|
errCount++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.getMessage(), e);
|
||||||
|
}
|
||||||
|
|
||||||
// System.out.println("读一次耗时:" + (System.currentTimeMillis() - st) + ", " + Double.parseDouble(flip(weight)));
|
// System.out.println("读一次耗时:" + (System.currentTimeMillis() - st) + ", " + Double.parseDouble(flip(weight)));
|
||||||
list.add(weight);
|
list.add(weight);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.getMessage(), e);
|
||||||
}
|
}
|
||||||
|
|
||||||
String max = "0";
|
String max = "0";
|
||||||
|
|
|
||||||
|
|
@ -95,7 +95,7 @@ public class Config extends JFinalConfig {
|
||||||
public static DeviceThread deviceThread = new DeviceThread();
|
public static DeviceThread deviceThread = new DeviceThread();
|
||||||
public static SocketIOService socketio = null;
|
public static SocketIOService socketio = null;
|
||||||
private static boolean client_run = true;
|
private static boolean client_run = true;
|
||||||
public static final String CLINET_VERSION = "20210307";
|
public static final String CLINET_VERSION = "20210308";
|
||||||
|
|
||||||
public static String getRootPath() {
|
public static String getRootPath() {
|
||||||
return PathKit.getWebRootPath()
|
return PathKit.getWebRootPath()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue