add:添加报警灯交互逻辑
This commit is contained in:
@@ -255,17 +255,22 @@ public class TwoNDCSocketConnectionAutoRun extends AbstractAutoRunnable {
|
||||
if (ObjectUtil.isNotEmpty(device)) {
|
||||
if (device.getDeviceDriver() instanceof StandardAutodoorDeviceDriver) {
|
||||
standardAutodoorDeviceDriver = (StandardAutodoorDeviceDriver) device.getDeviceDriver();
|
||||
if(device_code.equals("AD1")||device_code.equals("AD2")||device_code.equals("AD3")||device_code.equals("AD4")) {
|
||||
standardAutodoorDeviceDriver.writing("to_command", 1);
|
||||
if (device_code.equals("AD1") || device_code.equals("AD2") || device_code.equals("AD3") || device_code.equals("AD4")) {
|
||||
standardAutodoorDeviceDriver.writing("to_command", 1);
|
||||
if (standardAutodoorDeviceDriver.getDoor() == 1) {
|
||||
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
|
||||
} else {
|
||||
log.info("未下发NDC信号原因: 读取开门到位信号值为:{}", standardAutodoorDeviceDriver.getDoor());
|
||||
}
|
||||
}else if(device_code.equals("AD5")||device_code.equals("AD6")||device_code.equals("AD7")||device_code.equals("AD8")||device_code.equals("AD9")) {
|
||||
} else if (device_code.equals("AD5") || device_code.equals("AD6") || device_code.equals("AD7") || device_code.equals("AD8") || device_code.equals("AD9")) {
|
||||
standardAutodoorDeviceDriver.writing("to_command", 1);
|
||||
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
|
||||
}
|
||||
} else if (device.getDeviceDriver() instanceof LampThreecolorDeviceDriver) {
|
||||
lampThreecolorDeviceDriver = (LampThreecolorDeviceDriver) device.getDeviceDriver();
|
||||
if (lampThreecolorDeviceDriver.getAction() == 1) {
|
||||
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
log.info(agvaddr + "对应设备号为空!");
|
||||
@@ -278,8 +283,8 @@ public class TwoNDCSocketConnectionAutoRun extends AbstractAutoRunnable {
|
||||
}
|
||||
device = deviceAppService.findDeviceByCode(device_code);
|
||||
if (ObjectUtil.isNotEmpty(device)) {
|
||||
standardAutodoorDeviceDriver = (StandardAutodoorDeviceDriver) device.getDeviceDriver();
|
||||
if (device.getDeviceDriver() instanceof StandardAutodoorDeviceDriver) {
|
||||
standardAutodoorDeviceDriver = (StandardAutodoorDeviceDriver) device.getDeviceDriver();
|
||||
standardAutodoorDeviceDriver.writing("to_command", 2);
|
||||
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
|
||||
}
|
||||
@@ -359,13 +364,13 @@ public class TwoNDCSocketConnectionAutoRun extends AbstractAutoRunnable {
|
||||
dos.flush();
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
try{
|
||||
try {
|
||||
Thread.sleep(5000);
|
||||
log.info("再次下发agv数据:" + Bytes2HexString(b));
|
||||
System.out.println("再次下发agv数据:" + Bytes2HexString(b));
|
||||
dos.write(b);
|
||||
dos.flush();
|
||||
} catch (Exception e1){
|
||||
} catch (Exception e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,10 @@ import java.util.List;
|
||||
@Slf4j
|
||||
public class ItemProtocol {
|
||||
|
||||
public static String item_heartbeat = "heartbeat";
|
||||
public static String item_mode = "mode";
|
||||
public static String item_action = "action";
|
||||
public static String item_error = "error";
|
||||
public static String item_to_command = "to_command";
|
||||
|
||||
|
||||
@@ -19,10 +22,22 @@ public class ItemProtocol {
|
||||
this.driver = driver;
|
||||
}
|
||||
|
||||
public int getHeartbeat() {
|
||||
return this.getOpcIntegerValue(item_heartbeat);
|
||||
}
|
||||
|
||||
public int getMode() {
|
||||
return this.getOpcIntegerValue(item_mode);
|
||||
}
|
||||
|
||||
public int getAction() {
|
||||
return this.getOpcIntegerValue(item_action);
|
||||
}
|
||||
|
||||
public int getError() {
|
||||
return this.getOpcIntegerValue(item_error);
|
||||
}
|
||||
|
||||
public int getToCommand() {
|
||||
return this.getOpcIntegerValue(item_to_command);
|
||||
}
|
||||
@@ -31,6 +46,7 @@ public class ItemProtocol {
|
||||
public int getOpcIntegerValue(String protocol) {
|
||||
Integer value = this.driver.getIntegeregerValue(protocol);
|
||||
if (value == null) {
|
||||
log.error("读取错误!");
|
||||
} else {
|
||||
return value;
|
||||
}
|
||||
@@ -40,13 +56,12 @@ public class ItemProtocol {
|
||||
|
||||
public static List<ItemDto> getReadableItemDtos() {
|
||||
ArrayList list = new ArrayList();
|
||||
list.add(new ItemDto(item_mode, "模式", "08010"));
|
||||
list.add(new ItemDto(item_action, "动作信号", "DB51.B3"));
|
||||
return list;
|
||||
}
|
||||
|
||||
public static List<ItemDto> getWriteableItemDtos() {
|
||||
ArrayList list = new ArrayList();
|
||||
list.add(new ItemDto(item_to_command, "作业命令", "08011"));
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ import org.nl.acs.device_driver.DeviceDriver;
|
||||
import org.nl.acs.device_driver.defination.OpcDeviceDriverDefination;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
@@ -51,9 +52,14 @@ public class LampThreecolorDefination implements OpcDeviceDriverDefination {
|
||||
|
||||
@Override
|
||||
public List<ItemDto> getReadableItemDtos() {
|
||||
return ItemProtocol.getReadableItemDtos();
|
||||
return getReadableItemDtos2();
|
||||
}
|
||||
|
||||
public static List<ItemDto> getReadableItemDtos2() {
|
||||
List<ItemDto> list = new ArrayList();
|
||||
list.add(new ItemDto(ItemProtocol.item_action, "动作信号", "DB600.B3"));
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemDto> getWriteableItemDtos() {
|
||||
|
||||
@@ -30,10 +30,14 @@ public class LampThreecolorDeviceDriver extends AbstractOpcDeviceDriver implemen
|
||||
DeviceExecuteLogService logServer = SpringContextHolder.getBean(DeviceExecuteLogService.class);
|
||||
@Autowired
|
||||
LuceneExecuteLogService luceneExecuteLogService = SpringContextHolder.getBean(LuceneExecuteLogService.class);
|
||||
int mode;
|
||||
int to_command;
|
||||
int last_mode;
|
||||
int last_to_command;
|
||||
int mode = 0;
|
||||
int action = 0;
|
||||
int error = 0;
|
||||
int last_action = 0;
|
||||
int last_mode = 0;
|
||||
int last_error = 0;
|
||||
/**
|
||||
* 放货准备锁
|
||||
*/
|
||||
@@ -82,12 +86,24 @@ public class LampThreecolorDeviceDriver extends AbstractOpcDeviceDriver implemen
|
||||
@Override
|
||||
public void execute() {
|
||||
String message = null;
|
||||
device_code = this.getDevice().getDevice_code();
|
||||
mode = this.itemProtocol.getOpcIntegerValue(ItemProtocol.item_mode);
|
||||
to_command = this.itemProtocol.getOpcIntegerValue(ItemProtocol.item_to_command);
|
||||
last_mode = mode;
|
||||
last_to_command = to_command;
|
||||
|
||||
String device_code = this.getDevice().getDevice_code();
|
||||
mode = this.itemProtocol.getMode();
|
||||
action = this.itemProtocol.getAction();
|
||||
error = this.itemProtocol.getError();
|
||||
if (mode != last_mode) {
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "信号mode:" + last_mode + "->" + mode);
|
||||
}
|
||||
if (action != last_action) {
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "action:" + last_action + "->" + action);
|
||||
}
|
||||
if (error != last_error) {
|
||||
//this.execute_log.setContainer("");
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "error:" + last_error + "->" + error);
|
||||
}
|
||||
last_action = action;
|
||||
last_mode = mode;
|
||||
last_error = error;
|
||||
}
|
||||
|
||||
public void writing(String param, String value) {
|
||||
|
||||
@@ -587,8 +587,6 @@ public class TaskServiceImpl extends CommonServiceImpl<TaskMapper, Task> impleme
|
||||
task_code = CodeUtil.getNewCode("TASK_NO");
|
||||
task_code = CommonFinalParam.HYPHEN_ + task_code;
|
||||
}
|
||||
String start_device_code = dto.getStart_device_code();
|
||||
String next_device_code = dto.getNext_device_code();
|
||||
String route_plan_code = dto.getRoute_plan_code();
|
||||
dto.setCreate_by(StrUtil.isNotEmpty(currentUsername) ? currentUsername : "LMS");
|
||||
dto.setUpdate_by(currentUsername);
|
||||
@@ -597,10 +595,15 @@ public class TaskServiceImpl extends CommonServiceImpl<TaskMapper, Task> impleme
|
||||
dto.setTask_code(task_code);
|
||||
dto.setRoute_plan_code(route_plan_code);
|
||||
dto.setTask_status(TaskStatusEnum.READY.getIndex());
|
||||
dto.setStart_point_code(start_device_code);
|
||||
dto.setNext_point_code(next_device_code);
|
||||
dto.setStart_device_code(start_device_code);
|
||||
dto.setNext_device_code(next_device_code);
|
||||
if (StrUtil.isNotEmpty(dto.getStart_point_code())&&StrUtil.isNotEmpty(dto.getNext_point_code())){
|
||||
dto.setStart_device_code(dto.getStart_point_code());
|
||||
dto.setNext_device_code(dto.getNext_point_code());
|
||||
}
|
||||
if (StrUtil.isNotEmpty(dto.getStart_device_code())&&StrUtil.isNotEmpty(dto.getNext_device_code())) {
|
||||
dto.setStart_point_code(dto.getStart_device_code());
|
||||
dto.setNext_point_code(dto.getNext_device_code());
|
||||
}
|
||||
|
||||
if (StrUtil.isEmpty(dto.getPriority())) {
|
||||
dto.setPriority(CommonFinalParam.ONE);
|
||||
}
|
||||
@@ -614,12 +617,12 @@ public class TaskServiceImpl extends CommonServiceImpl<TaskMapper, Task> impleme
|
||||
}
|
||||
|
||||
DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class);
|
||||
Device nextdevice = appService.findDeviceByCode(next_device_code);
|
||||
Device nextdevice = appService.findDeviceByCode(dto.getNext_device_code());
|
||||
if (nextdevice == null) {
|
||||
//TODO 国际化处理
|
||||
throw new BadRequestException("终点设备未配置");
|
||||
}
|
||||
Device startdevice = appService.findDeviceByCode(start_device_code);
|
||||
Device startdevice = appService.findDeviceByCode(dto.getStart_device_code());
|
||||
if (startdevice == null) {
|
||||
//TODO 国际化处理
|
||||
throw new BadRequestException("起点设备未配置");
|
||||
|
||||
Reference in New Issue
Block a user