🐛 fix(fanuc): 修复 J519 队列等待与日志注入
* 为 FANUC 命令、状态和 J519 客户端注入独立日志记录器 * 补充不可接收命令状态下队列完成等待的回归测试 * 调整 J519 命令流结束后的状态处理语义
This commit is contained in:
@@ -39,23 +39,49 @@ public sealed class FanucControllerRuntime : IControllerRuntime, IDisposable
|
||||
/// 初始化 FANUC 控制器运行时。
|
||||
/// </summary>
|
||||
/// <param name="logger">运行时日志记录器。</param>
|
||||
/// <param name="commandLogger">FANUC 10012 命令通道客户端日志记录器。</param>
|
||||
/// <param name="stateLogger">FANUC 10010 状态通道客户端日志记录器。</param>
|
||||
/// <param name="j519Logger">J519 客户端日志记录器。</param>
|
||||
public FanucControllerRuntime(ILogger<FanucControllerRuntime> logger, ILogger<FanucJ519Client> j519Logger)
|
||||
public FanucControllerRuntime(
|
||||
ILogger<FanucControllerRuntime> logger,
|
||||
ILogger<FanucCommandClient> commandLogger,
|
||||
ILogger<FanucStateClient> stateLogger,
|
||||
ILogger<FanucJ519Client> j519Logger)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(logger);
|
||||
ArgumentNullException.ThrowIfNull(commandLogger);
|
||||
ArgumentNullException.ThrowIfNull(stateLogger);
|
||||
ArgumentNullException.ThrowIfNull(j519Logger);
|
||||
|
||||
_commandClient = new FanucCommandClient();
|
||||
_stateClient = new FanucStateClient();
|
||||
_commandClient = new FanucCommandClient(commandLogger);
|
||||
_stateClient = new FanucStateClient(new FanucStateClientOptions(), stateLogger);
|
||||
_j519Client = new FanucJ519Client(j519Logger);
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 初始化 FANUC 控制器运行时,并仅显式传入运行时与 J519 日志记录器。
|
||||
/// </summary>
|
||||
/// <param name="logger">运行时日志记录器。</param>
|
||||
/// <param name="j519Logger">J519 客户端日志记录器。</param>
|
||||
public FanucControllerRuntime(ILogger<FanucControllerRuntime> logger, ILogger<FanucJ519Client> j519Logger)
|
||||
: this(
|
||||
logger,
|
||||
NullLogger<FanucCommandClient>.Instance,
|
||||
NullLogger<FanucStateClient>.Instance,
|
||||
j519Logger)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 初始化一份无日志的 FANUC 控制器运行时,供离线测试或手工构造场景使用。
|
||||
/// </summary>
|
||||
public FanucControllerRuntime()
|
||||
: this(NullLogger<FanucControllerRuntime>.Instance, NullLogger<FanucJ519Client>.Instance)
|
||||
: this(
|
||||
NullLogger<FanucControllerRuntime>.Instance,
|
||||
NullLogger<FanucCommandClient>.Instance,
|
||||
NullLogger<FanucStateClient>.Instance,
|
||||
NullLogger<FanucJ519Client>.Instance)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -737,18 +763,20 @@ public sealed class FanucControllerRuntime : IControllerRuntime, IDisposable
|
||||
sample.TrajectoryTime);
|
||||
}
|
||||
}
|
||||
if (_j519Client.EndCommandStreamAfterQueueDrained && commands.Count > 0)
|
||||
{
|
||||
// 正常结束命令流时追加独立结束帧,避免把最后一个真实轨迹采样点和结束语义混在一起。
|
||||
commands.Add(new FanucJ519Command(
|
||||
sequence: 0,
|
||||
targetJoints: commands[^1].TargetJoints,
|
||||
lastData: 1,
|
||||
writeIoType: 2,
|
||||
writeIoIndex: 1,
|
||||
writeIoMask: 0,
|
||||
writeIoValue: 0));
|
||||
}
|
||||
//TODO 不进行结束,一致发送最后一帧
|
||||
|
||||
// if (_j519Client.EndCommandStreamAfterQueueDrained && commands.Count > 0)
|
||||
// {
|
||||
// // 正常结束命令流时追加独立结束帧,避免把最后一个真实轨迹采样点和结束语义混在一起。
|
||||
// commands.Add(new FanucJ519Command(
|
||||
// sequence: 0,
|
||||
// targetJoints: commands[^1].TargetJoints,
|
||||
// lastData: 1,
|
||||
// writeIoType: 2,
|
||||
// writeIoIndex: 1,
|
||||
// writeIoMask: 0,
|
||||
// writeIoValue: 0));
|
||||
// }
|
||||
TryWriteDenseSendArtifacts(result, outputDir, sentJointRows, sentTimingRows, sentJerkRows, triggerBindings);
|
||||
|
||||
// 上层只负责生成完整目标序列,真实出队节拍交给 J519 状态包驱动。
|
||||
|
||||
@@ -609,8 +609,8 @@ public sealed class FanucJ519Client : IDisposable
|
||||
if (_endCommandStreamAfterQueueDrained && command.LastData == 1)
|
||||
{
|
||||
// LastData 是命令流的正常结束语义;结束后保留状态接收,但不继续回发保姿包。
|
||||
_monitorOnlyAfterLastData = true;
|
||||
_motionStarted = false;
|
||||
// _monitorOnlyAfterLastData = true;
|
||||
// _motionStarted = false;
|
||||
CompleteCommandQueueLocked();
|
||||
}
|
||||
else if (willDrainQueue && _commandQueue is { Count: 0 })
|
||||
|
||||
Reference in New Issue
Block a user