Commit 85e136dc authored by Spencer Du's avatar Spencer Du

Can only input values when specific lasers are on

parent 0dd0d36c
......@@ -37,7 +37,19 @@ class MainWindow(QtWidgets.QMainWindow):
time.sleep(1)
menubar = self.menuBar()
fileMenu = menubar.addMenu('Devices')
fileMenu = menubar.addMenu("Devices")
startMenu = menubar.addMenu("Start")
stopMenu = menubar.addMenu("Stop")
startMenu.triggered.connect(self.start)
# pybutton = QPushButton("Run", self)
# pybutton.resize(25,15)
# pybutton.move(0,20)
# pybutton2 = QPushButton("Stop", self)
# pybutton2.resize(25,18)
# pybutton2.move(40,20)
def readFile(fname):
try:
......
......@@ -9,6 +9,7 @@ class embedded:
def start():
try:
os.remove("list_of_device(s)_currently_active.txt")
os.remove("laser.ini")
print("Activating device(s)")
except:
print("Activating devices(s)")
......
......@@ -32,7 +32,6 @@ class Ui_Laser(object):
self.label_3.setObjectName("label_3")
self.gridLayout.addWidget(self.label_3, 2, 4, 1, 2)
self.pushButton_9 = QtWidgets.QPushButton(self.centralwidget)
self.pushButton_9.clicked.connect(self.printValue)
self.pushButton_9.setObjectName("pushButton_9")
self.gridLayout.addWidget(self.pushButton_9, 9, 0, 1, 2)
self.lineEdit_5 = QtWidgets.QLineEdit(self.centralwidget)
......@@ -54,7 +53,6 @@ class Ui_Laser(object):
self.label.setObjectName("label")
self.gridLayout.addWidget(self.label, 2, 0, 1, 2)
self.pushButton_10 = QtWidgets.QPushButton(self.centralwidget)
self.pushButton_10.clicked.connect(self.printValue2)
self.pushButton_10.setObjectName("pushButton_10")
self.gridLayout.addWidget(self.pushButton_10, 9, 2, 1, 2)
self.verticalSlider = QtWidgets.QSlider(self.centralwidget)
......@@ -73,7 +71,6 @@ class Ui_Laser(object):
self.verticalSlider_4.setObjectName("verticalSlider_4")
self.gridLayout.addWidget(self.verticalSlider_4, 6, 6, 1, 1)
self.pushButton_15 = QtWidgets.QPushButton(self.centralwidget)
# self.pushButton_15.clicked.connect(self.printValue7)
self.pushButton_15.setObjectName("pushButton_15")
self.gridLayout.addWidget(self.pushButton_15, 9, 12, 1, 2)
self.lineEdit_2 = QtWidgets.QLineEdit(self.centralwidget)
......@@ -100,11 +97,9 @@ class Ui_Laser(object):
self.label_16.setObjectName("label_16")
self.gridLayout.addWidget(self.label_16, 4, 8, 1, 1)
self.pushButton_11 = QtWidgets.QPushButton(self.centralwidget)
self.pushButton_11.clicked.connect(self.printValue3)
self.pushButton_11.setObjectName("pushButton_11")
self.gridLayout.addWidget(self.pushButton_11, 9, 4, 1, 2)
self.pushButton_14 = QtWidgets.QPushButton(self.centralwidget)
self.pushButton_14.clicked.connect(self.printValue6)
self.pushButton_14.setObjectName("pushButton_14")
self.gridLayout.addWidget(self.pushButton_14, 9, 10, 1, 2)
self.label_19 = QtWidgets.QLabel(self.centralwidget)
......@@ -122,6 +117,7 @@ class Ui_Laser(object):
self.gridLayout.addWidget(self.label_20, 7, 12, 1, 2)
self.pushButton = QtWidgets.QPushButton(self.centralwidget)
self.pushButton.setCheckable(True)
self.pushButton.clicked.connect(self.btnstate)
self.pushButton.setObjectName("pushButton")
self.gridLayout.addWidget(self.pushButton, 3, 0, 1, 2)
self.lineEdit_4 = QtWidgets.QLineEdit(self.centralwidget)
......@@ -164,7 +160,6 @@ class Ui_Laser(object):
self.lineEdit_7.setObjectName("lineEdit_7")
self.gridLayout.addWidget(self.lineEdit_7, 8, 12, 1, 2)
self.pushButton_12 = QtWidgets.QPushButton(self.centralwidget)
self.pushButton_12.clicked.connect(self.printValue4)
self.pushButton_12.setObjectName("pushButton_12")
self.gridLayout.addWidget(self.pushButton_12, 9, 6, 1, 2)
self.pushButton_2 = QtWidgets.QPushButton(self.centralwidget)
......@@ -180,7 +175,6 @@ class Ui_Laser(object):
self.lineEdit_6.setObjectName("lineEdit_6")
self.gridLayout.addWidget(self.lineEdit_6, 8, 10, 1, 2)
self.pushButton_13 = QtWidgets.QPushButton(self.centralwidget)
self.pushButton_13.clicked.connect(self.printValue5)
self.pushButton_13.setObjectName("pushButton_13")
self.gridLayout.addWidget(self.pushButton_13, 9, 8, 1, 2)
self.pushButton_6 = QtWidgets.QPushButton(self.centralwidget)
......@@ -211,125 +205,15 @@ class Ui_Laser(object):
self.retranslateUi(Laser)
QtCore.QMetaObject.connectSlotsByName(Laser)
def retranslateUi(self, Laser):
_translate = QtCore.QCoreApplication.translate
Laser.setWindowTitle(_translate("Laser", "MainWindow"))
self.label_9.setText(_translate("Laser", "0"))
self.label_4.setText(_translate("Laser", "561nm"))
self.label_3.setText(_translate("Laser", "515nm"))
self.pushButton_9.setText(_translate("Laser", "Button"))
self.label_6.setText(_translate("Laser", "638nm"))
self.label_18.setText(_translate("Laser", "100"))
self.label_13.setText(_translate("Laser", "0"))
self.label.setText(_translate("Laser", "445nm"))
self.pushButton_10.setText(_translate("Laser", "Button"))
self.label_17.setText(_translate("Laser", "0"))
self.pushButton_15.setText(_translate("Laser", "Button"))
self.label_14.setText(_translate("Laser", "100"))
self.label_5.setText(_translate("Laser", "594nm"))
self.pushButton_4.setText(_translate("Laser", "ON"))
self.pushButton_5.setText(_translate("Laser", "ON"))
self.label_16.setText(_translate("Laser", "100"))
self.pushButton_11.setText(_translate("Laser", "Button"))
self.pushButton_14.setText(_translate("Laser", "Button"))
self.label_19.setText(_translate("Laser", "0"))
self.label_7.setText(_translate("Laser", "LED"))
self.pushButton_7.setText(_translate("Laser", "ON"))
self.label_20.setText(_translate("Laser", "0"))
self.pushButton.setText(_translate("Laser", "ON"))
self.label_2.setText(_translate("Laser", "488nm"))
self.pushButton_3.setText(_translate("Laser", "ON"))
self.label_15.setText(_translate("Laser", "0"))
self.label_21.setText(_translate("Laser", "100"))
self.pushButton_12.setText(_translate("Laser", "Button"))
self.pushButton_2.setText(_translate("Laser", "ON"))
self.pushButton_13.setText(_translate("Laser", "Button"))
self.pushButton_6.setText(_translate("Laser", "ON"))
self.label_10.setText(_translate("Laser", "0"))
self.label_12.setText(_translate("Laser", "100"))
self.pushButton_8.setText(_translate("Laser", "ON"))
self.label_8.setText(_translate("Laser", "100"))
self.label_11.setText(_translate("Laser", "100"))
def getConfig():
if os.path.exists("laser.ini"):
config = configparser.RawConfigParser()
config.read("laser.ini")
try:
self.verticalSlider.setValue(config.getint("445nm", "intensity"))
print("455nm laser set")
except Exception as e:
print("455nm laser not set")
try:
self.lineEdit.setText(str(config.getint("445nm", "intensity")))
print("455nm laser textbox set")
except Exception as e:
print("455nm laser textbox not set")
try:
self.verticalSlider_2.setValue(config.getint("488nm", "intensity"))
print("488nm laser set")
except Exception as e:
print("488nm laser not set")
try:
self.lineEdit_2.setText(str(config.getint("488nm", "intensity")))
print("488nm laser textbox set")
except Exception as e:
print("488nm laser textbox not set")
try:
self.verticalSlider_3.setValue(config.getint("515nm", "intensity"))
print("515nm laser set")
except Exception as e:
print("515nm laser not set")
try:
self.lineEdit_3.setText(str(config.getint("515nm", "intensity")))
print("515nm laser textbox set")
except Exception as e:
print("515nm laser textbox not set")
try:
self.verticalSlider_4.setValue(config.getint("561nm", "intensity"))
print("561nm laser set")
except Exception as e:
print("561nm laser not set")
try:
self.lineEdit_4.setText(str(config.getint("561nm", "intensity")))
print("561nm laser textbox set")
except Exception as e:
print("561nm laser textbox not set")
try:
self.verticalSlider_5.setValue(config.getint("594nm", "intensity"))
print("594nm laser set")
except Exception as e:
print("594nm laser not set")
try:
self.lineEdit_5.setText(str(config.getint("594nm", "intensity")))
print("594nm laser textbox set")
except Exception as e:
print("594nm laser textbox not set")
try:
self.verticalSlider_6.setValue(config.getint("638nm", "intensity"))
print("638nm laser set")
except Exception as e:
print("638nm laser not set")
try:
self.lineEdit_6.setText(str(config.getint("638nm", "intensity")))
print("638nm laser textbox set")
except Exception as e:
print("638nm laser textbox not set")
else:
print("Config file does not exist")
getConfig()
def btnstate(self):
if self.pushButton.isChecked():
self.pushButton_9.clicked.connect(self.printValue)
self.pushButton_10.clicked.connect(self.printValue2)
self.pushButton_11.clicked.connect(self.printValue3)
self.pushButton_12.clicked.connect(self.printValue4)
self.pushButton_13.clicked.connect(self.printValue5)
self.pushButton_14.clicked.connect(self.printValue6)
def printValue(self):
if not os.path.exists("laser.ini"):
......@@ -391,7 +275,7 @@ class Ui_Laser(object):
config.set("445nm", "intensity", textboxValue)
config.set("Subscriptions", "445nm", "microscope/light_sheet_microscope/UI/laser/445nm")
config.write(f)
def printValue2(self):
if not os.path.exists("laser.ini"):
textboxValue2 = self.lineEdit.text()
......@@ -399,7 +283,7 @@ class Ui_Laser(object):
self.verticalSlider_2.setValue(0)
else:
self.verticalSlider_2.setValue(int(textboxValue2))
client = device()
client.run()
......@@ -586,7 +470,7 @@ class Ui_Laser(object):
self.verticalSlider_5.setValue(0)
else:
self.verticalSlider_5.setValue(int(textboxValue5))
client = device()
client.run()
......@@ -648,7 +532,7 @@ class Ui_Laser(object):
self.verticalSlider_6.setValue(0)
else:
self.verticalSlider_6.setValue(int(textboxValue6))
client = device()
client.run()
......@@ -701,7 +585,132 @@ class Ui_Laser(object):
config.add_section("638nm")
config.set("638nm", "intensity", textboxValue6)
config.set("Subscriptions", "638nm", "microscope/light_sheet_microscope/UI/laser/638nm")
config.write(f)
config.write(f)
def retranslateUi(self, Laser):
_translate = QtCore.QCoreApplication.translate
Laser.setWindowTitle(_translate("Laser", "MainWindow"))
self.label_9.setText(_translate("Laser", "0"))
self.label_4.setText(_translate("Laser", "561nm"))
self.label_3.setText(_translate("Laser", "515nm"))
self.pushButton_9.setText(_translate("Laser", "Button"))
self.label_6.setText(_translate("Laser", "638nm"))
self.label_18.setText(_translate("Laser", "100"))
self.label_13.setText(_translate("Laser", "0"))
self.label.setText(_translate("Laser", "445nm"))
self.pushButton_10.setText(_translate("Laser", "Button"))
self.label_17.setText(_translate("Laser", "0"))
self.pushButton_15.setText(_translate("Laser", "Button"))
self.label_14.setText(_translate("Laser", "100"))
self.label_5.setText(_translate("Laser", "594nm"))
self.pushButton_4.setText(_translate("Laser", "ON"))
self.pushButton_5.setText(_translate("Laser", "ON"))
self.label_16.setText(_translate("Laser", "100"))
self.pushButton_11.setText(_translate("Laser", "Button"))
self.pushButton_14.setText(_translate("Laser", "Button"))
self.label_19.setText(_translate("Laser", "0"))
self.label_7.setText(_translate("Laser", "LED"))
self.pushButton_7.setText(_translate("Laser", "ON"))
self.label_20.setText(_translate("Laser", "0"))
self.pushButton.setText(_translate("Laser", "ON"))
self.label_2.setText(_translate("Laser", "488nm"))
self.pushButton_3.setText(_translate("Laser", "ON"))
self.label_15.setText(_translate("Laser", "0"))
self.label_21.setText(_translate("Laser", "100"))
self.pushButton_12.setText(_translate("Laser", "Button"))
self.pushButton_2.setText(_translate("Laser", "ON"))
self.pushButton_13.setText(_translate("Laser", "Button"))
self.pushButton_6.setText(_translate("Laser", "ON"))
self.label_10.setText(_translate("Laser", "0"))
self.label_12.setText(_translate("Laser", "100"))
self.pushButton_8.setText(_translate("Laser", "ON"))
self.label_8.setText(_translate("Laser", "100"))
self.label_11.setText(_translate("Laser", "100"))
def getConfig():
if os.path.exists("laser.ini"):
config = configparser.RawConfigParser()
config.read("laser.ini")
try:
self.verticalSlider.setValue(config.getint("445nm", "intensity"))
print("455nm laser set")
self.pushButton.setChecked(True)
except Exception as e:
print("455nm laser not set")
try:
self.lineEdit.setText(str(config.getint("445nm", "intensity")))
print("455nm laser textbox set")
except Exception as e:
print("455nm laser textbox not set")
try:
self.verticalSlider_2.setValue(config.getint("488nm", "intensity"))
print("488nm laser set")
self.pushButton_2.setChecked(True)
except Exception as e:
print("488nm laser not set")
try:
self.lineEdit_2.setText(str(config.getint("488nm", "intensity")))
print("488nm laser textbox set")
except Exception as e:
print("488nm laser textbox not set")
try:
self.verticalSlider_3.setValue(config.getint("515nm", "intensity"))
print("515nm laser set")
self.pushButton_3.setChecked(True)
except Exception as e:
print("515nm laser not set")
try:
self.lineEdit_3.setText(str(config.getint("515nm", "intensity")))
print("515nm laser textbox set")
except Exception as e:
print("515nm laser textbox not set")
try:
self.verticalSlider_4.setValue(config.getint("561nm", "intensity"))
print("561nm laser set")
self.pushButton_4.setChecked(True)
except Exception as e:
print("561nm laser not set")
try:
self.lineEdit_4.setText(str(config.getint("561nm", "intensity")))
print("561nm laser textbox set")
except Exception as e:
print("561nm laser textbox not set")
try:
self.verticalSlider_5.setValue(config.getint("594nm", "intensity"))
print("594nm laser set")
self.pushButton_5.setChecked(True)
except Exception as e:
print("594nm laser not set")
try:
self.lineEdit_5.setText(str(config.getint("594nm", "intensity")))
print("594nm laser textbox set")
except Exception as e:
print("594nm laser textbox not set")
try:
self.verticalSlider_6.setValue(config.getint("638nm", "intensity"))
print("638nm laser set")
self.pushButton_6.setChecked(True)
except Exception as e:
print("638nm laser not set")
try:
self.lineEdit_6.setText(str(config.getint("638nm", "intensity")))
print("638nm laser textbox set")
except Exception as e:
print("638nm laser textbox not set")
else:
print("Config file does not exist")
getConfig()
# def printValue7(self):
# textboxValue7 = self.lineEdit_7.text()
......
laser
laser
laser
laser
laser
laser
laser
laser
laser
laser
laser
cameras
laser
cameras
laser
cameras
laser
cameras
laser
cameras
laser
cameras
laser
cameras
laser
cameras
laser
cameras
laser
cameras
laser
cameras
laser
cameras
laser
cameras
laser
cameras
laser
cameras
laser
cameras
laser
cameras
laser
cameras
laser
cameras
laser
cameras
laser
cameras
laser
cameras
laser
cameras
laser
cameras
laser
cameras
laser
cameras
laser
cameras
laser
cameras
laser
cameras
Real Iris virginica 0.110 0.365 0.600 0.978
Fake Iris versicolor 0.418 0.606 0.927 0.121
Real Iris setosa 0.773 0.286 0.802 0.937
Fake Iris virginica 0.411 0.824 0.871 0.371
Fake Iris virginica 0.044 0.270 0.089 0.411
Fake Iris versicolor 0.704 0.219 0.372 0.986
Fake Iris virginica 0.351 0.042 0.299 0.312
Fake Iris virginica 0.178 0.454 0.876 0.395
Real Iris virginica 0.369 0.624 0.198 0.464
Fake Iris setosa 0.956 0.482 0.406 0.211
Fake Iris setosa 0.548 0.738 0.478 0.053
Fake Iris versicolor 0.632 0.504 0.075 0.051
Fake Iris setosa 0.693 0.641 0.515 0.095
Fake Iris versicolor 0.785 0.113 0.926 0.809
Real Iris versicolor 0.969 0.356 0.658 0.271
Real Iris virginica 0.001 0.561 0.372 0.801
Real Iris virginica 0.281 0.284 0.260 0.257
Real Iris setosa 0.935 0.760 0.078 0.640
Fake Iris virginica 0.744 0.374 0.761 0.534
Fake Iris versicolor 0.219 0.985 0.036 0.727
import sys
from PyQt5 import QtCore, QtWidgets
from PyQt5.QtWidgets import QMainWindow, QWidget, QPushButton, QAction
from PyQt5.QtCore import QSize
from PyQt5.QtGui import QIcon
class MainWindow(QMainWindow):
def __init__(self):
QMainWindow.__init__(self)
self.setMinimumSize(QSize(300, 100))
self.setWindowTitle("PyQt menu example - pythonprogramminglanguage.com")
# Add button widget
pybutton = QPushButton('Pyqt', self)
pybutton.clicked.connect(self.clickMethod)
pybutton.resize(100,32)
pybutton.move(130, 30)
pybutton.setToolTip('This is a tooltip message.')
# Create new action
newAction = QAction(QIcon('new.png'), '&New', self)
newAction.setShortcut('Ctrl+N')
newAction.setStatusTip('New document')
newAction.triggered.connect(self.newCall)
# Create new action
openAction = QAction(QIcon('open.png'), '&Open', self)
openAction.setShortcut('Ctrl+O')
openAction.setStatusTip('Open document')
openAction.triggered.connect(self.openCall)
# Create exit action
exitAction = QAction(QIcon('exit.png'), '&Exit', self)
exitAction.setShortcut('Ctrl+Q')
exitAction.setStatusTip('Exit application')
exitAction.triggered.connect(self.exitCall)
# Create menu bar and add action
menuBar = self.menuBar()
fileMenu = menuBar.addMenu('&File')
fileMenu.addAction(newAction)
fileMenu.addAction(openAction)
fileMenu.addAction(exitAction)
def openCall(self):
print('Open')
def newCall(self):
print('New')
def exitCall(self):
print('Exit app')
def clickMethod(self):
print('PyQt')
if __name__ == "__main__":
app = QtWidgets.QApplication(sys.argv)
mainWin = MainWindow()
mainWin.show()
sys.exit( app.exec_() )
\ No newline at end of file
def calculate_bill_amount(gems_list, price_list, reqd_gems, reqd_quantity):
bill_amount = 0
# this is the portion where I should write my logic
import random
return bill_amount
observations = ['Real', 'Fake']
flowers = ['Iris setosa', 'Iris virginica', 'Iris versicolor']
# List of gems available in the store
gems_list = ["Emerald", "Ivory", "Jasper", "Ruby", "Garnet"]
with open('DB_data.dat', 'w') as f:
for _ in range(20):
observation = random.choice(observations)
flower = random.choice(flowers)
sepal_width = random.random()
sepal_length = random.random()
petal_width = random.random()
petal_length = random.random()
# Price of gems available in the store. gems_list and price_list have one-to-one correspondence
price_list = [1760, 2119, 1599, 3920, 3999]
# List of gems required by the customer
reqd_gems = ["Ivory", "Emerald", "Garnet"]
# Quantity of gems required by the customer. reqd_gems and reqd_quantity have one-to-one correspondence
reqd_quantity = [3, 10, 12]
bill_amount = calculate_bill_amount(gems_list, price_list, reqd_gems, reqd_quantity)
print(bill_amount)
\ No newline at end of file
f.write('{} {} {:.3f} {:.3f} {:.3f} {:.3f}\n'.format(
observation,
flower,
sepal_length,
sepal_width,
petal_length,
petal_width))
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment