Details
-
Type:
Story
-
Status: Done
-
Resolution: Done
-
Fix Version/s: None
-
Component/s: None
-
Labels:
-
Story Points:0.5
-
Epic Link:
-
Sprint:TSSW Sprint - Mar 28 - Apr 11
-
Team:Telescope and Site
-
Urgent?:No
Description
The ATWhiteLight XML has two very large mask words that I have written enum constants for. The masks come from a low-level controller (I don't control them). Here is one:
<Enumeration>
|
ChillerL22Alarms_EXTERNAL_RTD_SENSOR_OPEN = 0x1,
|
ChillerL22Alarms_EXTERNAL_RTD_SENSOR_SHORT = 0x2,
|
...
|
ChillerL22Alarms_FRONT_LEFT_FAN_OPEN = 0x40000000,
|
ChillerL22Alarms_FRONT_RIGHT_FAN_OPEN = 0x80000000
|
</Enumeration>
|
The problem is that sal declares these as constants of type long, which is not large enough to hold the final value. We need unsigned long here.
One possible solution is to allow the user to specify a data type as an argument in the Enumeration tag. That is maximally flexible and avoids any "magic". It also is a very important signal to the user that the type of any field that uses this enumeration must not be "int" or "long". Thus I think it is a far better solution that simply picking a suitable type and using it.
It'd be neat if the enumeration could get its type from all topic fields that are of the enumeration type (and they would all have to match), but that seems likely to be more work than it is worth.
My short-term workaround is to omit the final value, though I'm a bit disappointed to have to do that. This brings up another request:
Please also consider supporting some way to include comment lines in enumeration values. That way I could easily document that I'm leaving out a value (and why). It would also be useful for documenting "this mask value not used" (of which the AT white light chiller has a surprising number). I tried three things, none of which worked: a standard XML comment (which I think is the best solution, since this is an XML file and editors will display it as comment), a line beginning with //, and a line beginning with #. It's not a big deal and is not worth a lot of work. For this case I will just change the too-large value to a comment appearing right after the close enumeration tag.
If it begins a value with 0x then it is a mask and thus unsigned ?
It is a rule/convention/sal-constraint in that case and gets documented accordingly.