Hi all,

while working on the BACNet mspec I did notice, that it would be quite 
beneficial, if we had support for some sort of enum concept.
While thinking even more about it, perhaps it would also be good NOT to use 
enum types in Java as quite often only a part of the enum value range is 
specified and the rest can be freely defined by the vendors or users.
Using enums in Java would sort of eliminate this ability.

So I would suggest to generally use some singleton classes pattern as it is 
mostly used in languages without enum support.

Here a suggested syntax:

For classical “single-value” enums:


[enum 'ApplicationTags' uint 4
    ['0x0' 'NULL']
    ['0x1' 'BOOLEAN']
    ['0x2' 'UNSIGNED_INTEGER']
    ['0x3' 'SIGNED_INTEGER']
    ['0x4' 'REAL']
    ['0x5' 'DOUBLE']
    ['0x6' 'OCTET_STRING']
    ['0x7' 'CHARACTER_STRING']
    ['0x8' 'BIT_STRING']
    ['0x9' 'ENUMERATED']
    ['0xA' 'DATE']
    ['0xB' 'TIME']
    ['0xC' 'BACNET_OBJECT_IDENTIFIER']
]

In the S7 protocol we sometimes have one code that defines the value, but there 
are multiple other values tied to these constants.
Here I would use something like this:


[enum 'ApplicationTags' uint 4 [uint 8 'hurz', char 8 'lalala', bit 'dumdidum']
    ['0x0' 'NULL'              ['0x1', 'A', '1']]
    ['0x1' 'BOOLEAN'           ['0x1', 'A', '1']]
    ['0x2' 'UNSIGNED_INTEGER'  ['0x1', 'A', '1']]
    ['0x3' 'SIGNED_INTEGER'    ['0x1', 'A', '1']]

    ...

]

What do you think?

Chris

Reply via email to