def __init__(self, parent=None): QtGui.QWidget.__init__(self, parent) self.projectSavePath = os.getcwd() # Configurable DDS properties: self._DDS_name = 'Black_DDS' # Must match FPGA name self._boards = ('ad9910', 'ad9959') self._FPGA_bitFile = 'DDSfirmware.bit' # Place bitfile in ./FPGA self._checkOutputs = False self.codefile = None # Initialize FPGA self.xem = ok.FrontPanel() self.xem = fpgaInit(self._DDS_name, 0, self._FPGA_bitFile, 40) # Initialize ADBoards # The DDSs on these boards will be put in the "DDS" list, in the order of the boards, # then in the order of the channel for the DDS on each board. self.boards = [] self.boardChannelIndex = []; for i in range(len(self._boards)): print 'Initializing board ' + self._boards[i] b = adBoard(self.xem, self._boards[i], i) b.initialize(self._checkOutputs) self.boards.append(b) for j in range(b.channelLimit): self.boardChannelIndex.append((i, j)) print "DDS %i = Board %i, Channel %i" % (i+j, i, j) # Initialize UI window self.ui = Ui_Form() self.ui.setupUi(self) self.setWindowTitle(self._DDS_name + " Pulse Programmer & DAQ") # Variable to count the number of runs so far self.runNum = 0 # Update limits for the input FREQ, AMP, PHASE boxes for i in range(len(self.boardChannelIndex)): self.ui.stateobj['DDS%i_FREQ'%i].setRange(0, self.boards[self.boardChannelIndex[i][0]].freqLimit) self.ui.stateobj['DDS%i_AMP'%i].setRange(0, self.boards[self.boardChannelIndex[i][0]].ampLimit) self.ui.stateobj['DDS%i_PHASE'%i].setRange(0, self.boards[self.boardChannelIndex[i][0]].phaseLimit) # Load parameters from previous usage of this app self.load_parameters() # Initialize graph with zero values self.data = numpy.zeros([100,3], 'Int32') self.plotdata = numpy.zeros([100,3], 'Float32') self.ui.histogram_dataitem = None # Initialize DAQ: self.DAQ_Running = False self.lock = threading.Lock() QtCore.QObject.connect(self, QtCore.SIGNAL("updateParamTable(int, PyQt_PyObject)"), self.updateParamTable) QtCore.QObject.connect(self, QtCore.SIGNAL("updateDAQGraph(PyQt_PyObject, PyQt_PyObject, PyQt_PyObject, int, PyQt_PyObject, int)"), self.updateDAQGraph)
class MyForm(QtGui.QMainWindow): def __init__(self, parent=None): QtGui.QWidget.__init__(self, parent) self.projectSavePath = os.getcwd() # Configurable DDS properties: self._DDS_name = 'Black_DDS' # Must match FPGA name self._boards = ('ad9910', 'ad9959') self._FPGA_bitFile = 'DDSfirmware.bit' # Place bitfile in ./FPGA self._checkOutputs = False self.codefile = None # Initialize FPGA self.xem = ok.FrontPanel() self.xem = fpgaInit(self._DDS_name, 0, self._FPGA_bitFile, 40) # Initialize ADBoards # The DDSs on these boards will be put in the "DDS" list, in the order of the boards, # then in the order of the channel for the DDS on each board. self.boards = [] self.boardChannelIndex = []; for i in range(len(self._boards)): print 'Initializing board ' + self._boards[i] b = adBoard(self.xem, self._boards[i], i) b.initialize(self._checkOutputs) self.boards.append(b) for j in range(b.channelLimit): self.boardChannelIndex.append((i, j)) print "DDS %i = Board %i, Channel %i" % (i+j, i, j) # Initialize UI window self.ui = Ui_Form() self.ui.setupUi(self) self.setWindowTitle(self._DDS_name + " Pulse Programmer & DAQ") # Variable to count the number of runs so far self.runNum = 0 # Update limits for the input FREQ, AMP, PHASE boxes for i in range(len(self.boardChannelIndex)): self.ui.stateobj['DDS%i_FREQ'%i].setRange(0, self.boards[self.boardChannelIndex[i][0]].freqLimit) self.ui.stateobj['DDS%i_AMP'%i].setRange(0, self.boards[self.boardChannelIndex[i][0]].ampLimit) self.ui.stateobj['DDS%i_PHASE'%i].setRange(0, self.boards[self.boardChannelIndex[i][0]].phaseLimit) # Load parameters from previous usage of this app self.load_parameters() # Initialize graph with zero values self.data = numpy.zeros([100,3], 'Int32') self.plotdata = numpy.zeros([100,3], 'Float32') self.ui.histogram_dataitem = None # Initialize DAQ: self.DAQ_Running = False self.lock = threading.Lock() QtCore.QObject.connect(self, QtCore.SIGNAL("updateParamTable(int, PyQt_PyObject)"), self.updateParamTable) QtCore.QObject.connect(self, QtCore.SIGNAL("updateDAQGraph(PyQt_PyObject, PyQt_PyObject, PyQt_PyObject, int, PyQt_PyObject, int)"), self.updateDAQGraph) # Choose a new project directory to save all files from experiments: def chooseProjectDirectory(self): fname = QtGui.QFileDialog.getExistingDirectory(self, 'Choose Project Folder', os.getcwd()) fname = fname.toUtf8().data() # Convert QString to normal string if len(fname) == 0: return # The dialog was cancelled! self.projectSavePath = fname self.ui.savePathLabelPath.setText(fname) print 'Set project directory to ', fname # Choose file with AOM frequencies to run, instead of typing them in. def chooseDDSFrequencyFile(self): fname = QtGui.QFileDialog.getOpenFileName(self, 'Choose PP Parameter File', os.getcwd()) fname = fname.toUtf8().data() # Convert QString to normal string try: f = open(fname, 'r') except IOError: print 'Error opening PP parameter file ', fname return False else: print fname self.ui.rampSettingsBox.setText( f.read() ) f.close() # This method opens a dialog that allows the user to select a .PP file from the # filesystem. The .PP is then sent to the Pulse Programmer to be stored in RAM. def openFile(self): # Open PP file fname = QtGui.QFileDialog.getOpenFileName(self, 'Open PP File', os.getcwd() + '/prog/') fname = fname.toUtf8().data() # Convert QString to normal string try: f = open(fname, 'r') except IOError: print 'Error opening PP file ', fname return False print fname f.close() self.codefile = fname # Send the .PP file to the Pulse Programmer return self.pp_upload() # This method saves the data obtained from the Pulse Programmer to a selected data # file. def saveAs(self): data = self.data fname = QtGui.QFileDialog.getSaveFileName(self, 'Save Data File', os.getcwd()) try: fd = open(fname, 'w') for i in range(len(data)): fd.write('%d %d %d\n'%(data[i, 0], data[i, 1], data[i,2])) fd.close except Exception, E: print E return True