add: agv改造
This commit is contained in:
@@ -7,9 +7,7 @@ import org.nl.acs.AcsConfig;
|
||||
import org.nl.acs.agv.server.NDCAgvService;
|
||||
import org.nl.acs.device.domain.Device;
|
||||
import org.nl.acs.device.service.DeviceService;
|
||||
import org.nl.acs.device_driver.agv.ndcone.AgvNdcOneDeviceDriver;
|
||||
import org.nl.acs.device_driver.agv.ndctwo.AgvNdcTwoDeviceDriver;
|
||||
import org.nl.acs.device_driver.autodoor.standard_autodoor.StandardAutodoorDeviceDriver;
|
||||
|
||||
import org.nl.acs.ext.wms.service.AcsToWmsService;
|
||||
import org.nl.acs.ext.wms.service.impl.AcsToWmsServiceImpl;
|
||||
import org.nl.acs.instruction.domain.Instruction;
|
||||
@@ -142,12 +140,7 @@ public class TwoNDCSocketConnectionAutoRun extends AbstractAutoRunnable {
|
||||
|
||||
boolean flag = false;
|
||||
if (arr.length < 10) {
|
||||
LuceneLogDto logDto = LuceneLogDto.builder()
|
||||
.device_code("ndc")
|
||||
.content("接收agv上报信息:" + bs)
|
||||
.build();
|
||||
logDto.setLog_level(4);
|
||||
luceneExecuteLogService.deviceExecuteLog(logDto);
|
||||
|
||||
log.info("接收agv上报信息:" + bs);
|
||||
} else {
|
||||
if (arr[8] * 256 + arr[9] == 0x73) {
|
||||
@@ -175,8 +168,7 @@ public class TwoNDCSocketConnectionAutoRun extends AbstractAutoRunnable {
|
||||
String device_code = null;
|
||||
String old_device_code = null;
|
||||
String emptyNum = null;
|
||||
//自动门
|
||||
StandardAutodoorDeviceDriver standardAutodoorDeviceDriver;
|
||||
|
||||
if (agvaddr != 0) {
|
||||
old_device_code = deviceService.queryDeviceCodeByAddress(agvaddr);
|
||||
if (StrUtil.contains(old_device_code, "-")) {
|
||||
@@ -192,8 +184,7 @@ public class TwoNDCSocketConnectionAutoRun extends AbstractAutoRunnable {
|
||||
device = deviceAppService.findDeviceByCode(device_code);
|
||||
}
|
||||
|
||||
AgvNdcTwoDeviceDriver agvNdcTwoDeviceDriver;
|
||||
AgvNdcOneDeviceDriver agvNdcOneDeviceDriver;
|
||||
|
||||
//开始任务
|
||||
if (phase == 0x01) {
|
||||
if (!ObjectUtil.isEmpty(inst)) {
|
||||
@@ -213,15 +204,7 @@ public class TwoNDCSocketConnectionAutoRun extends AbstractAutoRunnable {
|
||||
} else {
|
||||
String agvcar = inst.getCarno();
|
||||
Device agvDevice = deviceAppService.findDeviceByCode(agvcar);
|
||||
if (agvDevice != null) {
|
||||
if (agvDevice.getDeviceDriver() instanceof AgvNdcTwoDeviceDriver) {
|
||||
agvNdcTwoDeviceDriver = (AgvNdcTwoDeviceDriver) agvDevice.getDeviceDriver();
|
||||
agvNdcTwoDeviceDriver.setInstruction(null);
|
||||
} else if (device.getDeviceDriver() instanceof AgvNdcOneDeviceDriver) {
|
||||
agvNdcOneDeviceDriver = (AgvNdcOneDeviceDriver) device.getDeviceDriver();
|
||||
agvNdcOneDeviceDriver.setInstruction(null);
|
||||
}
|
||||
}
|
||||
|
||||
inst.setInstruction_status("2");
|
||||
try {
|
||||
instructionService.finish(inst);
|
||||
@@ -251,52 +234,14 @@ public class TwoNDCSocketConnectionAutoRun extends AbstractAutoRunnable {
|
||||
log.info(agvaddr + "对应设备号为空!");
|
||||
return;
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(device)) {
|
||||
if (device.getDeviceDriver() instanceof StandardAutodoorDeviceDriver) {
|
||||
standardAutodoorDeviceDriver = (StandardAutodoorDeviceDriver) device.getDeviceDriver();
|
||||
try {
|
||||
standardAutodoorDeviceDriver.writing("to_open", "1");
|
||||
standardAutodoorDeviceDriver.writing("to_close", "0");
|
||||
} catch (Exception e) {
|
||||
log.info("下发电气信号失败:" + e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (standardAutodoorDeviceDriver.getOpen() == 1 && standardAutodoorDeviceDriver.getToOpen() == 1) {
|
||||
log.info("下发开门信号值为:{},读取开门信号值为:{}", standardAutodoorDeviceDriver.getToOpen(), standardAutodoorDeviceDriver.getOpen());
|
||||
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
|
||||
} else {
|
||||
log.info("未下发NDC信号原因: 下发开门信号值为:{},读取开门信号值为:{}", standardAutodoorDeviceDriver.getToOpen(), standardAutodoorDeviceDriver.getToClose());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
log.info(agvaddr + "对应设备号为空!");
|
||||
}
|
||||
|
||||
|
||||
} else if (phase == 0x51) {
|
||||
if (ObjectUtil.isEmpty(device_code)) {
|
||||
log.info(agvaddr + "对应设备号为空!");
|
||||
return;
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(device)) {
|
||||
if (device.getDeviceDriver() instanceof StandardAutodoorDeviceDriver) {
|
||||
standardAutodoorDeviceDriver = (StandardAutodoorDeviceDriver) device.getDeviceDriver();
|
||||
try {
|
||||
standardAutodoorDeviceDriver.writing("to_close", "1");
|
||||
standardAutodoorDeviceDriver.writing("to_open", "0");
|
||||
} catch (Exception e) {
|
||||
log.info("下发电气信号失败:" + e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (standardAutodoorDeviceDriver.getClose() == 1) {
|
||||
log.info("读取关门信号值为:{}", standardAutodoorDeviceDriver.getClose());
|
||||
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
|
||||
} else {
|
||||
log.info("未下发NDC信号原因: 读取自动门信号值为:{}", standardAutodoorDeviceDriver.getClose());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
log.info(device_code + "对应设备号为空!");
|
||||
}
|
||||
|
||||
} else if (phase == 0x64){
|
||||
log.info("AGV车号{}反馈充电任务下发成功,锁定充电桩{}",agvaddr,station);
|
||||
Dict dict = dictService.getDictByName3("station",String.valueOf(agvaddr),null);
|
||||
@@ -329,17 +274,7 @@ public class TwoNDCSocketConnectionAutoRun extends AbstractAutoRunnable {
|
||||
device = deviceAppService.findDeviceByCode(Integer.toString(arr[20]));
|
||||
}
|
||||
try {
|
||||
if (ObjectUtil.isNotEmpty(device)) {
|
||||
if (device.getDeviceDriver() instanceof AgvNdcTwoDeviceDriver) {
|
||||
agvNdcTwoDeviceDriver = (AgvNdcTwoDeviceDriver) device.getDeviceDriver();
|
||||
agvNdcTwoDeviceDriver.processSocket(arr);
|
||||
} else if (device.getDeviceDriver() instanceof AgvNdcOneDeviceDriver) {
|
||||
agvNdcOneDeviceDriver = (AgvNdcOneDeviceDriver) device.getDeviceDriver();
|
||||
agvNdcOneDeviceDriver.processSocket(arr);
|
||||
}
|
||||
} else {
|
||||
log.info("当前phase:" + phase + "未找到对应设备");
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
log.info("processSocket出错:{},{}", e, e.getMessage());
|
||||
e.printStackTrace();
|
||||
|
||||
@@ -15,9 +15,7 @@ import org.nl.acs.common.base.CommonFinalParam;
|
||||
import org.nl.acs.device.domain.Device;
|
||||
import org.nl.acs.device.service.DeviceService;
|
||||
import org.nl.acs.device_driver.DeviceDriver;
|
||||
import org.nl.acs.device_driver.FeedLmsRealFailed;
|
||||
import org.nl.acs.device_driver.agv.utils.TwoAgvPhase;
|
||||
import org.nl.acs.device_driver.autodoor.standard_autodoor.StandardAutodoorDeviceDriver;
|
||||
import org.nl.acs.device_driver.conveyor.standard_inspect_site.StandardInspectSiteDeviceDriver;
|
||||
import org.nl.acs.device_driver.conveyor.standard_ordinary_site.StandardOrdinarySiteDeviceDriver;
|
||||
import org.nl.acs.device_driver.driver.AbstractDeviceDriver;
|
||||
@@ -54,7 +52,7 @@ import java.util.Map;
|
||||
@Slf4j
|
||||
@Data
|
||||
@RequiredArgsConstructor
|
||||
public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements DeviceDriver, DeviceStageMonitor, FeedLmsRealFailed {
|
||||
public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements DeviceDriver, DeviceStageMonitor {
|
||||
|
||||
ISysParamService ISysParamService = SpringContextHolder.getBean(ISysParamService.class);
|
||||
InstructionService instructionService = SpringContextHolder.getBean(InstructionServiceImpl.class);
|
||||
@@ -162,8 +160,7 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic
|
||||
StandardOrdinarySiteDeviceDriver standardOrdinarySiteDeviceDriver;
|
||||
//标准-光电检测
|
||||
StandardInspectSiteDeviceDriver standardInspectSiteDeviceDriver;
|
||||
//自动门
|
||||
StandardAutodoorDeviceDriver standardAutodoorDeviceDriver;
|
||||
|
||||
|
||||
|
||||
if (phase == 0x02) {
|
||||
@@ -401,44 +398,8 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic
|
||||
}
|
||||
|
||||
|
||||
//进入区域(phase值)
|
||||
else if (phase == 0x50) {
|
||||
device = deviceAppService.findDeviceByCode(device_code);
|
||||
if (device.getDeviceDriver() instanceof StandardAutodoorDeviceDriver) {
|
||||
standardAutodoorDeviceDriver = (StandardAutodoorDeviceDriver) device.getDeviceDriver();
|
||||
String address = standardAutodoorDeviceDriver.getExtraValue().get("address").toString();
|
||||
|
||||
try {
|
||||
standardAutodoorDeviceDriver.writing("to_open", "1");
|
||||
|
||||
} catch (Exception e) {
|
||||
log.info("下发电气信号失败:" + e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
log.info("未下发NDC信号原因: 下发开门信号值为:{},读取开门信号值为:{}", standardAutodoorDeviceDriver.getToOpen(), standardAutodoorDeviceDriver.getOpen());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
//离开区域(phase值)
|
||||
else if (phase == 0x51) {
|
||||
data = ndcAgvService.sendAgvOneModeInst(phase, index, 0);
|
||||
|
||||
if (device.getDeviceDriver() instanceof StandardAutodoorDeviceDriver) {
|
||||
standardAutodoorDeviceDriver = (StandardAutodoorDeviceDriver) device.getDeviceDriver();
|
||||
|
||||
try {
|
||||
|
||||
standardAutodoorDeviceDriver.writing("to_close", "1");
|
||||
|
||||
} catch (Exception e) {
|
||||
log.info("下发电气信号失败:" + e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
|
||||
}
|
||||
}
|
||||
//上报异常信息
|
||||
//(不需要WCS反馈)
|
||||
else if (phase == 0x67) {
|
||||
@@ -508,15 +469,6 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject feedLmsRealFailedInfo() {
|
||||
JSONObject jo = new JSONObject();
|
||||
jo.put("device_code", this.getDevice().getDevice_code());
|
||||
jo.put("device_name", this.getDevice().getDevice_name());
|
||||
jo.put("fault_code", String.valueOf(error));
|
||||
jo.put("fault_info", error == 0 ? "正常" : error_message);
|
||||
jo.put("fault_type", error_type);
|
||||
return jo;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -34,7 +34,6 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
import javax.annotation.PostConstruct;
|
||||
import java.util.*;
|
||||
|
||||
import static sun.audio.AudioDevice.device;
|
||||
|
||||
@Service
|
||||
@AllArgsConstructor
|
||||
|
||||
@@ -1,74 +0,0 @@
|
||||
package org.nl.system.service.quartz.task;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.acs.agv.server.AgvService;
|
||||
import org.nl.acs.agv.server.dto.AgvDto;
|
||||
import org.nl.acs.ext.wms.service.AcsToWmsService;
|
||||
import org.nl.common.mnt.websocket.MsgType;
|
||||
import org.nl.common.mnt.websocket.SocketMsg;
|
||||
import org.nl.common.mnt.websocket.WebSocketServer;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 查询AGV设备状态
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class ToAgvDevice {
|
||||
@Autowired
|
||||
AcsToWmsService acsToWmsService;
|
||||
@Autowired
|
||||
AgvService agvService;
|
||||
|
||||
public void run() throws Exception {
|
||||
JSONObject json = new JSONObject();
|
||||
Map<String, AgvDto> agv_map = agvService.findAllAgvFromCache();
|
||||
|
||||
JSONArray agv_rows = new JSONArray();
|
||||
JSONObject row = new JSONObject();
|
||||
|
||||
for (AgvDto agvDto : agv_map.values()) {
|
||||
row.put("device_code", agvDto.getName());
|
||||
row.put("energyLevel", agvDto.getEnergyLevel());
|
||||
if (agvDto.getState().equals("UNKNOWN")) {
|
||||
row.put("status_name", "有任务");
|
||||
row.put("flag", "1");
|
||||
}
|
||||
if (agvDto.getState().equals("UNAVAILABLE")) {
|
||||
row.put("status_name", "网络异常");
|
||||
row.put("flag", "1");
|
||||
}
|
||||
if (agvDto.getState().equals("ERROR")) {
|
||||
row.put("status_name", "机器错误");
|
||||
row.put("flag", "1");
|
||||
}
|
||||
if (agvDto.getState().equals("IDLE")) {
|
||||
row.put("status_name", "空闲");
|
||||
row.put("flag", "0");
|
||||
}
|
||||
if (agvDto.getState().equals("EXECUTING")) {
|
||||
row.put("status_name", "运行中");
|
||||
row.put("flag", "0");
|
||||
}
|
||||
if (agvDto.getState().equals("CHARGING")) {
|
||||
row.put("status_name", "充电中");
|
||||
row.put("flag", "0");
|
||||
}
|
||||
row.put("transportOrder", agvDto.getTransportOrder());
|
||||
row.put("positionX", agvDto.getPositionX());
|
||||
row.put("positionY", agvDto.getPositionY());
|
||||
row.put("positionAngle", agvDto.getPositionAngle());
|
||||
agv_rows.add(row);
|
||||
}
|
||||
json.put("agv_rows", agv_rows);
|
||||
SocketMsg deviceInfo = new SocketMsg(json, MsgType.INFO);
|
||||
WebSocketServer.sendInfo(deviceInfo, "toAgvDevice_data");
|
||||
|
||||
// acsToWmsService.feedbackAgv(row);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user