Closed Sujay-M closed 5 years ago
You may want to take a look at the Test written for the ScheduleObject here https://github.com/infiniteautomation/BACnet4J/blob/master/src/test/java/com/serotonin/bacnet4j/obj/ScheduleObjectTest.java
@terrypacker , sorry for the delayed response. I might have missed the notification. Thank you, I'll check the above mentioned file..
Hi,
I am trying to write to weekly schedule property in a schedule object. I have little knowledge of the spec regarding this, please let me know if i am doing any mistakes. This is the daily schedule i am trying to write.
final DailySchedule dailySchedule = new DailySchedule(new SequenceOf<>(new TimeValue(new Time(8, 0, 0, 0), new Real(10)), new TimeValue(new Time(17, 0, 0, 0), new Real(11))));
final ScheduleObject so = new ScheduleObject(localDevice, 0, "sch0", effectivePeriod, weeklySchedule, exceptionSchedule, new Real(8), listOfObjectPropertyReferences, 12, false);
so.writeProperty(null, PropertyIdentifier.weeklySchedule, 1, dailySchedule);
When i do this, i get the following exception.
Exception in thread "main" java.lang.ClassCastException: com.serotonin.bacnet4j.type.constructed.DailySchedule cannot be cast to com.serotonin.bacnet4j.type.constructed.BACnetArray at com.serotonin.bacnet4j.obj.ScheduleObject.validateProperty(ScheduleObject.java:187) at com.serotonin.bacnet4j.obj.BACnetObject.writeProperty(BACnetObject.java:486) at com.serotonin.bacnet4j.obj.BACnetObject.writeProperty(BACnetObject.java:455) at com.serotonin.bacnet4j.TestArray.main(TestArray.java:75)
Question 1: Is writing to a specific array index not allowed?
When i do this it works fine,
so.writeProperty(null, PropertyIdentifier.weeklySchedule, weeklySchedule);
where weeklySchedule is array[7] of dailySchedules.Question 2. But when i try to write from a client, the BACnetArray is getting deserialized as SequenceOf. So i get a class cast exception. Is there any difference in SequenceOf and BACnetArray or am i writing it wrongly?
Following is the code snippet used.
`
`
Exception:
java.lang.ClassCastException: com.serotonin.bacnet4j.type.constructed.SequenceOf cannot be cast to com.serotonin.bacnet4j.type.constructed.BACnetArray at com.serotonin.bacnet4j.obj.ScheduleObject.validateProperty(ScheduleObject.java:187) at com.serotonin.bacnet4j.obj.BACnetObject.writeProperty(BACnetObject.java:486) at com.serotonin.bacnet4j.service.confirmed.WritePropertyRequest.handle(WritePropertyRequest.java:102) at com.serotonin.bacnet4j.transport.DefaultTransport.handleConfirmedRequest(DefaultTransport.java:870) at com.serotonin.bacnet4j.transport.DefaultTransport.incomingConfirmedRequest(DefaultTransport.java:827) at com.serotonin.bacnet4j.transport.DefaultTransport.receiveAPDU(DefaultTransport.java:640) at com.serotonin.bacnet4j.transport.DefaultTransport.receiveImpl(DefaultTransport.java:578) at com.serotonin.bacnet4j.transport.DefaultTransport.run(DefaultTransport.java:498) at java.base/java.lang.Thread.run(Thread.java:844)