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