This commit is contained in:
xuzhiheng
2025-06-09 10:34:24 +08:00
parent 503771fe7c
commit 2cc6f2906b
49 changed files with 1471 additions and 514 deletions

View File

@@ -37,6 +37,8 @@ import org.opentcs.kernel.extensions.servicewebapi.v1.binding.PostVehicleRoutesR
import org.opentcs.kernel.extensions.servicewebapi.v1.binding.PutVehicleAllowedOrderTypesTO;
import org.opentcs.kernel.extensions.servicewebapi.v1.binding.PutVehicleEnergyLevelThresholdSetTO;
import org.opentcs.manage.AdapterManage;
import org.opentcs.manage.entity.ActionStatus;
import org.opentcs.manage.entity.AgvInfo;
/**
* Handles requests related to vehicles.
@@ -69,22 +71,38 @@ public class VehicleHandler {
* 接收平台异步回调处理
*/
public void postReceiveCallback(Object data) {
System.out.println("jsonObject-----ssss: " + data.toString());
// System.out.println("jsonObject-----ssss: " + data.toString());
//截取平台响应的字符串
// String jsonStr = data.toString().split("=", 2)[1];
String jsonStr = data.toString();
String jsonStr = data.toString().split("=", 2)[1];
// String jsonStr = data.toString();
JSONObject jsonObject = JSON.parseObject(jsonStr);
String name = jsonObject.getString("name");
String name = jsonObject.getString("vehicle_name");
Integer type = jsonObject.getInteger("type");
Vehicle vehicle = vehicleService.fetchObject(Vehicle.class, name);
if (vehicle == null) {
throw new ObjectUnknownException("postReceiveCallback Unknown vehicle: " + name);
}
//将数据更新到线程安全的集合中,防止线程阻塞
AdapterManage.setAdapterStatus(name);
if (type == 1) {
AdapterManage.setAdapterVehicleModel(name, jsonStr);
} else if (type == 5) {
if (AdapterManage.getAdapterStatus(name)) {
vehicleService.enableCommAdapter(vehicle.getReference());
} else {
//todo 关闭暂时有问题
vehicleService.disableCommAdapter(vehicle.getReference());
}
if (type == 1) { //上报agv详细信息
AgvInfo agvInfo = AdapterManage.setAdapterVehicleModel(name, jsonStr);
vehicleService.sendCommAdapterMessage(vehicle.getReference(), agvInfo);
} else if (type == 5) { //上报动作完成
//动作完成上报
AdapterManage.setActionStatus(name);
ActionStatus actionStatus = new ActionStatus();
actionStatus.setStatus(true);
vehicleService.sendCommAdapterMessage(vehicle.getReference(), actionStatus);
}
}