boon-metrology 1.0
C-based Applications for Smart Grid
Loading...
Searching...
No Matches
boon_metrology.h
1#pragma once
2
3#include <archive.h>
4#include <archive_entry.h>
5#include <stdbool.h>
6#include <stddef.h>
7#include <stdint.h>
8
9#include "serialize.h"
10
11// for post metrology sample return value key
12#define PM_NO_CHANGE 0
13#define PM_ERROR 1
14#define PM_STATE_CHANGE 2
15
16#define MAX_TIMESTAMP_LENGTH 50
17
26struct LoadChange {
27 bool m_LoadChangeDetected; /* any load change in the active power */
28 bool m_EVChangeDetected; /* EV state change detected */
29 bool m_BatteryChangeDetected; /* battery state change detected */
30 int m_ClusterID; /* cluster ID associated with the convolve filter pattern */
31};
32
39 float MinVal;
40 float MaxVal;
41};
42
48 struct FeatureStruct VoltageAverage;
49 struct FeatureStruct Current;
50 struct FeatureStruct LineToLineVoltage;
51 struct FeatureStruct ActivePower;
52 struct FeatureStruct ReactivePower;
53 struct FeatureStruct VoltageTHD;
54 struct FeatureStruct CurrentTHD;
55};
56
61 float PercentVariation; // The Nano model percent variation
62 int StreamingWindowSize; // Typically = 1
63 uint32_t NumTrainingSamples; // This many metrology samples will be consumed prior to switching to monitoring mode
64};
65
67 // Nano model settings for load disaggregation
68 uint16_t FilterWindowSize; // Window for load transition checking
69 uint16_t PatternWindowSize; // Window for pattern generation
70 float PercentVariation; // Nano model percent variation for training disaggregation of discrete jumps (loads and generation)
71 uint32_t NumTrainingSamples; // This many metrology samples will be consumed prior to switching to monitoring mode
72 float DetectionThreshold; // The threshold for detecting jumps in Current
73};
74
76 // PV Model settings
77 uint16_t NumTrainingSamples; // The number of samples to use for disaggregating PV active power transitions from discrete loads
78 float ZValueThreshold; // The statistical z-threshold tolerance to separate PV from discrete jumps
79};
80
82 uint32_t NumTrainingSamples; // Number of historical samples to retain for computing DHC estimates
83};
84
94
95#ifdef __cplusplus
96extern "C" {
97#endif
98
99struct BoonMetrology;
100
105float GetBoonMetrologyVersion();
106
112const char* GetErrorString(struct BoonMetrology* BM);
113
119struct BoonMetrology* ConstructBoonMetrology(uint16_t SamplesPerSecond);
120
126void FreeBoonMetrology(struct BoonMetrology* BM);
127
134void GetBoonMetrologyConfiguration(struct BoonMetrology* BM, struct BoonMetrologyConfiguration* BMC);
135
142bool ConfigureLoadDisaggregation(struct BoonMetrology* BM, struct LoadDisaggregationSettings* LDS);
143
150bool ConfigurePVDisaggregation(struct BoonMetrology* BM, struct PVDisaggregationSettings* PVDS);
151
158bool ConfigurePowerQualityMonitoring(struct BoonMetrology* BM, struct PowerQualitySettings* PQS);
159
166bool ConfigureDynamicHostingCapacity(struct BoonMetrology* BM, struct DynamicHostingCapacitySettings* DHS);
167
179bool IncrementalSerialize(struct BoonMetrology* BM, const char* DirPath, ArchiveWriteCallbackType WriteCallbackFunction,
180 struct IncrementalArchiveFileStatus* AFS, size_t TransferBufferSize, void* UserData);
181
192bool IncrementalDeserialize(struct BoonMetrology* BM, const char* DirPath, ArchiveReadCallbackType ReadCallbackFunction,
193 struct IncrementalArchiveFileStatus* AFS, size_t TransferBufferSize, void* UserData);
194
203bool SerializeBoonMetrology(struct BoonMetrology* BM, uint8_t** Buffer, size_t* BufferLength);
204
212bool DeserializeBoonMetrology(struct BoonMetrology* BM, uint8_t* Buffer, size_t BufferLength);
213
219 char Time[MAX_TIMESTAMP_LENGTH]; // date // LD
220 float VoltageAverage; // volts // DHC, PQM
221 float Current; // amps // PQM
222 float LineToLineVoltage; // volts // PQM
223 float ActivePower; // kW // DHC, PQM, LD, PVD
224 float ReactivePower; // kVAR // DHC, PQM, LD
225 float VoltageTHD; // % // PQM, LD
226 float CurrentTHD; // % // PQM, LD
227};
228
236bool PostMetrologySample(struct BoonMetrology* BM, const struct MetrologySample* MS, struct LoadChange* LC);
237
244bool GetPVDisaggregationEstimate(struct BoonMetrology* BM, float* PVEstimate);
245
251const char* GetDisaggregation(struct BoonMetrology* BM);
252
258void ResetPVDisaggregationEstimate(struct BoonMetrology* BM);
259
268bool GetPowerQualityScore(struct BoonMetrology* BM, float* QualityScore);
269
278bool GetVoltageEstimatePQ(struct BoonMetrology* BM, float DeltaP, float DeltaQ, float* DeltaVEstimate);
279
287bool GetVoltageEstimateP(struct BoonMetrology* BM, float DeltaP, float* DeltaVEstimate);
288
294const char* GetStatus(struct BoonMetrology* BM);
295
301const char* GetStatusPowerQualityMonitoring(struct BoonMetrology* BM);
302
308const char* GetStatusDynamicHostingCapacity(struct BoonMetrology* BM);
309
315const char* GetStatusPVDisaggregation(struct BoonMetrology* BM);
316
322const char* GetStatusLoadDisaggregation(struct BoonMetrology* BM);
323
329const char* GetDiagnostics(struct BoonMetrology* BM);
330
331#define DT_DHC 0x0001
332#define DT_PVDisaggregation 0x0002
333#define DT_LoadDisaggregation 0x0004
334#define DT_PowerQualityMonitoring 0x0008
335#define DT_ALL_USE_CASES DT_DHC | DT_PVDisaggregation | DT_LoadDisaggregation | DT_PowerQualityMonitoring
336
337#define DT_ExcludeRecentSamples 0x2000
338#define DT_ClusterCountOnly 0x4000
339#define DT_ExcludeNano 0x8000
340
346const char* GetDiagnosticsByType(struct BoonMetrology* BM, uint16_t ResultsList);
347
348#ifdef __cplusplus
349}
350#endif
Structure to contain the settings that determine Boon Metrology model configuration when ConfigureBoo...
Definition boon_metrology.h:88
Definition boon_metrology.h:81
float MaxVal
Definition boon_metrology.h:40
float MinVal
Definition boon_metrology.h:39
A struct for an individual feature.
Definition boon_metrology.h:38
Definition serialize.h:15
struct for load change information to return
Definition boon_metrology.h:26
Definition boon_metrology.h:66
Initialize values not being used to 0.
Definition boon_metrology.h:218
The current metrology values used across at least one use case.
Definition boon_metrology.h:47
Definition boon_metrology.h:75
The settings that will be used to configure the power quality monitoring use case.
Definition boon_metrology.h:60