堆垛机读取修改
This commit is contained in:
@@ -100,6 +100,9 @@ public class MsgDdj extends BaseEntity
|
||||
|
||||
private String plcDbReadAddress;
|
||||
|
||||
private String ip;
|
||||
private String port;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -40,6 +40,8 @@ public class DeviceSsj extends BaseEntity
|
||||
@Excel(name = "设备IP")
|
||||
private String ipAddress;
|
||||
|
||||
private String port;
|
||||
|
||||
/** PLC读取地址 */
|
||||
@Excel(name = "PLC读取地址")
|
||||
private String plcDbReadAddress;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.ruoyi.schedule;
|
||||
|
||||
import com.ruoyi.common.core.text.Convert;
|
||||
import com.ruoyi.device.ddj.domain.MsgDdj;
|
||||
import com.ruoyi.device.ddj.service.IMsgDdjService;
|
||||
import com.ruoyi.device.ssj.domain.DeviceSsj;
|
||||
@@ -101,29 +102,29 @@ public class ScheduleThread {
|
||||
for (DeviceSsj deviceSsj : deviceSsjs) {
|
||||
ssjList.put(deviceSsj.getDeviceCode(), deviceSsj);
|
||||
}
|
||||
PlcSsjRead plcSsjRead = new PlcSsjRead(ssjList, new PlcConnectInfo(deviceSsjs.get(0).getIpAddress(), Convert.toInt(deviceSsjs.get(0).getPort())));
|
||||
Thread plcSsjReadThread = new Thread(plcSsjRead);
|
||||
plcSsjReadCustomThread = new CustomThread<PlcSsjRead>(plcSsjReadThread, plcSsjRead);
|
||||
PlcSsjRead.deviceSsjMap = ssjList;
|
||||
|
||||
|
||||
|
||||
//获取堆垛机
|
||||
ConcurrentHashMap<String, MsgDdj> ddjList = new ConcurrentHashMap<>();
|
||||
List<MsgDdj> msgDdjs = msgDdjService.selectMsgDdjList(new MsgDdj());
|
||||
for (MsgDdj msgDdj : msgDdjs) {
|
||||
msgDdj.setPlcDbReadAddress(msgDdj.getPlcDbReadAddress());
|
||||
PlcDdjRead plcDdjRead = new PlcDdjRead(msgDdj, new PlcConnectInfo(msgDdj.getIp(), Convert.toInt(msgDdj.getPort())));
|
||||
Thread plcDdjReadThread = new Thread(plcDdjRead);
|
||||
switch (msgDdj.getId()){
|
||||
case 1:
|
||||
msgDdj.setPlcDbReadAddress("DB41.0");
|
||||
PlcDdjRead plcDdjRead1 = new PlcDdjRead(ddjList, new PlcConnectInfo("127.0.0.1", 102));
|
||||
Thread plcDdjReadThread1 = new Thread(plcDdjRead1);
|
||||
plcDdj1ReadCustomThread = new CustomThread<PlcDdjRead>(plcDdjReadThread1, plcDdjRead1);
|
||||
plcDdj1ReadCustomThread = new CustomThread<PlcDdjRead>(plcDdjReadThread, plcDdjRead);
|
||||
break;
|
||||
case 2:
|
||||
msgDdj.setPlcDbReadAddress("DB42.0");
|
||||
PlcDdjRead plcDdjRead2 = new PlcDdjRead(ddjList, new PlcConnectInfo("127.0.0.2", 102));
|
||||
Thread plcDdjReadThread2 = new Thread(plcDdjRead2);
|
||||
plcDdj2ReadCustomThread = new CustomThread<PlcDdjRead>(plcDdjReadThread2, plcDdjRead2);
|
||||
plcDdj2ReadCustomThread = new CustomThread<PlcDdjRead>(plcDdjReadThread, plcDdjRead);
|
||||
break;
|
||||
|
||||
}
|
||||
ddjList.put("ddj" + msgDdj.getId(), msgDdj);
|
||||
}
|
||||
PlcDdjRead.deviceDdjMap = ddjList;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -26,9 +26,10 @@ public class PlcDdjRead extends Thread {
|
||||
private final String ip;
|
||||
private final int port;
|
||||
private boolean success = false;
|
||||
private MsgDdj msgDdj;
|
||||
|
||||
public PlcDdjRead(ConcurrentHashMap<String, MsgDdj> deviceDdjMap, PlcConnectInfo plcConnectInfo) {
|
||||
PlcDdjRead.deviceDdjMap = deviceDdjMap;
|
||||
public PlcDdjRead(MsgDdj msgDdj, PlcConnectInfo plcConnectInfo) {
|
||||
this.msgDdj = msgDdj;
|
||||
this.ip = plcConnectInfo.getIp();
|
||||
this.port = plcConnectInfo.getPort();
|
||||
}
|
||||
@@ -46,12 +47,7 @@ public class PlcDdjRead extends Thread {
|
||||
while (isRun) {
|
||||
try {
|
||||
if (IsConnect()) {
|
||||
for (String key : deviceDdjMap.keySet()) {
|
||||
MsgDdj msgDdj = deviceDdjMap.get(key);
|
||||
if (msgDdj != null) {
|
||||
readPlcDdj(msgDdj);
|
||||
}
|
||||
}
|
||||
Thread.sleep(1000);
|
||||
} else {
|
||||
reConnect();
|
||||
|
||||
@@ -315,7 +315,7 @@ export default {
|
||||
this.initMockData()
|
||||
},
|
||||
mounted() {
|
||||
this.timer = setInterval(() => {
|
||||
this.timer = setInterval(() => {x
|
||||
this.initMockData();
|
||||
}, 1000); // 每1秒刷新一次
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user