|
|
|
@ -62,15 +62,15 @@ public class CollectUtils { |
|
|
|
* @param defaultValue 未读取到数据时的默认值 |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
public static List<DeviceVo> getReadXMZValueList(List<Device> deviceList,String IP,BigDecimal defaultValue){ |
|
|
|
public static List<DeviceVo> getReadXMZValueList(List<DeviceVo> deviceList,String IP,BigDecimal defaultValue){ |
|
|
|
SiemensS7Net siemensS7Net = new SiemensS7Net(SiemensPLCS.S1200,IP); |
|
|
|
OperateResult connect = siemensS7Net.ConnectServer(); |
|
|
|
List<DeviceVo> deviceVoList = new ArrayList<>(); |
|
|
|
if (connect.IsSuccess) { |
|
|
|
log.info("IP:{} 连接成功!!!", IP); |
|
|
|
for (Device device : deviceList) { |
|
|
|
for (DeviceVo device : deviceList) { |
|
|
|
int i = readXMZValue(siemensS7Net, device.getDeviceIp()); |
|
|
|
deviceVoList.add(new DeviceVo(device, new BigDecimal(i))); |
|
|
|
deviceVoList.add(new DeviceVo(device, new BigDecimal(i),device.getCollectId())); |
|
|
|
log.info("设备:{} 读取值:{}", device.getDeviceDesc(), i); |
|
|
|
} |
|
|
|
siemensS7Net.ConnectClose(); |
|
|
|
@ -78,7 +78,7 @@ public class CollectUtils { |
|
|
|
log.info("IP:{} 连接失败!!!", IP); |
|
|
|
log.info("设置默认值:{}",defaultValue); |
|
|
|
deviceList.forEach(device -> { |
|
|
|
deviceVoList.add(new DeviceVo(device, new BigDecimal(0))); |
|
|
|
deviceVoList.add(new DeviceVo(device, new BigDecimal(0),device.getCollectId())); |
|
|
|
}); |
|
|
|
} |
|
|
|
return deviceVoList; |
|
|
|
@ -92,15 +92,15 @@ public class CollectUtils { |
|
|
|
* @param defaultValue 未读取到数据时的默认值 |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
public static List<DeviceVo> getReadSLValueList(List<Device> deviceList,String IP,int port,BigDecimal defaultValue){ |
|
|
|
public static List<DeviceVo> getReadSLValueList(List<DeviceVo> deviceList,String IP,int port,BigDecimal defaultValue){ |
|
|
|
MelsecMcNet melsecMcNet = new MelsecMcNet(IP, port); |
|
|
|
OperateResult connect = melsecMcNet.ConnectServer(); |
|
|
|
List<DeviceVo> deviceVoList = new ArrayList<>(); |
|
|
|
if (connect.IsSuccess) { |
|
|
|
log.info("IP:{} 连接成功!!!", IP); |
|
|
|
for (Device device : deviceList) { |
|
|
|
for (DeviceVo device : deviceList) { |
|
|
|
int i = readSLValue(melsecMcNet, device.getDeviceIp()); |
|
|
|
deviceVoList.add(new DeviceVo(device, new BigDecimal(i))); |
|
|
|
deviceVoList.add(new DeviceVo(device, new BigDecimal(i),device.getCollectId())); |
|
|
|
log.info("设备:{} 读取值:{}", device.getDeviceDesc(), i); |
|
|
|
} |
|
|
|
melsecMcNet.ConnectClose(); |
|
|
|
@ -108,7 +108,7 @@ public class CollectUtils { |
|
|
|
log.info("IP:{} 连接失败!!!", IP); |
|
|
|
log.info("设置默认值:{}",defaultValue); |
|
|
|
deviceList.forEach(device -> { |
|
|
|
deviceVoList.add(new DeviceVo(device, new BigDecimal(0))); |
|
|
|
deviceVoList.add(new DeviceVo(device, new BigDecimal(0),device.getCollectId())); |
|
|
|
}); |
|
|
|
} |
|
|
|
return deviceVoList; |
|
|
|
@ -122,11 +122,11 @@ public class CollectUtils { |
|
|
|
* @param defaultValue |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
public static List<DeviceVo> getReadValueList(List<Device> deviceList,String IP,BigDecimal defaultValue){ |
|
|
|
public static List<DeviceVo> getReadValueList(List<DeviceVo> deviceList,String IP,BigDecimal defaultValue){ |
|
|
|
// 目前未出现逻辑 |
|
|
|
List<DeviceVo> deviceVoList = new ArrayList<>(); |
|
|
|
deviceList.forEach(device -> { |
|
|
|
deviceVoList.add(new DeviceVo(device, new BigDecimal(0))); |
|
|
|
deviceVoList.add(new DeviceVo(device, new BigDecimal(0),device.getCollectId())); |
|
|
|
}); |
|
|
|
return deviceVoList; |
|
|
|
} |
|
|
|
|