Commit b09d5a05 authored by wanghao's avatar wanghao

1 指令指令完成,但是 没有检测到机械臂完成。

parent d22727dd
......@@ -148,13 +148,16 @@ public class ModbusResultHandler implements Consumer<DeviceStatusReaderDto> {
} catch (ModbusInitException e) {
log.error("Modbus初始化异常:ip={}, port={}", ip, port, e);
palletDeviceBinding.setStatus("5");
recordAlarm(palletDeviceBinding, "Modbus初始化失败:" + e.getMessage());
} catch (ModbusTransportException e) {
log.error("Modbus传输异常:ip={}, port={}, deviceId={}", ip, port, deviceId, e);
palletDeviceBinding.setStatus("5");
recordAlarm(palletDeviceBinding, "Modbus写时间失败:" + e.getMessage());
} catch (Exception e) {
// 捕获其他异常(如NPE、数据溢出)
log.error("处理Modbus数据异常:ip={}, port={}, deviceId={}", ip, port, deviceId, e);
palletDeviceBinding.setStatus("5");
recordAlarm(palletDeviceBinding, "数据处理异常:" + e.getMessage());
} finally {
// 关键:关闭Modbus连接,避免资源泄漏
......@@ -300,7 +303,6 @@ public class ModbusResultHandler implements Consumer<DeviceStatusReaderDto> {
return str == null || str.trim().isEmpty();
}
}
// 创建通用的停止条件(可选)
public static Predicate<int[]> createDefaultStopCondition() {
return values -> values.length >= 2 && values[1] == DeviceStatusReaderAndTimeSetter.TARGET_VALUE;
......
......@@ -21,8 +21,7 @@ public class DeviceComm501Device1Job extends BaseDeviceCommJob {
}
@Override
protected List<Integer> getDeviceIds() {
// 端口501对应的设备ID列表
return Collections.singletonList(1);
protected int getDeviceId() {
return 1;
}
}
......@@ -20,8 +20,7 @@ public class DeviceComm501Device2Job extends BaseDeviceCommJob {
}
@Override
protected List<Integer> getDeviceIds() {
// 端口501对应的设备ID列表
return Collections.singletonList(2);
protected int getDeviceId() {
return 2;
}
}
......@@ -20,8 +20,7 @@ public class DeviceComm501Device3Job extends BaseDeviceCommJob {
}
@Override
protected List<Integer> getDeviceIds() {
// 端口501对应的设备ID列表
return Collections.singletonList(3);
protected int getDeviceId() {
return 3;
}
}
package com.zehong.system.task.DeviceCommJob;
import com.zehong.system.task.BaseDeviceCommJob;
import org.springframework.stereotype.Component;
import java.util.Arrays;
import java.util.List;
/**
* @author lenovo
* @date 2025/9/25
* @description TODO
*/
@Component
public class DeviceComm501Job extends BaseDeviceCommJob {
@Override
protected int getFixedPort() {
return 501; // 固定端口501
}
@Override
protected List<Integer> getDeviceIds() {
// 端口501对应的设备ID列表
return Arrays.asList(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27);
}
}
package com.zehong.system.task.DeviceCommJob;
import com.zehong.system.task.BaseDeviceCommJob;
import org.springframework.stereotype.Component;
import java.util.Arrays;
import java.util.List;
/**
* @author lenovo
* @date 2025/9/25
* @description TODO
*/
@Component
public class DeviceComm502Job extends BaseDeviceCommJob {
@Override
protected int getFixedPort() {
return 502; // 固定端口502
}
@Override
protected List<Integer> getDeviceIds() {
// 端口502对应的设备ID列表
return Arrays.asList(28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54);
}
}
package com.zehong.system.task.DeviceCommJob;
import com.zehong.system.task.BaseDeviceCommJob;
import org.springframework.stereotype.Component;
import java.util.Arrays;
import java.util.List;
/**
* @author lenovo
* @date 2025/9/25
* @description TODO
*/
@Component
public class DeviceComm503Job extends BaseDeviceCommJob {
@Override
protected int getFixedPort() {
return 503; // 固定端口503
}
@Override
protected List<Integer> getDeviceIds() {
// 端口503对应的设备ID列表
return Arrays.asList(55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment