@@ -63,7 +63,9 @@ public class Telegram(string? identification, IEnumerable<(OBISId obisid, IEnume
63
63
/// <summary>Number of long power failures in any phase.</summary>
64
64
public int ? ElectricityLongFailures => ParseInt ( OBISRegistry . ElectricityLongFailures ) ;
65
65
/// <summary>Power Failure Event Log.</summary>
66
- public IEnumerable < TimeStampedValue < TimeSpan > > ElectricityFailureLog => ParseTimeStampedValues ( OBISRegistry . ElectricityFailureLog , ( d , v ) => TimeSpan . FromSeconds ( ParseLongUnit ( d , v ) ? . Value ?? 0 ) , 2 ) ;
66
+ public IEnumerable < TimeStampedValue < TimeSpan > > ElectricityFailureLog
67
+ => ParseTimeStampedValues ( OBISRegistry . ElectricityFailureLog , ( d , v ) => TimeSpan . FromSeconds ( ParseLongUnit ( d , v ) ? . Value ?? 0 ) , 2 ) ;
68
+
67
69
/// <summary>Number of voltage sags in phase L1.</summary>
68
70
public int ? ElectricitySagsL1 => ParseInt ( OBISRegistry . ElectricitySagsL1 ) ;
69
71
/// <summary>Number of voltage sags in phase L2.</summary>
@@ -213,7 +215,8 @@ protected static bool TryParseDateTimeOffsetCore(string? value, out DateTimeOffs
213
215
/// <paramref name="result"/> contains a valid <see cref="byte"/> or null when the method returns false.
214
216
/// </param>
215
217
/// <returns>True if the parse operation was successful; otherwise, false.</returns>
216
- protected static bool TryParseHexByteCore ( string ? value , out byte result ) => byte . TryParse ( value , NumberStyles . HexNumber , _culture , out result ) ;
218
+ protected static bool TryParseHexByteCore ( string ? value , out byte result )
219
+ => byte . TryParse ( value , NumberStyles . HexNumber , _culture , out result ) ;
217
220
218
221
/// <summary>
219
222
/// Attempts to parse an integer value.
@@ -224,7 +227,8 @@ protected static bool TryParseDateTimeOffsetCore(string? value, out DateTimeOffs
224
227
/// <paramref name="result"/> contains a valid <see cref="int"/> or null when the method returns false.
225
228
/// </param>
226
229
/// <returns>True if the parse operation was successful; otherwise, false.</returns>
227
- protected static bool TryParseIntCore ( string ? value , out int result ) => int . TryParse ( value , NumberStyles . Integer , _culture , out result ) ;
230
+ protected static bool TryParseIntCore ( string ? value , out int result )
231
+ => int . TryParse ( value , NumberStyles . Integer , _culture , out result ) ;
228
232
229
233
/// <summary>
230
234
/// Attempts to parse a long value.
@@ -235,7 +239,8 @@ protected static bool TryParseDateTimeOffsetCore(string? value, out DateTimeOffs
235
239
/// <paramref name="result"/> contains a valid <see cref="long"/> or null when the method returns false.
236
240
/// </param>
237
241
/// <returns>True if the parse operation was successful; otherwise, false.</returns>
238
- protected static bool TryParseLongCore ( string ? value , out long result ) => long . TryParse ( value , NumberStyles . Integer , _culture , out result ) ;
242
+ protected static bool TryParseLongCore ( string ? value , out long result )
243
+ => long . TryParse ( value , NumberStyles . Integer , _culture , out result ) ;
239
244
240
245
/// <summary>
241
246
/// Attempts to parse a decimal value.
@@ -246,7 +251,8 @@ protected static bool TryParseDateTimeOffsetCore(string? value, out DateTimeOffs
246
251
/// <paramref name="result"/> contains a valid <see cref="decimal"/> or null when the method returns false.
247
252
/// </param>
248
253
/// <returns>True if the parse operation was successful; otherwise, false.</returns>
249
- protected static bool TryParseDecimalCore ( string ? value , out decimal result ) => decimal . TryParse ( value , NumberStyles . AllowDecimalPoint , _culture , out result ) ;
254
+ protected static bool TryParseDecimalCore ( string ? value , out decimal result )
255
+ => decimal . TryParse ( value , NumberStyles . AllowDecimalPoint , _culture , out result ) ;
250
256
251
257
/// <summary>
252
258
/// Attempts to parse an enum value.
@@ -258,7 +264,8 @@ protected static bool TryParseDateTimeOffsetCore(string? value, out DateTimeOffs
258
264
/// <paramref name="result"/> contains a valid enum value or null when the method returns false.
259
265
/// </param>
260
266
/// <returns>True if the parse operation was successful; otherwise, false.</returns>
261
- protected static bool TryParseEnumCore < T > ( string ? value , out T result ) where T : struct => Enum . TryParse < T > ( value , out result ) ;
267
+ protected static bool TryParseEnumCore < T > ( string ? value , out T result )
268
+ where T : struct => Enum . TryParse < T > ( value , out result ) ;
262
269
263
270
/// <summary>
264
271
/// Parses a timestamp in yyMMddHHmmss to a <see cref="DateTimeOffset"/>.
@@ -329,7 +336,8 @@ protected static bool TryParseDateTimeOffsetCore(string? value, out DateTimeOffs
329
336
/// The <see cref="OBISDescriptor"/> specifying the value to find in the telegram and parse as <see cref="UnitValue{T}"/>
330
337
/// </param>
331
338
/// <returns>Returns a <see cref="UnitValue{T}"/> when parsing the given <paramref name="descriptor"/> succeeded, null otherwise.</returns>
332
- protected UnitValue < int > ? ParseIntUnit ( OBISDescriptor descriptor ) => ParseIntUnit ( descriptor , GetByDescriptor ( descriptor ) ) ;
339
+ protected UnitValue < int > ? ParseIntUnit ( OBISDescriptor descriptor )
340
+ => ParseIntUnit ( descriptor , GetByDescriptor ( descriptor ) ) ;
333
341
/// <summary>
334
342
/// Attempts to parse a given value with unit from a given <see cref="OBISDescriptor"/>.
335
343
/// </summary>
@@ -406,7 +414,8 @@ protected static bool TryParseDateTimeOffsetCore(string? value, out DateTimeOffs
406
414
/// <param name="expected">The expected <see cref="OBISUnit"/> the value should represent.</param>
407
415
/// <param name="actual">The actual unit the value represents.</param>
408
416
/// <returns>True when the given string matches the given <see cref="OBISUnit"/>, false otherwise.</returns>
409
- protected static bool IsCorrectUnit ( OBISUnit expected , string ? actual ) => TryParseEnumCore < OBISUnit > ( actual , out var result ) && expected == result ;
417
+ protected static bool IsCorrectUnit ( OBISUnit expected , string ? actual )
418
+ => TryParseEnumCore < OBISUnit > ( actual , out var result ) && expected == result ;
410
419
411
420
/// <summary>
412
421
/// Parses values in (date)(value)(date)(value)... format to an <see cref="TimeStampedValue{T}"/> enumerable.
@@ -462,7 +471,9 @@ protected static (string? value, string? unit) SplitValues(string? value, char u
462
471
/// </summary>
463
472
/// <param name="value">The "hex byte format string".</param>
464
473
/// <returns>The string the "hex byte string" represents.</returns>
465
- protected static string ? DecodeString ( string ? value ) => ( ! string . IsNullOrEmpty ( value ) && value . Length % 2 == 0 ) ? Encoding . ASCII . GetString ( [ .. DecodeHexString ( value ) ] ) : value ;
474
+ protected static string ? DecodeString ( string ? value )
475
+ => ( ! string . IsNullOrEmpty ( value ) && value . Length % 2 == 0 ) ? Encoding . ASCII . GetString ( [ .. DecodeHexString ( value ) ] ) : value ;
476
+
466
477
/// <summary>
467
478
/// Decodes a string in "hex byte format" to it's byte values.
468
479
/// </summary>
0 commit comments