Skip to content
This repository was archived by the owner on Jul 1, 2025. It is now read-only.

Commit 39e225d

Browse files
dfcoffinclaude
andcommitted
Complete ElectricPowerQualitySummaryDto and ReadingTypeDto with comprehensive ESPI-compliant field definitions
- Complete ElectricPowerQualitySummaryDto with all power quality fields including flicker, harmonics, voltage quality, interruptions, and frequency measurements per IEC standards - Complete ReadingTypeDto with comprehensive reading characteristics including commodity, accumulation behavior, pricing structures, phase information, and measurement intervals - Add comprehensive JAXB XML annotations with proper propOrder for NAESB ESPI 1.0 specification compliance - Include detailed documentation for all fields with ESPI values, units, and standards references (IEC 61000 series, IEEE 1159) - Implement utility methods for measurement validation, unit conversions, and human-readable descriptions - Support time-of-use pricing, tiered pricing, critical peak pricing, and demand response programs - Add interval analysis methods for standard 15-minute and daily reading types - Provide power quality assessment methods including voltage quality, frequency analysis, and interruption categorization - Ensure compatibility with MapStruct mapping and entity relationship patterns 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent 957daad commit 39e225d

File tree

2 files changed

+745
-10
lines changed

2 files changed

+745
-10
lines changed

src/main/java/org/greenbuttonalliance/espi/common/dto/usage/ElectricPowerQualitySummaryDto.java

Lines changed: 256 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,25 @@
2121
package org.greenbuttonalliance.espi.common.dto.usage;
2222

2323
import jakarta.xml.bind.annotation.*;
24+
import org.greenbuttonalliance.espi.common.dto.DateTimeIntervalDto;
2425

2526
/**
2627
* ElectricPowerQualitySummary DTO record for JAXB XML marshalling/unmarshalling.
2728
*
28-
* Represents electric power quality summary information.
29-
* Placeholder implementation for basic structure.
29+
* Represents a comprehensive summary of power quality events for electric power delivery.
30+
* Contains information about voltage quality, frequency variations, interruptions,
31+
* flicker, harmonics, and other power quality metrics as defined by the NAESB ESPI 1.0 specification.
32+
*
33+
* All power quality measurements follow IEC standards for power quality measurement and assessment.
3034
*/
3135
@XmlRootElement(name = "ElectricPowerQualitySummary", namespace = "http://naesb.org/espi")
3236
@XmlAccessorType(XmlAccessType.FIELD)
33-
@XmlType(name = "ElectricPowerQualitySummary", namespace = "http://naesb.org/espi")
37+
@XmlType(name = "ElectricPowerQualitySummary", namespace = "http://naesb.org/espi", propOrder = {
38+
"description", "flickerPlt", "flickerPst", "harmonicVoltage", "longInterruptions",
39+
"mainsVoltage", "measurementProtocol", "powerFrequency", "rapidVoltageChanges",
40+
"shortInterruptions", "summaryInterval", "supplyVoltageDips", "supplyVoltageImbalance",
41+
"supplyVoltageVariations", "tempOvervoltage", "usagePointId"
42+
})
3443
public record ElectricPowerQualitySummaryDto(
3544

3645
@XmlTransient
@@ -40,13 +49,255 @@ public record ElectricPowerQualitySummaryDto(
4049
String uuid,
4150

4251
@XmlElement(name = "description")
43-
String description
52+
String description,
53+
54+
/**
55+
* Flicker PLT (Long-term) measurement.
56+
* Represents long-term flicker severity as per IEC 61000-4-15.
57+
* Measured over 2-hour intervals.
58+
* Unit: dimensionless (0.0 to 20.0 typical range)
59+
*/
60+
@XmlElement(name = "flickerPlt")
61+
Long flickerPlt,
62+
63+
/**
64+
* Flicker PST (Short-term) measurement.
65+
* Represents short-term flicker severity as per IEC 61000-4-15.
66+
* Measured over 10-minute intervals.
67+
* Unit: dimensionless (0.0 to 20.0 typical range)
68+
*/
69+
@XmlElement(name = "flickerPst")
70+
Long flickerPst,
71+
72+
/**
73+
* Total harmonic distortion for voltage.
74+
* Represents the harmonic content in the voltage waveform.
75+
* Unit: percentage of fundamental frequency (stored as basis points, e.g., 500 = 5.00%)
76+
*/
77+
@XmlElement(name = "harmonicVoltage")
78+
Long harmonicVoltage,
79+
80+
/**
81+
* Number of long interruptions during the summary period.
82+
* Interruptions lasting longer than 3 minutes as per IEEE 1159.
83+
* Unit: count
84+
*/
85+
@XmlElement(name = "longInterruptions")
86+
Long longInterruptions,
87+
88+
/**
89+
* RMS voltage of the mains supply.
90+
* Represents the effective voltage value.
91+
* Unit: millivolts (mV)
92+
*/
93+
@XmlElement(name = "mainsVoltage")
94+
Long mainsVoltage,
95+
96+
/**
97+
* Measurement protocol identifier.
98+
* Indicates the standard or method used for measurements.
99+
* Typical values:
100+
* - 1: IEC 61000-4-15 (Flicker)
101+
* - 2: IEC 61000-4-7 (Harmonics)
102+
* - 3: IEEE 1159 (Interruptions)
103+
* - 4: IEC 61000-4-30 (General power quality)
104+
*/
105+
@XmlElement(name = "measurementProtocol")
106+
Short measurementProtocol,
107+
108+
/**
109+
* Power frequency measurement.
110+
* Nominal frequency is typically 50Hz or 60Hz.
111+
* Unit: millihertz (mHz) - e.g., 60000 for 60.000 Hz
112+
*/
113+
@XmlElement(name = "powerFrequency")
114+
Long powerFrequency,
115+
116+
/**
117+
* Number of rapid voltage changes during the summary period.
118+
* Voltage changes exceeding specified thresholds per IEC 61000-4-15.
119+
* Unit: count
120+
*/
121+
@XmlElement(name = "rapidVoltageChanges")
122+
Long rapidVoltageChanges,
123+
124+
/**
125+
* Number of short interruptions during the summary period.
126+
* Interruptions lasting between 0.5 seconds and 3 minutes per IEEE 1159.
127+
* Unit: count
128+
*/
129+
@XmlElement(name = "shortInterruptions")
130+
Long shortInterruptions,
131+
132+
/**
133+
* Summary interval for this power quality summary.
134+
* Time period covered by these measurements.
135+
* Typically covers 24-hour periods for daily summaries.
136+
*/
137+
@XmlElement(name = "summaryInterval")
138+
DateTimeIntervalDto summaryInterval,
139+
140+
/**
141+
* Number of supply voltage dips during the summary period.
142+
* Temporary reductions in RMS voltage below 90% of nominal per IEC 61000-4-11.
143+
* Unit: count
144+
*/
145+
@XmlElement(name = "supplyVoltageDips")
146+
Long supplyVoltageDips,
147+
148+
/**
149+
* Supply voltage imbalance measurement.
150+
* Represents asymmetry in three-phase voltage systems per IEC 61000-4-27.
151+
* Unit: percentage of positive sequence component (stored as basis points)
152+
*/
153+
@XmlElement(name = "supplyVoltageImbalance")
154+
Long supplyVoltageImbalance,
155+
156+
/**
157+
* Supply voltage variations measurement.
158+
* Long-term voltage magnitude variations from nominal per IEC 61000-4-30.
159+
* Unit: percentage deviation from nominal (stored as basis points)
160+
*/
161+
@XmlElement(name = "supplyVoltageVariations")
162+
Long supplyVoltageVariations,
163+
164+
/**
165+
* Temporary overvoltage events count.
166+
* Voltage increases above 110% of nominal for limited duration per IEEE 1159.
167+
* Unit: count
168+
*/
169+
@XmlElement(name = "tempOvervoltage")
170+
Long tempOvervoltage,
171+
172+
/**
173+
* Reference to the usage point this power quality summary belongs to.
174+
* Represents the logical relationship to the measurement point.
175+
*/
176+
@XmlTransient
177+
Long usagePointId
178+
44179
) {
45180

46181
/**
47182
* Default constructor for JAXB.
48183
*/
49184
public ElectricPowerQualitySummaryDto() {
50-
this(null, null, null);
185+
this(null, null, null, null, null, null, null, null, null, null, null, null, null,
186+
null, null, null, null, null, null);
187+
}
188+
189+
/**
190+
* Constructor with basic identification.
191+
*
192+
* @param id the database identifier
193+
* @param uuid the unique resource identifier
194+
* @param description human-readable description
195+
*/
196+
public ElectricPowerQualitySummaryDto(Long id, String uuid, String description) {
197+
this(id, uuid, description, null, null, null, null, null, null, null, null, null,
198+
null, null, null, null, null, null, null);
199+
}
200+
201+
/**
202+
* Checks if this summary contains voltage quality measurements.
203+
*
204+
* @return true if voltage-related measurements are present
205+
*/
206+
public boolean hasVoltageQualityData() {
207+
return mainsVoltage != null ||
208+
supplyVoltageVariations != null ||
209+
supplyVoltageImbalance != null ||
210+
supplyVoltageDips != null ||
211+
tempOvervoltage != null ||
212+
harmonicVoltage != null;
213+
}
214+
215+
/**
216+
* Checks if this summary contains interruption data.
217+
*
218+
* @return true if interruption measurements are present
219+
*/
220+
public boolean hasInterruptionData() {
221+
return longInterruptions != null || shortInterruptions != null;
222+
}
223+
224+
/**
225+
* Checks if this summary contains flicker measurements.
226+
*
227+
* @return true if flicker measurements are present
228+
*/
229+
public boolean hasFlickerData() {
230+
return flickerPlt != null || flickerPst != null;
231+
}
232+
233+
/**
234+
* Checks if this summary contains frequency data.
235+
*
236+
* @return true if frequency measurements are present
237+
*/
238+
public boolean hasFrequencyData() {
239+
return powerFrequency != null;
240+
}
241+
242+
/**
243+
* Gets the total number of interruptions (short + long).
244+
*
245+
* @return total interruptions count, or null if no data available
246+
*/
247+
public Long getTotalInterruptions() {
248+
if (shortInterruptions == null && longInterruptions == null) {
249+
return null;
250+
}
251+
return (shortInterruptions != null ? shortInterruptions : 0) +
252+
(longInterruptions != null ? longInterruptions : 0);
253+
}
254+
255+
/**
256+
* Gets the power frequency in Hz (converting from millihertz).
257+
*
258+
* @return frequency in Hz, or null if not set
259+
*/
260+
public Double getPowerFrequencyInHz() {
261+
return powerFrequency != null ? powerFrequency / 1000.0 : null;
262+
}
263+
264+
/**
265+
* Gets the mains voltage in volts (converting from millivolts).
266+
*
267+
* @return voltage in volts, or null if not set
268+
*/
269+
public Double getMainsVoltageInVolts() {
270+
return mainsVoltage != null ? mainsVoltage / 1000.0 : null;
271+
}
272+
273+
/**
274+
* Gets the voltage imbalance as a percentage.
275+
*
276+
* @return voltage imbalance percentage, or null if not set
277+
*/
278+
public Double getSupplyVoltageImbalancePercent() {
279+
return supplyVoltageImbalance != null ? supplyVoltageImbalance / 100.0 : null;
280+
}
281+
282+
/**
283+
* Gets the harmonic voltage distortion as a percentage.
284+
*
285+
* @return harmonic voltage percentage, or null if not set
286+
*/
287+
public Double getHarmonicVoltagePercent() {
288+
return harmonicVoltage != null ? harmonicVoltage / 100.0 : null;
289+
}
290+
291+
/**
292+
* Checks if the power frequency is within normal bounds.
293+
* Assumes 60Hz nominal frequency with ±0.5Hz tolerance.
294+
*
295+
* @return true if frequency is within bounds, false otherwise
296+
*/
297+
public boolean isPowerFrequencyNormal() {
298+
Double freqHz = getPowerFrequencyInHz();
299+
if (freqHz == null) return false;
300+
// Typical tolerance for 60Hz systems
301+
return freqHz >= 59.5 && freqHz <= 60.5;
51302
}
52303
}

0 commit comments

Comments
 (0)