Browse Source

add:添加报警灯交互逻辑

master
涂强 2 weeks ago
parent
commit
ae8098736f
  1. 17
      acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/auto/run/TwoNDCSocketConnectionAutoRun.java
  2. 19
      acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/lamp_three_color/ItemProtocol.java
  3. 8
      acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/lamp_three_color/LampThreecolorDefination.java
  4. 30
      acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/lamp_three_color/LampThreecolorDeviceDriver.java
  5. 19
      acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/task/service/impl/TaskServiceImpl.java

17
acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/auto/run/TwoNDCSocketConnectionAutoRun.java

@ -255,17 +255,22 @@ public class TwoNDCSocketConnectionAutoRun extends AbstractAutoRunnable {
if (ObjectUtil.isNotEmpty(device)) { if (ObjectUtil.isNotEmpty(device)) {
if (device.getDeviceDriver() instanceof StandardAutodoorDeviceDriver) { if (device.getDeviceDriver() instanceof StandardAutodoorDeviceDriver) {
standardAutodoorDeviceDriver = (StandardAutodoorDeviceDriver) device.getDeviceDriver(); standardAutodoorDeviceDriver = (StandardAutodoorDeviceDriver) device.getDeviceDriver();
if(device_code.equals("AD1")||device_code.equals("AD2")||device_code.equals("AD3")||device_code.equals("AD4")) { if (device_code.equals("AD1") || device_code.equals("AD2") || device_code.equals("AD3") || device_code.equals("AD4")) {
standardAutodoorDeviceDriver.writing("to_command", 1); standardAutodoorDeviceDriver.writing("to_command", 1);
if (standardAutodoorDeviceDriver.getDoor() == 1) { if (standardAutodoorDeviceDriver.getDoor() == 1) {
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0); data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
} else { } else {
log.info("未下发NDC信号原因: 读取开门到位信号值为:{}", standardAutodoorDeviceDriver.getDoor()); 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); standardAutodoorDeviceDriver.writing("to_command", 1);
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0); 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 { } else {
log.info(agvaddr + "对应设备号为空!"); log.info(agvaddr + "对应设备号为空!");
@ -278,8 +283,8 @@ public class TwoNDCSocketConnectionAutoRun extends AbstractAutoRunnable {
} }
device = deviceAppService.findDeviceByCode(device_code); device = deviceAppService.findDeviceByCode(device_code);
if (ObjectUtil.isNotEmpty(device)) { if (ObjectUtil.isNotEmpty(device)) {
standardAutodoorDeviceDriver = (StandardAutodoorDeviceDriver) device.getDeviceDriver();
if (device.getDeviceDriver() instanceof StandardAutodoorDeviceDriver) { if (device.getDeviceDriver() instanceof StandardAutodoorDeviceDriver) {
standardAutodoorDeviceDriver = (StandardAutodoorDeviceDriver) device.getDeviceDriver();
standardAutodoorDeviceDriver.writing("to_command", 2); standardAutodoorDeviceDriver.writing("to_command", 2);
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0); data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
} }
@ -359,13 +364,13 @@ public class TwoNDCSocketConnectionAutoRun extends AbstractAutoRunnable {
dos.flush(); dos.flush();
} catch (Exception e) { } catch (Exception e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
try{ try {
Thread.sleep(5000); Thread.sleep(5000);
log.info("再次下发agv数据:" + Bytes2HexString(b)); log.info("再次下发agv数据:" + Bytes2HexString(b));
System.out.println("再次下发agv数据:" + Bytes2HexString(b)); System.out.println("再次下发agv数据:" + Bytes2HexString(b));
dos.write(b); dos.write(b);
dos.flush(); dos.flush();
} catch (Exception e1){ } catch (Exception e1) {
e1.printStackTrace(); e1.printStackTrace();
} }

19
acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/lamp_three_color/ItemProtocol.java

@ -9,7 +9,10 @@ import java.util.List;
@Slf4j @Slf4j
public class ItemProtocol { public class ItemProtocol {
public static String item_heartbeat = "heartbeat";
public static String item_mode = "mode"; 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"; public static String item_to_command = "to_command";
@ -19,10 +22,22 @@ public class ItemProtocol {
this.driver = driver; this.driver = driver;
} }
public int getHeartbeat() {
return this.getOpcIntegerValue(item_heartbeat);
}
public int getMode() { public int getMode() {
return this.getOpcIntegerValue(item_mode); return this.getOpcIntegerValue(item_mode);
} }
public int getAction() {
return this.getOpcIntegerValue(item_action);
}
public int getError() {
return this.getOpcIntegerValue(item_error);
}
public int getToCommand() { public int getToCommand() {
return this.getOpcIntegerValue(item_to_command); return this.getOpcIntegerValue(item_to_command);
} }
@ -31,6 +46,7 @@ public class ItemProtocol {
public int getOpcIntegerValue(String protocol) { public int getOpcIntegerValue(String protocol) {
Integer value = this.driver.getIntegeregerValue(protocol); Integer value = this.driver.getIntegeregerValue(protocol);
if (value == null) { if (value == null) {
log.error("读取错误!");
} else { } else {
return value; return value;
} }
@ -40,13 +56,12 @@ public class ItemProtocol {
public static List<ItemDto> getReadableItemDtos() { public static List<ItemDto> getReadableItemDtos() {
ArrayList list = new ArrayList(); ArrayList list = new ArrayList();
list.add(new ItemDto(item_mode, "模式", "08010")); list.add(new ItemDto(item_action, "动作信号", "DB51.B3"));
return list; return list;
} }
public static List<ItemDto> getWriteableItemDtos() { public static List<ItemDto> getWriteableItemDtos() {
ArrayList list = new ArrayList(); ArrayList list = new ArrayList();
list.add(new ItemDto(item_to_command, "作业命令", "08011"));
return list; return list;
} }

8
acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/lamp_three_color/LampThreecolorDefination.java

@ -7,6 +7,7 @@ import org.nl.acs.device_driver.DeviceDriver;
import org.nl.acs.device_driver.defination.OpcDeviceDriverDefination; import org.nl.acs.device_driver.defination.OpcDeviceDriverDefination;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
@ -51,9 +52,14 @@ public class LampThreecolorDefination implements OpcDeviceDriverDefination {
@Override @Override
public List<ItemDto> getReadableItemDtos() { 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 @Override
public List<ItemDto> getWriteableItemDtos() { public List<ItemDto> getWriteableItemDtos() {

30
acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/lamp_three_color/LampThreecolorDeviceDriver.java

@ -30,10 +30,14 @@ public class LampThreecolorDeviceDriver extends AbstractOpcDeviceDriver implemen
DeviceExecuteLogService logServer = SpringContextHolder.getBean(DeviceExecuteLogService.class); DeviceExecuteLogService logServer = SpringContextHolder.getBean(DeviceExecuteLogService.class);
@Autowired @Autowired
LuceneExecuteLogService luceneExecuteLogService = SpringContextHolder.getBean(LuceneExecuteLogService.class); LuceneExecuteLogService luceneExecuteLogService = SpringContextHolder.getBean(LuceneExecuteLogService.class);
int mode;
int to_command; int to_command;
int last_mode;
int last_to_command; 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 @Override
public void execute() { public void execute() {
String message = null; 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) { public void writing(String param, String value) {

19
acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/task/service/impl/TaskServiceImpl.java

@ -587,8 +587,6 @@ public class TaskServiceImpl extends CommonServiceImpl<TaskMapper, Task> impleme
task_code = CodeUtil.getNewCode("TASK_NO"); task_code = CodeUtil.getNewCode("TASK_NO");
task_code = CommonFinalParam.HYPHEN_ + task_code; 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(); String route_plan_code = dto.getRoute_plan_code();
dto.setCreate_by(StrUtil.isNotEmpty(currentUsername) ? currentUsername : "LMS"); dto.setCreate_by(StrUtil.isNotEmpty(currentUsername) ? currentUsername : "LMS");
dto.setUpdate_by(currentUsername); dto.setUpdate_by(currentUsername);
@ -597,10 +595,15 @@ public class TaskServiceImpl extends CommonServiceImpl<TaskMapper, Task> impleme
dto.setTask_code(task_code); dto.setTask_code(task_code);
dto.setRoute_plan_code(route_plan_code); dto.setRoute_plan_code(route_plan_code);
dto.setTask_status(TaskStatusEnum.READY.getIndex()); dto.setTask_status(TaskStatusEnum.READY.getIndex());
dto.setStart_point_code(start_device_code); if (StrUtil.isNotEmpty(dto.getStart_point_code())&&StrUtil.isNotEmpty(dto.getNext_point_code())){
dto.setNext_point_code(next_device_code); dto.setStart_device_code(dto.getStart_point_code());
dto.setStart_device_code(start_device_code); dto.setNext_device_code(dto.getNext_point_code());
dto.setNext_device_code(next_device_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())) { if (StrUtil.isEmpty(dto.getPriority())) {
dto.setPriority(CommonFinalParam.ONE); dto.setPriority(CommonFinalParam.ONE);
} }
@ -614,12 +617,12 @@ public class TaskServiceImpl extends CommonServiceImpl<TaskMapper, Task> impleme
} }
DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class);
Device nextdevice = appService.findDeviceByCode(next_device_code); Device nextdevice = appService.findDeviceByCode(dto.getNext_device_code());
if (nextdevice == null) { if (nextdevice == null) {
//TODO 国际化处理 //TODO 国际化处理
throw new BadRequestException("终点设备未配置"); throw new BadRequestException("终点设备未配置");
} }
Device startdevice = appService.findDeviceByCode(start_device_code); Device startdevice = appService.findDeviceByCode(dto.getStart_device_code());
if (startdevice == null) { if (startdevice == null) {
//TODO 国际化处理 //TODO 国际化处理
throw new BadRequestException("起点设备未配置"); throw new BadRequestException("起点设备未配置");

Loading…
Cancel
Save