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.
Creating a Schedule Object in BACnet4j
-
I am trying to create a schedule object in BACnet4j using the following (simplified for clarity):
import com.serotonin.bacnet4j.LocalDevice; import com.serotonin.bacnet4j.exception.BACnetServiceException; import com.serotonin.bacnet4j.npdu.ip.IpNetwork; import com.serotonin.bacnet4j.obj.BACnetObject; import com.serotonin.bacnet4j.transport.Transport; import com.serotonin.bacnet4j.type.enumerated.ObjectType; import com.serotonin.bacnet4j.type.enumerated.PropertyIdentifier; import com.serotonin.bacnet4j.type.primitive.Enumerated; import com.serotonin.bacnet4j.type.primitive.ObjectIdentifier; public class ScheduleTest { public static void main(String[] args) { try { LocalDevice localDevice = new LocalDevice(21, new Transport(new IpNetwork("255.255.255.0"))); BACnetObject schedule = new BACnetObject(localDevice, new ObjectIdentifier(ObjectType.schedule, 0)); schedule.setProperty(PropertyIdentifier.scheduleDefault, new Enumerated(0)); } catch (BACnetServiceException e) { e.printStackTrace(); } } } ```However, when I run it, I get this:
com.serotonin.bacnet4j.exception.BACnetServiceException: class=Property, code=Invalid data type, message=expected class com.serotonin.bacnet4j.type.AmbiguousValue, received=class com.serotonin.bacnet4j.type.primitive.Enumerated
at com.serotonin.bacnet4j.obj.ObjectProperties.validateValue(ObjectProperties.java:154)
at com.serotonin.bacnet4j.obj.BACnetObject.setProperty(BACnetObject.java:192)
at ScheduleTest.main(ScheduleTest.java:21) -
Hello community,
I am also having some troubles with the Bacnet schedule, or there might be something I do not understand.
Can someone provide a brief example of a working Bacnet schedule object, because I did not find any?Thanks in advance.
Best regards, -
Up.
Has no one succeeded to implement this object ?
-
I have, but BACnet4j doesn't make it straight forward.
First you need to subclass BACnetObject and make a Schedule object class.
In that schedule object class, have a local variable for schedule default property.
In the constructor, set the present value and schedule default properties with this value:
new AmbiguousValue(new ByteQueue(new byte[]{0}))Then override the get() and set() methods, so that if the schedule default property is being set/retrieved, you get it from your local variable instead of the property map.
-
Sorry to answer so lately, I finally found back my login and password for this site.
Tank you Joolz, your comment helped me buld a schedule object. I'll try to paste a very basic example when I'll figure out how to put my code into code tag.