This repository has been archived by the owner on Jun 14, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
184 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
src/main/java/no/entra/bacnet/property/ReadPropertyResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package no.entra.bacnet.property; | ||
|
||
import no.entra.bacnet.internal.property.ReadSinglePropertyResult; | ||
import org.slf4j.Logger; | ||
|
||
import java.util.Objects; | ||
|
||
import static org.slf4j.LoggerFactory.getLogger; | ||
|
||
/* | ||
{ | ||
"objectId": "device, 8", | ||
"property-identifier": "PropertiesServicesSupported", | ||
"property-array-index": 0, | ||
"value": "00000111000000000000101111000000000000001111100000000000" | ||
} | ||
*/ | ||
public class ReadPropertyResponse { | ||
private static final Logger log = getLogger(ReadPropertyResponse.class); | ||
|
||
private final ReadSinglePropertyResult result; | ||
|
||
public ReadPropertyResponse(ReadSinglePropertyResult result) { | ||
this.result = result; | ||
} | ||
|
||
public ReadSinglePropertyResult getResult() { | ||
return result; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "ReadPropertyResponse{" + | ||
"result=" + result + | ||
'}'; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (o == null || getClass() != o.getClass()) return false; | ||
ReadPropertyResponse that = (ReadPropertyResponse) o; | ||
return Objects.equals(getResult(), that.getResult()); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(getResult()); | ||
} | ||
} |
105 changes: 103 additions & 2 deletions
105
src/main/java/no/entra/bacnet/property/ReadPropertyService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,117 @@ | ||
package no.entra.bacnet.property; | ||
|
||
import no.entra.bacnet.BacnetRequest; | ||
import no.entra.bacnet.apdu.Apdu; | ||
import no.entra.bacnet.bvlc.Bvlc; | ||
import no.entra.bacnet.internal.apdu.MessageType; | ||
import no.entra.bacnet.internal.apdu.SDContextTag; | ||
import no.entra.bacnet.internal.bvlc.BvlcBuilder; | ||
import no.entra.bacnet.internal.bvlc.BvlcFunction; | ||
import no.entra.bacnet.internal.npdu.NpduBuilder; | ||
import no.entra.bacnet.internal.objects.ObjectProperties; | ||
import no.entra.bacnet.internal.properties.PropertyReference; | ||
import no.entra.bacnet.npdu.Npdu; | ||
import no.entra.bacnet.objects.ObjectId; | ||
import no.entra.bacnet.services.ConfirmedServiceChoice; | ||
import no.entra.bacnet.services.Service; | ||
|
||
import java.util.Set; | ||
|
||
import static no.entra.bacnet.internal.apdu.ArrayTag.ARRAY1_END; | ||
import static no.entra.bacnet.internal.apdu.ArrayTag.ARRAY1_START; | ||
import static no.entra.bacnet.utils.HexUtils.intToHexString; | ||
|
||
public class ReadPropertyService extends BacnetRequest implements Service { | ||
private Integer invokeId = null; | ||
private Set<ObjectProperties> objectProperties = null; | ||
private ObjectId objectId = null; | ||
private Set<PropertyReference> propertyReferences = null; | ||
private ReadPropertyResponse readPropertyResponse = null; | ||
|
||
public ReadPropertyService() { | ||
} | ||
|
||
public Integer getInvokeId() { | ||
return invokeId; | ||
} | ||
|
||
public void setInvokeId(Integer invokeId) { | ||
this.invokeId = invokeId; | ||
} | ||
|
||
public Set<ObjectProperties> getObjectProperties() { | ||
return objectProperties; | ||
} | ||
|
||
public void setObjectProperties(Set<ObjectProperties> objectProperties) { | ||
this.objectProperties = objectProperties; | ||
} | ||
|
||
public ObjectId getObjectId() { | ||
return objectId; | ||
} | ||
|
||
public void setObjectId(ObjectId objectId) { | ||
this.objectId = objectId; | ||
} | ||
|
||
public Set<PropertyReference> getPropertyReferences() { | ||
return propertyReferences; | ||
} | ||
|
||
public void setPropertyReferences(Set<PropertyReference> propertyReferences) { | ||
this.propertyReferences = propertyReferences; | ||
} | ||
|
||
public ReadPropertyResponse getReadPropertyResponse() { | ||
return readPropertyResponse; | ||
} | ||
|
||
public void setReadPropertyResponse(ReadPropertyResponse readPropertyResponse) { | ||
this.readPropertyResponse = readPropertyResponse; | ||
} | ||
|
||
@Override | ||
public String buildHexString() { | ||
return null; | ||
Apdu apdu = Apdu.ApduBuilder.builder() | ||
.withApduType(MessageType.ConfirmedRequest) | ||
.isSegmented(false) | ||
.hasMoreSegments(false) | ||
.isSegmentedReplyAllowed(true) | ||
.withMaxSegmentsAcceptedAbove64() | ||
.withMaxApduLength1476() | ||
.build(); | ||
String apduHexString = apdu.toHexString() | ||
+ intToHexString(getInvokeId(), 2) | ||
+ ConfirmedServiceChoice.ReadPropertyMultiple.getServiceChoiceHex(); | ||
if (objectId != null && propertyReferences != null) { | ||
apduHexString += SDContextTag.TAG0LENGTH4 + objectId.toHexString(); | ||
apduHexString += ARRAY1_START.toString(); | ||
for (PropertyReference propertyReference : propertyReferences) { | ||
apduHexString += propertyReference.buildHexString(); | ||
} | ||
apduHexString += ARRAY1_END; | ||
} | ||
int numberOfOctets = (apduHexString.length() / 2) + 6; | ||
Bvlc bvlc = new BvlcBuilder(BvlcFunction.OriginalUnicastNpdu).withTotalNumberOfOctets(numberOfOctets).build(); | ||
Npdu npdu = new NpduBuilder().withExpectingReply().build(); | ||
String hexString = bvlc.toHexString() + npdu.toHexString() + apduHexString; | ||
throw new RuntimeException("Not Implemented"); | ||
} | ||
|
||
@Override | ||
public boolean expectReply() { | ||
return false; | ||
return true; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "ReadPropertyService{" + | ||
"invokeId=" + invokeId + | ||
", objectProperties=" + objectProperties + | ||
", objectId=" + objectId + | ||
", propertyReferences=" + propertyReferences + | ||
", readPropertyResponse=" + readPropertyResponse + | ||
"} " + super.toString(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters