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

FIX: pragmas on motionstage #118

Closed klauer closed 5 years ago

klauer commented 5 years ago

There are some finer points about this that need to be discussed at some point, but for now this PR just fixes the usage of a pytmc pragma on an FB_MotionStage in conjunction with the stcmd generation script:

Bug:

Traceback (most recent call last):
  ...
  File "/reg/g/pcds/epics/R7.0.2-2.0/ioc/ads-ioc/v0.0.2/iocBoot/templates/st.cmd.template", line 63, in top-level template code
    epicsEnvSet("MOTOR_PREFIX",    "{{motor|epics_prefix}}")
  File "/usr/local/lib/python3.7/site-packages/pytmc/bin/stcmd.py", line 137, in epics_prefix
    return get_name(obj, user_config)[0]
  File "/usr/local/lib/python3.7/site-packages/pytmc/bin/stcmd.py", line 118, in get_name
    config = pragmas.squash_configs(*configs)
  File "/usr/local/lib/python3.7/site-packages/pytmc/pragmas.py", line 190, in squash_configs
    squashed['pv'].append(config.pop('pv', None))
AttributeError: 'tuple' object has no attribute 'pop'

Looks like pragmas functions were tweaked and stcmd was not updated to follow that - another hole in the test suite.

Now an FB_MotionStage with a pragma of pv: my:prefix:AXIS1 will correctly generate the following:

epicsEnvSet("MOTOR_PREFIX",    "my:prefix:")
epicsEnvSet("MOTOR_NAME",      "AXIS1")

and a filter of the form {{motor|pragma('precision', 3) }} will get the precision: field from the FB_MotionStage pragma as well.

codecov-io commented 5 years ago

Codecov Report

Merging #118 into master will decrease coverage by 0.38%. The diff coverage is 0%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #118      +/-   ##
==========================================
- Coverage    76.3%   75.91%   -0.39%     
==========================================
  Files          16       16              
  Lines        1760     1769       +9     
==========================================
  Hits         1343     1343              
- Misses        417      426       +9
Impacted Files Coverage Δ
pytmc/bin/stcmd.py 65.54% <0%> (-5.37%) :arrow_down:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 2636c09...4c27e6e. Read the comment docs.

klauer commented 5 years ago

@ZLLentz the proposed DUT_* refactor should be based on this code.

ZLLentz commented 5 years ago

@klauer I'll start the refactor with a branch off of this branch. Is this ready for review? I think it looks good.

klauer commented 5 years ago

Yes, it should be ready for review.

klauer commented 5 years ago

Sounds good, @n-wbrown - apologies for the lazy coding! Since @ZLLentz's PR relies on this one, I'd like to merge this and push the docstring commit to his PR (or a separate one altogether). That OK?