|
@@ -0,0 +1,107 @@
|
|
|
+"""
|
|
|
+This is a helper function to create a Toolbar for operation mode buttons
|
|
|
+In the main view. It is split into this file to better seperate concerns,
|
|
|
+since these buttons have to talk with the board directly.
|
|
|
+"""
|
|
|
+from PyQt4 import QtGui, QtCore
|
|
|
+from .groupedelements import Elements
|
|
|
+from .backend import board
|
|
|
+from .backend.board import available_boards
|
|
|
+
|
|
|
+
|
|
|
+#FIXME:
|
|
|
+#We wanted to support multiple boards at some point but dropped
|
|
|
+#the idea eventually. The board selection is still partially in
|
|
|
+#the codebase though ... In the future, this might change agin
|
|
|
+#but for now just using board 0 is good enough in 99.99% of the
|
|
|
+#cases
|
|
|
+BOARD_ID = 0
|
|
|
+
|
|
|
+
|
|
|
+class ModeSelectToolbar(QtGui.QToolBar):
|
|
|
+
|
|
|
+ def __init__(self, parent):
|
|
|
+ super(ModeSelectToolbar, self).__init__()
|
|
|
+
|
|
|
+ self.modeLabel = QtGui.QLabel("Sampling Mode:")
|
|
|
+ self.modeDropdown = QtGui.QComboBox(self)
|
|
|
+ self.modeDropdown.addItem("Normal")
|
|
|
+ self.modeDropdown.addItem("Equivalent Timesampling")
|
|
|
+ self.modeDropdown.addItem("Test Pattern")
|
|
|
+
|
|
|
+ #Important: Connect the changed callback AFTER adding the items
|
|
|
+ #or otherwise adding the first item will immediately fire the
|
|
|
+ #callback while launching the gui, potentially causing problems
|
|
|
+ self.modeDropdown.currentIndexChanged.connect(self._modeChanged)
|
|
|
+
|
|
|
+
|
|
|
+ self.dummyDataCheckbox = QtGui.QCheckBox()
|
|
|
+ self.dummyDataCheckbox.setChecked(False)
|
|
|
+ self.dummyDataCheckbox.clicked.connect(self._activateDummyData)
|
|
|
+
|
|
|
+
|
|
|
+ self.addWidget(self.modeLabel)
|
|
|
+ self.addWidget(self.modeDropdown)
|
|
|
+ self.addWidget(self.dummyDataCheckbox)
|
|
|
+ self.addWidget(QtGui.QLabel("Generate Dummy Data"))
|
|
|
+
|
|
|
+
|
|
|
+ def _modeChanged(self):
|
|
|
+ mode = self.modeDropdown.currentIndex()
|
|
|
+ #FIXME:
|
|
|
+ #These should really be functions in the board backend class
|
|
|
+ #I really dislike slinging magic values around in random
|
|
|
+ #files that no one can understand again later on ...
|
|
|
+
|
|
|
+ #Pre-Calculate the mask to switch "Equivalent Sampling" off
|
|
|
+ #since the sampling modes are supposed to be mutually
|
|
|
+ #exlusive. Set bit [23] to 0 (Zero-Indexed)
|
|
|
+ current = board.pci.read(BOARD_ID, 0x9040)[0]
|
|
|
+ mask = 0xF7FFFFFF
|
|
|
+ new = current & mask
|
|
|
+
|
|
|
+ if mode == 0:
|
|
|
+ #normal mode
|
|
|
+ board.pci.write(BOARD_ID, 30000, 0x9044)
|
|
|
+ board.pci.write(BOARD_ID, 402000, 0x9064)
|
|
|
+ board.pci.write(BOARD_ID, 0000, 0x9044)
|
|
|
+ board.pci.write(BOARD_ID, new, 0x9040)
|
|
|
+ #print("Sampling Mode Changed to 'Normal Mode'")
|
|
|
+ elif mode == 1:
|
|
|
+ #Equivalent Sampling mode
|
|
|
+ #print("Sampling Mode Changed to 'Equivalent Timesampling'")
|
|
|
+ #mask = 0b00000000100000000000000000000000
|
|
|
+ #Set bits [23] (Zero-Indexed)
|
|
|
+ mask = 0x8000000
|
|
|
+ new = current | mask
|
|
|
+ board.pci.write(BOARD_ID, new, 0x9040)
|
|
|
+ elif mode == 2:
|
|
|
+ #Test Pattern
|
|
|
+ board.pci.write(BOARD_ID, 30000, 0x9044)
|
|
|
+ board.pci.write(BOARD_ID, 403000, 0x9064)
|
|
|
+ board.pci.write(BOARD_ID, 0000, 0x9044)
|
|
|
+ board.pci.write(BOARD_ID, new, 0x9040)
|
|
|
+ #print("Sampling Mode Changed to 'Test Pattern'")
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ def _activateDummyData(self):
|
|
|
+ current = board.pci.read(BOARD_ID, 0x9040)[0]
|
|
|
+ if self.dummyDataCheckbox.isChecked():
|
|
|
+ #mask = 0b00001010000000000000000000000000
|
|
|
+ #Set bits [25] and [27] (Zero-Indexed)
|
|
|
+ mask = 0xa000000
|
|
|
+ new = current | mask
|
|
|
+ board.pci.write(BOARD_ID, new, 0x9040)
|
|
|
+ #print("Activate Dummy Data")
|
|
|
+ else:
|
|
|
+ #mask = 0b00001010000000000000000000000000
|
|
|
+ #Remove bits [25] and [27] (Zero-Indexed)
|
|
|
+ mask = 0xF5FFFFFF
|
|
|
+ new = current & mask
|
|
|
+ board.pci.write(BOARD_ID, new, 0x9040)
|
|
|
+ #print("Deactivate Dummy Data")
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|