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: subitem pragma support #243

Closed klauer closed 3 years ago

klauer commented 3 years ago

Closes #223 Fixes as a follow-up to #240 Closes #242

Feature point: extends pragma syntax, allowing for forward-references to sub-items (e.g., member variables of function blocks).

If fbTest contains a member variable variable1 with a different io setting than desirable for the particular use case, this PR now allows for changing it by way of adding this pragma:

variable1.io: io

with the overall syntax of [member].[sub-member].pragma_key: pragma_value.

Started off with a slightly modified kfe-motion.tmc file (here), setting arrStates.array: 1..4 "externally".

Appears to be working locally, but I suspect I won't be catching all edge cases. Going to re-run pytmc on some IOCs and compare the output now.

Debug tool does not show these pragmas cleanly. Not sure I'll have the time to fix it this go around.

klauer commented 3 years ago

I didn't see anything strange when re-running make db on all the PLC projects I have locally. Based on the tests passing and those results, I'm at least reasonably certain I didn't screw something up majorly here.

ZLLentz commented 3 years ago

Is there any part of this you want a close review on? I'm having trouble following all the codepaths just reading through. I'll definitely give this a try with the cclib states things (since that is a patch that needs to happen anyway).

klauer commented 3 years ago

Yeah, it's admittedly a confusing mess, despite starting off kinda sorta clean - the usual story.

Testing it out as a user is good enough as a reviewer here, I think: verifying that it doesn't screw up your db for one, and seeing if it fits enough of what you might want in the future to consider #223 closed.

ZLLentz commented 3 years ago

Got sidetracked- The diff looks very promising: https://github.com/ZLLentz/lcls-plc-kfe-motion/commit/56581ac5a4da11857955f4cadad414b2459b76c4

A little puzzled by the culling of my st.cmd though- I haven't changed anything here. It looks like the default names are eliminated. These are the axis placeholders for the RTDSK0 and the AT1K4

klauer commented 3 years ago

Oof, your test saved me (us) a lot of headaches - I neglected to double-check st.cmd. I think I know where to look for the cause; will fix it up and push shortly.

klauer commented 3 years ago

Thanks, @ZLLentz! Here goes nothing...