-
Notifications
You must be signed in to change notification settings - Fork 69
/
Copy pathPowerMultiCalculatorAdapter.cs
569 lines (470 loc) · 26 KB
/
PowerMultiCalculatorAdapter.cs
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
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
//******************************************************************************************************
// PowerMultiCalculatorAdapter.cs - Gbtc
//
// Copyright © 2012, Grid Protection Alliance. All Rights Reserved.
//
// Licensed to the Grid Protection Alliance (GPA) under one or more contributor license agreements. See
// the NOTICE file distributed with this work for additional information regarding copyright ownership.
// The GPA licenses this file to you under the MIT License (MIT), the "License"; you may
// not use this file except in compliance with the License. You may obtain a copy of the License at:
//
// http://www.opensource.org/licenses/MIT
//
// Unless agreed to in writing, the subject software distributed under the License is distributed on an
// "AS-IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. Refer to the
// License for the specific language governing permissions and limitations.
//
// Code Modification History:
// ----------------------------------------------------------------------------------------------------
// 11/02/2015 - Ryan McCoy
// Generated original version of source code.
// 12/02/2015 - J. Ritchie Carroll
// Updated power calculations to use common Power functions.
//
//******************************************************************************************************
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using GSF;
using GSF.Collections;
using GSF.Configuration;
using GSF.Data;
using GSF.Diagnostics;
using GSF.TimeSeries;
using GSF.TimeSeries.Adapters;
using GSF.Units;
using GSF.Units.EE;
namespace PowerCalculations.PowerMultiCalculator;
/// <summary>
/// Performs MW, MVA, and MVAR calculations based on current and voltage phasors input to the adapter
/// </summary>
[Description("PowerMultiCalculatorAdapter: Performs MW, MVAR and MVA calculations based on current and voltage phasors input to the adapter")]
public class PowerMultiCalculatorAdapter : ActionAdapterBase
{
#region [ Members ]
// Constants
internal const bool DefaultTrackRecentValues = false;
private const string DefaultTableName = "PowerCalculation";
private const bool DefaultAlwaysProduceResult = false;
private const VoltageAdjustmentStrategy DefaultAdjustmentStrategy = VoltageAdjustmentStrategy.LineToNeutral;
private const bool DefaultEnableTemporalProcessing = false;
private const BadDataStrategy DefaultBadDataStrategy = BadDataStrategy.FlagAsBad;
private const double SqrtOf3 = 1.7320508075688772935274463415059D;
private const int ValuesToTrack = 5;
// Fields
private PowerCalculation[] m_configuredCalculations;
private Dictionary<MeasurementKey, VoltageAdjustmentStrategy> m_adjustmentStrategies;
private RunningAverage m_averageCalculationsPerFrame;
private RunningAverage m_averageCalculationTime;
private RunningAverage m_averageTotalCalculationTime;
private ConcurrentQueue<IMeasurement> m_lastActivePowerCalculations;
private ConcurrentQueue<IMeasurement> m_lastReactivePowerCalculations;
private ConcurrentQueue<IMeasurement> m_lastApparentPowerCalculations;
private double m_lastTotalCalculationTime;
private int m_lastTotalCalculations;
#endregion
#region [ Constructors ]
/// <summary>
/// Creates the adapter
/// </summary>
public PowerMultiCalculatorAdapter()
{
try
{
// Validate that data operation and adapter instance exist within database
PowerCalculationConfigurationValidation.ValidateDatabaseDefinitions();
}
catch
{
// This should never cause unhanded exception
}
}
#endregion
#region [ Properties ]
/// <summary>
/// Gets or sets flag that determines if the last few values should be monitored for diagnostics.
/// </summary>
[ConnectionStringParameter]
[Description("Flag that determines if the last few values should be monitored for diagnostics.")]
[DefaultValue(DefaultTrackRecentValues)]
public bool TrackRecentValues { get; set; } = DefaultTrackRecentValues;
/// <summary>
/// Gets or sets the name of the table this adapter will use to obtain its metadata.
/// </summary>
[ConnectionStringParameter]
[Description("Defines the name of the table this adapter will use to obtain its metadata.")]
[DefaultValue(DefaultTableName)]
public string TableName { get; set; } = DefaultTableName;
/// <summary>
/// Gets or sets flag indicating whether or not this adapter will produce a result for all calculations. If this value is true and a calculation fails,
/// the adapter will produce NaN for that calculation. If this value is false and a calculation fails, the adapter will not produce any result.
/// </summary>
[ConnectionStringParameter]
[Description("Defines flag that determines if adapter should always produce a result. When true, adapter will produce NaN for calculations that fail.")]
[DefaultValue(DefaultAlwaysProduceResult)]
public bool AlwaysProduceResult { get; set; } = DefaultAlwaysProduceResult;
/// <summary>
/// Gets or sets the default strategy used to adjust voltage values for based on the nature of the voltage measurements.
/// </summary>
[ConnectionStringParameter]
[Description("Defines default strategy used to adjust voltage values for based on the nature of the voltage measurements.")]
[DefaultValue(DefaultAdjustmentStrategy)]
public VoltageAdjustmentStrategy AdjustmentStrategy { get; set; } = DefaultAdjustmentStrategy;
/// <summary>
/// Gets or sets flag that determines if adapter should enable temporal processing support.
/// </summary>
[ConnectionStringParameter]
[Description("Defines flag that determines if adapter should enable temporal processing support.")]
[DefaultValue(DefaultEnableTemporalProcessing)]
public bool EnableTemporalProcessing { get; set; } = DefaultEnableTemporalProcessing;
/// <summary>
/// Gets or sets SI units factor to use for power calculations, defaults to Mega (10^6).
/// </summary>
[ConnectionStringParameter]
[Description("Defines SI units factor to use for power calculations, defaults to Mega (10^6).")]
[DefaultValue(SI.Mega)]
public double SIUnitsFactor { get; set; } = SI.Mega;
/// <summary>
/// Gets or sets the bad data strategy used to when inputs are marked with bad quality.
/// </summary>
[ConnectionStringParameter]
[Description("Defines bad data strategy used to when inputs are marked with bad quality.")]
[DefaultValue(DefaultBadDataStrategy)]
public BadDataStrategy BadDataStrategy { get; set; } = DefaultBadDataStrategy;
/// <summary>
/// Gets the flag indicating if this adapter supports temporal processing.
/// </summary>
public override bool SupportsTemporalProcessing => EnableTemporalProcessing;
/// <summary>
/// Returns the adapter status, including real-time statistics about adapter operation
/// </summary>
public override string Status
{
get
{
StringBuilder status = new();
VoltageAdjustmentStrategy[] strategies = m_adjustmentStrategies?.Values.ToArray() ?? Array.Empty<VoltageAdjustmentStrategy>();
status.Append(base.Status);
status.AppendLine($" SI Factor for Outputs: {SI.ToScaledString(SIUnitsFactor, 0, "W")} ({SIUnitsFactor})");
status.AppendLine($"Default Voltage Adjustment: {AdjustmentStrategy}");
status.AppendLine($" Bad Data Strategy: {BadDataStrategy}");
status.AppendLine($" Temporal Processing: {(EnableTemporalProcessing ? "Enabled" : "Disabled")}");
status.AppendLine($" Per-Circuit Adjustments: {strategies.Length:N0}");
if (strategies.Length > 0)
{
int strategyCount(params VoltageAdjustmentStrategy[] targetStrategies) =>
strategies.Count(targetStrategies.Contains);
status.AppendLine(" -- Totals per Adjustment Strategy --");
status.AppendLine($" Est. 3-Phase Line-to-Line : {strategyCount(VoltageAdjustmentStrategy.LineToLine):N0}");
status.AppendLine($" Est. 3-Phase Line-to-Neutral : {strategyCount(VoltageAdjustmentStrategy.LineToNeutral):N0}");
status.AppendLine($" 1-Phase Line-to-Line : {strategyCount(VoltageAdjustmentStrategy.LineToLineSinglePhase):N0}");
status.AppendLine($" 1-Phase Line-to-Neutral/None : {strategyCount(VoltageAdjustmentStrategy.LineToNeutralSinglePhase, VoltageAdjustmentStrategy.None):N0}");
}
status.AppendLine($" Total Calcs: {m_lastTotalCalculations:N0} for last frame");
status.AppendLine($" Average Total Calcs: {Math.Round(m_averageCalculationsPerFrame.Average):N3} per frame");
lock (m_averageCalculationTime)
status.AppendLine($" Average Calc Time: {m_averageCalculationTime.Average:N3} ms per V/I phasor pair");
status.AppendLine($" Total Calc Time: {m_lastTotalCalculationTime:N3} ms for last frame");
status.AppendLine($" Average Total Calc Time: {m_averageTotalCalculationTime.Average:N3} ms per frame");
if (!TrackRecentValues)
{
status.AppendLine();
return status.ToString();
}
status.AppendLine(" Last Active Power Measurements:");
if (m_lastActivePowerCalculations.Any())
{
foreach (IMeasurement measurement in m_lastActivePowerCalculations)
status.AppendLine($"\t{measurement.Key} = {measurement.AdjustedValue:N3}");
}
else
{
status.AppendLine("\tNot enough values calculated yet...");
}
status.AppendLine(" Last Reactive Power Measurements:");
if (m_lastReactivePowerCalculations.Any())
{
foreach (IMeasurement measurement in m_lastReactivePowerCalculations)
status.AppendLine($"\t{measurement.Key} = {measurement.AdjustedValue:N3}");
}
else
{
status.AppendLine("\tNot enough values calculated yet...");
}
status.AppendLine(" Last Apparent Power Measurements:");
if (m_lastApparentPowerCalculations.Any())
{
foreach (IMeasurement measurement in m_lastApparentPowerCalculations)
status.AppendLine($"\t{measurement.Key} = {measurement.AdjustedValue:N3}");
}
else
{
status.AppendLine("\tNot enough values calculated yet...");
}
status.AppendLine();
return status.ToString();
}
}
#endregion
#region [ Methods ]
/// <summary>
/// Loads configuration from the database and configures adapter to run with that configuration
/// </summary>
public override void Initialize()
{
base.Initialize();
HashSet<IMeasurement> outputMeasurements = new();
List<PowerCalculation> configuredCalculations = new();
m_adjustmentStrategies = new Dictionary<MeasurementKey, VoltageAdjustmentStrategy>();
m_averageCalculationsPerFrame = new RunningAverage();
m_averageCalculationTime = new RunningAverage();
m_averageTotalCalculationTime = new RunningAverage();
if (Settings.TryGetValue(nameof(TableName), out string tableName))
TableName = tableName;
// 0 1 2 3 4 5
string query = "SELECT ID, CircuitDescription, VoltageAngleSignalID, VoltageMagSignalID, CurrentAngleSignalID, CurrentMagSignalID, " +
// 6 7 8
"ActivePowerOutputSignalID, ReactivePowerOutputSignalID, ApparentPowerOutputSignalID " +
$"FROM {TableName} WHERE NodeId = {{0}} AND Enabled <> 0";
using (AdoDataConnection database = new("systemSettings"))
using (IDataReader reader = database.ExecuteReader(query, ConfigurationFile.Current.Settings["systemSettings"]["NodeID"].ValueAs<Guid>()))
{
while (reader.Read())
{
configuredCalculations.Add(new PowerCalculation
{
PowerCalculationID = reader.GetInt32(0),
CircuitDescription = reader.GetString(1),
VoltageAngleMeasurementKey = MeasurementKey.LookUpBySignalID(Guid.Parse(reader[2].ToString())),
VoltageMagnitudeMeasurementKey = MeasurementKey.LookUpBySignalID(Guid.Parse(reader[3].ToString())),
CurrentAngleMeasurementKey = MeasurementKey.LookUpBySignalID(Guid.Parse(reader[4].ToString())),
CurrentMagnitudeMeasurementKey = MeasurementKey.LookUpBySignalID(Guid.Parse(reader[5].ToString())),
ActivePowerOutputMeasurement = AddOutputMeasurement(Guid.Parse(reader[6].ToString()), outputMeasurements),
ReactivePowerOutputMeasurement = AddOutputMeasurement(Guid.Parse(reader[7].ToString()), outputMeasurements),
ApparentPowerOutputMeasurement = AddOutputMeasurement(Guid.Parse(reader[8].ToString()), outputMeasurements)
});
}
}
m_configuredCalculations = configuredCalculations.ToArray();
if (m_configuredCalculations.Length > 0)
{
InputMeasurementKeys = m_configuredCalculations.SelectMany(calculation => new[]
{
calculation.CurrentAngleMeasurementKey,
calculation.CurrentMagnitudeMeasurementKey,
calculation.VoltageAngleMeasurementKey,
calculation.VoltageMagnitudeMeasurementKey
})
.ToArray();
}
else
{
throw new InvalidOperationException("Skipped initialization of power calculator: no defined power calculations...");
}
if (outputMeasurements.Any())
OutputMeasurements = outputMeasurements.ToArray();
Dictionary<string, string> settings = Settings;
// Load parameters
if (settings.TryGetValue(nameof(TrackRecentValues), out string setting))
TrackRecentValues = setting.ParseBoolean();
if (settings.TryGetValue(nameof(AlwaysProduceResult), out setting))
AlwaysProduceResult = setting.ParseBoolean();
if (settings.TryGetValue(nameof(AdjustmentStrategy), out setting) && Enum.TryParse(setting, true, out VoltageAdjustmentStrategy adjustmentStrategy))
AdjustmentStrategy = adjustmentStrategy;
if (settings.TryGetValue(nameof(EnableTemporalProcessing), out setting))
EnableTemporalProcessing = setting.ParseBoolean();
if (settings.TryGetValue(nameof(SIUnitsFactor), out setting) && double.TryParse(setting, out double factor))
SIUnitsFactor = factor;
if (settings.TryGetValue(nameof(BadDataStrategy), out setting) && Enum.TryParse(setting, true, out BadDataStrategy badDataStrategy))
BadDataStrategy = badDataStrategy;
if (TrackRecentValues)
{
m_lastActivePowerCalculations = new ConcurrentQueue<IMeasurement>();
m_lastReactivePowerCalculations = new ConcurrentQueue<IMeasurement>();
m_lastApparentPowerCalculations = new ConcurrentQueue<IMeasurement>();
}
// Define per power calculation line adjustment strategies
foreach (PowerCalculation powerCalculation in m_configuredCalculations)
{
if (powerCalculation.VoltageMagnitudeMeasurementKey is null || string.IsNullOrWhiteSpace(powerCalculation.CircuitDescription))
continue;
try
{
Dictionary<string, string> circuitSettings = powerCalculation.CircuitDescription.ParseKeyValuePairs();
if (circuitSettings.TryGetValue(nameof(AdjustmentStrategy), out setting) && Enum.TryParse(setting, true, out adjustmentStrategy))
m_adjustmentStrategies[powerCalculation.VoltageMagnitudeMeasurementKey] = adjustmentStrategy;
}
catch (Exception ex)
{
OnStatusMessage(MessageLevel.Warning, $"Failed to parse settings from circuit description \"{powerCalculation.CircuitDescription}\": {ex.Message}");
}
}
}
/// <summary>
/// Calculates MW, MVAR and MVA then publishes those measurements.
/// </summary>
/// <param name="frame">Input values for calculation</param>
/// <param name="index">Index of frame within second.</param>
protected override void PublishFrame(IFrame frame, int index)
{
ConcurrentDictionary<MeasurementKey, IMeasurement> measurements = frame.Measurements;
AsyncDoubleBufferedQueue<IMeasurement> publicationBuffer = new() { ProcessItemsFunction = OnNewMeasurements };
long frameCalculationStartTime = DateTime.UtcNow.Ticks;
int calculations = 0;
Parallel.ForEach(m_configuredCalculations, powerCalculation =>
{
try
{
long powerCalculationStartTime = DateTime.UtcNow.Ticks;
bool calculateActivePower = powerCalculation.ActivePowerOutputMeasurement is not null;
bool calculateReactivePower = powerCalculation.ReactivePowerOutputMeasurement is not null;
bool calculateApparentPower = powerCalculation.ApparentPowerOutputMeasurement is not null;
double activePower = double.NaN, reactivePower = double.NaN, apparentPower = double.NaN;
bool badInputDetected = false;
bool includeInput(IMeasurement measurement)
{
bool qualityIsGood = measurement.ValueQualityIsGood();
if (BadDataStrategy == BadDataStrategy.DropData || qualityIsGood)
return qualityIsGood;
badInputDetected = true;
return true;
}
try
{
double voltageMagnitude = 0.0D, voltageAngle = 0.0D, currentMagnitude = 0.0D, currentAngle = 0.0D;
bool allInputsReceived = false;
if (measurements.TryGetValue(powerCalculation.VoltageMagnitudeMeasurementKey, out IMeasurement measurement) && includeInput(measurement))
{
voltageMagnitude = measurement.AdjustedValue;
if (!m_adjustmentStrategies.TryGetValue(powerCalculation.VoltageMagnitudeMeasurementKey, out VoltageAdjustmentStrategy adjustmentStrategy))
adjustmentStrategy = AdjustmentStrategy;
// ReSharper disable once SwitchStatementMissingSomeEnumCasesNoDefault
switch (adjustmentStrategy)
{
case VoltageAdjustmentStrategy.LineToNeutral:
voltageMagnitude *= 3.0D;
break;
case VoltageAdjustmentStrategy.LineToLine:
voltageMagnitude *= SqrtOf3;
break;
case VoltageAdjustmentStrategy.LineToLineSinglePhase:
voltageMagnitude /= SqrtOf3;
break;
}
if (measurements.TryGetValue(powerCalculation.VoltageAngleMeasurementKey, out measurement) && includeInput(measurement))
{
voltageAngle = measurement.AdjustedValue;
if (measurements.TryGetValue(powerCalculation.CurrentMagnitudeMeasurementKey, out measurement) && includeInput(measurement))
{
currentMagnitude = measurement.AdjustedValue;
if (measurements.TryGetValue(powerCalculation.CurrentAngleMeasurementKey, out measurement) && includeInput(measurement))
{
currentAngle = measurement.AdjustedValue;
allInputsReceived = true;
}
}
}
}
if (allInputsReceived)
{
// Calculate power (P), reactive power (Q) and apparent power (|S|)
Phasor voltage = new(PhasorType.Voltage, Angle.FromDegrees(voltageAngle), voltageMagnitude);
Phasor current = new(PhasorType.Current, Angle.FromDegrees(currentAngle), currentMagnitude);
if (calculateActivePower)
activePower = (double)Phasor.CalculateActivePower(voltage, current) / SIUnitsFactor;
if (calculateReactivePower)
reactivePower = (double)Phasor.CalculateReactivePower(voltage, current) / SIUnitsFactor;
if (calculateApparentPower)
apparentPower = (double)Phasor.CalculateApparentPower(voltage, current) / SIUnitsFactor;
}
}
catch (Exception ex)
{
OnProcessException(MessageLevel.Warning, ex);
}
finally
{
List<IMeasurement> outputMeasurements = new(3);
MeasurementStateFlags flags = badInputDetected ? MeasurementStateFlags.BadData : MeasurementStateFlags.Normal;
if (calculateActivePower)
{
Measurement activePowerMeasurement = Measurement.Clone(powerCalculation.ActivePowerOutputMeasurement, activePower, frame.Timestamp, flags);
if (AlwaysProduceResult || !double.IsNaN(activePowerMeasurement.Value))
{
outputMeasurements.Add(activePowerMeasurement);
calculations++;
if (TrackRecentValues)
{
m_lastActivePowerCalculations.Enqueue(activePowerMeasurement);
while (m_lastActivePowerCalculations.Count > ValuesToTrack)
m_lastActivePowerCalculations.TryDequeue(out _);
}
}
}
if (calculateReactivePower)
{
Measurement reactivePowerMeasurement = Measurement.Clone(powerCalculation.ReactivePowerOutputMeasurement, reactivePower, frame.Timestamp, flags);
if (AlwaysProduceResult || !double.IsNaN(reactivePowerMeasurement.Value))
{
outputMeasurements.Add(reactivePowerMeasurement);
calculations++;
if (TrackRecentValues)
{
m_lastReactivePowerCalculations.Enqueue(reactivePowerMeasurement);
while (m_lastReactivePowerCalculations.Count > ValuesToTrack)
m_lastReactivePowerCalculations.TryDequeue(out _);
}
}
}
if (calculateApparentPower)
{
Measurement apparentPowerMeasurement = Measurement.Clone(powerCalculation.ApparentPowerOutputMeasurement, apparentPower, frame.Timestamp, flags);
if (AlwaysProduceResult || !double.IsNaN(apparentPowerMeasurement.Value))
{
outputMeasurements.Add(apparentPowerMeasurement);
calculations++;
if (TrackRecentValues)
{
m_lastApparentPowerCalculations.Enqueue(apparentPowerMeasurement);
while (m_lastApparentPowerCalculations.Count > ValuesToTrack)
m_lastApparentPowerCalculations.TryDequeue(out _);
}
}
}
publicationBuffer.Enqueue(outputMeasurements);
lock (m_averageCalculationTime)
m_averageCalculationTime.AddValue(new Ticks(DateTime.UtcNow.Ticks - powerCalculationStartTime).ToMilliseconds());
}
}
catch (Exception ex)
{
OnProcessException(MessageLevel.Error, new InvalidOperationException($"Failed to calculate power for {powerCalculation.CircuitDescription}: {ex.Message}", ex));
}
});
// Wait for all power calculations to publish
SpinWait.SpinUntil(() => publicationBuffer.Count == 0);
m_lastTotalCalculations = calculations;
m_averageCalculationsPerFrame.AddValue(calculations);
m_lastTotalCalculationTime = new Ticks(DateTime.UtcNow.Ticks - frameCalculationStartTime).ToMilliseconds();
m_averageTotalCalculationTime.AddValue(m_lastTotalCalculationTime);
}
#endregion
#region [ Static ]
// Static Methods
private static Measurement AddOutputMeasurement(Guid signalID, HashSet<IMeasurement> outputMeasurements)
{
MeasurementKey key = MeasurementKey.LookUpBySignalID(signalID);
if (key.SignalID == Guid.Empty)
return null;
Measurement measurement = new() { Metadata = key.Metadata };
outputMeasurements.Add(measurement);
return measurement;
}
#endregion
}