Commit 83069059 authored by Spencer Du's avatar Spencer Du

camera ui completed

parent bde722f6
......@@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>381</width>
<width>468</width>
<height>336</height>
</rect>
</property>
......@@ -15,7 +15,7 @@
</property>
<widget class="QWidget" name="centralwidget">
<layout class="QGridLayout" name="gridLayout">
<item row="5" column="2">
<item row="6" column="2">
<widget class="QPushButton" name="pushButton_2">
<property name="font">
<font>
......@@ -27,72 +27,97 @@
</property>
</widget>
</item>
<item row="7" column="3" colspan="2">
<widget class="QLabel" name="label_11">
<property name="text">
<string>Left</string>
</property>
<item row="5" column="1" colspan="2">
<widget class="QComboBox" name="comboBox">
<item>
<property name="text">
<string>Program</string>
</property>
</item>
<item>
<property name="text">
<string>Shutter Priority</string>
</property>
</item>
<item>
<property name="text">
<string>Aperture Priority</string>
</property>
</item>
<item>
<property name="text">
<string>Manual</string>
</property>
</item>
</widget>
</item>
<item row="9" column="0" colspan="2">
<widget class="QPushButton" name="pushButton_8">
<item row="6" column="1">
<widget class="QLineEdit" name="lineEdit_2">
<property name="text">
<string>Reset Crop ROI</string>
<string/>
</property>
</widget>
</item>
<item row="3" column="3">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Link</string>
</property>
<item row="5" column="4" colspan="3">
<widget class="QComboBox" name="comboBox_2">
<item>
<property name="text">
<string>Program</string>
</property>
</item>
<item>
<property name="text">
<string>Shutter Priority</string>
</property>
</item>
<item>
<property name="text">
<string>Aperture Priority</string>
</property>
</item>
<item>
<property name="text">
<string>Manual</string>
</property>
</item>
</widget>
</item>
<item row="4" column="4" colspan="3">
<widget class="QComboBox" name="comboBox_2"/>
<item row="8" column="1">
<widget class="QLineEdit" name="lineEdit_4"/>
</item>
<item row="5" column="3">
<widget class="QCheckBox" name="checkBox_2">
<item row="2" column="8">
<widget class="QPushButton" name="pushButton">
<property name="text">
<string/>
<string>ms</string>
</property>
</widget>
</item>
<item row="7" column="0">
<widget class="QLabel" name="label_9">
<property name="text">
<string>Top</string>
<item row="6" column="6" colspan="2">
<widget class="QPushButton" name="pushButton_3">
<property name="font">
<font>
<pointsize>6</pointsize>
</font>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QComboBox" name="comboBox_3"/>
</item>
<item row="2" column="0" colspan="2">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Delay</string>
<string>px</string>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QLabel" name="label_8">
<item row="9" column="7">
<widget class="QPushButton" name="pushButton_7">
<property name="font">
<font>
<pointsize>6</pointsize>
</font>
</property>
<property name="text">
<string>Crop ROI</string>
<string>px</string>
</property>
</widget>
</item>
<item row="4" column="1" colspan="2">
<widget class="QComboBox" name="comboBox"/>
</item>
<item row="5" column="4" colspan="2">
<widget class="QComboBox" name="comboBox_4"/>
</item>
<item row="7" column="1">
<widget class="QComboBox" name="comboBox_5"/>
</item>
<item row="8" column="2">
<widget class="QPushButton" name="pushButton_5">
<widget class="QPushButton" name="pushButton_4">
<property name="font">
<font>
<pointsize>6</pointsize>
......@@ -103,51 +128,38 @@
</property>
</widget>
</item>
<item row="8" column="0">
<widget class="QLabel" name="label_10">
<property name="text">
<string>Width</string>
</property>
</widget>
<item row="6" column="4" colspan="2">
<widget class="QLineEdit" name="lineEdit_3"/>
</item>
<item row="5" column="0">
<item row="6" column="0">
<widget class="QLabel" name="label_7">
<property name="text">
<string>Lines</string>
</property>
</widget>
</item>
<item row="0" column="0" colspan="2">
<widget class="QLabel" name="label">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<item row="9" column="0">
<widget class="QLabel" name="label_10">
<property name="text">
<string>Exposure Time</string>
<string>Width</string>
</property>
</widget>
</item>
<item row="1" column="0" colspan="5">
<widget class="QSlider" name="horizontalSlider">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<item row="5" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Mode</string>
</property>
</widget>
</item>
<item row="7" column="5" colspan="2">
<widget class="QComboBox" name="comboBox_7"/>
</item>
<item row="8" column="3" colspan="2">
<item row="9" column="3" colspan="2">
<widget class="QLabel" name="label_12">
<property name="text">
<string>Height</string>
</property>
</widget>
</item>
<item row="7" column="7">
<item row="8" column="7">
<widget class="QPushButton" name="pushButton_6">
<property name="font">
<font>
......@@ -159,47 +171,56 @@
</property>
</widget>
</item>
<item row="8" column="1">
<widget class="QComboBox" name="comboBox_6"/>
</item>
<item row="1" column="5" colspan="3">
<widget class="QLineEdit" name="lineEdit"/>
<item row="4" column="1">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Right</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_3">
<item row="4" column="4" colspan="2">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Mode</string>
<string>Left</string>
</property>
</widget>
</item>
<item row="5" column="6" colspan="2">
<widget class="QPushButton" name="pushButton_3">
<property name="font">
<font>
<pointsize>6</pointsize>
</font>
<item row="1" column="0" colspan="2">
<widget class="QLabel" name="label">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>px</string>
<string>Exposure Time</string>
</property>
</widget>
</item>
<item row="3" column="4" colspan="2">
<widget class="QLabel" name="label_6">
<item row="8" column="3" colspan="2">
<widget class="QLabel" name="label_11">
<property name="text">
<string>Left</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLabel" name="label_4">
<item row="10" column="0" colspan="2">
<widget class="QPushButton" name="pushButton_8">
<property name="text">
<string>Right</string>
<string>Reset Crop ROI</string>
</property>
</widget>
</item>
<item row="8" column="7">
<widget class="QPushButton" name="pushButton_7">
<item row="8" column="0">
<widget class="QLabel" name="label_9">
<property name="text">
<string>Top</string>
</property>
</widget>
</item>
<item row="9" column="2">
<widget class="QPushButton" name="pushButton_5">
<property name="font">
<font>
<pointsize>6</pointsize>
......@@ -210,35 +231,62 @@
</property>
</widget>
</item>
<item row="8" column="5" colspan="2">
<widget class="QComboBox" name="comboBox_8"/>
</item>
<item row="4" column="3">
<widget class="QCheckBox" name="checkBox">
<item row="3" column="0" colspan="2">
<widget class="QLabel" name="label_2">
<property name="text">
<string/>
<string>Delay</string>
</property>
</widget>
</item>
<item row="7" column="2">
<widget class="QPushButton" name="pushButton_4">
<property name="font">
<font>
<pointsize>6</pointsize>
</font>
</property>
<item row="7" column="1">
<widget class="QLabel" name="label_8">
<property name="text">
<string>px</string>
<string>Crop ROI</string>
</property>
</widget>
</item>
<item row="1" column="8">
<widget class="QPushButton" name="pushButton">
<item row="3" column="6" colspan="2">
<widget class="QLineEdit" name="lineEdit_8"/>
</item>
<item row="3" column="8">
<widget class="QPushButton" name="pushButton_9">
<property name="text">
<string>ms</string>
</property>
</widget>
</item>
<item row="9" column="1">
<widget class="QLineEdit" name="lineEdit_5"/>
</item>
<item row="8" column="5">
<widget class="QLineEdit" name="lineEdit_6"/>
</item>
<item row="9" column="5">
<widget class="QLineEdit" name="lineEdit_7"/>
</item>
<item row="2" column="6" colspan="2">
<widget class="QLineEdit" name="lineEdit"/>
</item>
<item row="2" column="0" colspan="6">
<widget class="QSlider" name="horizontalSlider">
<property name="maximum">
<number>5000</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QPushButton" name="pushButton_10">
<property name="text">
<string>ON</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QStatusBar" name="statusbar"/>
......
This diff is collapsed.
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'cameras.ui'
#
# Created by: PyQt5 UI code generator 5.13.2
#
# WARNING! All changes made in this file will be lost!
from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5.QtCore import Qt
import os
import configparser
import time
import json
from mqtt import *
class Ui_MainWindow(object):
def setupUi(self, MainWindow):
MainWindow.setObjectName("MainWindow")
MainWindow.resize(468, 336)
self.centralwidget = QtWidgets.QWidget(MainWindow)
self.centralwidget.setObjectName("centralwidget")
self.gridLayout = QtWidgets.QGridLayout(self.centralwidget)
self.gridLayout.setObjectName("gridLayout")
self.label = QtWidgets.QLabel(self.centralwidget)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.MinimumExpanding, QtWidgets.QSizePolicy.Fixed)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.label.sizePolicy().hasHeightForWidth())
self.label.setSizePolicy(sizePolicy)
self.label.setObjectName("label")
self.gridLayout.addWidget(self.label, 0, 0, 1, 2)
self.label_11 = QtWidgets.QLabel(self.centralwidget)
self.label_11.setObjectName("label_11")
self.gridLayout.addWidget(self.label_11, 7, 3, 1, 2)
self.pushButton_8 = QtWidgets.QPushButton(self.centralwidget)
self.pushButton_8.setObjectName("pushButton_8")
self.gridLayout.addWidget(self.pushButton_8, 9, 0, 1, 2)
self.label_5 = QtWidgets.QLabel(self.centralwidget)
self.label_5.setObjectName("label_5")
self.gridLayout.addWidget(self.label_5, 3, 3, 1, 1)
self.label_9 = QtWidgets.QLabel(self.centralwidget)
self.label_9.setObjectName("label_9")
self.gridLayout.addWidget(self.label_9, 7, 0, 1, 1)
self.pushButton_5 = QtWidgets.QPushButton(self.centralwidget)
font = QtGui.QFont()
font.setPointSize(6)
self.pushButton_5.setFont(font)
self.pushButton_5.setObjectName("pushButton_5")
self.gridLayout.addWidget(self.pushButton_5, 8, 2, 1, 1)
self.label_2 = QtWidgets.QLabel(self.centralwidget)
self.label_2.setObjectName("label_2")
self.gridLayout.addWidget(self.label_2, 2, 0, 1, 2)
self.label_8 = QtWidgets.QLabel(self.centralwidget)
self.label_8.setObjectName("label_8")
self.gridLayout.addWidget(self.label_8, 6, 1, 1, 1)
self.label_7 = QtWidgets.QLabel(self.centralwidget)
self.label_7.setObjectName("label_7")
self.gridLayout.addWidget(self.label_7, 5, 0, 1, 1)
self.label_10 = QtWidgets.QLabel(self.centralwidget)
self.label_10.setObjectName("label_10")
self.gridLayout.addWidget(self.label_10, 8, 0, 1, 1)
self.label_3 = QtWidgets.QLabel(self.centralwidget)
self.label_3.setObjectName("label_3")
self.gridLayout.addWidget(self.label_3, 4, 0, 1, 1)
self.label_12 = QtWidgets.QLabel(self.centralwidget)
self.label_12.setObjectName("label_12")
self.gridLayout.addWidget(self.label_12, 8, 3, 1, 2)
self.pushButton_6 = QtWidgets.QPushButton(self.centralwidget)
font = QtGui.QFont()
font.setPointSize(6)
self.pushButton_6.setFont(font)
self.pushButton_6.setObjectName("pushButton_6")
self.gridLayout.addWidget(self.pushButton_6, 7, 7, 1, 1)
self.label_4 = QtWidgets.QLabel(self.centralwidget)
self.label_4.setObjectName("label_4")
self.gridLayout.addWidget(self.label_4, 3, 1, 1, 1)
self.label_6 = QtWidgets.QLabel(self.centralwidget)
self.label_6.setObjectName("label_6")
self.gridLayout.addWidget(self.label_6, 3, 4, 1, 2)
self.pushButton_7 = QtWidgets.QPushButton(self.centralwidget)
font = QtGui.QFont()
font.setPointSize(6)
self.pushButton_7.setFont(font)
self.pushButton_7.setObjectName("pushButton_7")
self.gridLayout.addWidget(self.pushButton_7, 8, 7, 1, 1)
self.pushButton_4 = QtWidgets.QPushButton(self.centralwidget)
font = QtGui.QFont()
font.setPointSize(6)
self.pushButton_4.setFont(font)
self.pushButton_4.setObjectName("pushButton_4")
self.gridLayout.addWidget(self.pushButton_4, 7, 2, 1, 1)
self.pushButton = QtWidgets.QPushButton(self.centralwidget)
self.pushButton.setObjectName("pushButton")
self.gridLayout.addWidget(self.pushButton, 1, 8, 1, 1)
self.pushButton_3 = QtWidgets.QPushButton(self.centralwidget)
font = QtGui.QFont()
font.setPointSize(6)
self.pushButton_3.setFont(font)
self.pushButton_3.setObjectName("pushButton_3")
self.gridLayout.addWidget(self.pushButton_3, 5, 6, 1, 2)
self.checkBox_2 = QtWidgets.QCheckBox(self.centralwidget)
self.checkBox_2.setText("")
self.checkBox_2.setObjectName("checkBox_2")
self.gridLayout.addWidget(self.checkBox_2, 5, 3, 1, 1)
self.checkBox = QtWidgets.QCheckBox(self.centralwidget)
self.checkBox.setText("")
self.checkBox.setObjectName("checkBox")
self.gridLayout.addWidget(self.checkBox, 4, 3, 1, 1)
self.checkBox.clicked.connect(self.checkBoxChangedAction)
self.comboBox_2 = QtWidgets.QComboBox(self.centralwidget)
self.comboBox_2.setObjectName("comboBox_2")
self.comboBox_2.addItem("")
self.comboBox_2.addItem("")
self.comboBox_2.addItem("")
self.comboBox_2.addItem("")
self.gridLayout.addWidget(self.comboBox_2, 4, 4, 1, 3)
self.comboBox = QtWidgets.QComboBox(self.centralwidget)
self.comboBox.setObjectName("comboBox")
self.comboBox.addItem("")
self.comboBox.addItem("")
self.comboBox.addItem("")
self.comboBox.addItem("")
self.gridLayout.addWidget(self.comboBox, 4, 1, 1, 2)
self.pushButton_2 = QtWidgets.QPushButton(self.centralwidget)
font = QtGui.QFont()
font.setPointSize(6)
self.pushButton_2.setFont(font)
self.pushButton_2.setObjectName("pushButton_2")
self.gridLayout.addWidget(self.pushButton_2, 5, 2, 1, 1)
self.lineEdit_2 = QtWidgets.QLineEdit(self.centralwidget)
self.lineEdit_2.setText("")
self.lineEdit_2.setObjectName("lineEdit_2")
self.gridLayout.addWidget(self.lineEdit_2, 5, 1, 1, 1)
self.lineEdit_2.returnPressed.connect(self.leftLines)
self.lineEdit_3 = QtWidgets.QLineEdit(self.centralwidget)
self.lineEdit_3.setObjectName("lineEdit_3")
self.gridLayout.addWidget(self.lineEdit_3, 5, 4, 1, 2)
self.lineEdit_3.returnPressed.connect(self.rightLines)
self.lineEdit_4 = QtWidgets.QLineEdit(self.centralwidget)
self.lineEdit_4.setObjectName("lineEdit_4")
self.gridLayout.addWidget(self.lineEdit_4, 7, 1, 1, 1)
self.lineEdit_5 = QtWidgets.QLineEdit(self.centralwidget)
self.lineEdit_5.setObjectName("lineEdit_5")
self.gridLayout.addWidget(self.lineEdit_5, 8, 1, 1, 1)
self.lineEdit_6 = QtWidgets.QLineEdit(self.centralwidget)
self.lineEdit_6.setObjectName("lineEdit_6")
self.gridLayout.addWidget(self.lineEdit_6, 7, 5, 1, 1)
self.lineEdit_7 = QtWidgets.QLineEdit(self.centralwidget)
self.lineEdit_7.setObjectName("lineEdit_7")
self.gridLayout.addWidget(self.lineEdit_7, 8, 5, 1, 1)
self.pushButton_9 = QtWidgets.QPushButton(self.centralwidget)
self.pushButton_9.setObjectName("pushButton_9")
self.gridLayout.addWidget(self.pushButton_9, 2, 8, 1, 1)
self.lineEdit_8 = QtWidgets.QLineEdit(self.centralwidget)
self.lineEdit_8.setObjectName("lineEdit_8")
self.gridLayout.addWidget(self.lineEdit_8, 2, 6, 1, 2)
self.lineEdit = QtWidgets.QLineEdit(self.centralwidget)
self.lineEdit.returnPressed.connect(self.exposureTime)
self.lineEdit.setObjectName("lineEdit")
self.gridLayout.addWidget(self.lineEdit, 1, 6, 1, 2)
self.horizontalSlider = QtWidgets.QSlider(self.centralwidget)
self.horizontalSlider.setMaximum(5000)
self.horizontalSlider.setOrientation(QtCore.Qt.Horizontal)
self.horizontalSlider.setObjectName("horizontalSlider")
self.gridLayout.addWidget(self.horizontalSlider, 1, 0, 1, 6)
MainWindow.setCentralWidget(self.centralwidget)
self.statusbar = QtWidgets.QStatusBar(MainWindow)
self.statusbar.setObjectName("statusbar")
MainWindow.setStatusBar(self.statusbar)
self.retranslateUi(MainWindow)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
def exposureTime(self):
if not os.path.exists("cameras.ini"):
textboxValue = self.lineEdit.text()
if self.lineEdit.text() == "":
self.horizontalSlider.setValue(0)
else:
self.horizontalSlider.setValue(int(textboxValue))
client = device()
client.run()
client.loop_start()
print("\n" + "Connected to broker")
time.sleep(1)
print("Subscribing to topic", "microscope/light_sheet_microscope/UI/cameras")
client.subscribe("microscope/light_sheet_microscope/UI/cameras")
print("Publishing message to topic", "microscope/light_sheet_microscope/UI/cameras")
client.publish("microscope/light_sheet_microscope/UI/cameras", json.dumps({"type": "device", "payload":{"name": "cameras", "cmd": "set exposure time of cameras"}}, indent=2))
time.sleep(1)
client.loop_stop()
print("Exposure time: " + textboxValue + "ms")
config = configparser.RawConfigParser()
f = open("cameras.ini", "w")
config.add_section("Exposure time")
config.set("Exposure time", "Time", textboxValue + "ms")
config.write(f)
else:
textboxValue = self.lineEdit.text()
if self.lineEdit.text() == "":
self.horizontalSlider.setValue(0)
else:
self.horizontalSlider.setValue(int(textboxValue))
client = device()
client.run()
client.loop_start()
print("\n" + "Connected to broker")
time.sleep(1)
print("Subscribing to topic", "microscope/light_sheet_microscope/UI/cameras")
client.subscribe("microscope/light_sheet_microscope/UI/cameras")
print("Publishing message to topic", "microscope/light_sheet_microscope/UI/cameras")
client.publish("microscope/light_sheet_microscope/UI/cameras", json.dumps({"type": "device", "payload":{"name": "cameras", "cmd": "set exposure time of cameras"}}, indent=2))
time.sleep(1)
client.loop_stop()
print("Exposure time: " + textboxValue + "ms")
config = configparser.RawConfigParser()
f = open("cameras.ini", "w")
try:
config.add_section("Exposure time")
except Exception as e: