From 6be9cc14821903e0d29ba941404b986b02aa650d Mon Sep 17 00:00:00 2001 From: Thawann Malfatti Date: Mon, 19 Aug 2019 09:41:30 -0300 Subject: [PATCH] Add statement for multiple signal chains --- Python3/SettingsXML.py | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/Python3/SettingsXML.py b/Python3/SettingsXML.py index 562251e..b6cb0ef 100644 --- a/Python3/SettingsXML.py +++ b/Python3/SettingsXML.py @@ -91,20 +91,30 @@ def XML2Dict(File): def GetSamplingRate(File): Info = XML2Dict(File) Error = 'Cannot parse sample rate. Check your settings.xml file at SIGNALCHAIN>PROCESSOR>Sources/Rhythm FPGA.' + SignalChains = [_ for _ in Info.keys() if 'SIGNALCHAIN' in _] try: - if 'SampleRateString' in Info['SIGNALCHAIN']['PROCESSOR']['Sources/Rhythm FPGA']['EDITOR']: - Rate = Info['SIGNALCHAIN']['PROCESSOR']['Sources/Rhythm FPGA']['EDITOR']['SampleRateString'] - Rate = float(Rate.split(' ')[0])*1000 - return(Rate) - elif Info['SIGNALCHAIN']['PROCESSOR']['Sources/Rhythm FPGA']['EDITOR']['SampleRate'] == '17': - Rate = 30000 - return(Rate) - else: + for SignalChain in SignalChains: + if 'Sources/Rhythm FPGA' in Info[SignalChain]['PROCESSOR'].keys(): + if 'SampleRateString' in Info[SignalChain]['PROCESSOR']['Sources/Rhythm FPGA']['EDITOR']: + Rate = Info[SignalChain]['PROCESSOR']['Sources/Rhythm FPGA']['EDITOR']['SampleRateString'] + Rate = float(Rate.split(' ')[0])*1000 + elif Info[SignalChain]['PROCESSOR']['Sources/Rhythm FPGA']['EDITOR']['SampleRate'] == '17': + Rate = 30000 + elif Info[SignalChain]['PROCESSOR']['Sources/Rhythm FPGA']['EDITOR']['SampleRate'] == '16': + Rate = 25000 + else: + Rate = None + else: + Rate = None + + if not Rate: print(Error); return(None) - except: - print(Error); return(None) + else: + return(Rate) + except Exception as Ex: + print(Ex); print(Error); return(None) def GetRecChs(File):