Skip to content

Commit

Permalink
work regarding #15
Browse files Browse the repository at this point in the history
  • Loading branch information
Darius Berghe committed May 16, 2017
1 parent d0bc175 commit f945e71
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 36 deletions.
1 change: 0 additions & 1 deletion buildinstaller.wxs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
<Directory Id="INSTALLDIR" Name="GPIBCS">
<Component Id="ApplicationFiles" Guid="12345678-1234-1234-1234-222222222221">
<File Id="ApplicationExecutable" Source="dist\gpibcs.exe"/>
<File Id="ApplicationFile1" Source="gpibcs.conf"/>
</Component>
<Directory Id="IconsFolder" Name="icons">
<Component Id="ComponentFiles" Guid="12345678-1234-1234-1234-222222222222">
Expand Down
2 changes: 1 addition & 1 deletion doc/user-manual.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ <h1 id="tel-gpibcs"><a name="tel-gpibcs" href="#tel-gpibcs"></a>TEL GPIBCS</h1><
</code></pre><h3 id="3.b.-gpib-commands"><a name="3.b.-gpib-commands" href="#3.b.-gpib-commands"></a>3.b. GPIB commands</h3><p>A typical use case is a write followed by a read. By writing <code>Ft</code> and reading the response on can get the TEL prober model. Click <code>ibwrt</code> first, and <code>ibrd</code> secondly. This frequently used sequence can also be accomplished using the button <code>ibwrt-&gt;ibrd</code>.<br><img src="01a.png" alt="1"></p><p>Commands that require a wait on a particular SRQ can accomplished manually by an <code>ibwrt</code> followed by repeated clicks on <code>ibrsp</code> until the desired SRQ is received. The equivalent action can be performed by pressing the equivalent <code>ibwrt-&gt;waitsrq</code> button.<br><img src="01b.png" alt="1"></p><h3 id="gpib-command-sequences"><a name="gpib-command-sequences" href="#gpib-command-sequences"></a>GPIB command sequences</h3><p>Clicking on the side button exposes the sequence panel. You can load, edit, save and execute GPIB command sequences from this panel.</p><p>To <strong>edit</strong> command sequences, double click in an empty cell of the table and start typing. You can also insert/remove rows by right clicking anywhere in the table to get a context menu with such choices.<br><img src="10.png" alt="10"></p><p>The sequence table contains 3 columns: <strong>command</strong>, <strong>data</strong> and <strong>timeout</strong>. Hover the mouse over any of the table headers to get hints of what should you insert into each, what are the measurement units etc.</p><p>To <strong>save</strong> the sequence for future use click <strong>Save</strong> or <strong>Save As</strong> icons in the top right and choose a destionation file in <em>.csv</em> format.<br><img src="11.png" alt="11"></p><p>To <strong>load</strong> a sequence, click on the sequence selection combo box and select <code>Load sequence...</code>. Pick for example <code>bin1_pass.csv</code> and the file contents will be displayed in the sequence table.<br><img src="12a.png" alt="12a"><br><img src="12b.png" alt="12a"></p><p>Once you’re happy with your sequence you can run it by clicking on <code>Run</code>. Note that a sequence can be repeated for a specified number of times using the sequence multiplier. You can stop the execution of any command by clicking the stop button while a sequence’s execution is pending.<br><img src="13b.png" alt="12a"><br><img src="13a.png" alt="12a"></p><h2 id="4.-user-interface-tips"><a name="4.-user-interface-tips" href="#4.-user-interface-tips"></a>4. User interface tips</h2><ul>
<li>Some items are documented using mouse hover hints, make sure to use this feature.</li><li>You can browse the sequence selector using the keyboard navigation arrows when the selector is in focus.</li></ul><h2 id="5.-configuration-parameters"><a name="5.-configuration-parameters" href="#5.-configuration-parameters"></a>5. Configuration parameters</h2><ul>
<li><p>Section <code>logging</code><br><code>logfilename</code> - log file name [default: gpibcs.log]<br><code>logfilesize</code> - log file size measured in kilobytes [default: 102400]<br><code>logfilelevel</code> - level of details in the file [default: 1] (1 - highest, 5 - lowest)<br><code>logconsolelevel</code> - level of details on the GUI console [default: 2] (1 - highest, 5 - lowest)</p>
</li><li><p>Section <code>gpib</code><br><code>gpibdevice</code> - default device to use in the format GPIBx::y::INSTR where x is the dongle number (incremental from zero) and y is the primary address configured on the prober. Leave blank to ask for device selection each time.<br><code>gpibresponsetimeout</code> - GPIB bus timeout in seconds [default: 3]</p>
</li><li><p>Section <code>gpib</code><br><code>gpibdevice</code> - default device to use in the format GPIBx::y::INSTR where x is the dongle number (incremental from zero) and y is the primary address configured on the prober. Leave blank to ask for device selection each time.<br><code>gpibtimeout</code> - GPIB bus timeout in seconds [default: 3]</p>
</li><li><p>Section <code>gui</code><br><code>lastuseddir</code> - last used directory when loading sequences. It is overwritten on exit.<br><code>autoloaddirs</code> - by setting this to a comma separated list of directories, the sequences within the directories will show up in the selection drop-down list</p>
</li></ul><h2 id="contact"><a name="contact" href="#contact"></a>Contact</h2><p>For any bug reports or feature requests please contact darius.berghe@europe.tel.com.</p>

Expand Down
2 changes: 1 addition & 1 deletion doc/user-manual.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ Once you're happy with your sequence you can run it by clicking on `Run`. Note t

* Section `gpib`
`gpibdevice` - default device to use in the format GPIBx::y::INSTR where x is the dongle number (incremental from zero) and y is the primary address configured on the prober. Leave blank to ask for device selection each time.
`gpibresponsetimeout` - GPIB bus timeout in seconds [default: 3]
`gpibtimeout` - GPIB bus timeout in seconds [default: 3]

* Section `gui`
`lastuseddir` - last used directory when loading sequences. It is overwritten on exit.
Expand Down
14 changes: 0 additions & 14 deletions gpibcs.conf

This file was deleted.

30 changes: 21 additions & 9 deletions gpibcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ def confparseExHandle(filename, e):
confparseExHandle(filename, e)

try:
cfg['gpibDevice'] = parser.get('gpib', 'gpibDevice')
if cfg['gpibDevice'] != 'none':
cfg['gpibDevice'] = parser.get('gpib', 'gpibDevice')
except Exception as e:
confparseExHandle(filename, e)

Expand Down Expand Up @@ -106,7 +107,7 @@ def loggingsetup(cfg, logginghandler):
# create a rotating logger to a file
rootLogger = logging.getLogger('')
rootLogger.setLevel(cfg['logFileLevel'])
fileHandler = RotatingFileHandler(cfg['logFileName'], maxBytes=cfg['logFileSize'], backupCount=5)
fileHandler = RotatingFileHandler(os.path.join(cfg['configDir'], cfg['logFileName']), maxBytes=cfg['logFileSize'], backupCount=5)
fileHandler.setLevel(cfg['logFileLevel'])
fileFormatter = logging.Formatter('%(asctime)s.%(msecs)03d %(levelname)-8s %(message)s', datefmt='%Y/%d/%m %H:%M:%S')
fileHandler.setFormatter(fileFormatter)
Expand All @@ -124,7 +125,7 @@ def loggingsetup(cfg, logginghandler):
rootLogger.addHandler(fileHandler)
rootLogger.addHandler(consoleLogger)

def main():
def main(debug):
# make sure we're displaying the correct version before importing ui code
updateVersion()
import ui
Expand All @@ -135,13 +136,23 @@ def main():
cfg['logFileSize'] = 1024000
cfg['logFileLevel'] = logging.DEBUG
cfg['logConsoleLevel'] = logging.INFO
cfg['gpibDevice'] = 'GPIB0::5::INSTR'
cfg['gpibTimeout'] = 3
cfg['lastUsedDir'] = ''
cfg['autoLoadDirs'] = []
if debug:
cfg['gpibDevice'] = 'none'
else:
cfg['gpibDevice'] = ''
cfg['gpibTimeout'] = 1
cfg['installDir'] = os.path.dirname(os.path.realpath(__file__))
if (os.name == 'posix'):
cfg['configDir'] = os.path.expanduser('~/.config/gpibcs')
os.makedirs(cfg['configDir'], exist_ok=True)
else:
cfg['configDir'] = os.path.expanduser('~/gpibcs')
os.makedirs(cfg['configDir'], exist_ok=True)
cfg['lastUsedDir'] = cfg['configDir']
cfg['autoLoadDirs'] = [cfg['installDir'], cfg['configDir']]

# find out which .conf file we are using
filename = os.path.basename(__file__).split('.')[0] + '.conf'
filename = os.path.join(cfg['configDir'], 'gpibcs.conf')

# overwrite configuration with the contents of .conf file
parser = confparse(filename, cfg)
Expand All @@ -158,4 +169,5 @@ def main():
sys.exit(s)

if __name__ == '__main__':
main()
debug = True if len(sys.argv) > 1 and sys.argv[1] == '--debug' else False
main(debug)
26 changes: 16 additions & 10 deletions ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,8 @@ def closeEvent(self, event):
self._parser.set('gui', 'autoloaddirs', ', '.join(self._cfg['autoLoadDirs']))

try:
with open('gpibcs.conf', 'w') as configfile:
filename = os.path.join(self._cfg['configDir'], 'gpibcs.conf')
with open(filename, 'w') as configfile:
self._parser.write(configfile)
except Exception as e:
quit_msg = "Some settings could not be saved, most likely due to insufficient permissions for gpibcs.conf."
Expand All @@ -434,7 +435,7 @@ def connect(self, cfg):
self.rm = ResourceManager()

i = cfg['gpibDevice']
if i != 'test':
if i != 'none':
r = None

# No device available
Expand Down Expand Up @@ -467,30 +468,35 @@ class BugReportDialog(QDialog, bugreport.Ui_bugReportDialog):
def __init__(self, cfg):
super(BugReportDialog, self).__init__()
self.setupUi(self)
self._cfg = cfg

self.bugFileLink.clicked.connect(self.bugFileLinkClicked)
self.bugReportLink.clicked.connect(self.bugReportLinkClicked)

self.installationPath = os.path.dirname(os.path.realpath(cfg['logFileName']))
self.bugReportPath = os.path.join(self.installationPath, 'bugreport-' + time.strftime("%Y%m%d-%H%M%S") + '.zip')
cwd = os.getcwd()
os.chdir(self._cfg['configDir'])

bugReportPath = os.path.join(self._cfg['configDir'], 'bugreport-' + time.strftime("%Y%m%d-%H%M%S") + '.zip')

z = zf.ZipFile(self.bugReportPath, 'w')
z = zf.ZipFile(bugReportPath, 'w')

# add the .conf file to the zip
z.write('gpibcs.conf')

# add the .log files to the zip
for f in glob.glob(os.path.basename(cfg['logFileName']) + "*"):
for f in glob.glob(os.path.basename(self._cfg['logFileName']) + "*"):
z.write(f)

# add the sequence files to the zip
for f in os.listdir('sequence'):
z.write('sequence/' + os.path.basename(f))
for f in glob.glob(os.path.basename("*.csv")):
z.write(f)

self.bugFileLabel.setText(bugReportPath)

self.bugFileLabel.setText(self.bugReportPath)
os.chdir(cwd)

def bugFileLinkClicked(self):
webbrowser.open(self.installationPath)
webbrowser.open(self._cfg['configDir'])

def bugReportLinkClicked(self):
webbrowser.open('https://github.com/buha/gpibcs/issues/new')
Expand Down

0 comments on commit f945e71

Please sign in to comment.