Пример #1
0
    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)
Пример #2
0
    def __init__(self):
        #initialize FPGA
        self.xem = ok.FrontPanel()
        self.xem = fpgaInit(self._DDS_name, 0, self._FPGA_bitFile, 40)
        
        #initialize ADBoards
        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)) # Append a tuple (board#, channel#)
            
        
        #initialize GUI
        self.lock = threading.Lock()
        self.data = numpy.zeros([100,3], 'Int32')
        self.plotdata = numpy.zeros([100,3], 'Float32')
        self.stateobj = {}
        self.state = {}

        vbox = gtk.VBox(False, 0)
        hbox = gtk.HBox(False, 0)
        window = gtk.Window()
        window.set_title(self._DDS_name + " Controller")

        stateframe = gtk.Frame("State")

        box = self.make_state_view()
        stateframe.add(box)
        progdef = self.make_progdef_view()
        controlbox = self.make_control_view()

        self.figure = plt.figure() # define the Figure
        self.axis1 = self.figure.add_subplot(111)  # Add Plot to the figure
        self.axis2 = self.axis1.twinx() # Add Second plot to figure which uses other yaxis
        self.plot = FigureCanvas(self.figure)  # a gtk.DrawingArea


        # Add frames
        vbox.pack_start(stateframe, False, False, 1)
        vbox.pack_start(self.plot, True, True, 1)
        vbox.pack_start(controlbox, False, False, 1)
        hbox.pack_start(vbox, True, True, 1)
        hbox.pack_start(progdef, False, False, 1)

        window.add(hbox)

        # connect quit signals
        window.connect("delete_event", self.on_quit_activate, None)
        window.connect("destroy", self.on_quit_activate, None)

        # add an idle callback
        #gobject.timeout_add(50, self.update_state) #Changed 50 to 2000 CWC 04042012
        # Done, show it
        window.show_all()


        # start network
        self.plug = etherplug.etherplug(self.service_netcomm, NETPORT)
        for i in range(len(self.boardChannelIndex)):
            self.plug.register_hook('FREQ%i'%i, self.stateobj['DDS%i_FRQ'%i][0].set_value)
            self.plug.register_hook('AMP%i'%i, self.stateobj['DDS%i_AMP'%i][0].set_value)
            
        self.plug.register_hook('SHUTR', self.stateobj['SHUTR'][0].set_value)
        self.plug.register_hook('SETPROG', self.pp_setprog)
        self.plug.register_hook('PARAMETER', self.parameter_set)
        self.plug.register_hook('RUNIT', self.pp_run)
        self.plug.register_hook('NBRIGHT?', self.net_countabove)
        self.plug.register_hook('LASTAVG?', self.net_lastavg)
        self.plug.register_hook('MEMORY?', self.net_memory)
        self.plug.register_hook('PARAMETER?', self.parameter_read)

        return