Skip to content

Allow the vs record's precision to be specified by the PREC field#17

Merged
keenanlang merged 2 commits intomasterfrom
issue16
Mar 12, 2026
Merged

Allow the vs record's precision to be specified by the PREC field#17
keenanlang merged 2 commits intomasterfrom
issue16

Conversation

@kmpeters
Copy link
Copy Markdown
Member

Allow the vs record's precision to be specified by the PREC field.

Commit eef412e includes changes suggested by Claude Opus 4.6 via Argo.

The changes "work" and have been tested at 3ID-B, however, it isn't obvious to me if other modifiations are required. I'm not familiar enough with all the devices supported by the vs record, so I don't know which fields in get_precision should be controlled by the PREC field and which, if any, should remain hard-coded.

These improvements were proposed by Claude Opus 4.6 via Argo. The code was tested at 3ID-B.
@keenanlang keenanlang merged commit aaef0b8 into master Mar 12, 2026
6 checks passed
@kmpeters kmpeters deleted the issue16 branch March 12, 2026 18:53
@anjohnson
Copy link
Copy Markdown
Member

FYI: The basic record types in Base use PREC for VAL and related fields (OVAL, PVAL etc.), but call recGblGetPrec(paddr, precision) for almost everything else. That gives 15 for fields that are floating-point, and 0 for the rest (those probably should be 7 for float and 15 for double, but that isn't what's currently implemented, and we don't have any DBF_FLOAT fields in the Base records anyway).

Some record types have a global variable which can be set with the iocsh var command for the precision of specific fields such as boHIGHprecision for the HIGH field of the bo record (a double holding the pulse width in seconds) — I didn't want to make those a fixed number, and this lets individual IOCs override the default of 2.

Other records such as the aSub, calc and sub that have INP links ask the link what the precision is of the link's target to provide the precision for the local field fetched from that link. They have similar code for returning unit strings too, which is pretty cool if you have a display manager which actually shows the unit strings properly.

Then there's the mbb[io]Direct records, which don't have a PREC field or provide a floating-point value, but they return the value of the NOBT field for VAL. Until I ran git grep just now I didn't know about that at all. I doubt if anything actually uses that, although it's possible that something like the MEDM Byte widet might.

@kmpeters kmpeters added the AI AI was used for some part of this issue or PR label Mar 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI AI was used for some part of this issue or PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants