Sfoglia il codice sorgente

feat(d2-02): control 调试会话数据类(DebugSession/DebugCommandResult)

huangjie 2 giorni fa
parent
commit
e3fa590

+ 14 - 0
ivf_tl_operate_2.0/control/ivf_tl_ControlHost/Debug/DebugCommandResult.cs

@@ -0,0 +1,14 @@
+using Newtonsoft.Json;
+namespace IvfTl.ControlHost.Debug
+{
+    /// <summary>命令/借用统一返回体。code 见 spec §4。</summary>
+    public class DebugCommandResult
+    {
+        [JsonProperty("ok")] public bool Ok { get; set; }
+        [JsonProperty("result", NullValueHandling = NullValueHandling.Ignore)] public object Result { get; set; }
+        [JsonProperty("error", NullValueHandling = NullValueHandling.Ignore)] public string Error { get; set; }
+        [JsonProperty("code", NullValueHandling = NullValueHandling.Ignore)] public string Code { get; set; }
+        public static DebugCommandResult Okay(object result = null) => new DebugCommandResult { Ok = true, Result = result };
+        public static DebugCommandResult Fail(string code, string error) => new DebugCommandResult { Ok = false, Code = code, Error = error };
+    }
+}

+ 19 - 0
ivf_tl_operate_2.0/control/ivf_tl_ControlHost/Debug/DebugSession.cs

@@ -0,0 +1,19 @@
+using System;
+using IvfTl.Hardware;
+namespace IvfTl.ControlHost.Debug
+{
+    /// <summary>一次调试借用会话。lease 是 control 进程内借到的舱句柄;LastSeen 用注入时钟刷新。</summary>
+    public sealed class DebugSession
+    {
+        public string SessionId { get; }
+        public int HouseSn { get; }
+        public IHardwareLease Lease { get; }
+        public DateTime LastSeen { get; set; }
+        public int CurrentHor { get; set; } = -1;
+        public int CurrentVer { get; set; } = -1;
+        public DebugSession(string sessionId, int houseSn, IHardwareLease lease, DateTime now)
+        {
+            SessionId = sessionId; HouseSn = houseSn; Lease = lease; LastSeen = now;
+        }
+    }
+}