-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SMHE-1609: Improve Mx382AlarmDecoder handling #1041
SMHE-1609: Improve Mx382AlarmDecoder handling #1041
Conversation
Signed-off-by: Andre Bolder <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In case of an exception in decoding the message it would be nice to see the whole message instead of only the byte(s) that were not expected.
|
||
// Datetime is not used, so can be skipped as well | ||
this.skipDateTime(inputStream); | ||
// Datetime is read and copied |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The datetime bytes are read but not used
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Modified the comment that the datetime is skipped.
// The next byte of the datetime is the length byte | ||
final byte lengthOfData = this.readByte(inputStream); | ||
this.readBytes(inputStream, lengthOfData); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are the dateTime bytes not appended?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The datetime is not used in this message and for other messages the dates are also skipped.
private void addAlarm() { | ||
this.builder.withTriggerType(PUSH_ALARM_TRIGGER); | ||
final Set<AlarmTypeDto> alarmSet = new HashSet<>(); | ||
alarmSet.add(AlarmTypeDto.LAST_GASP); | ||
this.builder.addAlarms(alarmSet); | ||
} | ||
|
||
private void checkByte(final InputStream inputStream, final byte expectedByte, final String name) | ||
private void handleByte(final InputStream inputStream, final byte expectedByte, final String name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this renamed to handleByte? It seems to do the same as checkBytes, but then only for 1 byte.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
renamed back to checkBytes
@@ -39,16 +45,52 @@ void testDecode() throws UnrecognizedMessageDataException { | |||
assertThat(dlmsPushNotification.getEquipmentIdentifier()).isEqualTo(this.equipmentIdentifier); | |||
} | |||
|
|||
/* | |||
* Decode with an alarm message that contains a date time stamp, this has an alternative length withing the WDPU header (2a on index 7, 8th byte). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
within
instead of withing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
modified
… UnrecognizedMessageDataException Signed-off-by: Andre Bolder <[email protected]>
Signed-off-by: Andre Bolder <[email protected]>
Signed-off-by: Andre Bolder <[email protected]>
Kudos, SonarCloud Quality Gate passed! |
Accept Mx382AlarmDecoder message with date and time within the message so alarm will be forwarded.