Schedule encoding/decoding
This is a work in progress, feel free to comment on it to guide the implementation.
Currently it compiles, hasn't been tested yet. It also doesn't have unit tests for schedule.
TimeValue had to be changed to use BACNET_SHORT_APPLICATION_DATA_VALUE - it would not compile when I used the normal data value struct.
I also had to rename the struct in object/schedule.c due to name conflict.
No idea what went wrong in the windows build this time
I'd prefer to rename BACNET_SHORT_APPLICATION_DATA_VALUE to something other than "SHORT". The BACnetTimeValue is described in the BACnet standard as:
BACnetTimeValue ::= SEQUENCE {
time Time,
value ABSTRACT-SYNTAX.&Type -- any primitive datatype; complex types cannot be decoded
}
Perhaps BACNET_PRIMATIVE_VALUE, although it is really just limiting to 32-bit values (except on compiler that allow 64-bit integers).
It's too bad that the values of BACnetPriorityValue are not constrained enough or that would be a good definition and name:
BACnetPriorityValue ::= CHOICE {
null NULL,
real REAL,
enumerated ENUMERATED,
unsigned Unsigned,
boolean BOOLEAN,
integer INTEGER,
double Double,
time Time,
characterstring CharacterString,
octetstring OCTET STRING,
bitstring BIT STRING,
date Date,
objectidentifier BACnetObjectIdentifier,
constructed-value [0] ABSTRACT-SYNTAX.&Type,
datetime [1] BACnetDateTime
}
Also, please don't do magic "up-casting" to BACNET_APPLICATION_DATA_VALUE - structure members aren't guaranteed exact binary placement. Remove dummy structure members, and add pre/post copy as needed, or create separate handling functions for the BACNET_PRIMATIVE_VALUE data structure values and include BACNET_PRIMATIVE_VALUE directly in BACnet_Application_Data_Value structure.
I don't see how the two structs could be aligned differently, but it's a relatively small change so why not, it's done. There's some overhead incurred in the conversion, though. I also renamed the struct to BACNET_PRIMITIVE_DATA_VALUE.
I had to change the schedule object implementation in schedule.c/.h so Present_Value is now a copy instead of a pointer into the struct, this was the place where casting was really needed.
Please run clang-format on the changed files so that the style will be aligned.
Formatted, sorry it takes so long, we're using the fork and it works fine, so this got deprioritized.
Now there's a conflict, not sure what to do with that. It'd be easier if you resolved it when merging... or I can try to rebase.
note that clang-format changed a lot of things I never touched, so the diff is now huge ... I think this also caused the conflict.
Yikes! Sorry about that. If you want to revert the clang-format I can do bulk format after the merge.
it's now force-pushed to the commit before formatting