pcdshub / pytmc

Generate EPICS IOCs and records from TwinCAT projects - along with many TwinCAT project tools
https://pcdshub.github.io/pytmc/
Other
10 stars 11 forks source link

ENH: add scale and offset support for ints and floats #262

Closed klauer closed 3 years ago

klauer commented 3 years ago

Closes #261

Details (borrowed from docs in PR)

Integer and floating point values may have an EPICS-side scaling applied.

Example:

scale: 3.0
offset: 1.0

Values will be scaled according to the following:

readback_value = raw_value * scale + offset
setpoint_value = (user_value - offset) / scale

Note:

If either ``scale`` or ``offset`` are applied to an integer symbol, the
generated EPICS record type will no longer be a "long" integer input/output
record but rather change to an analog input/output record.

Keep this in mind if using advanced "field" directives in your pragmas.

If unspecified, scale will be assumed to be 1.0 and offset 0.0.

klauer commented 3 years ago

No problem and thanks, @ZLLentz.

I think we'll be looking to merge/tag and include this in a pcds-envs release so @slacAWallace will be able to use it to resolve his PMPS fixed-float issues.

ZLLentz commented 3 years ago

Yeah, I was planning to do pcds-envs this week- though you might understand literally everything is stalled for the moment.

klauer commented 3 years ago

Oh, and I didn't mention it originally, but this style of "tell me what you want to happen - scale/offset" versus "specifically give me an analog input record" is the direction I hope future pragmas additions will continue in. It'll offer more flexibility in the end.

Yeah, the network outage has been terribly disruptive for almost everything I've been trying to do. I can only imagine how much more it has affected your tasks...