|
@ -22,6 +22,7 @@ import org.nl.acs.opc.DeviceAppService; |
|
|
import org.nl.acs.opc.DeviceAppServiceImpl; |
|
|
import org.nl.acs.opc.DeviceAppServiceImpl; |
|
|
import org.nl.acs.opc.DeviceType; |
|
|
import org.nl.acs.opc.DeviceType; |
|
|
import org.nl.exception.BadRequestException; |
|
|
import org.nl.exception.BadRequestException; |
|
|
|
|
|
import org.nl.start.auto.run.NDCSocketConnectionAutoRun; |
|
|
import org.nl.utils.SpringContextHolder; |
|
|
import org.nl.utils.SpringContextHolder; |
|
|
import org.slf4j.MDC; |
|
|
import org.slf4j.MDC; |
|
|
import org.springframework.stereotype.Service; |
|
|
import org.springframework.stereotype.Service; |
|
@ -51,7 +52,7 @@ public class NDCAgvServiceImpl implements NDCAgvService { |
|
|
try { |
|
|
try { |
|
|
MDC.put(log_file_type, log_type); |
|
|
MDC.put(log_file_type, log_type); |
|
|
if (StrUtil.equals(acsConfigService.findConfigFromCache().get(AcsConfig.FORKAGV).toString(), "1")) { |
|
|
if (StrUtil.equals(acsConfigService.findConfigFromCache().get(AcsConfig.FORKAGV).toString(), "1")) { |
|
|
int index = Integer.parseInt(inst.getAgv_jobno()); |
|
|
int index = ObjectUtil.isEmpty(inst.getAgv_jobno())?0:Integer.parseInt(inst.getAgv_jobno()); |
|
|
|
|
|
|
|
|
byte indexhigh = (byte) IntToHexHigh(index); |
|
|
byte indexhigh = (byte) IntToHexHigh(index); |
|
|
byte indexlow = (byte) IntToHexLow(index); |
|
|
byte indexlow = (byte) IntToHexLow(index); |
|
@ -181,7 +182,7 @@ public class NDCAgvServiceImpl implements NDCAgvService { |
|
|
}; |
|
|
}; |
|
|
log.info("下发AGV作业指令--{}", str1); |
|
|
log.info("下发AGV作业指令--{}", str1); |
|
|
|
|
|
|
|
|
// NDCSocketConnectionAutoRun.write(b);
|
|
|
NDCSocketConnectionAutoRun.write(b); |
|
|
System.out.println("下发agv指令数据:" + Bytes2HexString(b)); |
|
|
System.out.println("下发agv指令数据:" + Bytes2HexString(b)); |
|
|
} |
|
|
} |
|
|
} finally { |
|
|
} finally { |
|
@ -230,73 +231,15 @@ public class NDCAgvServiceImpl implements NDCAgvService { |
|
|
return new byte[0]; |
|
|
return new byte[0]; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public byte[] sendAgvOneModeInst(int phase, int index, int result) { |
|
|
public byte[] sendAgvOneModeInst(int phase, int index, int result) { |
|
|
try { |
|
|
|
|
|
MDC.put(log_file_type, log_type); |
|
|
|
|
|
if (phase < 0 || index < 0) |
|
|
if (phase < 0 || index < 0) |
|
|
return null; |
|
|
return null; |
|
|
byte indexhigh = (byte) IntToHexHigh(index); |
|
|
byte indexhigh = (byte) IntToHexHigh(index); |
|
|
byte indexlow = (byte) IntToHexLow(index); |
|
|
byte indexlow = (byte) IntToHexLow(index); |
|
|
byte phasehigh = (byte) IntToHexHigh(phase); |
|
|
byte phasehigh = (byte) IntToHexHigh(phase); |
|
|
byte phaselow = (byte) IntToHexLow(phase); |
|
|
byte phaselow = (byte) IntToHexLow(phase); |
|
|
byte resulthigh = (byte) IntToHexHigh(result); |
|
|
|
|
|
byte resultlow = (byte) IntToHexLow(result); |
|
|
|
|
|
|
|
|
|
|
|
int type = Integer.parseInt(acsConfigService.findConfigFromCache().get(AcsConfig.BUSINESSTYPE)); |
|
|
byte[] b = new byte[]{(byte) 0X87, (byte) 0XCD, |
|
|
byte[] b = new byte[]{}; |
|
|
|
|
|
switch (type) { |
|
|
|
|
|
case 0: |
|
|
|
|
|
b = new byte[]{(byte) 0X87, (byte) 0XCD, |
|
|
|
|
|
(byte) 0X00, (byte) 0X08, |
|
|
|
|
|
(byte) 0X00, (byte) 0X0A, |
|
|
|
|
|
(byte) 0X00, (byte) 0X01, |
|
|
|
|
|
(byte) 0X00, (byte) 0X6D, |
|
|
|
|
|
(byte) 0X00, (byte) 0X06, |
|
|
|
|
|
(byte) indexhigh, (byte) indexlow, |
|
|
|
|
|
(byte) 0X01, (byte) 0X12, |
|
|
|
|
|
(byte) phasehigh, (byte) phaselow |
|
|
|
|
|
}; |
|
|
|
|
|
break; |
|
|
|
|
|
case 1: |
|
|
|
|
|
b = new byte[]{(byte) 0X87, (byte) 0XCD, |
|
|
|
|
|
(byte) 0X00, (byte) 0X08, |
|
|
|
|
|
(byte) 0X00, (byte) 0X0D, |
|
|
|
|
|
(byte) 0X00, (byte) 0X01, |
|
|
|
|
|
(byte) 0X00, (byte) 0X6D, |
|
|
|
|
|
(byte) 0X00, (byte) 0X08, |
|
|
|
|
|
(byte) indexhigh, (byte) indexlow, |
|
|
|
|
|
(byte) 0X01, (byte) 0X12, |
|
|
|
|
|
(byte) phasehigh, (byte) phaselow, |
|
|
|
|
|
(byte) resulthigh, (byte) resultlow |
|
|
|
|
|
}; |
|
|
|
|
|
break; |
|
|
|
|
|
case 2: |
|
|
|
|
|
b = new byte[]{(byte) 0X87, (byte) 0XCD, |
|
|
|
|
|
(byte) 0X00, (byte) 0X08, |
|
|
|
|
|
(byte) 0X00, (byte) 0X0A, |
|
|
|
|
|
(byte) 0X00, (byte) 0X01, |
|
|
|
|
|
(byte) 0X00, (byte) 0X6D, |
|
|
|
|
|
(byte) 0X00, (byte) 0X06, |
|
|
|
|
|
(byte) indexhigh, (byte) indexlow, |
|
|
|
|
|
(byte) 0X01, (byte) 0X12, |
|
|
|
|
|
(byte) phasehigh, (byte) phaselow |
|
|
|
|
|
}; |
|
|
|
|
|
break; |
|
|
|
|
|
case 5: |
|
|
|
|
|
b = new byte[]{(byte) 0X87, (byte) 0XCD, |
|
|
|
|
|
(byte) 0X00, (byte) 0X08, |
|
|
|
|
|
(byte) 0X00, (byte) 0X0A, |
|
|
|
|
|
(byte) 0X00, (byte) 0X01, |
|
|
|
|
|
(byte) 0X00, (byte) 0X6D, |
|
|
|
|
|
(byte) 0X00, (byte) 0X06, |
|
|
|
|
|
(byte) indexhigh, (byte) indexlow, |
|
|
|
|
|
(byte) 0X01, (byte) 0X12, |
|
|
|
|
|
(byte) phasehigh, (byte) phaselow |
|
|
|
|
|
}; |
|
|
|
|
|
break; |
|
|
|
|
|
case 7: |
|
|
|
|
|
b = new byte[]{(byte) 0X87, (byte) 0XCD, |
|
|
|
|
|
(byte) 0X00, (byte) 0X08, |
|
|
(byte) 0X00, (byte) 0X08, |
|
|
(byte) 0X00, (byte) 0X0A, |
|
|
(byte) 0X00, (byte) 0X0A, |
|
|
(byte) 0X00, (byte) 0X01, |
|
|
(byte) 0X00, (byte) 0X01, |
|
@ -306,15 +249,12 @@ public class NDCAgvServiceImpl implements NDCAgvService { |
|
|
(byte) 0X01, (byte) 0X12, |
|
|
(byte) 0X01, (byte) 0X12, |
|
|
(byte) phasehigh, (byte) phaselow |
|
|
(byte) phasehigh, (byte) phaselow |
|
|
}; |
|
|
}; |
|
|
break; |
|
|
|
|
|
} |
|
|
|
|
|
log.info("反馈agv动作数据--index:" + hexToString(indexhigh & 0xFF) + hexToString(indexlow & 0xFF) + ",phase:" + hexToString(phasehigh & 0xFF) + hexToString(phaselow & 0xFF)); |
|
|
log.info("反馈agv动作数据--index:" + hexToString(indexhigh & 0xFF) + hexToString(indexlow & 0xFF) + ",phase:" + hexToString(phasehigh & 0xFF) + hexToString(phaselow & 0xFF)); |
|
|
|
|
|
|
|
|
System.out.println("反馈agv动作数据:" + Bytes2HexString(b)); |
|
|
System.out.println("反馈agv动作数据:" + Bytes2HexString(b)); |
|
|
return b; |
|
|
return b; |
|
|
} finally { |
|
|
|
|
|
MDC.remove(log_file_type); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|