MangoAutomation / BACnet4J

BACnet/IP stack written in Java. Forked from http://sourceforge.net/projects/bacnet4j/
GNU General Public License v3.0
187 stars 111 forks source link

Bacnet4J cannot write BinaryPV properly #95

Closed yangshuyi closed 4 months ago

yangshuyi commented 4 months ago

I'm now using Bacnet4j version 6.0.0. I read the previous value in DDC, and try to write the new value, then I try to read from bacnet in a loop to check the write action is success or not.

Below code can be executed without any error/exception, but the value still shows to be the previous one. Can anyone help me find the root cause?

Encodable writeValue = BinaryPV.active;
RequestUtils.writeProperty(
                localDevice,
                remoteDevice,
                new ObjectIdentifier(ObjectType.binaryValue, objectInstance),
                PropertyIdentifier.presentValue,
                writeValue);

the output like:

previous value inactive write: active value:0 value:0 value:0 value:0 value:0 value:0 value:0 value:0 value:0

kishorevenki commented 4 months ago

This behavior could be due to inactive value is set at some higher priority of BV object. Please read the priority-array property of BV that you are writing. If there is any value at higher priority other than NULL, then relinquish them all one-by-one by wiriting Present-Value to NULL in the appropriate priority.

yangshuyi commented 4 months ago

you are correct. By setting all priority value to be null, then set my new value can take effect. Thank you.

By the way, do you know how to read out all priority-array values? There's only one API can read the value, but the last one does not mean priority.

public static Encodable readProperty(final LocalDevice localDevice, final RemoteDevice d,
            final ObjectIdentifier oid, final PropertyIdentifier pid, final UnsignedInteger propertyArrayIndex)
kishorevenki commented 4 months ago

Good to know that your problem is resolved. In this API, PropertyArrayIndex is optional. So if you send RP request with oid = BV,0; pid = priority-array, the result will be array of 16 .

Regards, Kishore

yangshuyi commented 4 months ago

I appreciate your kindly help. Thank you so much.