|
|
@ -5,13 +5,18 @@ 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.device_driver.basedriver.agv.ndcone.AgvNdcOneDeviceDriver; |
|
|
|
import org.nl.acs.ext.wms.service.AcsToWmsService; |
|
|
|
import org.nl.acs.opc.Device; |
|
|
|
import org.nl.acs.opc.DeviceAppService; |
|
|
|
import org.nl.acs.opc.DeviceType; |
|
|
|
import org.nl.modules.mnt.websocket.MsgType; |
|
|
|
import org.nl.modules.mnt.websocket.SocketMsg; |
|
|
|
import org.nl.modules.mnt.websocket.WebSocketServer; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Component; |
|
|
|
|
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
/** |
|
|
@ -25,17 +30,20 @@ public class ToAgvDevice { |
|
|
|
AcsToWmsService acsToWmsService; |
|
|
|
@Autowired |
|
|
|
AgvService agvService; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
DeviceAppService deviceAppService; |
|
|
|
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()); |
|
|
|
AgvNdcOneDeviceDriver agvNdcOneDeviceDriver; |
|
|
|
try { |
|
|
|
List<Device> deviceList = deviceAppService.findDeviceByType(DeviceType.agv); |
|
|
|
for(Device device:deviceList) { |
|
|
|
if (device.getDeviceDriver() instanceof AgvNdcOneDeviceDriver) { |
|
|
|
agvNdcOneDeviceDriver = (AgvNdcOneDeviceDriver) device.getDeviceDriver(); |
|
|
|
row.put("device_code", agvNdcOneDeviceDriver.getDevice_code()); |
|
|
|
row.put("energyLevel", agvNdcOneDeviceDriver.getElectric_qty()); |
|
|
|
// 车状态:
|
|
|
|
// 1:关机
|
|
|
|
// 2:运行中
|
|
|
@ -44,64 +52,43 @@ public class ToAgvDevice { |
|
|
|
// 5:充电中
|
|
|
|
// 6:故障中
|
|
|
|
// 7:低电量
|
|
|
|
if (agvDto.getState().equals("1")) { |
|
|
|
if (agvNdcOneDeviceDriver.getStatus()==1) { |
|
|
|
row.put("device_status", "UNKNOWN"); |
|
|
|
row.put("status_name", "关机"); |
|
|
|
} else if (agvDto.getState().equals("2")) { |
|
|
|
} else if (agvNdcOneDeviceDriver.getStatus()==2) { |
|
|
|
row.put("device_status", "EXECUTING"); |
|
|
|
row.put("status_name", "有任务"); |
|
|
|
} else if (agvDto.getState().equals("3")) { |
|
|
|
} else if (agvNdcOneDeviceDriver.getStatus()==3) { |
|
|
|
// row.put("device_status", "EXECUTING");
|
|
|
|
// row.put("status_name", "交通管制");
|
|
|
|
} else if (agvDto.getState().equals("4")) { |
|
|
|
} else if (agvNdcOneDeviceDriver.getStatus()==4) { |
|
|
|
row.put("device_status", "IDLE"); |
|
|
|
row.put("status_name", "空闲"); |
|
|
|
} else if (agvDto.getState().equals("5")) { |
|
|
|
} else if (agvNdcOneDeviceDriver.getStatus()==5) { |
|
|
|
row.put("device_status", "CHARGING"); |
|
|
|
row.put("status_name", "充电"); |
|
|
|
} else if (agvDto.getState().equals("6")) { |
|
|
|
} else if (agvNdcOneDeviceDriver.getStatus()==6) { |
|
|
|
row.put("device_status", "ERROR"); |
|
|
|
row.put("status_name", "故障"); |
|
|
|
} else if (agvDto.getState().equals("7")) { |
|
|
|
} else if (agvNdcOneDeviceDriver.getStatus()==7) { |
|
|
|
// row.put("device_status", "ERROR");
|
|
|
|
// row.put("status_name", "低电量");
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// if (agvDto.getState().equals("UNKNOWN")) {
|
|
|
|
// row.put("status_name", "有任务");
|
|
|
|
// 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()); |
|
|
|
row.put("transportOrder", agvNdcOneDeviceDriver.getOrder()); |
|
|
|
row.put("positionX", agvNdcOneDeviceDriver.getX()); |
|
|
|
row.put("positionY", agvNdcOneDeviceDriver.getY()); |
|
|
|
row.put("positionAngle", agvNdcOneDeviceDriver.getAngle()); |
|
|
|
agv_rows.add(row); |
|
|
|
|
|
|
|
} |
|
|
|
// json.put("agv_rows", agv_rows);
|
|
|
|
// SocketMsg deviceInfo = new SocketMsg(json, MsgType.INFO);
|
|
|
|
// WebSocketServer.sendInfo(deviceInfo, "toAgvDevice_data");
|
|
|
|
} |
|
|
|
|
|
|
|
}catch (Exception e){ |
|
|
|
System.out.println(e.getMessage()); |
|
|
|
} |
|
|
|
|
|
|
|
System.out.println(agv_rows.toString()); |
|
|
|
|
|
|
|
acsToWmsService.feedbackAgv(agv_rows); |
|
|
|
} |
|
|
|