wenxiangchao
3 天以前 b544d5cccd76735e034c8055918a50927b437474
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
namespace Aging.ResourceContracts
{
    public enum OperationState
    {
        Succeeded, Failed,
        /// <summary>栅栏校验失败:Grant 的 epoch/generation 已失效(含 Broker 重启)。</summary>
        RejectedStaleLease,
        /// <summary>INV-04 雏形:客户端 configHash 与 Broker 生效配置不一致。</summary>
        RejectedConfigMismatch,
        /// <summary>会话队列满。</summary>
        RejectedQueueFull,
        /// <summary>已发送但结果未知(INV-06:禁止当未执行)。</summary>
        Unknown
    }
 
    /// <summary>一次有界设备动作(MVP=OneShot)。Grants 必须覆盖 resources。</summary>
    public sealed class DeviceOperation
    {
        /// <summary>白名单操作码,如 "CAN_SEND"/"CAN_RECV"/"CAN_AUTO_RESPONSE"/"CAN_STATUS"。</summary>
        public string OperationCode { get; set; } = "";
        public string ParametersJson { get; set; } = "{}";
        public string IdempotencyKey { get; set; } = "";
        public string ConfigHash { get; set; } = "";
        public LeaseGrant[] Grants { get; set; } = new LeaseGrant[0];
        public long DeadlineUtcMs { get; set; }
    }
 
    public sealed class OperationResult
    {
        public string RequestId { get; set; } = "";
        public OperationState State { get; set; }
        public string ErrorCode { get; set; } = "";
        public string ReadbackJson { get; set; } = "{}";
        public long ServerEpoch { get; set; }
    }
}