# HG changeset patch # User David Douard # Date 1201343970 -3600 # Node ID 022e881b758e7c863e6bfee74e02957a82f9cc5b # Parent 61809bb871bf2911e5e2b09e6d33cfa98ac5be53 moved some files & one bugfix diff -r 61809bb871bf -r 022e881b758e gpib.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gpib.py Sat Jan 26 11:39:30 2008 +0100 @@ -0,0 +1,64 @@ +""" +gpib: create serial connection to GPIB-USB device (ProLogix is the +only supported device for now). +""" +import serial +from serial.serialutil import SerialException +import time + +class ConnectionError(Exception): + pass + +class Constants(object): + def __init__(self): + self.constants = {} + self.descriptions = {} + self.rev_constants = {} + for v, k, m in self._constants: + self.k = v + self.constants[v] = k + self.rev_constants[k] = v + self.descriptions[v] = m + + def __getitem__(self, k): + if isinstance(k, basestring): + return self.rev_constants[k] + else: + return self.constants[k] + + def get_description(self, k): + if isinstance(k, basestring): + k = self.rev_constants[k] + return self.descriptions[k] + + +class MODE(Constants): + _constants = [(1, "CONTROLLER", "Set device as Controller in Charge"), + (0, "DEVICE", "Set device as simple listener"), + ] +# TODO +# class STATUS_BYTE(Constants): +# # IEEE 488.2 Status Byte constants +# MAV = 0x10 # Message AVailable: bit 4 of the Status Byte +# ESB = 0x20 # Event Status Bit: bit 5 of the Status Byte +# MSS = 0x40 # Master Summary Status bit: bit 6 of the Status Byte (NOT +# # sent in response to a serial poll) +# RQS = 0x40 # Request Service: bit 6 of the Status Byte (when sent in +# # response to a serial poll) +# class SESR(Constants): +# # SESR constants (Standard Event Status Register) +# PON = 0x80 # Power On: Power has been turned On since last register +# # read access +# URQ = 0x40 # User Request: the user has activated some device control +# # (whatever the Remote Local state is) +# CME = 0x20 # Command Error +# EXE = 0x10 # Execution Error +# DDE = 0x08 # Device Dependant Error +# QYE = 0x04 # QuerY Error (attempt to read data while Output Queue is +# # empty, or data in the OQ was lost) +# RQC = 0x02 # Request Control: tell the CiC that the device wants to +# # become the CiC +# OPC = 0x01 # Operation Complete: device has completed any pending +# # operation (ready to accept new commands). This bit is +# # generated in response to a OPC command. + diff -r 61809bb871bf -r 022e881b758e icons/led_green.svg --- a/icons/led_green.svg Fri Jan 25 21:01:30 2008 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,144 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - diff -r 61809bb871bf -r 022e881b758e icons/led_green_off.svg --- a/icons/led_green_off.svg Fri Jan 25 21:01:30 2008 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,116 +0,0 @@ - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - diff -r 61809bb871bf -r 022e881b758e icons/led_red.svg --- a/icons/led_red.svg Fri Jan 25 21:01:30 2008 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,144 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - diff -r 61809bb871bf -r 022e881b758e icons/led_red_off.svg --- a/icons/led_red_off.svg Fri Jan 25 21:01:30 2008 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,144 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - diff -r 61809bb871bf -r 022e881b758e plotter/gpib.py --- a/plotter/gpib.py Fri Jan 25 21:01:30 2008 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,64 +0,0 @@ -""" -gpib: create serial connection to GPIB-USB device (ProLogix is the -only supported device for now). -""" -import serial -from serial.serialutil import SerialException -import time - -class ConnectionError(Exception): - pass - -class Constants(object): - def __init__(self): - self.constants = {} - self.descriptions = {} - self.rev_constants = {} - for v, k, m in self._constants: - self.k = v - self.constants[v] = k - self.rev_constants[k] = v - self.descriptions[v] = m - - def __getitem__(self, k): - if isinstance(k, basestring): - return self.rev_constants[k] - else: - return self.constants[k] - - def get_description(self, k): - if isinstance(k, basestring): - k = self.rev_constants[k] - return self.descriptions[k] - - -class MODE(Constants): - _constants = [(1, "CONTROLLER", "Set device as Controller in Charge"), - (0, "DEVICE", "Set device as simple listener"), - ] -# TODO -# class STATUS_BYTE(Constants): -# # IEEE 488.2 Status Byte constants -# MAV = 0x10 # Message AVailable: bit 4 of the Status Byte -# ESB = 0x20 # Event Status Bit: bit 5 of the Status Byte -# MSS = 0x40 # Master Summary Status bit: bit 6 of the Status Byte (NOT -# # sent in response to a serial poll) -# RQS = 0x40 # Request Service: bit 6 of the Status Byte (when sent in -# # response to a serial poll) -# class SESR(Constants): -# # SESR constants (Standard Event Status Register) -# PON = 0x80 # Power On: Power has been turned On since last register -# # read access -# URQ = 0x40 # User Request: the user has activated some device control -# # (whatever the Remote Local state is) -# CME = 0x20 # Command Error -# EXE = 0x10 # Execution Error -# DDE = 0x08 # Device Dependant Error -# QYE = 0x04 # QuerY Error (attempt to read data while Output Queue is -# # empty, or data in the OQ was lost) -# RQC = 0x02 # Request Control: tell the CiC that the device wants to -# # become the CiC -# OPC = 0x01 # Operation Complete: device has completed any pending -# # operation (ready to accept new commands). This bit is -# # generated in response to a OPC command. - diff -r 61809bb871bf -r 022e881b758e plotter/hpgl_parser.py --- a/plotter/hpgl_parser.py Fri Jan 25 21:01:30 2008 +0100 +++ b/plotter/hpgl_parser.py Sat Jan 26 11:39:30 2008 +0100 @@ -23,7 +23,7 @@ if data[self.idx] == chr(0x03): self.ESC() else: - cmd = data[self.idx: self.idx+2] + cmd = data[self.idx: self.idx+2].upper() self.idx += 2 getattr(self, cmd)() while self.idx + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + diff -r 61809bb871bf -r 022e881b758e plotter/icons/led_green_off.svg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/plotter/icons/led_green_off.svg Sat Jan 26 11:39:30 2008 +0100 @@ -0,0 +1,116 @@ + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + diff -r 61809bb871bf -r 022e881b758e plotter/icons/led_red.svg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/plotter/icons/led_red.svg Sat Jan 26 11:39:30 2008 +0100 @@ -0,0 +1,144 @@ + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + diff -r 61809bb871bf -r 022e881b758e plotter/icons/led_red_off.svg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/plotter/icons/led_red_off.svg Sat Jan 26 11:39:30 2008 +0100 @@ -0,0 +1,144 @@ + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + diff -r 61809bb871bf -r 022e881b758e plotter/qgpib_plotter.py --- a/plotter/qgpib_plotter.py Fri Jan 25 21:01:30 2008 +0100 +++ b/plotter/qgpib_plotter.py Sat Jan 26 11:39:30 2008 +0100 @@ -11,8 +11,11 @@ else: from gpib_plotter import GPIBplotter from hpgl_qt import QHPGLPlotterWidget +import hpgl_plotter_rc -form_class, base_class = uic.loadUiType(os.path.join(os.path.dirname(__file__), "qhpgl_plotter.ui")) +ldir = os.path.abspath(os.path.dirname(__file__)) +sys.path.append(ldir) +form_class, base_class = uic.loadUiType(os.path.join(ldir, "qhpgl_plotter.ui")) from qpreferences import PreferenceItem, AbstractPreferences, PreferencesEditor @@ -128,7 +131,13 @@ def saveTriggered(self, checked=False): print "save" def saveAsTriggered(self, checked=False): - print "saveAs" + index = self.plotsView.selectionModel().currentIndex() + if index.isValid(): + filename = QtGui.QFileDialog.getSaveFileName(self, "Selecte a file name to save HPGL file", '.', 'HPGL files (*.plt)\nAll files (*)') + n = index.row() + value = unicode(self.plotsView.model().data(index, Qt.DisplayRole).toString()) + open(filename, 'w').write(self._plots[value]) + def initializeGPIB(self): self._online = False