Skip to content

Use try/except to determine channel reader in frameCPP

In a discussion with @emaros, he has recommended not using the FrTOC.GetADC() method and similar to determine the channel type, but rather just trying each of the Read*Data methods in turn:

try:
    stream.ReadFrAdcData(...)
except IndexError:
    try:
        stream.ReadFrProcData(...)
    except IndexError:
        try:
            stream.Read.FrSimData(...)
        except IndexError:
            raise ValueError('no channel found')

or something like that. For large files this is likely much more efficient than FrTOC.GetADC().