Skip to content
This repository has been archived by the owner on Jun 14, 2024. It is now read-only.

Commit

Permalink
#14 Push commit to correspond with issue on github. Will break the te…
Browse files Browse the repository at this point in the history
…sts.
  • Loading branch information
baardl committed Sep 10, 2020
1 parent ab08cbc commit 8d302ca
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,24 @@ public static ObservationList mapToChangeOfValueObservation(Service service, Str
Octet[] timeRemainingOctets = covReader.nextOctets(numTimeRemainingOctets);
int timeRemainingSec = toInt(timeRemainingOctets);

// String resultListHexString = covReader.unprocessedHexString();
// resultListHexString = filterResultList(resultListHexString);
// log.info("*** {}", resultListHexString);
// properties = findProperties(covReader, resultListHexString);

String objectId = monitoredObjectId.getObjectType() + "_" + monitoredObjectId.getInstanceNumber();
Source source = new Source(deviceId.getInstanceNumber(), objectId);

String resultListHexString = covReader.unprocessedHexString();
resultListHexString = filterResultList(resultListHexString);
log.info("*** {}", resultListHexString);
properties = findProperties(covReader, resultListHexString);
// resultListHexString = filterResultList(resultListHexString);
List<Value> bacnetValues = parseListOfValues(resultListHexString);
for (Value bacnetValue : bacnetValues) {
String observationId = null; //TODO how to create unique id for the observation. Is that needed?
Object value = bacnetValue.getValue();
String name = bacnetValue.getPropertyIdentifier().name();
Observation observation = new Observation(observationId, source, value, name);
observations.add(observation);
}
/*
try {
Octet startList = covReader.next();
Expand Down Expand Up @@ -93,6 +107,7 @@ public static ObservationList mapToChangeOfValueObservation(Service service, Str
*/

/*
if (properties != null && properties.size() > 0) {
for (String key : properties.keySet()) {
Object value = properties.get(key);
Expand All @@ -112,6 +127,8 @@ public static ObservationList mapToChangeOfValueObservation(Service service, Str
}
}
*/


ObservationList observationList = new ObservationList(observations);
observationList.setSubscriptionRemainingSeconds(timeRemainingSec);
Expand Down Expand Up @@ -179,8 +196,20 @@ public static ObservationList parseConfirmedCOVNotification(String changeOfValue
//List of values
//4e095519012e4441a4cccd2f4f

String objectId = objectIdentifier.getObjectType() + "_" + objectIdentifier.getInstanceNumber();
Source source = new Source(deviceId.getInstanceNumber(), objectId);

String resultListHexString = covReader.unprocessedHexString();
resultListHexString = filterResultList(resultListHexString);
// resultListHexString = filterResultList(resultListHexString);
List<Value> bacnetValues = parseListOfValues(resultListHexString);
for (Value bacnetValue : bacnetValues) {
String observationId = null; //TODO how to create unique id for the observation. Is that needed?
Object value = bacnetValue.getValue();
String name = bacnetValue.getPropertyIdentifier().name();
Observation observation = new Observation(observationId, source, value, name);
observations.add(observation);
}
/*
properties = findProperties(covReader, resultListHexString);
if (properties != null && properties.size() > 0) {
Expand All @@ -201,6 +230,7 @@ public static ObservationList parseConfirmedCOVNotification(String changeOfValue
observations.add(observation);
}
}
*/


ObservationList observationList = new ObservationList(observations);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/no/entra/bacnet/json/values/ValueParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public static List<Value> parseListOfValues(String listOfValuesHexString) {
return values;
}

private static Object findValue(ApplicationTag applicationTag, String valueHex) {
static Object findValue(ApplicationTag applicationTag, String valueHex) {
Object value = null;
int type = applicationTag.findType();
switch (type) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ void validateUnConfirmedCovNotificationTest() {
assertEquals("AnalogValue_1", source.getObjectId());

//Verify value
Observation observation = observations.getObservations().get(0);
Observation observation = observations.getObservations().get(1);
assertEquals("StatusFlags", observation.getName());
assertEquals("0400", observation.getValue());
observation = observations.getObservations().get(1);
observation = observations.getObservations().get(0);
assertEquals("PresentValue", observation.getName());
assertEquals("00000000", observation.getValue());

Expand Down

0 comments on commit 8d302ca

Please sign in to comment.