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: some fields only apply to input/output records #205

Closed klauer closed 4 years ago

klauer commented 4 years ago

pytmc's pragma syntax only allows for a general "field: FIELDNAME FIELDVALUE"-style specification, which gets applied to both the input and output record.

We can apply a bit of knowledge about the records and their fields to allow for this form to remain valid, but also only apply the fields to the appropriate records.

The fields in this PR were generated by way of pyPDB and the caproto test suite. A messy but functional:

$ ipython -i caproto/tests/dbd.py
In [1]: dbd = DbdFile.parse_file('caproto/tests/reference-dbd/motorSim.dbd')

In [2]: def compare(input_rec, output_rec):
   ...:     input_fields = set(dbd.field_metadata[input_rec])
   ...:     output_fields = set(dbd.field_metadata[output_rec])
   ...:     output_only = list(sorted(set(output_fields) - set(input_fields)))
   ...:     input_only = list(sorted(set(input_fields) - set(output_fields)))
   ...:     input_only.remove('INP')
   ...:     output_only.remove('OUT')
   ...:     print(f'# Records: {input_rec} / {output_rec}')
   ...:     print('output_only_fields =', str(output_only).replace('[', '{').replace(']', '}'))
   ...:     print('input_only_fields =', str(input_only).replace('[', '{').replace(']', '}'))
   ...:

In [3]: compare('mbbi', 'mbbo')
# Records: mbbi / mbbo
output_only_fields =  {'DOL', 'IVOA', 'IVOV', 'OMSL', 'ORBV', 'RBV'}
input_only_fields =  {'AFTC', 'AFVL', 'SVAL'}
klauer commented 4 years ago

(Again, tests are passing but the project linter is failing; CI will need to be fixed down the line)

klauer commented 4 years ago

I'd like to add the test you describe at some point - will make an issue for it.