-
Notifications
You must be signed in to change notification settings - Fork 9
/
0316356c-b1fe-490a-89ce-73c8f67ebccc.mop
234 lines (234 loc) · 9.11 KB
/
0316356c-b1fe-490a-89ce-73c8f67ebccc.mop
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
{
"Name": "TestsEvaluator",
"_id": "0316356c-b1fe-490a-89ce-73c8f67ebccc",
"Namespace": "lib.testing",
"Description": "Controls the evaluation of connected Tester operators.\r\n\r\nhttps://streber.framefield.com/933",
"Inputs": [
{
"Name": "Inputs",
"MetaInstanceID": "b104e8e1-ff7a-43ad-98d5-29c2bc4efbb7",
"DefaultValue": {
"Type": "Text",
"Value": ""
},
"MetaID": "c522a66e-3260-4692-b3e3-79fd0361fa3d",
"IsMultiInput": "True",
"Relevance": "Required",
"Description": "",
"Min": "-100000",
"Max": "100000",
"Scale": "0.1",
"ScaleType": "Linear",
"EnumValues": []
},
{
"Name": "RunTrigger",
"MetaInstanceID": "3959d79a-343c-4935-ba55-35f42cdc387b",
"DefaultValue": {
"Type": "Float",
"Value": "0"
},
"MetaID": "3f76dee3-3897-44ac-82d6-25ce9f53a506",
"IsMultiInput": "False",
"Relevance": "Optional",
"Description": "",
"Min": "0",
"Max": "1",
"Scale": "0.1",
"ScaleType": "Linear",
"EnumValues": []
},
{
"Name": "RebuildReferenceTrigger",
"MetaInstanceID": "6e4d0d0e-c733-4b5b-9998-ac7791cc7c22",
"DefaultValue": {
"Type": "Float",
"Value": "0"
},
"MetaID": "3f76dee3-3897-44ac-82d6-25ce9f53a506",
"IsMultiInput": "False",
"Relevance": "Optional",
"Description": "",
"Min": "0",
"Max": "1",
"Scale": "0.1",
"ScaleType": "Linear",
"EnumValues": []
},
{
"Name": "Filter",
"MetaInstanceID": "09d4f5d1-2ecb-433f-9e8c-3900645477bf",
"DefaultValue": {
"Type": "Text",
"Value": ".*"
},
"MetaID": "c522a66e-3260-4692-b3e3-79fd0361fa3d",
"IsMultiInput": "False",
"Relevance": "Optional",
"Description": "",
"Min": "-100000",
"Max": "100000",
"Scale": "0.1",
"ScaleType": "Linear",
"EnumValues": []
}
],
"Outputs": [
{
"Name": "Result",
"MetaInstanceID": "4c30c4df-a17c-4bf5-bf9c-95d731a2f440",
"MetaID": "c522a66e-3260-4692-b3e3-79fd0361fa3d"
}
],
"OperatorParts": [
{
"MetaInstanceID": "6a62a8c4-7094-451c-8305-f26c0ffebabc",
"MetaID": "a9360001-b86f-4734-9864-451830e2085e",
"Name": "TestsEvaluatorFunc",
"Version": "6117b5e3-d7a9-410c-a31f-5a7eccd03c2d",
"Type": "Float",
"IsMultiInput": "True",
"Script": [
"//>>> _using",
"using System;",
"using System.Collections.Generic;",
"using System.Linq;",
"using System.Text;",
"using SharpDX;",
"using SharpDX.Direct3D11;",
"using SharpDX.Windows;",
"//<<< _using",
"using Framefield.Core.Testing;",
"",
"namespace Framefield.Core.IDa9360001_b86f_4734_9864_451830e2085e",
"{",
" public class Class_TestsEvaluator : OperatorPart.Function, ITestEvaluator",
" {",
" //>>> _inputids",
" private enum InputId",
" {",
" Inputs = 0,",
" RunTrigger = 1,",
" RebuildReferenceTrigger = 2,",
" Filter = 3",
" }",
" //<<< _inputids",
"",
" public bool GetStartTestsEnabled(OperatorPartContext context)",
" {",
" var invalidator = new OperatorPart.InvalidateTimeAccessors();",
" OperatorPart.Connections[(int)InputId.RunTrigger].TraverseWithFunction(null, invalidator);",
" return OperatorPart.Connections[(int)InputId.RunTrigger].Eval(context).Value > 0.5;",
" }",
"",
" public bool GetRebuildReferenceEnabled(OperatorPartContext context)",
" {",
" var invalidator = new OperatorPart.InvalidateTimeAccessors();",
" OperatorPart.Connections[(int)InputId.RebuildReferenceTrigger].TraverseWithFunction(null, invalidator);",
" return OperatorPart.Connections[(int)InputId.RebuildReferenceTrigger].Eval(context).Value > 0.5;",
" }",
"",
" public string GetFilter(OperatorPartContext context)",
" {",
" var invalidator = new OperatorPart.InvalidateTimeAccessors();",
" OperatorPart.Connections[(int)InputId.Filter].TraverseWithFunction(null, invalidator);",
" return OperatorPart.Connections[(int)InputId.Filter].Eval(context).Text;",
" }",
"",
"",
" public override OperatorPartContext Eval(OperatorPartContext context, List<OperatorPart> inputs, int outputIdx)",
" { ",
" Object evaluator = null;",
" if (!context.Objects.TryGetValue(OperatorPartContext.TESTS_EVALUATOR_ID, out evaluator))",
" {",
" evaluator = this;",
"",
" //make input subtree invalid to ensure a full update",
" foreach (var input in inputs[(int)InputId.Inputs].Connections)",
" {",
" var testerCollector = new OperatorPart.CollectOpPartFunctionsOfType<TesterFunction>();",
" input.TraverseWithFunction(testerCollector, null);",
" foreach (var tester in testerCollector.CollectedOpPartFunctions)",
" tester.OperatorPart.EmitChangedEvent();",
" }",
" }",
"",
" string accumulatedInputResults = \"\";",
" foreach (var input in inputs[(int)InputId.Inputs].Connections)",
" {",
" //during evaluation the object variables could be cleared. so we need to",
" //set this before each evaluation",
" context.Objects[OperatorPartContext.TESTS_EVALUATOR_ID] = evaluator;",
"",
" accumulatedInputResults += input.Eval(context).Text;",
" }",
"",
" if (String.IsNullOrEmpty(accumulatedInputResults))",
" {",
" context.Text = \"\";",
" return context;",
" }",
" ",
" String intendedInput = \"\";",
" foreach (var line in accumulatedInputResults.Split('\\n'))",
" {",
" if (!String.IsNullOrEmpty(line))",
" intendedInput += String.Format(\" {0}\\n\", line);",
" }",
" ",
" String suiteResult = \"\";",
" if (accumulatedInputResults.Contains(\"FAILED\"))",
" suiteResult = \"FAILED\";",
" else if (accumulatedInputResults.Contains(\"reference updated\"))",
" suiteResult = \"reference updated\";",
" else if (accumulatedInputResults.Contains(\"passed\"))",
" suiteResult = \"passed\";",
" ",
" context.Text = String.Format(\"{0} : {1}\\n{2}\", OperatorPart.Parent.Parent.ToString(), suiteResult, intendedInput);",
" _lastResult = context.Text;",
" return context;",
" }",
" ",
" String _lastResult = \"\";",
" }",
"}",
"",
""
],
"AdditionalAssemblies": []
}
],
"Operators": [],
"Connections": [
{
"SourceOp": "00000000-0000-0000-0000-000000000000",
"SourceOpPart": "6a62a8c4-7094-451c-8305-f26c0ffebabc",
"TargetOp": "00000000-0000-0000-0000-000000000000",
"TargetOpPart": "4c30c4df-a17c-4bf5-bf9c-95d731a2f440"
},
{
"SourceOp": "00000000-0000-0000-0000-000000000000",
"SourceOpPart": "b104e8e1-ff7a-43ad-98d5-29c2bc4efbb7",
"TargetOp": "00000000-0000-0000-0000-000000000000",
"TargetOpPart": "6a62a8c4-7094-451c-8305-f26c0ffebabc"
},
{
"SourceOp": "00000000-0000-0000-0000-000000000000",
"SourceOpPart": "3959d79a-343c-4935-ba55-35f42cdc387b",
"TargetOp": "00000000-0000-0000-0000-000000000000",
"TargetOpPart": "6a62a8c4-7094-451c-8305-f26c0ffebabc"
},
{
"SourceOp": "00000000-0000-0000-0000-000000000000",
"SourceOpPart": "6e4d0d0e-c733-4b5b-9998-ac7791cc7c22",
"TargetOp": "00000000-0000-0000-0000-000000000000",
"TargetOpPart": "6a62a8c4-7094-451c-8305-f26c0ffebabc"
},
{
"SourceOp": "00000000-0000-0000-0000-000000000000",
"SourceOpPart": "09d4f5d1-2ecb-433f-9e8c-3900645477bf",
"TargetOp": "00000000-0000-0000-0000-000000000000",
"TargetOpPart": "6a62a8c4-7094-451c-8305-f26c0ffebabc"
}
]
}