Please Note This forum exists for community support for the Mango product family and the Radix IoT Platform. Although Radix IoT employees participate in this forum from time to time, there is no guarantee of a response to anything posted here, nor can Radix IoT, LLC guarantee the accuracy of any information expressed or conveyed. Specific project questions from customers with active support contracts are asked to send requests to support@radixiot.com.
ClassCastException in PropertyStates
-
When a com.serotonin.bacnet4j.type.constructed.ProptertyStates object is instantiated via the PropertyStates(int type, BaseType state) constructor, the getState() function will work fine as a BaseType object is required.
However, when a PropertyStates object is instantiated via the public PropertyStates(ByteQueue queue) constructor, the getState() function can generate ClassCastExceptions if it is not a BaseType.
In my case, I had a ClassCastException because this.state was a BinaryPV, which isn't a BaseType.
Changing
public BaseType getState() { return (BaseType) state.getDatum(); }
to this
public Encodable getState() { return state.getDatum(); }
resolves the problem. Or if getState returned this.state, that should probably work too.