Permalink
Browse files

added trigger menu

  • Loading branch information...
1 parent f2b8471 commit db6930e06f4df65f8a4282294899f55ad6ff38e2 @andrmuel committed May 15, 2011
Showing with 120 additions and 3 deletions.
  1. +30 −0 MS2601B.py
  2. +7 −0 MenuIDs.py
  3. +1 −0 PrologixGPIB.py
  4. +51 −3 gui.wxg
  5. +31 −0 wxgui.py
View
@@ -56,6 +56,10 @@ class MS2601B:
ANTENNAS = {"DIPOLE": 0, "LOG-PERIODIC (1)": 1, "LOG-PERIODIC (2)": 2, "LOOP": 3, "USER": 4, "OFF": 5}
ANTENNAS_INV = dict([(b,a) for (a,b) in ANTENNAS.iteritems()])
+ # trigger types
+ TRIGGER_TYPES = {"FREE": 0, "VIDEO": 1, "LINE": 2, "EXT": 3, "SINGLE": 4, "START": 5}
+ TRIGGER_TYPES_INV = dict([(b,a) for (a,b) in TRIGGER_TYPES.iteritems()])
+
def __init__(self):
self.gpib = PrologixGPIB.PrologixGPIB(GPIB_ADDR)
self.res_bw_dirty = True
@@ -69,6 +73,7 @@ def __init__(self):
self.scale_dirty = True
self.unit_dirty = True
self.antenna_dirty = True
+ self.trigger_dirty = True
self.correction_data_dirty = True
self.response_data_dirty = True
@@ -113,6 +118,8 @@ def set_initial(self):
self.unit_dirty = False
self.antenna = "OFF"
self.antenna_dirty = False
+ self.trigger = "FREE"
+ self.trigger_dirty = False
self.correction_data = True
self.correction_data_dirty = False
self.response_data = True
@@ -154,6 +161,8 @@ def get_resolution_bandwidth_auto(self):
def set_resolution_bandwidth_auto(self, auto):
self.res_bw_auto = auto
+ self.res_bw_auto_dirty = False
+ self.res_bw_dirty = True
self.set_value("ARB", int(auto))
if self.get_sweep_time_auto():
self.sweep_time_dirty = True
@@ -167,6 +176,7 @@ def get_resolution_bandwidth(self):
def set_resolution_bandwidth(self, rbw):
self.res_bw = rbw
self.res_bw_dirty = False
+ self.res_bw_auto = False
self.set_value("RBW", self.RES_BW[rbw])
if self.get_sweep_time_auto():
self.sweep_time_dirty = True
@@ -180,6 +190,7 @@ def get_attenuation_auto(self):
def set_attenuation_auto(self, auto):
self.atten_auto = auto
self.atten_auto_dirty = False
+ self.atten_dirty = True
self.set_value("AAT", int(auto))
def get_attenuation(self):
@@ -191,6 +202,7 @@ def get_attenuation(self):
def set_attenuation(self, atten):
self.atten = atten
self.atten_dirty = False
+ self.atten_auto = False
self.set_value("ATT", self.ATTEN[atten])
def get_sweep_time_auto(self):
@@ -202,6 +214,7 @@ def get_sweep_time_auto(self):
def set_sweep_time_auto(self, auto):
self.sweep_time_auto = auto
self.sweep_time_auto_dirty = False
+ self.sweep_time_dirty = True
self.set_value("AST", int(auto))
def get_sweep_time(self):
@@ -213,6 +226,7 @@ def get_sweep_time(self):
def set_sweep_time(self, rbw):
self.sweep_time = rbw
self.sweep_time_dirty = False
+ self.sweep_time_auto = False
self.set_value("SWT", self.SWEEP_TIME[rbw])
def get_video_bandwidth_auto(self):
@@ -224,6 +238,7 @@ def get_video_bandwidth_auto(self):
def set_video_bandwidth_auto(self, auto):
self.video_bw_auto = auto
self.video_bw_auto_dirty = False
+ self.video_bw_dirty = True
self.set_value("AVB", int(auto))
if self.get_sweep_time_auto():
self.sweep_time_dirty = True
@@ -237,6 +252,7 @@ def get_video_bandwidth(self):
def set_video_bandwidth(self, rbw):
self.video_bw = rbw
self.video_bw_dirty = False
+ self.video_bw_auto = False
self.set_value("VBW", self.VIDEO_BW[rbw])
if self.get_sweep_time_auto():
self.sweep_time_dirty = True
@@ -278,6 +294,20 @@ def set_antenna(self, antenna):
self.antenna_dirty = False
self.set_value("ANT", self.ANTENNAS[antenna])
+ def sweep(self):
+ self.send("SWP")
+
+ def get_trigger(self):
+ if self.trigger_dirty:
+ self.trigger = self.TRIGGER_TYPES_INV[self.get_value("TRG")]
+ self.trigger_dirty = False
+ return self.trigger
+
+ def set_trigger(self, trigger):
+ self.trigger = trigger
+ self.trigger_dirty = False
+ self.set_value("TRG", self.TRIGGER_TYPES[trigger])
+
def start_calibration(self, mode=0):
"""
Start calibration process.
View
@@ -23,3 +23,10 @@
MENU_UNIT_DBUV_M = 23
MENU_CALIBRATION_CORRECTION_DATA = 24
MENU_CALIBRATION_RESPONSE_DATA = 25
+MENU_TRIGGER_FREE = 26
+MENU_TRIGGER_VIDEO = 27
+MENU_TRIGGER_LINE = 28
+MENU_TRIGGER_EXT = 29
+MENU_TRIGGER_SINGLE = 30
+MENU_TRIGGER_START = 31
+MENU_TRIGGER_SWEEP = 32
View
@@ -100,6 +100,7 @@ def gpib_send_clr(self):
def gpib_readline(self):
self.read()
self.send_prologix_command("read 10")
+ time.sleep(0.1)
while True:
line = self.read().strip()
if len(line) > 0:
View
54 gui.wxg
@@ -1,5 +1,5 @@
<?xml version="1.0"?>
-<!-- generated by wxGlade 0.6.3 on Sun May 15 19:11:59 2011 -->
+<!-- generated by wxGlade 0.6.3 on Sun May 15 20:02:45 2011 -->
<application path="/home/andrmuel/projects/MS2601B/ms2601b-gpib/wxgui.py" name="app" class="" option="0" language="python" top_window="frame" encoding="UTF-8" use_gettext="0" overwrite="0" use_new_namespace="1" for_version="2.8" is_template="0">
<object class="MainFrame" name="frame" base="EditFrame">
@@ -12,12 +12,12 @@
<menus>
<menu name="" label="Device">
<item>
- <label>Initial</label>
+ <label>Initial settings</label>
<id>MENU_INITIAL</id>
<handler>menu_handler_initial</handler>
</item>
<item>
- <label>Local</label>
+ <label>Local control</label>
<id>MENU_LOCAL</id>
<handler>menu_handler_local</handler>
</item>
@@ -92,6 +92,54 @@
<handler>menu_handler_unit</handler>
</item>
</menu>
+ <menu name="" label="Trigger">
+ <item>
+ <label>Free</label>
+ <id>MENU_TRIGGER_FREE</id>
+ <radio>1</radio>
+ <handler>menu_handler_trigger</handler>
+ </item>
+ <item>
+ <label>Video</label>
+ <id>MENU_TRIGGER_VIDEO</id>
+ <radio>1</radio>
+ <handler>menu_handler_trigger</handler>
+ </item>
+ <item>
+ <label>Line</label>
+ <id>MENU_TRIGGER_LINE</id>
+ <radio>1</radio>
+ <handler>menu_handler_trigger</handler>
+ </item>
+ <item>
+ <label>External</label>
+ <id>MENU_TRIGGER_EXT</id>
+ <radio>1</radio>
+ <handler>menu_handler_trigger</handler>
+ </item>
+ <item>
+ <label>Single</label>
+ <id>MENU_TRIGGER_SINGLE</id>
+ <radio>1</radio>
+ <handler>menu_handler_trigger</handler>
+ </item>
+ <item>
+ <label>Restart</label>
+ <id>MENU_TRIGGER_START</id>
+ <radio>1</radio>
+ <handler>menu_handler_trigger</handler>
+ </item>
+ <item>
+ <label>---</label>
+ <id>---</id>
+ <name>---</name>
+ </item>
+ <item>
+ <label>Sweep</label>
+ <id>MENU_TRIGGER_SWEEP</id>
+ <handler>menu_handler_trigger_sweep</handler>
+ </item>
+ </menu>
<menu name="" label="Calibration">
<item>
<label>All</label>
View
@@ -41,6 +41,16 @@ def __init__(self, *args, **kwds):
wxglade_tmp_menu.Append(MENU_UNIT_DBUV_M, u"dBµV/m", "", wx.ITEM_RADIO)
self.menubar.Append(wxglade_tmp_menu, "Unit")
wxglade_tmp_menu = wx.Menu()
+ wxglade_tmp_menu.Append(MENU_TRIGGER_FREE, "Free", "", wx.ITEM_RADIO)
+ wxglade_tmp_menu.Append(MENU_TRIGGER_VIDEO, "Video", "", wx.ITEM_RADIO)
+ wxglade_tmp_menu.Append(MENU_TRIGGER_LINE, "Line", "", wx.ITEM_RADIO)
+ wxglade_tmp_menu.Append(MENU_TRIGGER_EXT, "External", "", wx.ITEM_RADIO)
+ wxglade_tmp_menu.Append(MENU_TRIGGER_SINGLE, "Single", "", wx.ITEM_RADIO)
+ wxglade_tmp_menu.Append(MENU_TRIGGER_START, "Restart", "", wx.ITEM_RADIO)
+ wxglade_tmp_menu.AppendSeparator()
+ wxglade_tmp_menu.Append(MENU_TRIGGER_SWEEP, "Sweep", "", wx.ITEM_NORMAL)
+ self.menubar.Append(wxglade_tmp_menu, "Trigger")
+ wxglade_tmp_menu = wx.Menu()
wxglade_tmp_menu.Append(MENU_CALIBRATION_ALL, "All", "", wx.ITEM_NORMAL)
wxglade_tmp_menu.Append(MENU_CALIBRATION_LEVEL_1, "Level (1)", "", wx.ITEM_NORMAL)
wxglade_tmp_menu.Append(MENU_CALIBRATION_LEVEL_2, "Level (2)", "", wx.ITEM_NORMAL)
@@ -92,6 +102,13 @@ def __init__(self, *args, **kwds):
self.Bind(wx.EVT_MENU, self.menu_handler_unit, id=MENU_UNIT_V)
self.Bind(wx.EVT_MENU, self.menu_handler_unit, id=MENU_UNIT_DBUV_EMF)
self.Bind(wx.EVT_MENU, self.menu_handler_unit, id=MENU_UNIT_DBUV_M)
+ self.Bind(wx.EVT_MENU, self.menu_handler_trigger, id=MENU_TRIGGER_FREE)
+ self.Bind(wx.EVT_MENU, self.menu_handler_trigger, id=MENU_TRIGGER_VIDEO)
+ self.Bind(wx.EVT_MENU, self.menu_handler_trigger, id=MENU_TRIGGER_LINE)
+ self.Bind(wx.EVT_MENU, self.menu_handler_trigger, id=MENU_TRIGGER_EXT)
+ self.Bind(wx.EVT_MENU, self.menu_handler_trigger, id=MENU_TRIGGER_SINGLE)
+ self.Bind(wx.EVT_MENU, self.menu_handler_trigger, id=MENU_TRIGGER_START)
+ self.Bind(wx.EVT_MENU, self.menu_handler_trigger_sweep, id=MENU_TRIGGER_SWEEP)
self.Bind(wx.EVT_MENU, self.menu_handler_calibrate_all, id=MENU_CALIBRATION_ALL)
self.Bind(wx.EVT_MENU, self.menu_handler_calibrate_level_1, id=MENU_CALIBRATION_LEVEL_1)
self.Bind(wx.EVT_MENU, self.menu_handler_calibrate_level_2, id=MENU_CALIBRATION_LEVEL_2)
@@ -128,6 +145,10 @@ def __init__(self, *args, **kwds):
self.ANTENNA_TO_MENUITEM_ID = {"DIPOLE": MENU_ANTENNA_DIPOLE, "LOG-PERIODIC (1)": MENU_ANTENNA_LOGPER_1, "LOG-PERIODIC (2)": MENU_ANTENNA_LOGPER_2, "LOOP": MENU_ANTENNA_LOOP, "USER": MENU_ANTENNA_USER, "OFF": MENU_ANTENNA_OFF}
self.MENUITEM_ID_TO_ANTENNA = dict([(b,a) for (a,b) in self.ANTENNA_TO_MENUITEM_ID.iteritems()])
self.update_antenna_menu()
+ # set up trigger menu correctly
+ self.TRIGGER_TYPE_TO_MENUITEM_ID = {"FREE": MENU_TRIGGER_FREE, "VIDEO": MENU_TRIGGER_VIDEO, "LINE": MENU_TRIGGER_LINE, "EXT": MENU_TRIGGER_EXT, "SINGLE": MENU_TRIGGER_SINGLE, "START": MENU_TRIGGER_START}
+ self.MENUITEM_ID_TO_TRIGGER_TYPE = dict([(b,a) for (a,b) in self.TRIGGER_TYPE_TO_MENUITEM_ID.iteritems()])
+ self.update_trigger_menu()
# set up calibration menu correctly
self.update_calibration_menu()
# update main settings with actual values
@@ -278,6 +299,7 @@ def menu_handler_initial(self, event): # wxGlade: MainFrame.<event_handler>
self.update_unit_menu()
self.update_antenna_menu()
self.update_calibration_menu()
+ self.update_trigger_menu()
def menu_handler_local(self, event): # wxGlade: MainFrame.<event_handler>
self.statusbar.SetStatusText("Returning control to local ...")
@@ -289,6 +311,12 @@ def menu_handler_scale(self, event): # wxGlade: MainFrame.<event_handler>
def menu_handler_antenna(self, event): # wxGlade: MainFrame.<event_handler>
self.ms2601b.set_antenna(self.MENUITEM_ID_TO_ANTENNA[event.GetId()])
+ def menu_handler_trigger(self, event): # wxGlade: MainFrame.<event_handler>
+ self.ms2601b.set_trigger(self.MENUITEM_ID_TO_TRIGGER_TYPE[event.GetId()])
+
+ def menu_handler_trigger_sweep(self, event): # wxGlade: MainFrame.<event_handler>
+ self.ms2601b.sweep()
+
def menu_handler_unit(self, event): # wxGlade: MainFrame.<event_handler>
self.ms2601b.set_unit(self.MENUITEM_ID_TO_UNIT[event.GetId()])
@@ -348,6 +376,9 @@ def update_calibration_menu(self):
self.menubar.FindItemById(MENU_CALIBRATION_CORRECTION_DATA).Check(self.ms2601b.get_correction_data())
self.menubar.FindItemById(MENU_CALIBRATION_RESPONSE_DATA).Check(self.ms2601b.get_response_data())
+ def update_trigger_menu(self):
+ self.menubar.FindItemById(self.TRIGGER_TYPE_TO_MENUITEM_ID[self.ms2601b.get_trigger()]).Check(True)
+
# end of class MainFrame

0 comments on commit db6930e

Please sign in to comment.