33
44namespace MaaFramework . Binding . Notification ;
55
6- /// <inheritdoc cref="MaaMsg.Resource.Loading.Prefix"/>
6+ #pragma warning disable CS1591 // 缺少对公共可见类型或成员的 XML 注释
7+
8+ /// <inheritdoc cref="MaaMsg.Resource.Loading"/>
9+ public enum ResourcePathType
10+ {
11+ Bundle ,
12+ OcrModel ,
13+ Pipeline ,
14+ Image ,
15+
16+ Unknown = - 1
17+ }
18+
19+ /// <inheritdoc cref="MaaMsg.Resource.Loading"/>
720public record ResourceLoadingDetail (
8- [ property: JsonPropertyName ( "res_id" ) ] int ResourceId ,
21+ [ property: JsonPropertyName ( "res_id" ) ] long ResourceId ,
922 [ property: JsonPropertyName ( "path" ) ] string Path ,
1023 [ property: JsonPropertyName ( "type" ) ] string Type ,
1124 [ property: JsonPropertyName ( "hash" ) ] string Hash
12- ) ;
25+ )
26+ {
27+ // 1. .NET 7 没有支持 aot 的 JsonStringEnumConverter<TEnum>
28+ // 2. Unknown 向前兼容,使用 JsonStringEnumConverter 还需要设置 option 并且将 Unknown 设置为默认值 0
29+ [ JsonIgnore ] public ResourcePathType ParsedType => Enum . TryParse < ResourcePathType > ( Type , true , out var result ) ? result : ResourcePathType . Unknown ;
30+ } ;
1331
14- /// <inheritdoc cref="MaaMsg.Controller.Action.Prefix "/>
32+ /// <inheritdoc cref="MaaMsg.Controller.Action"/>
1533public record ControllerActionDetail (
16- [ property: JsonPropertyName ( "ctrl_id" ) ] int ControllerId ,
34+ [ property: JsonPropertyName ( "ctrl_id" ) ] long ControllerId ,
1735 [ property: JsonPropertyName ( "uuid" ) ] string Uuid ,
1836 [ property: JsonPropertyName ( "action" ) ] string Action ,
1937 [ property: JsonPropertyName ( "param" ) ] JsonElement Param ,
2038 [ property: JsonPropertyName ( "info" ) ] JsonElement Info
2139) ;
2240
23- /// <inheritdoc cref="MaaMsg.Tasker.Task.Prefix "/>
41+ /// <inheritdoc cref="MaaMsg.Tasker.Task"/>
2442public record TaskerTaskDetail (
25- [ property: JsonPropertyName ( "task_id" ) ] int TaskId ,
43+ [ property: JsonPropertyName ( "task_id" ) ] long TaskId ,
2644 [ property: JsonPropertyName ( "entry" ) ] string Entry ,
2745 [ property: JsonPropertyName ( "uuid" ) ] string Uuid ,
2846 [ property: JsonPropertyName ( "hash" ) ] string Hash
2947) ;
3048
31- /// <inheritdoc cref="MaaMsg.Node.PipelineNode.Prefix "/>
49+ /// <inheritdoc cref="MaaMsg.Node.PipelineNode"/>
3250public record PipelineNodeDetail (
33- [ property: JsonPropertyName ( "task_id" ) ] int TaskId ,
34- [ property: JsonPropertyName ( "node_id" ) ] int NodeId ,
51+ [ property: JsonPropertyName ( "task_id" ) ] long TaskId ,
52+ [ property: JsonPropertyName ( "node_id" ) ] long NodeId ,
3553 [ property: JsonPropertyName ( "name" ) ] string Name ,
36- [ property: JsonPropertyName ( "focus" ) ] JsonElement ? Focus
54+ [ property: JsonPropertyName ( "focus" ) ] JsonElement Focus
3755) ;
3856
39- /// <inheritdoc cref="MaaMsg.Node.RecognitionNode.Prefix "/>
57+ /// <inheritdoc cref="MaaMsg.Node.RecognitionNode"/>
4058public record RecognitionNodeDetail (
41- [ property: JsonPropertyName ( "task_id" ) ] int TaskId ,
42- [ property: JsonPropertyName ( "node_id" ) ] int NodeId ,
59+ [ property: JsonPropertyName ( "task_id" ) ] long TaskId ,
60+ [ property: JsonPropertyName ( "node_id" ) ] long NodeId ,
4361 [ property: JsonPropertyName ( "name" ) ] string Name ,
44- [ property: JsonPropertyName ( "focus" ) ] JsonElement ? Focus
62+ [ property: JsonPropertyName ( "focus" ) ] JsonElement Focus
4563) ;
4664
47- /// <inheritdoc cref="MaaMsg.Node.ActionNode.Prefix "/>
65+ /// <inheritdoc cref="MaaMsg.Node.ActionNode"/>
4866public record ActionNodeDetail (
49- [ property: JsonPropertyName ( "task_id" ) ] int TaskId ,
50- [ property: JsonPropertyName ( "node_id" ) ] int NodeId ,
67+ [ property: JsonPropertyName ( "task_id" ) ] long TaskId ,
68+ [ property: JsonPropertyName ( "node_id" ) ] long NodeId ,
5169 [ property: JsonPropertyName ( "name" ) ] string Name ,
52- [ property: JsonPropertyName ( "focus" ) ] JsonElement ? Focus
70+ [ property: JsonPropertyName ( "focus" ) ] JsonElement Focus
5371) ;
5472
5573/// <summary>
@@ -61,26 +79,57 @@ public record NodeAttr(
6179 [ property: JsonPropertyName ( "anchor" ) ] bool Anchor
6280) ;
6381
64- /// <inheritdoc cref="MaaMsg.Node.NextList.Prefix "/>
82+ /// <inheritdoc cref="MaaMsg.Node.NextList"/>
6583public record NodeNextListDetail (
66- [ property: JsonPropertyName ( "task_id" ) ] int TaskId ,
84+ [ property: JsonPropertyName ( "task_id" ) ] long TaskId ,
6785 [ property: JsonPropertyName ( "name" ) ] string Name ,
6886 [ property: JsonPropertyName ( "list" ) ] IReadOnlyList < NodeAttr > NextList ,
69- [ property: JsonPropertyName ( "focus" ) ] JsonElement ? Focus
87+ [ property: JsonPropertyName ( "focus" ) ] JsonElement Focus
7088) ;
7189
72- /// <inheritdoc cref="MaaMsg.Node.Recognition.Prefix "/>
90+ /// <inheritdoc cref="MaaMsg.Node.Recognition"/>
7391public record NodeRecognitionDetail (
74- [ property: JsonPropertyName ( "task_id" ) ] int TaskId ,
75- [ property: JsonPropertyName ( "reco_id" ) ] int RecognitionId ,
92+ [ property: JsonPropertyName ( "task_id" ) ] long TaskId ,
93+ [ property: JsonPropertyName ( "reco_id" ) ] long RecognitionId ,
7694 [ property: JsonPropertyName ( "name" ) ] string Name ,
77- [ property: JsonPropertyName ( "focus" ) ] JsonElement ? Focus
95+ [ property: JsonPropertyName ( "focus" ) ] JsonElement Focus ,
96+ [ property: JsonPropertyName ( "anchor" ) ] string ? Anchor
7897) ;
7998
80- /// <inheritdoc cref="MaaMsg.Node.Action.Prefix "/>
99+ /// <inheritdoc cref="MaaMsg.Node.Action"/>
81100public record NodeActionDetail (
82- [ property: JsonPropertyName ( "task_id" ) ] int TaskId ,
83- [ property: JsonPropertyName ( "action_id" ) ] int ActionId ,
101+ [ property: JsonPropertyName ( "task_id" ) ] long TaskId ,
102+ [ property: JsonPropertyName ( "action_id" ) ] long ActionId ,
84103 [ property: JsonPropertyName ( "name" ) ] string Name ,
85- [ property: JsonPropertyName ( "focus" ) ] JsonElement ? Focus
104+ [ property: JsonPropertyName ( "focus" ) ] JsonElement Focus
86105) ;
106+
107+ public record WaitFreezesParam (
108+ [ property: JsonPropertyName ( "time" ) ] long MillisecondsTime ,
109+ [ property: JsonPropertyName ( "threshold" ) ] double Threshold ,
110+ [ property: JsonPropertyName ( "method" ) ] int Method ,
111+ [ property: JsonPropertyName ( "rate_limit" ) ] long MillisecondsRateLimit ,
112+ [ property: JsonPropertyName ( "timeout" ) ] long MillisecondsTimeout
113+ )
114+ {
115+ [ JsonIgnore ] public TimeSpan Time => TimeSpan . FromMilliseconds ( MillisecondsTime ) ;
116+ [ JsonIgnore ] public TimeSpan RateLimit => TimeSpan . FromMilliseconds ( MillisecondsRateLimit ) ;
117+ [ JsonIgnore ] public TimeSpan Timeout => TimeSpan . FromMilliseconds ( MillisecondsTimeout ) ;
118+ }
119+
120+ /// <inheritdoc cref="MaaMsg.Node.WaitFreezes"/>
121+ public record NodeWaitFreezesDetail (
122+ [ property: JsonPropertyName ( "task_id" ) ] long TaskId ,
123+ [ property: JsonPropertyName ( "wf_id" ) ] long WaitFreezesId ,
124+ [ property: JsonPropertyName ( "name" ) ] string Name ,
125+ [ property: JsonPropertyName ( "phase" ) ] string Phase ,
126+ [ property: JsonPropertyName ( "roi" ) ] IReadOnlyList < int > Roi ,
127+ [ property: JsonPropertyName ( "param" ) ] WaitFreezesParam Param ,
128+ [ property: JsonPropertyName ( "reco_ids" ) ] IReadOnlyList < long > ? RecognitionIds ,
129+ [ property: JsonPropertyName ( "elapsed" ) ] long ? MillisecondsElapsed ,
130+ [ property: JsonPropertyName ( "focus" ) ] JsonElement Focus
131+ // https://github.com/MaaXYZ/MaaFramework/blob/v5.10.5/source/MaaFramework/Task/Component/ActionHelper.cpp#L46
132+ )
133+ {
134+ [ JsonIgnore ] public TimeSpan ? Elapsed => MillisecondsElapsed . HasValue ? TimeSpan . FromMilliseconds ( MillisecondsElapsed . Value ) : null ;
135+ }
0 commit comments