From 01d5cfc65f62fe9d7c5ff00b69af109a1664543a Mon Sep 17 00:00:00 2001
From: wanshenmean <cathay_xy@163.com>
Date: 星期一, 30 三月 2026 10:34:11 +0800
Subject: [PATCH] docs: 添加 MES 托盘进站出站集成设计
---
Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineNewJob/ConveyorLineTargetAddressSelector.cs | 172 +++++++++++++++++++++++++++++++++++++++++++++++++++-----
1 files changed, 155 insertions(+), 17 deletions(-)
diff --git a/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineNewJob/ConveyorLineTargetAddressSelector.cs b/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineNewJob/ConveyorLineTargetAddressSelector.cs
index 2983836..062265a 100644
--- a/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineNewJob/ConveyorLineTargetAddressSelector.cs
+++ b/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineNewJob/ConveyorLineTargetAddressSelector.cs
@@ -1,45 +1,143 @@
-锘縰sing WIDESEAWCS_QuartzJob;
+using Microsoft.Extensions.Logging;
+using WIDESEAWCS_Core.LogHelper;
+using WIDESEAWCS_QuartzJob;
+
namespace WIDESEAWCS_Tasks
{
/// <summary>
- /// 杈撻�佺嚎璁惧璇锋眰澶勭悊鍣細澶勭悊鎷樻潫鏈�/鎻掓嫈閽夋満涓婁笅灞傝姹傘��
+ /// 杈撻�佺嚎鐩爣鍦板潃閫夋嫨鍣� - 澶勭悊鎷樻潫鏈�/鎻掓嫈閽夋満鐨勪笂涓嬪眰璇锋眰
/// </summary>
+ /// <remarks>
+ /// 鏍稿績鑱岃矗锛�
+ /// 1. 澶勭悊鍏ュ簱鍦烘櫙鐨勭洰鏍囧湴鍧�閫夋嫨
+ /// 2. 澶勭悊鍑哄簱鍦烘櫙鐨勭洰鏍囧湴鍧�閫夋嫨
+ /// 3. 鍒ゆ柇鎷樻潫鏈哄拰鎻掓嫈閽夋満鐨勭墿鏂欒姹傜姸鎬�
+ /// 4. 鍗忚皟杈撻�佺嚎涓庝笂涓嬪眰璁惧涔嬮棿鐨勭墿鏂欐祦杞�
+ ///
+ /// 鎷樻潫鏈哄拰鎻掓嫈閽夋満閮芥湁涓婁笅涓ゅ眰缁撴瀯锛�
+ /// 姣忓眰閮芥湁鐙珛鐨勭墿鏂欒姹傚拰鍑烘枡淇″彿锛岄渶瑕佸垎鍒鐞嗐��
+ /// </remarks>
public class ConveyorLineTargetAddressSelector
{
+ /// <summary>
+ /// 鎷樻潫鏈哄悕绉板父閲�
+ /// </summary>
private const string ConstraintMachineName = "鎷樻潫鏈�";
+
+ /// <summary>
+ /// 鎻掓嫈閽夋満鍚嶇О甯搁噺
+ /// </summary>
private const string PinMachineName = "鎻掓嫈閽夋満";
+ /// <summary>
+ /// 鎷樻潫鏈哄搴旂殑鐐逛綅缂栫爜鍒楄〃
+ /// </summary>
+ /// <remarks>
+ /// 褰撶洰鏍囧湴鍧�鍦ㄨ繖浜涚紪鐮佷腑鏃讹紝琛ㄧず闇�瑕佷笌鎷樻潫鏈轰氦浜掋��
+ /// </remarks>
+ private static readonly List<string> ConstraintMachineCodes = new List<string> { "10180", "20090" };
+
+ /// <summary>
+ /// 鎻掓嫈閽夋満瀵瑰簲鐨勭偣浣嶇紪鐮佸垪琛�
+ /// </summary>
+ /// <remarks>
+ /// 褰撶洰鏍囧湴鍧�鍦ㄨ繖浜涚紪鐮佷腑鏃讹紝琛ㄧず闇�瑕佷笌鎻掓嫈閽夋満浜や簰銆�
+ /// </remarks>
+ private static readonly List<string> PinMachineCodes = new List<string> { "10190", "20100" };
+
+ /// <summary>
+ /// 鏃ュ織璁板綍鍣�
+ /// </summary>
+ private readonly ILogger _logger;
+
+ /// <summary>
+ /// 鏋勯�犲嚱鏁�
+ /// </summary>
+ /// <param name="logger">鏃ュ織璁板綍鍣�</param>
+ public ConveyorLineTargetAddressSelector(ILogger logger)
+ {
+ _logger = logger;
+ }
+
+ /// <summary>
+ /// 澶勭悊鍏ュ簱鍦烘櫙鐨勪笅涓�鍦板潃璇锋眰
+ /// </summary>
+ /// <remarks>
+ /// 褰撳叆搴撲换鍔℃墽琛屽埌鏌愪釜浣嶇疆鏃惰皟鐢ㄦ鏂规硶銆�
+ /// 鍒ゆ柇鐩爣璁惧鏄惁闇�瑕佺墿鏂欐垨鍙互鍑烘枡銆�
+ /// </remarks>
+ /// <param name="conveyorLine">杈撻�佺嚎璁惧瀵硅薄</param>
+ /// <param name="nextAddress">涓嬩竴鍦板潃/鐩爣璁惧缂栫爜</param>
+ /// <param name="childDeviceCode">褰撳墠瀛愯澶囩紪鐮�</param>
public void HandleInboundNextAddress(CommonConveyorLine conveyorLine, string nextAddress, string childDeviceCode)
{
+ _logger.LogDebug("HandleInboundNextAddress锛氬叆搴撲笅涓�鍦板潃锛屽瓙璁惧: {ChildDeviceCode}锛岀洰鏍囧湴鍧�: {NextAddress}", childDeviceCode, nextAddress);
+ QuartzLogger.Debug($"HandleInboundNextAddress锛氬叆搴撲笅涓�鍦板潃锛屽瓙璁惧: {childDeviceCode}锛岀洰鏍囧湴鍧�: {nextAddress}", conveyorLine.DeviceCode);
+ // 璋冪敤閫氱敤澶勭悊鏂规硶锛宨sUpper = true 琛ㄧず澶勭悊涓婂眰
HandleDeviceRequest(conveyorLine, nextAddress, childDeviceCode, isUpper: true);
}
+ /// <summary>
+ /// 澶勭悊鍑哄簱鍦烘櫙鐨勪笅涓�鍦板潃璇锋眰
+ /// </summary>
+ /// <remarks>
+ /// 褰撳嚭搴撲换鍔℃墽琛屽埌鏌愪釜浣嶇疆鏃惰皟鐢ㄦ鏂规硶銆�
+ /// 鍒ゆ柇鐩爣璁惧鏄惁闇�瑕佺墿鏂欐垨鍙互鍑烘枡銆�
+ /// </remarks>
+ /// <param name="conveyorLine">杈撻�佺嚎璁惧瀵硅薄</param>
+ /// <param name="nextAddress">涓嬩竴鍦板潃/鐩爣璁惧缂栫爜</param>
+ /// <param name="childDeviceCode">褰撳墠瀛愯澶囩紪鐮�</param>
public void HandleOutboundNextAddress(CommonConveyorLine conveyorLine, string nextAddress, string childDeviceCode)
{
+ _logger.LogDebug("HandleOutboundNextAddress锛氬嚭搴撲笅涓�鍦板潃锛屽瓙璁惧: {ChildDeviceCode}锛岀洰鏍囧湴鍧�: {NextAddress}", childDeviceCode, nextAddress);
+ QuartzLogger.Debug($"HandleOutboundNextAddress锛氬嚭搴撲笅涓�鍦板潃锛屽瓙璁惧: {childDeviceCode}锛岀洰鏍囧湴鍧�: {nextAddress}", conveyorLine.DeviceCode);
+ // 璋冪敤閫氱敤澶勭悊鏂规硶锛宨sUpper = false 琛ㄧず澶勭悊涓嬪眰
HandleDeviceRequest(conveyorLine, nextAddress, childDeviceCode, isUpper: false);
}
+ /// <summary>
+ /// 閫氱敤璁惧璇锋眰澶勭悊鏂规硶
+ /// </summary>
+ /// <remarks>
+ /// 鏍规嵁鐩爣鍦板潃绫诲瀷锛堟嫎鏉熸満/鎻掓嫈閽夋満锛夎皟鐢ㄧ浉搴旂殑澶勭悊閫昏緫銆�
+ /// 澶勭悊涓婁笅灞傝澶囩殑鐗╂枡璇锋眰鍜屽嚭鏂欏崗璋冦��
+ /// </remarks>
+ /// <param name="conveyorLine">杈撻�佺嚎璁惧瀵硅薄</param>
+ /// <param name="nextAddress">涓嬩竴鍦板潃/鐩爣璁惧缂栫爜</param>
+ /// <param name="childDeviceCode">褰撳墠瀛愯澶囩紪鐮�</param>
+ /// <param name="isUpper">鏄惁澶勭悊涓婂眰锛坱rue=涓婂眰锛宖alse=涓嬪眰锛�</param>
private void HandleDeviceRequest(CommonConveyorLine conveyorLine, string nextAddress, string childDeviceCode, bool isUpper)
{
+ // 鑾峰彇鍏ㄥ眬璁惧鍒楄〃
var devices = Storage.Devices;
- if (string.Equals(nextAddress, ConstraintMachineName, StringComparison.Ordinal))
+ // 鍒ゆ柇鐩爣璁惧绫诲瀷
+ if (ConstraintMachineCodes.Contains(nextAddress))
{
+ // 鎷樻潫鏈哄鐞嗗垎鏀�
+ // 鏌ユ壘鎷樻潫鏈鸿澶�
ConstraintMachine? constraint = devices.OfType<ConstraintMachine>().FirstOrDefault(d => d.DeviceName == ConstraintMachineName);
if (constraint == null)
{
+ _logger.LogDebug("HandleDeviceRequest锛氭湭鎵惧埌鎷樻潫鏈鸿澶�");
+ QuartzLogger.Debug("HandleDeviceRequest锛氭湭鎵惧埌鎷樻潫鏈鸿澶�", conveyorLine.DeviceCode);
+ // 鏈壘鍒版嫎鏉熸満璁惧锛岀洿鎺ヨ繑鍥�
return;
}
+ // 澶勭悊鎷樻潫鏈虹殑璇锋眰
ProcessDeviceRequest(
conveyorLine,
childDeviceCode,
+ // 鑾峰彇鐗╂枡璇锋眰鏍囧織锛堜笂灞傛垨涓嬪眰锛�
getMaterialRequest: () => isUpper
- ? constraint.GetValue<ConstraintMachineDBName, bool>(ConstraintMachineDBName.MaterialRequestUpper)
- : constraint.GetValue<ConstraintMachineDBName, bool>(ConstraintMachineDBName.MaterialRequestLower),
+ ? constraint.GetValue<ConstraintMachineDBName, short>(ConstraintMachineDBName.MaterialRequestUpper) != 0
+ : constraint.GetValue<ConstraintMachineDBName, short>(ConstraintMachineDBName.MaterialRequestLower) != 0,
+ // 鑾峰彇鍑烘枡璇锋眰鏍囧織锛堜笂灞傛垨涓嬪眰锛�
getOutputRequest: () => isUpper
- ? constraint.GetValue<ConstraintMachineDBName, bool>(ConstraintMachineDBName.OutputRequestUpper)
- : constraint.GetValue<ConstraintMachineDBName, bool>(ConstraintMachineDBName.OutputRequestLower),
+ ? constraint.GetValue<ConstraintMachineDBName, short>(ConstraintMachineDBName.OutputRequestUpper) != 0
+ : constraint.GetValue<ConstraintMachineDBName, short>(ConstraintMachineDBName.OutputRequestLower) != 0,
+ // 璁剧疆杈撳嚭灏辩华鏍囧織锛堜笂灞傛垨涓嬪眰锛�
setOutputReady: outputReq =>
{
if (isUpper)
@@ -50,25 +148,34 @@
{
constraint.SetValue(ConstraintMachineDBName.ConstraintTrayOutputReadyLower, outputReq ? 1 : 0);
}
- });
+ },
+ "鎷樻潫鏈�");
}
- else if (string.Equals(nextAddress, PinMachineName, StringComparison.Ordinal))
+ else if (PinMachineCodes.Contains(nextAddress))
{
+ // 鎻掓嫈閽夋満澶勭悊鍒嗘敮
+ // 鏌ユ壘鎻掓嫈閽夋満璁惧
PinMachine? pinMachine = devices.OfType<PinMachine>().FirstOrDefault(d => d.DeviceName == PinMachineName);
if (pinMachine == null)
{
+ _logger.LogDebug("HandleDeviceRequest锛氭湭鎵惧埌鎻掓嫈閽夋満璁惧");
+ QuartzLogger.Debug("HandleDeviceRequest锛氭湭鎵惧埌鎻掓嫈閽夋満璁惧", conveyorLine.DeviceCode);
return;
}
+ // 澶勭悊鎻掓嫈閽夋満鐨勮姹�
ProcessDeviceRequest(
conveyorLine,
childDeviceCode,
+ // 鑾峰彇鐗╂枡璇锋眰鏍囧織锛堜笂灞傛垨涓嬪眰锛�
getMaterialRequest: () => isUpper
- ? pinMachine.GetValue<PinMachineDBName, bool>(PinMachineDBName.MaterialRequestUpper)
- : pinMachine.GetValue<PinMachineDBName, bool>(PinMachineDBName.MaterialRequestLower),
+ ? pinMachine.GetValue<PinMachineDBName, short>(PinMachineDBName.MaterialRequestUpper) != 0
+ : pinMachine.GetValue<PinMachineDBName, short>(PinMachineDBName.MaterialRequestLower) != 0,
+ // 鑾峰彇鍑烘枡璇锋眰鏍囧織锛堜笂灞傛垨涓嬪眰锛�
getOutputRequest: () => isUpper
- ? pinMachine.GetValue<PinMachineDBName, bool>(PinMachineDBName.OutputRequestUpper)
- : pinMachine.GetValue<PinMachineDBName, bool>(PinMachineDBName.OutputRequestLower),
+ ? pinMachine.GetValue<PinMachineDBName, short>(PinMachineDBName.OutputRequestUpper) != 0
+ : pinMachine.GetValue<PinMachineDBName, short>(PinMachineDBName.OutputRequestLower) != 0,
+ // 璁剧疆杈撳嚭灏辩华鏍囧織锛堜笂灞傛垨涓嬪眰锛�
setOutputReady: outputReq =>
{
if (isUpper)
@@ -79,30 +186,61 @@
{
pinMachine.SetValue(PinMachineDBName.PlugPinTrayOutputReadyLower, outputReq ? 1 : 0);
}
- });
+ },
+ "鎻掓嫈閽夋満");
}
}
- private static void ProcessDeviceRequest(
+ /// <summary>
+ /// 澶勭悊璁惧璇锋眰鐨勬牳蹇冮�昏緫
+ /// </summary>
+ /// <remarks>
+ /// 鏍规嵁鐗╂枡璇锋眰鍜屽嚭鏂欒姹傜殑鐘舵�侊細
+ /// - 濡傛灉鏈夌墿鏂欒姹傦紝璁剧疆鐩爣鍦板潃骞跺彂閫� ACK
+ /// - 濡傛灉鏈夊嚭鏂欒姹傦紝璁剧疆璁惧鐨勮緭鍑哄氨缁爣蹇�
+ /// </remarks>
+ /// <param name="conveyorLine">杈撻�佺嚎璁惧瀵硅薄</param>
+ /// <param name="childDeviceCode">褰撳墠瀛愯澶囩紪鐮�</param>
+ /// <param name="getMaterialRequest">鑾峰彇鐗╂枡璇锋眰鐘舵�佺殑濮旀墭</param>
+ /// <param name="getOutputRequest">鑾峰彇鍑烘枡璇锋眰鐘舵�佺殑濮旀墭</param>
+ /// <param name="setOutputReady">璁剧疆杈撳嚭灏辩华鏍囧織鐨勫鎵�</param>
+ /// <param name="deviceType">璁惧绫诲瀷鎻忚堪</param>
+ private void ProcessDeviceRequest(
CommonConveyorLine conveyorLine,
string childDeviceCode,
Func<bool> getMaterialRequest,
Func<bool> getOutputRequest,
- Action<bool> setOutputReady)
+ Action<bool> setOutputReady,
+ string deviceType)
{
+ // 鑾峰彇鐗╂枡璇锋眰鐘舵��
bool materialReq = getMaterialRequest();
+
+ // 鑾峰彇鍑烘枡璇锋眰鐘舵��
bool outputReq = getOutputRequest();
+ _logger.LogDebug("ProcessDeviceRequest锛歿DeviceType}锛屽瓙璁惧: {ChildDeviceCode}锛岀墿鏂欒姹�: {MaterialReq}锛屽嚭鏂欒姹�: {OutputReq}",
+ deviceType, childDeviceCode, materialReq, outputReq);
+ QuartzLogger.Debug($"ProcessDeviceRequest锛歿deviceType}锛屽瓙璁惧: {childDeviceCode}锛岀墿鏂欒姹�: {materialReq}锛屽嚭鏂欒姹�: {outputReq}", conveyorLine.DeviceCode);
+
+ // 濡傛灉璁惧闇�瑕佺墿鏂�
if (materialReq)
{
+ // 璁剧疆鐩爣鍦板潃涓� 1锛堣〃绀烘湁鏂欒繘鏉ワ級
conveyorLine.SetValue(ConveyorLineDBNameNew.Target, 1, childDeviceCode);
+
+ // 鍥炲 ACK 纭淇″彿
conveyorLine.SetValue(ConveyorLineDBNameNew.WCS_ACK, 1, childDeviceCode);
+
+ _logger.LogInformation("ProcessDeviceRequest锛歿DeviceType} 闇�瑕佺墿鏂欙紝宸茶缃洰鏍囧湴鍧�鍜孉CK", deviceType);
+ QuartzLogger.Info($"ProcessDeviceRequest锛歿deviceType} 闇�瑕佺墿鏂欙紝宸茶缃洰鏍囧湴鍧�鍜孉CK", conveyorLine.DeviceCode);
}
else
{
+ // 璁惧涓嶉渶瑕佺墿鏂欙紝璁剧疆杈撳嚭灏辩华鏍囧織
+ // 閫氱煡璁惧鍙互缁х画鍑烘枡
setOutputReady(outputReq);
}
}
}
}
-
--
Gitblit v1.9.3