lisai17@sina.com 2020-09-08 21:02:25 +08:00
parent 0dd93df916
commit 5ab37782e8
8 changed files with 50 additions and 41 deletions

View File

@ -155,9 +155,9 @@ public class DeviceThread extends Thread {
String plckey = plcconf.getString("ip") + "_" + plcconf.getIntValue("port");
// 一个摄像头只能连一次
Camera camera = new Camera(which + "_camera", cameraconf.getString("ip"));
HuangZhouScale scale = new HuangZhouScale(which + "_scale", scaleconf.getString("ip"), scaleconf.getIntValue("port"));
LEDThread led = new LEDThread(which + "_led", ledconf.getString("ip"), ledconf.getIntValue("port"));
Camera camera = new Camera(which + "_camera", cameraconf.getString("ip"));
XiShuiScale scale = new XiShuiScale(which + "_scale", scaleconf.getString("ip"), scaleconf.getIntValue("port"));
LEDThread led = new LEDThread(which + "_led", ledconf.getString("ip"), ledconf.getIntValue("port"));
PLC plc = null;
for (Map.Entry<String, PLC> entry : plcMap.entrySet()) {

View File

@ -203,8 +203,8 @@ public class LED extends Device {
public static void main(String[] args) {
try {
LED led = new LED("", "192.168.30.201", 5005);
led.screen("12345678", "等待车辆", "%s\\n %s \\n%s");
LED led = new LED("", "192.168.20.52", 5005);
led.screen("鄂A7D1P1", "等待车辆", "%s\\n %s \\n%s");
} catch (Exception e) {
e.printStackTrace();

View File

@ -256,10 +256,10 @@ public class PLC extends Device {
public static void main(String[] args) {
try {
PLC plc = new PLC("_plc", "192.168.0.220", 502, com.cowr.local.ssjygl.devicectrl.common.DeviceThread.defaultAddressTable);
PLC plc = new PLC("_plc", "192.168.20.20", 502, com.cowr.local.ssjygl.devicectrl.common.DeviceThread.defaultAddressTable);
plc.connect();
plc.isConnected();
plc.write("rodOut1Up");
plc.write("rodIn1Up");
// plc.write("rodOut2Up");
// plc.write("sensorIn2Reset");

View File

@ -11,8 +11,8 @@ import java.util.Map;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.stream.Collectors;
public class HuangZhouScale extends AbsScale {
public HuangZhouScale(String id, String ip, int port) {
public class XiShuiScale extends AbsScale {
public XiShuiScale(String id, String ip, int port) {
super(id, ip, port);
}
@ -31,14 +31,14 @@ public class HuangZhouScale extends AbsScale {
errCount++;
byte[] buf = new byte[9];
byte[] buf = new byte[18];
int read = inputStream.read(buf);
if (read != 9) {
if (read != 18) {
continue;
}
weight = flip(new String(Arrays.copyOfRange(buf, 1, buf.length)));
weight = new String(Arrays.copyOfRange(buf, 4, 10));
break;
}
@ -58,15 +58,15 @@ public class HuangZhouScale extends AbsScale {
while (run.get() && list.size() < 15) {
long st = System.currentTimeMillis();
byte[] buf = new byte[9];
byte[] buf = new byte[18];
int read = inputStream.read(buf);
if (read != 9 && errCount < 10) {
if (read != 18 && errCount < 10) {
errCount++;
continue;
}
String weight = new String(Arrays.copyOfRange(buf, 1, buf.length));
String weight = new String(Arrays.copyOfRange(buf, 4, 10));
if (!pattern.matcher(weight).matches() || weight.equals("000000")) {
// System.out.println("error:" + weight);
@ -78,8 +78,8 @@ public class HuangZhouScale extends AbsScale {
continue;
}
System.out.println("读一次耗时:" + (System.currentTimeMillis() - st) + ", " + Double.parseDouble(flip(weight)));
list.add(flip(weight));
// System.out.println("读一次耗时:" + (System.currentTimeMillis() - st) + ", " + Double.parseDouble(flip(weight)));
list.add(weight);
}
String max = "0";
@ -94,7 +94,7 @@ public class HuangZhouScale extends AbsScale {
public static void main(String[] args) {
HuangZhouScale s = new HuangZhouScale("scale", "192.168.0.189", 10001);
XiShuiScale s = new XiShuiScale("scale", "192.168.20.30", 10001);
try {
boolean connect = s.connect();

View File

@ -246,14 +246,23 @@ public class Config extends JFinalConfig {
}
me.add(new QuartzPlugin());
me.add(new RedisPlugin(
com.cowr.common.Const.REDIS_CACHENAME,
dbprop.get("redis.ip"),
dbprop.getInt("redis.port"),
0
, dbprop.get("redis.pwd")
, dbprop.getInt("redis.db")
));
if (StrKit.notBlank(dbprop.get("redis.pwd"), dbprop.get("redis.db"))) {
me.add(new RedisPlugin(
com.cowr.common.Const.REDIS_CACHENAME,
dbprop.get("redis.ip"),
dbprop.getInt("redis.port"),
0
, dbprop.get("redis.pwd")
, dbprop.getInt("redis.db")
));
} else {
me.add(new RedisPlugin(
com.cowr.common.Const.REDIS_CACHENAME,
dbprop.get("redis.ip"),
dbprop.getInt("redis.port"),
0
));
}
}
@Override
@ -271,7 +280,7 @@ public class Config extends JFinalConfig {
// 让 druid 允许在 sql 中使用 union
// https://github.com/alibaba/druid/wiki/%E9%85%8D%E7%BD%AE-wallfilter
wallFilter.getConfig().setSelectUnionCheck(false);
if("dev".equals(ENV)){
if ("dev".equals(ENV)) {
me.add(new DruidStatViewHandler("/druid"));
}
me.add(new GlobalHandler());
@ -327,7 +336,7 @@ public class Config extends JFinalConfig {
// 最后启动 deviceThread
// if ("prod".equals(ENV)) {
deviceThread.start();
deviceThread.start();
// }
} catch (Exception e) {
log.error(e.getMessage(), e);

View File

@ -2,15 +2,15 @@
devMode=true
#本地服务 和 云端服务 socket 通信
socketserver.enable=true
#socketserver.host=47.112.109.118
socketserver.host=localhost
socketserver.host=47.112.109.118
#socketserver.host=localhost
socketserver.port=21002
#和 web 端的 socket.io 通信端口
socketio.port=12002
#当前部署本地程序的砂站id
current.supermarket_id=6
current.supermarket_id=1
#打印用到的配置信息
print.vendor=浠水县长投环保有限公司

View File

@ -1,16 +1,16 @@
# mysql
# GRANT ALL PRIVILEGES ON *.* TO 'root'@'192.168.1.119' IDENTIFIED BY 'Local_1' WITH GRANT OPTION;
jdbcUrl=jdbc:mysql://rm-wz9wa070076b2uge2ro.mysql.rds.aliyuncs.com:3306/ssjy_xsx_dev?characterEncoding=utf8&useSSL=false&zeroDateTimeBehavior=convertToNull&useInformationSchema=true&serverTimezone=GMT%2B8&autoReconnect=true
user=ssjy_xsx
password=Ssjy_xs_890
#jdbcUrl=jdbc:mysql://rm-wz9wa070076b2uge2ro.mysql.rds.aliyuncs.com:3306/ssjy_xsx_dev?characterEncoding=utf8&useSSL=false&zeroDateTimeBehavior=convertToNull&useInformationSchema=true&serverTimezone=GMT%2B8&autoReconnect=true
#user=ssjy_xsx
#password=Ssjy_xs_890
#jdbcUrl=jdbc:mysql://192.168.1.119:3306/ssjy_xsx_dev?characterEncoding=utf8&useSSL=false&zeroDateTimeBehavior=convertToNull&useInformationSchema=true&serverTimezone=GMT%2B8&autoReconnect=true
#user=root
#password=Local_1
jdbcUrl=jdbc:mysql://localhost:3306/ssjy_xsx_dev?characterEncoding=utf8&useSSL=false&zeroDateTimeBehavior=convertToNull&useInformationSchema=true&serverTimezone=GMT%2B8&autoReconnect=true
user=root
password=Ssjy_xsx_890
# redis
redis.basekey=ssjcgl_xsx_dev
redis.ip=r-wz9168ab2f2f7ec4pd.redis.rds.aliyuncs.com
redis.ip=127.0.0.1
redis.port=6379
redis.pwd=CoWR1111
redis.db=13
redis.pwd=
redis.db=

View File

@ -10,7 +10,7 @@ socketserver.port=21002
socketio.port=12002
#当前部署本地程序的砂站id
current.supermarket_id=6
current.supermarket_id=1
#打印用到的配置信息
print.vendor=浠水县长投环保有限公司