Closed klauer closed 1 year ago
If you're feeling green-checkmarky today you may consider fixing the recipe here: https://github.com/pcdshub/pytmc/blob/73bd2d9767f9b54b69766793cba9db57a4bd681f/conda-recipe/meta.yaml#L27
Is there a specific project we should add as a test case for this?
We could make a simple one or use this one: https://github.com/pcdshub/lcls-plc-polycapillary/commit/a71e6f465d6292be827a27026ce0eb820d3b2249
Or is it not worth the extra effort?
It is worth the effort but digging into the root cause of this exhausted me so I think it'll be this kind of scenario: "merge and then create a would-be-nice-to-have-a-real-test issue"
I also need to pull apart this commit at some point (separate TODO): https://github.com/pcdshub/pytmc/pull/317/commits/c487c4719f48fb3cc7d429383ef982dfc7062298
I think it's totally reasonable to end it here and work on other things
Look at all that GREEN
💚
The issue
When TwinCAT is not configured according to our setup guide (specifically independent project files), the user gets a confusing traceback while attempting to generate an IOC startup script that links NC axes back to their
DUT_MotionStage
(orST_MotionStage
):This was a bit of a rabbit hole, because this error:
Is due to Jinja confusingly doing the following:
motor.nc_axis
and having it raise with the "No NC link found"motor["nc_axis"]
and having it raise becauseSymbol_DUT_MotionStage
does not support__getitem__
The core of the issue is not the getitem exception, but rather that there was no NC link found. Yet the NC links clearly existed in the project! So what was going on?
When misconfigured (or in the default configuration), TwinCAT stores mappings inside the
.tsproj
file (and in fact there is no XTI file to speak of for a PLC project). While technically this is OK from what TwinCAT expects, pytmc assumes you've gone through the process listed below. So it finds no mappings where it expects, and it can't correlate your symbol with an NC axis.The fix
(Several times multiplied by the number of NC axes in your project) So it's loud but it should still generate the IOC.
Configuration reference