opt: AGV下发任务优化

This commit is contained in:
yanps
2024-04-01 09:00:48 +08:00
parent b4e31c71a2
commit 2757ee6655
3 changed files with 219 additions and 49 deletions

View File

@@ -80,55 +80,191 @@ public class NDCAgvServiceImpl implements NDCAgvService {
log.info("sendAgvInstToNDC 指令下发NDC:" + "inst_code:" + inst.getInstruction_code() + ",agv_system_type:" + agv_system_type + ",agv_inst_type:" + inst.getAgv_inst_type() + log.info("sendAgvInstToNDC 指令下发NDC:" + "inst_code:" + inst.getInstruction_code() + ",agv_system_type:" + agv_system_type + ",agv_inst_type:" + inst.getAgv_inst_type() +
",priority:" + inst.getPriority() + ",startAddress:" + inst.getStart_point_code() + ",priority:" + inst.getPriority() + ",startAddress:" + inst.getStart_point_code() +
",nextAddress:" + inst.getNext_point_code()); ",nextAddress:" + inst.getNext_point_code());
if (StrUtil.equals(paramService.findByCode(AcsConfig.FORKAGV).getValue(), CommonFinalParam.ONE)) { if (StrUtil.equals(paramService.findByCode(AcsConfig.FORKAGV).getValue(), "1")) {
String instcode = inst.getInstruction_code(); if (!StrUtil.equals(agv_system_type, "1")) {
int type = Integer.parseInt(inst.getInstruction_type()); String instcode = inst.getInstruction_code();
int priority = Integer.parseInt(inst.getPriority()) + 128; int type = Integer.parseInt(inst.getAgv_inst_type());
DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); int priority = Integer.parseInt(inst.getPriority()) + 128;
DeviceService deviceService = SpringContextHolder.getBean(DeviceServiceImpl.class); DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class);
int startAddress = deviceService.queryAddressBydeviceCode(inst.getStart_point_code()); DeviceService deviceService = SpringContextHolder.getBean(DeviceServiceImpl.class);
int nextAddress = deviceService.queryAddressBydeviceCode(inst.getNext_point_code()); int startAddress = deviceService.queryAddressBydeviceCode(inst.getStart_point_code());
byte ikeyhigh = (byte) IntToHexHigh(Integer.parseInt(instcode)); int nextAddress = deviceService.queryAddressBydeviceCode(inst.getNext_point_code());
byte ikeylow = (byte) IntToHexLow(Integer.parseInt(instcode)); int startAddress2 = deviceService.queryAddressBydeviceCode(inst.getStart_point_code2());
byte typehigh = (byte) IntToHexHigh(type); int nextAddress2 = deviceService.queryAddressBydeviceCode(inst.getNext_point_code2());
byte typelow = (byte) IntToHexLow(type); byte ikeyhigh = (byte) IntToHexHigh(Integer.parseInt(instcode));
byte qhdhigh = (byte) IntToHexHigh(startAddress); byte ikeylow = (byte) IntToHexLow(Integer.parseInt(instcode));
byte qhdlow = (byte) IntToHexLow(startAddress); byte typehigh = (byte) IntToHexHigh(type);
byte fhdhigh = (byte) IntToHexHigh(nextAddress); byte typelow = (byte) IntToHexLow(type);
byte fhdlow = (byte) IntToHexLow(nextAddress); byte qhdhigh = (byte) IntToHexHigh(startAddress);
byte prioritylow = (byte) IntToHexLow(priority); byte qhdlow = (byte) IntToHexLow(startAddress);
String str = "十进制下发:"; byte qhdhigh2 = (byte) IntToHexHigh(startAddress2);
String str1 = "十六进制下发:"; byte qhdlow2 = (byte) IntToHexLow(startAddress2);
str += "ikey:" + (Integer.parseInt(instcode)); byte fhdhigh = (byte) IntToHexHigh(nextAddress);
str1 += "ikey:" + hexToString(ikeyhigh & 0xFF) + hexToString(ikeylow & 0xFF); byte fhdlow = (byte) IntToHexLow(nextAddress);
str += "/type:" + (type); byte fhdhigh2 = (byte) IntToHexHigh(nextAddress2);
str1 += "/type:" + hexToString(typehigh & 0xFF) + hexToString(typelow & 0xFF); byte fhdlow2 = (byte) IntToHexLow(nextAddress2);
str += "/qhd:" + (startAddress); byte prioritylow = (byte) IntToHexLow(priority);
str1 += "/qhd:" + hexToString(qhdhigh & 0xFF) + hexToString(qhdlow & 0xFF);
str += "/fhd:" + (nextAddress); String str = "十进制下发:";
str1 += "/fhd:" + hexToString(fhdhigh & 0xFF) + hexToString(fhdlow & 0xFF); String str1 = "十六进制下发:";
str += "/priority:" + (priority); str += "任务号 ikey:" + (Integer.parseInt(instcode));
str1 += "/priority:" + hexToString(prioritylow & 0xFF); str1 += "任务号 ikey:" + hexToString(ikeyhigh & 0xFF) + hexToString(ikeylow & 0xFF);
System.out.println(str);
System.out.println(str1); str += "指令类型 /type:" + (type);
byte[] b = new byte[]{(byte) 0X87, (byte) 0XCD, str1 += "指令类型 /type:" + hexToString(typehigh & 0xFF) + hexToString(typelow & 0xFF);
(byte) 0X00, (byte) 0X08,
(byte) 0X00, (byte) 0X12, str += "取货点 /qhd:" + (startAddress);
(byte) 0X00, (byte) 0X01, str1 += "取货点 /qhd:" + hexToString(qhdhigh & 0xFF) + hexToString(qhdlow & 0xFF);
(byte) 0X00, (byte) 0X71, str += "放货点 /fhd:" + (nextAddress);
(byte) 0X00, (byte) 0X0E, str1 += "放货点 /fhd:" + hexToString(fhdhigh & 0xFF) + hexToString(fhdlow & 0xFF);
(byte) 0X01, prioritylow,
(byte) 0X00, (byte) 0X01, str += "取货点2 /qhd2:" + (startAddress2);
(byte) ikeyhigh, (byte) ikeylow, str1 += "取货点2 /qhd2:" + hexToString(qhdhigh2 & 0xFF) + hexToString(qhdlow2 & 0xFF);
(byte) ikeyhigh, (byte) ikeylow, str += "放货点2 /fhd2:" + (nextAddress2);
(byte) typehigh, (byte) typelow, str1 += "放货点2 /fhd2:" + hexToString(fhdhigh2 & 0xFF) + hexToString(fhdlow2 & 0xFF);
(byte) qhdhigh, (byte) qhdlow,
(byte) fhdhigh, (byte) fhdlow str += "优先级 /priority:" + (priority);
}; str1 += "优先级 /priority:" + hexToString(prioritylow & 0xFF);
log.info("下发AGV作业指令--{}", str1);
// OneNDCSocketConnectionAutoRun.write(b); byte[] b = new byte[]{};
TwoNDCSocketConnectionAutoRun.write(b); if (type == 1) {
System.out.println("下发agv指令数据:" + Bytes2HexString(b)); b = new byte[]{(byte) 0X87, (byte) 0XCD,
(byte) 0X00, (byte) 0X08,
(byte) 0X00, (byte) 0X16,
(byte) 0X00, (byte) 0X01,
(byte) 0X00, (byte) 0X71,
(byte) 0X00, (byte) 0X12,
(byte) 0X01, prioritylow,
(byte) 0X00, (byte) 0X01,
(byte) ikeyhigh, (byte) ikeylow,
(byte) ikeyhigh, (byte) ikeylow,
(byte) typehigh, (byte) typelow,
(byte) qhdhigh, (byte) qhdlow,
(byte) qhdhigh2, (byte) qhdlow2,
(byte) fhdhigh, (byte) fhdlow,
(byte) fhdhigh2, (byte) fhdlow2
};
} else if (type == 2) {
b = new byte[]{(byte) 0X87, (byte) 0XCD,
(byte) 0X00, (byte) 0X08,
(byte) 0X00, (byte) 0X16,
(byte) 0X00, (byte) 0X01,
(byte) 0X00, (byte) 0X71,
(byte) 0X00, (byte) 0X12,
(byte) 0X01, prioritylow,
(byte) 0X00, (byte) 0X01,
(byte) ikeyhigh, (byte) ikeylow,
(byte) ikeyhigh, (byte) ikeylow,
(byte) typehigh, (byte) typelow,
(byte) qhdhigh, (byte) qhdlow,
(byte) 0X00, (byte) 0X00,
(byte) fhdhigh, (byte) fhdlow,
(byte) 0X00, (byte) 0X00
};
} else if (type == 3) {
b = new byte[]{(byte) 0X87, (byte) 0XCD,
(byte) 0X00, (byte) 0X08,
(byte) 0X00, (byte) 0X16,
(byte) 0X00, (byte) 0X01,
(byte) 0X00, (byte) 0X71,
(byte) 0X00, (byte) 0X12,
(byte) 0X01, prioritylow,
(byte) 0X00, (byte) 0X01,
(byte) ikeyhigh, (byte) ikeylow,
(byte) ikeyhigh, (byte) ikeylow,
(byte) typehigh, (byte) typelow,
(byte) qhdhigh, (byte) qhdlow,
(byte) qhdhigh2, (byte) qhdlow2,
(byte) fhdhigh, (byte) fhdlow,
(byte) fhdhigh2, (byte) fhdlow2
};
}
log.info("下发AGV作业指令 --{}", str1);
log.info("下发AGV作业指令--{}", str);
log.info("下发agv指令数据--{}", Bytes2HexString(b));
if (StrUtil.equals(agv_system_type, "2")) {
TwoNDCSocketConnectionAutoRun.write(b);
}
} else {
String instcode = inst.getInstruction_code();
int startHeight = Integer.parseInt(StrUtil.isEmpty(inst.getStart_height()) ? "0" : inst.getStart_height());
int nextHeight = Integer.parseInt(StrUtil.isEmpty(inst.getNext_height()) ? "0" : inst.getNext_height());
//默认取货放货高度都为0
//int type = Integer.parseInt(inst.getInstruction_type());
int type = 4;
if (startHeight != 0 && nextHeight != 0) {
//取货放货高度都不为0
type = 1;
} else if (startHeight != 0 && nextHeight == 0) {
//取货高度不为0 放货高度为0
type = 2;
} else if (startHeight == 0 && nextHeight != 0) {
//取货高度为0 放货高度不为0
type = 3;
}
int priority = Integer.parseInt(inst.getPriority()) + 128;
DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class);
DeviceService deviceService = SpringContextHolder.getBean(DeviceServiceImpl.class);
int startAddress = deviceService.queryAddressBydeviceCode(inst.getStart_point_code());
int nextAddress = deviceService.queryAddressBydeviceCode(inst.getNext_point_code());
byte ikeyhigh = (byte) IntToHexHigh(Integer.parseInt(instcode));
byte ikeylow = (byte) IntToHexLow(Integer.parseInt(instcode));
byte typehigh = (byte) IntToHexHigh(type);
byte typelow = (byte) IntToHexLow(type);
byte qhdhigh = (byte) IntToHexHigh(startAddress);
byte qhdlow = (byte) IntToHexLow(startAddress);
byte fhdhigh = (byte) IntToHexHigh(nextAddress);
byte fhdlow = (byte) IntToHexLow(nextAddress);
byte prioritylow = (byte) IntToHexLow(priority);
byte shhigh = (byte) IntToHexHigh(startHeight);
byte shlow = (byte) IntToHexLow(startHeight);
byte nhhigh = (byte) IntToHexHigh(nextHeight);
byte nhlow = (byte) IntToHexLow(nextHeight);
String str = "十进制下发:";
String str1 = "十六进制下发:";
str += "ikey:" + (Integer.parseInt(instcode));
str1 += "ikey:" + hexToString(ikeyhigh & 0xFF) + hexToString(ikeylow & 0xFF);
str += "/type:" + (type);
str1 += "/type:" + hexToString(typehigh & 0xFF) + hexToString(typelow & 0xFF);
str += "/qhd:" + (startAddress);
str1 += "/qhd:" + hexToString(qhdhigh & 0xFF) + hexToString(qhdlow & 0xFF);
str += "/fhd:" + (nextAddress);
str1 += "/fhd:" + hexToString(fhdhigh & 0xFF) + hexToString(fhdlow & 0xFF);
str += "/priority:" + (priority);
str1 += "/priority:" + hexToString(prioritylow & 0xFF);
System.out.println(str);
System.out.println(str1);
byte[] b = new byte[]{(byte) 0X87, (byte) 0XCD,
(byte) 0X00, (byte) 0X08,
(byte) 0X00, (byte) 0X16,
(byte) 0X00, (byte) 0X01,
(byte) 0X00, (byte) 0X71,
(byte) 0X00, (byte) 0X12,
(byte) 0X01, prioritylow,
(byte) 0X00, (byte) 0X01,
(byte) ikeyhigh, (byte) ikeylow,
(byte) ikeyhigh, (byte) ikeylow,
(byte) typehigh, (byte) typelow,
(byte) qhdhigh, (byte) qhdlow,
(byte) fhdhigh, (byte) fhdlow,
(byte) shhigh, (byte) shlow,
(byte) nhhigh, (byte) nhlow
};
log.info("下发AGV作业指令 --{}", str1);
log.info("下发AGV作业指令--{}", str);
log.info("下发agv指令数据--{}", Bytes2HexString(b));
OneNDCSocketConnectionAutoRun.write(b);
}
} }
} }

View File

@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<included>
<springProperty scope="context" name="logPath" source="logging.file.path" defaultValue="logs"/>
<property name="LOG_HOME" value="${logPath}"/>
<!-- 按照每天生成日志文件 -->
<appender name="FILE11" class="ch.qos.logback.core.rolling.RollingFileAppender">
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<!--日志文件输出的文件名-->
<FileNamePattern>${LOG_HOME}/一楼NDC系统/%d{yyyy-MM-dd}.%i.log</FileNamePattern>
<!--日志文件保留天数-->
<maxHistory>15</maxHistory>
<!--单个日志最大容量 至少10MB才能看得出来-->
<maxFileSize>200MB</maxFileSize>
<!--所有日志最多占多大容量-->
<totalSizeCap>2GB</totalSizeCap>
</rollingPolicy>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<!--格式化输出:%d表示日期%thread表示线程名%-5level级别从左显示5个字符宽度%msg日志消息%n是换行符-->
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern>
<charset>${log.charset}</charset>
</encoder>
</appender>
<!-- <logger name="org.nl.start.Init" level="info" additivity="true">
<appender-ref ref="FILE3"/>
</logger>-->
<!-- 打印sql -->
<logger name="org.nl.acs.auto.run.OneNDCSocketConnectionAutoRun" level="info" additivity="true">
<appender-ref ref="FILE11"/>
</logger>
</included>

View File

@@ -21,6 +21,7 @@ https://juejin.cn/post/6844903775631572999
<include resource="log/ACSToLMS.xml"/> <include resource="log/ACSToLMS.xml"/>
<include resource="log/LMSToACS.xml"/> <include resource="log/LMSToACS.xml"/>
<include resource="log/TwoNDCSocketConnectionAutoRun.xml"/> <include resource="log/TwoNDCSocketConnectionAutoRun.xml"/>
<include resource="log/NDCAgvServiceImpl.xml"/>
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender"> <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<!--withJansi 参数改为true--> <!--withJansi 参数改为true-->