Skip to content
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

Merged
merged 4 commits into from
Jul 21, 2023

Conversation

abolder
Copy link
Contributor

@abolder abolder commented Jul 21, 2023

Accept Mx382AlarmDecoder message with date and time within the message so alarm will be forwarded.

@abolder
Copy link
Contributor Author

abolder commented Jul 21, 2023

Copy link
Contributor

@harrymiddelburgetall harrymiddelburgetall left a 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
Copy link
Contributor

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

Copy link
Contributor Author

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);
}
Copy link
Contributor

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?

Copy link
Contributor Author

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)
Copy link
Contributor

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.

Copy link
Contributor Author

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).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

within instead of withing

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

modified

Andre Bolder added 2 commits July 21, 2023 11:12
… UnrecognizedMessageDataException

Signed-off-by: Andre Bolder <[email protected]>
Signed-off-by: Andre Bolder <[email protected]>
Signed-off-by: Andre Bolder <[email protected]>
@abolder
Copy link
Contributor Author

abolder commented Jul 21, 2023

@sonarcloud
Copy link

sonarcloud bot commented Jul 21, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

0.0% 0.0% Coverage
0.0% 0.0% Duplication

@abolder abolder merged commit 211f35b into development Jul 21, 2023
4 checks passed
@abolder abolder deleted the feature/smhe-1609_Mx382AlarmDecoder_improvements branch July 21, 2023 13:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants