change - 提升机逻辑调试、修改Apollo配置中心测试环境

dev
WenJY 1 day ago
parent a0552ea462
commit c8b90f199d

@ -10,9 +10,9 @@
"apollo": { "apollo": {
"AppId": "SlnWcs", "AppId": "SlnWcs",
"Env": "DEV", "Env": "DEV",
"MetaServer": "http://119.45.202.115:4320", // 4310 "MetaServer": "http://172.16.12.20:7320", // 4310
"ConfigServer": [ "ConfigServer": [
"http://119.45.202.115:4320" "http://172.16.12.20:7320"
] ]
} }
} }

@ -69,6 +69,7 @@ public class HoistService:IHoistService
{ {
hoistCode = setHoistActionDto.hoistCode, hoistCode = setHoistActionDto.hoistCode,
action = (HoistSdk.Enum.ControlAction)setHoistActionDto.action, action = (HoistSdk.Enum.ControlAction)setHoistActionDto.action,
deviceSerialNo = setHoistActionDto.deviceSerialNo,
}; };
var resp = this.hoistSdk.SetHoistAction(data); var resp = this.hoistSdk.SetHoistAction(data);

@ -79,7 +79,7 @@ public class HoistDispatchHub
{ {
hoistCode = deviceInfo.hostCode, hoistCode = deviceInfo.hostCode,
deviceSerialNo = deviceInfo.deviceSerialNo, deviceSerialNo = deviceInfo.deviceSerialNo,
action = ControlAction.Start action = ControlAction.Start,
}); });
if (res.code == HoistStatusEnum.) if (res.code == HoistStatusEnum.)
@ -145,6 +145,8 @@ public class HoistDispatchHub
public async Task<BaseDeviceInfo> GetFreeHoistAsync(string hostCode) public async Task<BaseDeviceInfo> GetFreeHoistAsync(string hostCode)
{ {
while (true) while (true)
{
lock (string.Empty)
{ {
RefreshDeviceParams(hostCode, out List<BaseDeviceInfo> deviceInfos); RefreshDeviceParams(hostCode, out List<BaseDeviceInfo> deviceInfos);
@ -157,7 +159,8 @@ public class HoistDispatchHub
if (freeHoist != null) if (freeHoist != null)
return freeHoist; return freeHoist;
await Task.Delay(1000); Thread.Sleep(1000);
}
} }
} }

@ -40,18 +40,11 @@ public class HoistConfig
/// <exception cref="Exception"></exception> /// <exception cref="Exception"></exception>
public HoistConfig(IConfiguration configuration) public HoistConfig(IConfiguration configuration)
{ {
if (string.IsNullOrEmpty(configuration["提升机控制地址"]))
{
throw new Exception("提升机控制地址 配置不正确,请检查Apollo配置.");
}
if (string.IsNullOrEmpty(configuration["PLC参数"])) if (string.IsNullOrEmpty(configuration["PLC参数"]))
{ {
throw new Exception("PLC参数 配置不正确,请检查Apollo配置."); throw new Exception("PLC参数 配置不正确,请检查Apollo配置.");
} }
hoist_control_addr = configuration["提升机控制地址"];
hoist_plc_param = configuration["PLC参数"]; hoist_plc_param = configuration["PLC参数"];
} }
} }

@ -138,20 +138,31 @@ public class HoistSdk:IHoistSdk
if (item.hostCode == hoistStatusDto.hoistCode) if (item.hostCode == hoistStatusDto.hoistCode)
{ {
var plc = _plcs.Where(x => x.ConfigKey.Equals(item.hostCode)).FirstOrDefault(); string plcKey = string.Empty;
var plc = _plcs.Where(x => x.ConfigKey.Equals(hoistStatusDto.hoistCode)).FirstOrDefault();
if (plc == null) if (plc == null)
{ {
foreach (var plcItem in _plcs)
{
if (plcItem.ConfigKey.Equals(item.hostCode))
{
plcItem.ConfigKey = plcItem.ConfigKey + "相同";
}
plcKey += plcItem.ConfigKey + ",";
}
result.code = "99"; result.code = "99";
result.message = $"未找到PLC: {item.hostCode}"; result.message = $"未找到PLC: {item.hostCode};现有PLC链接:{plcKey}";
result.hoistCode = hoistStatusDto.hoistCode; result.hoistCode = hoistStatusDto.hoistCode;
return result; return result;
} }
foreach (var param in item.deviceParams) foreach (var param in item.deviceParams)
{ {
int value = plc.readInt16ByAddress(param.paramAddress); int value = plc.readInt16ByAddress(Convert.ToString(param.paramAddress));
param.paramValue = param.objId; param.paramValue = value;
} }
} }

@ -94,14 +94,17 @@ var api = app.MapGroup("/api");
api.MapPost("/hoist/receive-pallet", (ReceivePalletRequest req, IBaseDeviceInfoService devSvc) => api.MapPost("/hoist/receive-pallet", (ReceivePalletRequest req, IBaseDeviceInfoService devSvc) =>
{ {
var device = devSvc.Query(x => x.deviceType == 2 && x.isFlag == 1) var device = devSvc.Query(x => x.deviceType == 2 && x.isFlag == 1)
.FirstOrDefault(d => d.hostCode == req.HostCode); .FirstOrDefault(d => d.hostCode == req.HostCode && d.deviceSerialNo == req.SerialNo);
if (device == null) return Results.Ok(new { success = false, msg = "设备不存在" }); if (device == null) return Results.Ok(new { success = false, msg = "设备不存在" });
var detail = new LiveTaskDetail var detail = new LiveTaskDetail
{ {
taskCode = req.TaskCode, palletBarcode = req.PalletBarcode, taskCode = req.TaskCode,
startPoint = req.StartPoint, endPoint = req.EndPoint, palletBarcode = req.PalletBarcode,
deviceType = 2, taskStatus = 1 startPoint = req.StartPoint,
endPoint = req.EndPoint,
deviceType = 2,
taskStatus = 1
}; };
hub.ReceivePallet(detail, device); hub.ReceivePallet(detail, device);
return Results.Ok(new { success = true }); return Results.Ok(new { success = true });
@ -111,9 +114,9 @@ api.MapPost("/hoist/receive-pallet", (ReceivePalletRequest req, IBaseDeviceInfoS
api.MapPost("/hoist/task-run", (TaskRunRequest req, IBaseDeviceInfoService devSvc) => api.MapPost("/hoist/task-run", (TaskRunRequest req, IBaseDeviceInfoService devSvc) =>
{ {
var device = devSvc.Query(x => x.deviceType == 2 && x.isFlag == 1) var device = devSvc.Query(x => x.deviceType == 2 && x.isFlag == 1)
.FirstOrDefault(d => d.hostCode == req.HostCode); .FirstOrDefault(d => d.hostCode == req.HostCode && d.deviceSerialNo == req.SerialNo);
if (device == null) return Results.Ok(new { success = false, msg = "设备不存在" }); if (device == null) return Results.Ok(new { success = false, msg = "设备不存在" });
device.deviceSerialNo = req.SerialNo;
hub.TaskRun(device); hub.TaskRun(device);
return Results.Ok(new { success = true }); return Results.Ok(new { success = true });
}); });
@ -122,13 +125,16 @@ api.MapPost("/hoist/task-run", (TaskRunRequest req, IBaseDeviceInfoService devSv
api.MapPost("/task/dispatch", (TaskDispatchRequest req, IBaseDeviceInfoService devSvc) => api.MapPost("/task/dispatch", (TaskDispatchRequest req, IBaseDeviceInfoService devSvc) =>
{ {
var device = devSvc.Query(x => x.deviceType == 2 && x.isFlag == 1) var device = devSvc.Query(x => x.deviceType == 2 && x.isFlag == 1)
.FirstOrDefault(d => d.hostCode == req.HostCode); .FirstOrDefault(d => d.hostCode == req.HostCode && d.deviceSerialNo == req.SerialNo);
if (device == null) return Results.Ok(new { success = false, msg = "设备不存在" }); if (device == null) return Results.Ok(new { success = false, msg = "设备不存在" });
var detail = new LiveTaskDetail var detail = new LiveTaskDetail
{ {
taskCode = req.TaskCode, startPoint = req.StartPoint, endPoint = req.EndPoint, taskCode = req.TaskCode,
deviceType = 2, taskStatus = 1 startPoint = req.StartPoint,
endPoint = req.EndPoint,
deviceType = 2,
taskStatus = 1
}; };
hub.TaskDispatch(device, detail); hub.TaskDispatch(device, detail);
return Results.Ok(new { success = true }); return Results.Ok(new { success = true });

@ -10,9 +10,9 @@
"apollo": { "apollo": {
"AppId": "SlnWcs", "AppId": "SlnWcs",
"Env": "DEV", "Env": "DEV",
"MetaServer": "http://119.45.202.115:4320", // 4310 "MetaServer": "http://172.16.12.20:7320", // 4310
"ConfigServer": [ "ConfigServer": [
"http://119.45.202.115:4320" "http://172.16.12.20:7320"
] ]
} }
} }

@ -44,6 +44,7 @@ public class InovanceImpl:IPlc
_stringChange = stringChange; _stringChange = stringChange;
this.inovanceTcp = new InovanceTcpNet(); this.inovanceTcp = new InovanceTcpNet();
this.inovanceTcp.Series = InovanceSeries.H3U;
this.inovanceTcp.ConnectTimeOut = 2000; this.inovanceTcp.ConnectTimeOut = 2000;
} }
@ -166,56 +167,7 @@ public class InovanceImpl:IPlc
{ {
try try
{ {
OperateResult operateResult = new OperateResult(); OperateResult operateResult = inovanceTcp.Write(address, value);
int s = 0;
string[] strArry = address.Split('.');
//先读取整个块的内容
var info = inovanceTcp.ReadInt16(strArry[0]);
if (info.Content == 0)
{
int length = _stringChange.ParseToInt(strArry[1]) + 1;
string[] array = new string[length];
for (int i = 0; i < length; i++)
{
if (i == _stringChange.ParseToInt(strArry[1]))
{
array[i] = value.ToString();
}
else
{
array[i] = "0";
}
}
//反转
Array.Reverse(array);
byte[] buffer = new byte[array.Length];
string result = "";
for (int i = 0; i < array.Length; i++)
{
result += (byte)Convert.ToInt32(array[i], 16);
}
s = Convert.ToInt32(result.Trim(), 2);
operateResult = inovanceTcp.Write(strArry[0], (ushort)s);
}
else
{
var inf2 = Convert.ToString(info.Content, 2);
string[] infoArray = new string[inf2.Length];
for (int i = 0; i < inf2.Length; i++)
{
infoArray[i] = inf2.Substring(i, 1);
}
Array.Reverse(infoArray);
infoArray[_stringChange.ParseToInt(strArry[1])] = value.ToString();
string result = "";
foreach (var item in infoArray)
{
result = result + item;
}
s = Convert.ToInt32(result.Trim(), 10);
operateResult = inovanceTcp.Write(strArry[0], s);
}
if (!operateResult.IsSuccess) if (!operateResult.IsSuccess)
{ {
throw new InvalidOperationException($"根据地址:{address};写入int16数据失败{operateResult.Message}"); throw new InvalidOperationException($"根据地址:{address};写入int16数据失败{operateResult.Message}");
@ -226,6 +178,68 @@ public class InovanceImpl:IPlc
{ {
throw new InvalidOperationException($"根据地址:{address};写入int16数据异常{ex.Message}"); throw new InvalidOperationException($"根据地址:{address};写入int16数据异常{ex.Message}");
} }
// try
// {
// OperateResult operateResult = new OperateResult();
// int s = 0;
// string[] strArry = address.Split('.');
//
// //先读取整个块的内容
// var info = inovanceTcp.ReadInt16(strArry[0]);
// if (info.Content == 0)
// {
// int length = _stringChange.ParseToInt(strArry[1]) + 1;
// string[] array = new string[length];
// for (int i = 0; i < length; i++)
// {
// if (i == _stringChange.ParseToInt(strArry[1]))
// {
// array[i] = value.ToString();
// }
// else
// {
// array[i] = "0";
// }
// }
// //反转
// Array.Reverse(array);
// byte[] buffer = new byte[array.Length];
// string result = "";
// for (int i = 0; i < array.Length; i++)
// {
// result += (byte)Convert.ToInt32(array[i], 16);
// }
// s = Convert.ToInt32(result.Trim(), 2);
// operateResult = inovanceTcp.Write(strArry[0], (ushort)s);
// }
// else
// {
// var inf2 = Convert.ToString(info.Content, 2);
// string[] infoArray = new string[inf2.Length];
// for (int i = 0; i < inf2.Length; i++)
// {
// infoArray[i] = inf2.Substring(i, 1);
// }
// Array.Reverse(infoArray);
// infoArray[_stringChange.ParseToInt(strArry[1])] = value.ToString();
// string result = "";
// foreach (var item in infoArray)
// {
// result = result + item;
// }
// s = Convert.ToInt32(result.Trim(), 10);
// operateResult = inovanceTcp.Write(strArry[0], s);
// }
// if (!operateResult.IsSuccess)
// {
// throw new InvalidOperationException($"根据地址:{address};写入int16数据失败{operateResult.Message}");
// }
// return operateResult.IsSuccess;
// }
// catch (Exception ex)
// {
// throw new InvalidOperationException($"根据地址:{address};写入int16数据异常{ex.Message}");
// }
} }
/// <summary> /// <summary>

@ -10,9 +10,9 @@
"apollo": { "apollo": {
"AppId": "SlnWcs", "AppId": "SlnWcs",
"Env": "DEV", "Env": "DEV",
"MetaServer": "http://119.45.202.115:4320", "MetaServer": "http://172.16.12.20:7320",
"ConfigServer": [ "ConfigServer": [
"http://119.45.202.115:4320" "http://172.16.12.20:7320"
] ]
} }
} }

@ -0,0 +1,56 @@
#region << 版 本 注 释 >>
/*--------------------------------------------------------------------
* (c) 2026 WenJY
* CLR4.0.30319.42000
* Mr.Wen's MacBook Pro
* Sln.Wcs
* CD7CB56F-3972-40A5-A811-880CFE6EC557
*
* WenJY
*
* 2026-06-18 14:57:01
* V1.0.0
*
*
*--------------------------------------------------------------------
*
*
*
*
* V1.0.0
*--------------------------------------------------------------------*/
#endregion << 版 本 注 释 >>
using Sln.Wcs.HoistDispatcher;
using Sln.Wcs.Model.Domain;
namespace Sln.Wcs;
public class HoistDispatchHubTest
{
private readonly HoistDispatchHub _hub;
public HoistDispatchHubTest(HoistDispatchHub hub)
{
_hub = hub;
}
public async void Run()
{
BaseDeviceInfo info = await _hub.GetFreeHoistAsync("1#Host");
_hub.TaskDispatch(info,new LiveTaskDetail()
{
deviceType = 2,
startPoint = "15#_L1_HOIST",
endPoint = "15#_L2_HOIST",
materialBarcode = "202606180001",
taskCode = "202606180001",
taskType = 1
});
_hub.TaskRun(info);
}
}

@ -10,9 +10,9 @@
"apollo": { "apollo": {
"AppId": "SlnWcs", "AppId": "SlnWcs",
"Env": "DEV", "Env": "DEV",
"MetaServer": "http://119.45.202.115:4320", // 4310 "MetaServer": "http://172.16.12.20:7320", //http://119.45.202.115:4320 4310
"ConfigServer": [ "ConfigServer": [
"http://119.45.202.115:4320" "http://172.16.12.20:7320"
] ]
} }
} }

@ -17,7 +17,11 @@
等待步骤执行WAIT => 筛选提升机、下发提升机任务 等待步骤执行WAIT => 筛选提升机、下发提升机任务
FINISHED/MANUALED => 完成/手动完成,可以进行后序任务 FINISHED/MANUALED => 完成/手动完成,可以进行后序任务
CANCELLED => 任务取消,终止调度任务 CANCELLED => 任务取消,终止调度任务
- [ ] Strategy执行到提升机任务时进行读取托盘条码验证物料并下发提升机启动信号 - [ ] Strategy执行到提升机任务时判断接驳位状态如果接驳位状态占用则说明有物料进行读取托盘条码验证物料并下发提升机启动信号
### 任务创建修改
- [ ] 添加手动放、手动取操作,如果是手动放,任务从提升机开始,手动取也是以提升机结束
- [ ] 手动放:任务执行则下发提升机任务
### 2. 任务执行引擎(分组并行方案) ### 2. 任务执行引擎(分组并行方案)
- [ ] 包材入库逻辑测试 - [ ] 包材入库逻辑测试

Loading…
Cancel
Save