From faea61e98b937cc0098839f90d57e71118186bd3 Mon Sep 17 00:00:00 2001 From: David Lutton Date: Thu, 21 Mar 2024 22:20:03 +0000 Subject: [PATCH] Add enumerate for HP 8116A --- src/labtoolkit/WaveformGenerator/HP8116A.py | 18 +++++++++++++----- src/labtoolkit/__init__.py | 16 ++++++++++++++-- 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/src/labtoolkit/WaveformGenerator/HP8116A.py b/src/labtoolkit/WaveformGenerator/HP8116A.py index 8b5b479..9acd52b 100644 --- a/src/labtoolkit/WaveformGenerator/HP8116A.py +++ b/src/labtoolkit/WaveformGenerator/HP8116A.py @@ -1,5 +1,4 @@ from ..Instrument import Instrument -from ..IEEE488 import IEEE488 class HP8116A(Instrument): @@ -52,19 +51,28 @@ def amplitude(self): @amplitude.setter # @AmplitudeLimiter - def amplitude(self, amplitude: + def amplitude(self, amplitude): self.write(f"AMP {amplitude} V") @property def offset(self): return self.query("IOFS") - @offset.setter # @AmplitudeLimiter - def offset(self, amplitude: + @offset.setter + def offset(self, amplitude): self.write(f"OFS {amplitude} V") @property def setup(self): # ' M1,CT0,T0,W0,H0,A0,L0,C0,D0,FRQ 55.0 HZ,DTY 50 %,WID 500 MS,AMP 1.00 V,OFS 7.50 V,' - return self.query('CST') \ No newline at end of file + setup_str = self.query('CST').strip() + # 'M1,CT0,T0,W0,H0,A0,L0,C0,D0,FRQ 55.0 HZ,DTY 50 %,WID 500 MS,AMP 1.00 V,OFS 7.50 V,' + + flags = [x for x in setup_str.split(',') if len(x) == 2 or len(x) == 3] + # ['M1', 'CT0', 'T0', 'W0', 'H0', 'A0', 'L0', 'C0', 'D0'] + + values = [x for x in setup_str.split(',') if len(x) > 3] + # ['FRQ 55.0 HZ', 'DTY 50 %', 'WID 500 MS', 'AMP 1.00 V', 'OFS 7.50 V'] + return setup_str + \ No newline at end of file diff --git a/src/labtoolkit/__init__.py b/src/labtoolkit/__init__.py index 41c4a8c..2e61b56 100644 --- a/src/labtoolkit/__init__.py +++ b/src/labtoolkit/__init__.py @@ -167,7 +167,7 @@ def enumerate_resources(self): # Hewlett-Packard, XXnnnnnnnn, ESG-3000A, A.01.00 # reorder to match normal IDNs # Hewlett Packard,ESG-3000A,XXnnnnnnnn,A.01.00 - # This is show & not explained in HP/Agilent manual + # This is shown & not explained in HP/Agilent manual parts = [parts[0], parts[2], parts[1], parts[3]] parts[1].removeprefix('MODEL ') if 'MODEL ' in parts[1] else parts[1] @@ -217,6 +217,11 @@ def enumerate_resources(self): mapping.loc[number, 'Serial'] = '' # mapping.loc[number, 'Serial'] = '0' + if ' NO MESSAGE' in IDN or ' SYNTAX' in IDN: + mapping.loc[number, 'Resource'] = resource + mapping.loc[number, 'Manufacturer'] = 'Hewlett Packard' + mapping.loc[number, 'Model'] = '8116A' + mapping.loc[number, 'Serial'] = '' except IndexError: pass @@ -279,6 +284,12 @@ def IDN_for_NVRS(self, inst, resource, mapping, number): def IDN_for_HP(self, inst, resource, mapping, number): ident = inst.query('ID?').strip() + if ident == 'HP3457A': + mapping.loc[number, 'Resource'] = resource + mapping.loc[number, 'Manufacturer'] = 'Hewlett Packard' + mapping.loc[number, 'Model'] = ident[2:] + mapping.loc[number, 'Serial'] = '' + return True if ident[0:2] == 'HP': # HP 8563E # HP 8564E @@ -480,4 +491,5 @@ def driver_load_all(self): """.""" for index, value in self.drivers_sorted()[['Type','Driver']].drop_duplicates().iterrows(): # print(f"labtoolkit.{value.Type}.{value.Driver}") - module = importlib.import_module(f'.{value.Type}.{value.Driver}', package='labtoolkit') \ No newline at end of file + module = importlib.import_module(f'.{value.Type}.{value.Driver}', package='labtoolkit') + \ No newline at end of file