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

Improve error messages for unsupported data types #281

Open klauer opened 2 years ago

klauer commented 2 years ago

@ZryletTC reported the following:

$ pytmc db --plc "SDSPLC"  "/reg/g/pcds/epics-dev/pennebak/sample-delivery/icldev/sample-delivery-system/sdsPLC/SDS.tsproj" "SDSPLC.db"
Traceback (most recent call last):
  File "/cds/group/pcds/pyps/conda/py39/envs/pcds-5.3.1/bin/pytmc", line 10, in <module>
    sys.exit(main())
  File "/cds/group/pcds/pyps/conda/py39/envs/pcds-5.3.1/lib/python3.9/site-packages/pytmc/bin/pytmc.py", line 91, in main
    func(**kwargs)
  File "/cds/group/pcds/pyps/conda/py39/envs/pcds-5.3.1/lib/python3.9/site-packages/pytmc/bin/db.py", line 290, in main
    records, exceptions = process(
  File "/cds/group/pcds/pyps/conda/py39/envs/pcds-5.3.1/lib/python3.9/site-packages/pytmc/bin/db.py", line 124, in process
    record_names = [single_record.pvname
  File "/cds/group/pcds/pyps/conda/py39/envs/pcds-5.3.1/lib/python3.9/site-packages/pytmc/bin/db.py", line 126, in <listcomp>
    for single_record in record_package.records
  File "/cds/group/pcds/pyps/conda/py39/envs/pcds-5.3.1/lib/python3.9/site-packages/pytmc/record.py", line 554, in records
    records = [self.generate_input_record()]
  File "/cds/group/pcds/pyps/conda/py39/envs/pcds-5.3.1/lib/python3.9/site-packages/pytmc/record.py", line 734, in generate_input_record
    record = super().generate_input_record()
  File "/cds/group/pcds/pyps/conda/py39/envs/pcds-5.3.1/lib/python3.9/site-packages/pytmc/record.py", line 451, in generate_input_record
    record.fields['DTYP'] = self.dtyp
  File "/cds/group/pcds/pyps/conda/py39/envs/pcds-5.3.1/lib/python3.9/site-packages/pytmc/record.py", line 731, in dtyp
    return data_types[self.chain.data_type.name]
KeyError: 'STRING'

This is because pytmc doesn't support arrays of strings. I don't recall if m-epics-twincat-ads supports string waveforms or not, but EPICS handling of them is poor enough to make it undesirable to support them here regardless.

The error message should be improved, including the symbol name and data type information.