feat: 实现 ControllerClient HTTP 兼容层及 FANUC 运行时

- 新增 Flyshot.ControllerClientCompat 兼容层模块
  - 新增 Flyshot.Runtime.Fanuc 运行时模块
  - 新增 LegacyHttpApiController 暴露 HTTP 兼容 API
  - 补充 RuntimeOrchestrationTests 等测试覆盖
  - 补充 docs/ 兼容性需求与逆向工程文档
  - 更新 Host 注册、配置及解决方案引用

  变更概览:
  - Flyshot.ControllerClientCompat — 旧 ControllerClient 语义的 HTTP 适配
  - Flyshot.Runtime.Fanuc — IControllerRuntime 的 FANUC 真机实现
  - LegacyHttpApiController — HTTP API 兼容旧 SDK
  - docs/ — 兼容性需求与逆向工程分析文档
  - 测试:RuntimeOrchestrationTests、LegacyHttpApiCompatibilityTests
This commit is contained in:
2026-04-24 16:55:25 +08:00
parent 4eeaa3fef3
commit 8a20d9f507
35 changed files with 3869 additions and 10 deletions

View File

@@ -0,0 +1,83 @@
using Flyshot.Core.Config;
using Flyshot.Core.Domain;
namespace Flyshot.ControllerClientCompat;
/// <summary>
/// 根据旧版 ControllerClient 的机器人名称,解析当前 replacement 仓库支持的真实模型文件。
/// </summary>
public sealed class ControllerClientCompatRobotCatalog
{
/// <summary>
/// 保存当前现场支持的机器人名称到模型相对路径映射。
/// </summary>
private static readonly IReadOnlyDictionary<string, string> SupportedRobotModelMap = new Dictionary<string, string>(StringComparer.Ordinal)
{
["FANUC_LR_Mate_200iD"] = Path.Combine("FlyingShot", "FlyingShot", "Models", "LR_Mate_200iD_7L.robot"),
["FANUC_LR_Mate_200iD_7L"] = Path.Combine("FlyingShot", "FlyingShot", "Models", "LR_Mate_200iD_7L.robot")
};
private readonly ControllerClientCompatOptions _options;
private readonly RobotModelLoader _robotModelLoader;
/// <summary>
/// 初始化机器人兼容目录解析器。
/// </summary>
/// <param name="options">兼容层基础配置。</param>
/// <param name="robotModelLoader">.robot 文件加载器。</param>
public ControllerClientCompatRobotCatalog(
ControllerClientCompatOptions options,
RobotModelLoader robotModelLoader)
{
_options = options ?? throw new ArgumentNullException(nameof(options));
_robotModelLoader = robotModelLoader ?? throw new ArgumentNullException(nameof(robotModelLoader));
}
/// <summary>
/// 根据旧客户端的机器人名称加载对应模型。
/// </summary>
/// <param name="robotName">旧客户端传入的机器人名称。</param>
/// <returns>兼容层加载出的机器人模型。</returns>
public RobotProfile LoadProfile(string robotName)
{
if (string.IsNullOrWhiteSpace(robotName))
{
throw new ArgumentException("机器人名称不能为空。", nameof(robotName));
}
if (!SupportedRobotModelMap.TryGetValue(robotName, out var modelRelativePath))
{
throw new InvalidOperationException($"Unsupported robot name: {robotName}");
}
var workspaceRoot = ResolveWorkspaceRoot();
var modelPath = Path.Combine(workspaceRoot, modelRelativePath);
return _robotModelLoader.LoadProfile(modelPath);
}
/// <summary>
/// 解析父工作区根目录,优先使用显式配置。
/// </summary>
/// <returns>包含 `FlyingShot/` 与 `Rvbust/` 的父工作区根目录。</returns>
private string ResolveWorkspaceRoot()
{
if (!string.IsNullOrWhiteSpace(_options.WorkspaceRoot))
{
return Path.GetFullPath(_options.WorkspaceRoot);
}
var current = new DirectoryInfo(AppContext.BaseDirectory);
while (current is not null)
{
// 宿主和测试都从 replacement 仓库内启动;找到 sln 后回退一级就是父工作区根目录。
if (File.Exists(Path.Combine(current.FullName, "FlyshotReplacement.sln")))
{
return Path.GetFullPath(Path.Combine(current.FullName, ".."));
}
current = current.Parent;
}
throw new DirectoryNotFoundException("Unable to locate the flyshot workspace root.");
}
}