Skip to content
Snippets Groups Projects
Commit 17effe5c authored by Harrison Edwards's avatar Harrison Edwards
Browse files

added laser/attenuator functionality

parent 9bd5a51d
Branches
No related merge requests found
......@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>733</width>
<height>621</height>
<width>1000</width>
<height>689</height>
</rect>
</property>
<property name="focusPolicy">
......@@ -17,17 +17,6 @@
<string>LCL System</string>
</property>
<widget class="QWidget" name="centralwidget">
<widget class="QWidget" name="verticalLayoutWidget">
<property name="geometry">
<rect>
<x>100</x>
<y>0</y>
<width>621</width>
<height>481</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout"/>
</widget>
<widget class="QPushButton" name="pushButton">
<property name="geometry">
<rect>
......@@ -44,10 +33,10 @@
<widget class="QPushButton" name="target_screenshot_button">
<property name="geometry">
<rect>
<x>10</x>
<y>10</y>
<width>81</width>
<height>61</height>
<x>3</x>
<y>3</y>
<width>71</width>
<height>31</height>
</rect>
</property>
<property name="focusPolicy">
......@@ -61,10 +50,10 @@
<widget class="QPushButton" name="non_target_screenshot_button">
<property name="geometry">
<rect>
<x>10</x>
<y>70</y>
<width>81</width>
<height>61</height>
<x>73</x>
<y>3</y>
<width>71</width>
<height>31</height>
</rect>
</property>
<property name="focusPolicy">
......@@ -78,26 +67,26 @@
<widget class="QPushButton" name="misc_screenshot_button">
<property name="geometry">
<rect>
<x>10</x>
<y>130</y>
<width>81</width>
<height>61</height>
<x>3</x>
<y>33</y>
<width>71</width>
<height>31</height>
</rect>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="text">
<string>Miscellaneous
<string>Misc.
Screenshot</string>
</property>
</widget>
<widget class="QTextEdit" name="comment_box">
<property name="geometry">
<rect>
<x>310</x>
<y>510</y>
<width>161</width>
<x>4</x>
<y>83</y>
<width>131</width>
<height>41</height>
</rect>
</property>
......@@ -105,10 +94,10 @@
<widget class="QGroupBox" name="groupBox">
<property name="geometry">
<rect>
<x>490</x>
<y>490</y>
<width>231</width>
<height>121</height>
<x>7</x>
<y>330</y>
<width>131</width>
<height>191</height>
</rect>
</property>
<property name="title">
......@@ -117,9 +106,9 @@
<widget class="QPushButton" name="down_button">
<property name="geometry">
<rect>
<x>40</x>
<x>38</x>
<y>60</y>
<width>90</width>
<width>51</width>
<height>23</height>
</rect>
</property>
......@@ -133,9 +122,9 @@
<widget class="QPushButton" name="right_button">
<property name="geometry">
<rect>
<x>80</x>
<x>59</x>
<y>40</y>
<width>75</width>
<width>51</width>
<height>23</height>
</rect>
</property>
......@@ -149,9 +138,9 @@
<widget class="QPushButton" name="up_button">
<property name="geometry">
<rect>
<x>40</x>
<x>37</x>
<y>20</y>
<width>90</width>
<width>51</width>
<height>23</height>
</rect>
</property>
......@@ -165,9 +154,9 @@
<widget class="QPushButton" name="left_button">
<property name="geometry">
<rect>
<x>10</x>
<x>13</x>
<y>40</y>
<width>75</width>
<width>51</width>
<height>23</height>
</rect>
</property>
......@@ -181,8 +170,8 @@
<widget class="QPushButton" name="home_stage_button">
<property name="geometry">
<rect>
<x>7</x>
<y>90</y>
<x>25</x>
<y>84</y>
<width>75</width>
<height>23</height>
</rect>
......@@ -197,8 +186,8 @@
<widget class="QPushButton" name="get_position_button">
<property name="geometry">
<rect>
<x>87</x>
<y>90</y>
<x>25</x>
<y>104</y>
<width>75</width>
<height>23</height>
</rect>
......@@ -213,8 +202,8 @@
<widget class="QDoubleSpinBox" name="step_size_doublespin_box">
<property name="geometry">
<rect>
<x>160</x>
<y>60</y>
<x>29</x>
<y>150</y>
<width>62</width>
<height>22</height>
</rect>
......@@ -241,8 +230,8 @@
<widget class="QLabel" name="step_size_label">
<property name="geometry">
<rect>
<x>170</x>
<y>40</y>
<x>29</x>
<y>130</y>
<width>47</width>
<height>13</height>
</rect>
......@@ -255,8 +244,8 @@
<widget class="QLabel" name="comment_box_label">
<property name="geometry">
<rect>
<x>310</x>
<y>490</y>
<x>6</x>
<y>63</y>
<width>71</width>
<height>16</height>
</rect>
......@@ -268,9 +257,9 @@
<widget class="QPushButton" name="user_comment_button">
<property name="geometry">
<rect>
<x>310</x>
<y>560</y>
<width>161</width>
<x>3</x>
<y>123</y>
<width>131</width>
<height>23</height>
</rect>
</property>
......@@ -285,8 +274,8 @@
<property name="geometry">
<rect>
<x>10</x>
<y>230</y>
<width>81</width>
<y>170</y>
<width>61</width>
<height>22</height>
</rect>
</property>
......@@ -303,8 +292,8 @@
<widget class="QLabel" name="magnification_label">
<property name="geometry">
<rect>
<x>10</x>
<y>210</y>
<x>9</x>
<y>150</y>
<width>71</width>
<height>16</height>
</rect>
......@@ -316,10 +305,10 @@
<widget class="QGroupBox" name="calibration_groupbox">
<property name="geometry">
<rect>
<x>130</x>
<y>500</y>
<width>161</width>
<height>71</height>
<x>7</x>
<y>230</y>
<width>131</width>
<height>91</height>
</rect>
</property>
<property name="title">
......@@ -328,9 +317,9 @@
<widget class="QPushButton" name="upper_left_calibration_button">
<property name="geometry">
<rect>
<x>8</x>
<x>27</x>
<y>20</y>
<width>75</width>
<width>70</width>
<height>23</height>
</rect>
</property>
......@@ -341,9 +330,9 @@
<widget class="QPushButton" name="bottom_left_calibration_button">
<property name="geometry">
<rect>
<x>8</x>
<x>27</x>
<y>40</y>
<width>75</width>
<width>70</width>
<height>23</height>
</rect>
</property>
......@@ -354,9 +343,9 @@
<widget class="QPushButton" name="bottom_right_calibration_button">
<property name="geometry">
<rect>
<x>80</x>
<y>40</y>
<width>75</width>
<x>27</x>
<y>60</y>
<width>70</width>
<height>23</height>
</rect>
</property>
......@@ -369,7 +358,7 @@
<property name="geometry">
<rect>
<x>10</x>
<y>270</y>
<y>200</y>
<width>75</width>
<height>23</height>
</rect>
......@@ -378,6 +367,69 @@
<string>Load Image</string>
</property>
</widget>
<widget class="QWidget" name="verticalLayoutWidget">
<property name="geometry">
<rect>
<x>145</x>
<y>3</y>
<width>851</width>
<height>681</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout"/>
</widget>
<widget class="QGroupBox" name="laser_controls_groupbox">
<property name="geometry">
<rect>
<x>10</x>
<y>520</y>
<width>120</width>
<height>151</height>
</rect>
</property>
<property name="title">
<string>Laser Controls</string>
</property>
<widget class="QPushButton" name="start_flashlamp_pushbutton">
<property name="geometry">
<rect>
<x>10</x>
<y>20</y>
<width>101</width>
<height>23</height>
</rect>
</property>
<property name="text">
<string>Flash Lamp Auto</string>
</property>
</widget>
<widget class="QPushButton" name="stop_flashlamp_pushbutton">
<property name="geometry">
<rect>
<x>10</x>
<y>50</y>
<width>101</width>
<height>23</height>
</rect>
</property>
<property name="text">
<string>Flash Lamp Off</string>
</property>
</widget>
<widget class="QPushButton" name="fire_qswitch_pushbutton">
<property name="geometry">
<rect>
<x>10</x>
<y>80</y>
<width>101</width>
<height>23</height>
</rect>
</property>
<property name="text">
<string>Fire Q-Switch</string>
</property>
</widget>
</widget>
</widget>
</widget>
<resources/>
......
......@@ -9,6 +9,7 @@ from PyQt5 import QtGui
from utils import screen_shooter,now,comment
from stage_controller import stage_controller
from image_movement_controller import image_based_movement_controller
from laser_controller import laser_controller, attenuator_controller
class ShowVideo(QtCore.QObject):
camera_port = 1
......@@ -24,8 +25,8 @@ class ShowVideo(QtCore.QObject):
@QtCore.pyqtSlot()
def startVideo(self):
comment('video properties:')
self.camera.set(3,2048)
self.camera.set(4,1644)
self.camera.set(3,1024)
self.camera.set(4,822)
self.camera.set(15,52.131)
for i in range(19):
comment('property {}, value: {}'.format(i,
......@@ -34,7 +35,7 @@ class ShowVideo(QtCore.QObject):
ret, image = self.camera.read()
image = cv2.cvtColor(image,cv2.COLOR_RGB2BGR)
self.screenshot_signal.emit(image)
radius = 100
radius = 50
y = int(image.shape[0]/2)
x = int(image.shape[1]/2)
cv2.line(image,(x-radius,y),(x+radius,y),(255,0,0),2)
......@@ -116,6 +117,10 @@ class main_window(QMainWindow):
self.ui.load_image_pushbutton.clicked.connect(image_move_controller.show_file_dialog)
self.ui.start_flashlamp_pushbutton.clicked.connect(laser.fire_auto)
self.ui.stop_flashlamp_pushbutton.clicked.connect(laser.simmer)
self.ui.fire_qswitch_pushbutton.clicked.connect(laser.fire_qswitch)
self.show()
comment('finished init')
......@@ -145,6 +150,8 @@ if __name__ == '__main__':
app = QApplication(sys.argv)
stage = stage_controller()
image_move_controller = image_based_movement_controller()
attenuator = attenuator_controller()
laser = laser_controller()
window = main_window()
window.vid.startVideo()
comment('exit with code: ' + str(app.exec_()))
......
......@@ -11,63 +11,57 @@ from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_MainWindow(object):
def setupUi(self, MainWindow):
MainWindow.setObjectName("MainWindow")
MainWindow.resize(733, 621)
MainWindow.resize(1000, 689)
MainWindow.setFocusPolicy(QtCore.Qt.StrongFocus)
self.centralwidget = QtWidgets.QWidget(MainWindow)
self.centralwidget.setObjectName("centralwidget")
self.verticalLayoutWidget = QtWidgets.QWidget(self.centralwidget)
self.verticalLayoutWidget.setGeometry(QtCore.QRect(100, 0, 621, 481))
self.verticalLayoutWidget.setObjectName("verticalLayoutWidget")
self.verticalLayout = QtWidgets.QVBoxLayout(self.verticalLayoutWidget)
self.verticalLayout.setContentsMargins(0, 0, 0, 0)
self.verticalLayout.setObjectName("verticalLayout")
self.pushButton = QtWidgets.QPushButton(self.centralwidget)
self.pushButton.setGeometry(QtCore.QRect(-90, 200, 75, 23))
self.pushButton.setObjectName("pushButton")
self.target_screenshot_button = QtWidgets.QPushButton(self.centralwidget)
self.target_screenshot_button.setGeometry(QtCore.QRect(10, 10, 81, 61))
self.target_screenshot_button.setGeometry(QtCore.QRect(3, 3, 71, 31))
self.target_screenshot_button.setFocusPolicy(QtCore.Qt.NoFocus)
self.target_screenshot_button.setObjectName("target_screenshot_button")
self.non_target_screenshot_button = QtWidgets.QPushButton(self.centralwidget)
self.non_target_screenshot_button.setGeometry(QtCore.QRect(10, 70, 81, 61))
self.non_target_screenshot_button.setGeometry(QtCore.QRect(73, 3, 71, 31))
self.non_target_screenshot_button.setFocusPolicy(QtCore.Qt.NoFocus)
self.non_target_screenshot_button.setObjectName("non_target_screenshot_button")
self.misc_screenshot_button = QtWidgets.QPushButton(self.centralwidget)
self.misc_screenshot_button.setGeometry(QtCore.QRect(10, 130, 81, 61))
self.misc_screenshot_button.setGeometry(QtCore.QRect(3, 33, 71, 31))
self.misc_screenshot_button.setFocusPolicy(QtCore.Qt.NoFocus)
self.misc_screenshot_button.setObjectName("misc_screenshot_button")
self.comment_box = QtWidgets.QTextEdit(self.centralwidget)
self.comment_box.setGeometry(QtCore.QRect(310, 510, 161, 41))
self.comment_box.setGeometry(QtCore.QRect(4, 83, 131, 41))
self.comment_box.setObjectName("comment_box")
self.groupBox = QtWidgets.QGroupBox(self.centralwidget)
self.groupBox.setGeometry(QtCore.QRect(490, 490, 231, 121))
self.groupBox.setGeometry(QtCore.QRect(7, 330, 131, 191))
self.groupBox.setObjectName("groupBox")
self.down_button = QtWidgets.QPushButton(self.groupBox)
self.down_button.setGeometry(QtCore.QRect(40, 60, 90, 23))
self.down_button.setGeometry(QtCore.QRect(38, 60, 51, 23))
self.down_button.setFocusPolicy(QtCore.Qt.NoFocus)
self.down_button.setObjectName("down_button")
self.right_button = QtWidgets.QPushButton(self.groupBox)
self.right_button.setGeometry(QtCore.QRect(80, 40, 75, 23))
self.right_button.setGeometry(QtCore.QRect(59, 40, 51, 23))
self.right_button.setFocusPolicy(QtCore.Qt.NoFocus)
self.right_button.setObjectName("right_button")
self.up_button = QtWidgets.QPushButton(self.groupBox)
self.up_button.setGeometry(QtCore.QRect(40, 20, 90, 23))
self.up_button.setGeometry(QtCore.QRect(37, 20, 51, 23))
self.up_button.setFocusPolicy(QtCore.Qt.NoFocus)
self.up_button.setObjectName("up_button")
self.left_button = QtWidgets.QPushButton(self.groupBox)
self.left_button.setGeometry(QtCore.QRect(10, 40, 75, 23))
self.left_button.setGeometry(QtCore.QRect(13, 40, 51, 23))
self.left_button.setFocusPolicy(QtCore.Qt.NoFocus)
self.left_button.setObjectName("left_button")
self.home_stage_button = QtWidgets.QPushButton(self.groupBox)
self.home_stage_button.setGeometry(QtCore.QRect(7, 90, 75, 23))
self.home_stage_button.setGeometry(QtCore.QRect(25, 84, 75, 23))
self.home_stage_button.setFocusPolicy(QtCore.Qt.NoFocus)
self.home_stage_button.setObjectName("home_stage_button")
self.get_position_button = QtWidgets.QPushButton(self.groupBox)
self.get_position_button.setGeometry(QtCore.QRect(87, 90, 75, 23))
self.get_position_button.setGeometry(QtCore.QRect(25, 104, 75, 23))
self.get_position_button.setFocusPolicy(QtCore.Qt.NoFocus)
self.get_position_button.setObjectName("get_position_button")
self.step_size_doublespin_box = QtWidgets.QDoubleSpinBox(self.groupBox)
self.step_size_doublespin_box.setGeometry(QtCore.QRect(160, 60, 62, 22))
self.step_size_doublespin_box.setGeometry(QtCore.QRect(29, 150, 62, 22))
self.step_size_doublespin_box.setFocusPolicy(QtCore.Qt.ClickFocus)
self.step_size_doublespin_box.setDecimals(0)
self.step_size_doublespin_box.setMinimum(50.0)
......@@ -76,39 +70,57 @@ class Ui_MainWindow(object):
self.step_size_doublespin_box.setProperty("value", 1000.0)
self.step_size_doublespin_box.setObjectName("step_size_doublespin_box")
self.step_size_label = QtWidgets.QLabel(self.groupBox)
self.step_size_label.setGeometry(QtCore.QRect(170, 40, 47, 13))
self.step_size_label.setGeometry(QtCore.QRect(29, 130, 47, 13))
self.step_size_label.setObjectName("step_size_label")
self.comment_box_label = QtWidgets.QLabel(self.centralwidget)
self.comment_box_label.setGeometry(QtCore.QRect(310, 490, 71, 16))
self.comment_box_label.setGeometry(QtCore.QRect(6, 63, 71, 16))
self.comment_box_label.setObjectName("comment_box_label")
self.user_comment_button = QtWidgets.QPushButton(self.centralwidget)
self.user_comment_button.setGeometry(QtCore.QRect(310, 560, 161, 23))
self.user_comment_button.setGeometry(QtCore.QRect(3, 123, 131, 23))
self.user_comment_button.setFocusPolicy(QtCore.Qt.NoFocus)
self.user_comment_button.setObjectName("user_comment_button")
self.magnification_combobox = QtWidgets.QComboBox(self.centralwidget)
self.magnification_combobox.setGeometry(QtCore.QRect(10, 230, 81, 22))
self.magnification_combobox.setGeometry(QtCore.QRect(10, 170, 61, 22))
self.magnification_combobox.setFocusPolicy(QtCore.Qt.NoFocus)
self.magnification_combobox.setEditable(True)
self.magnification_combobox.setCurrentText("")
self.magnification_combobox.setObjectName("magnification_combobox")
self.magnification_label = QtWidgets.QLabel(self.centralwidget)
self.magnification_label.setGeometry(QtCore.QRect(10, 210, 71, 16))
self.magnification_label.setGeometry(QtCore.QRect(9, 150, 71, 16))
self.magnification_label.setObjectName("magnification_label")
self.calibration_groupbox = QtWidgets.QGroupBox(self.centralwidget)
self.calibration_groupbox.setGeometry(QtCore.QRect(130, 500, 161, 71))
self.calibration_groupbox.setGeometry(QtCore.QRect(7, 230, 131, 91))
self.calibration_groupbox.setObjectName("calibration_groupbox")
self.upper_left_calibration_button = QtWidgets.QPushButton(self.calibration_groupbox)
self.upper_left_calibration_button.setGeometry(QtCore.QRect(8, 20, 75, 23))
self.upper_left_calibration_button.setGeometry(QtCore.QRect(27, 20, 70, 23))
self.upper_left_calibration_button.setObjectName("upper_left_calibration_button")
self.bottom_left_calibration_button = QtWidgets.QPushButton(self.calibration_groupbox)
self.bottom_left_calibration_button.setGeometry(QtCore.QRect(8, 40, 75, 23))
self.bottom_left_calibration_button.setGeometry(QtCore.QRect(27, 40, 70, 23))
self.bottom_left_calibration_button.setObjectName("bottom_left_calibration_button")
self.bottom_right_calibration_button = QtWidgets.QPushButton(self.calibration_groupbox)
self.bottom_right_calibration_button.setGeometry(QtCore.QRect(80, 40, 75, 23))
self.bottom_right_calibration_button.setGeometry(QtCore.QRect(27, 60, 70, 23))
self.bottom_right_calibration_button.setObjectName("bottom_right_calibration_button")
self.load_image_pushbutton = QtWidgets.QPushButton(self.centralwidget)
self.load_image_pushbutton.setGeometry(QtCore.QRect(10, 270, 75, 23))
self.load_image_pushbutton.setGeometry(QtCore.QRect(10, 200, 75, 23))
self.load_image_pushbutton.setObjectName("load_image_pushbutton")
self.verticalLayoutWidget = QtWidgets.QWidget(self.centralwidget)
self.verticalLayoutWidget.setGeometry(QtCore.QRect(145, 3, 851, 681))
self.verticalLayoutWidget.setObjectName("verticalLayoutWidget")
self.verticalLayout = QtWidgets.QVBoxLayout(self.verticalLayoutWidget)
self.verticalLayout.setContentsMargins(0, 0, 0, 0)
self.verticalLayout.setObjectName("verticalLayout")
self.laser_controls_groupbox = QtWidgets.QGroupBox(self.centralwidget)
self.laser_controls_groupbox.setGeometry(QtCore.QRect(10, 520, 120, 151))
self.laser_controls_groupbox.setObjectName("laser_controls_groupbox")
self.start_flashlamp_pushbutton = QtWidgets.QPushButton(self.laser_controls_groupbox)
self.start_flashlamp_pushbutton.setGeometry(QtCore.QRect(10, 20, 101, 23))
self.start_flashlamp_pushbutton.setObjectName("start_flashlamp_pushbutton")
self.stop_flashlamp_pushbutton = QtWidgets.QPushButton(self.laser_controls_groupbox)
self.stop_flashlamp_pushbutton.setGeometry(QtCore.QRect(10, 50, 101, 23))
self.stop_flashlamp_pushbutton.setObjectName("stop_flashlamp_pushbutton")
self.fire_qswitch_pushbutton = QtWidgets.QPushButton(self.laser_controls_groupbox)
self.fire_qswitch_pushbutton.setGeometry(QtCore.QRect(10, 80, 101, 23))
self.fire_qswitch_pushbutton.setObjectName("fire_qswitch_pushbutton")
MainWindow.setCentralWidget(self.centralwidget)
self.retranslateUi(MainWindow)
......@@ -122,7 +134,7 @@ class Ui_MainWindow(object):
" Screenshot"))
self.non_target_screenshot_button.setText(_translate("MainWindow", "Non-Target \n"
" Screenshot"))
self.misc_screenshot_button.setText(_translate("MainWindow", "Miscellaneous \n"
self.misc_screenshot_button.setText(_translate("MainWindow", "Misc. \n"
" Screenshot"))
self.groupBox.setTitle(_translate("MainWindow", "Stage Controls"))
self.down_button.setText(_translate("MainWindow", "Down"))
......@@ -140,6 +152,10 @@ class Ui_MainWindow(object):
self.bottom_left_calibration_button.setText(_translate("MainWindow", "Bottom Left"))
self.bottom_right_calibration_button.setText(_translate("MainWindow", "Bottom Right"))
self.load_image_pushbutton.setText(_translate("MainWindow", "Load Image"))
self.laser_controls_groupbox.setTitle(_translate("MainWindow", "Laser Controls"))
self.start_flashlamp_pushbutton.setText(_translate("MainWindow", "Flash Lamp Auto"))
self.stop_flashlamp_pushbutton.setText(_translate("MainWindow", "Flash Lamp Off"))
self.fire_qswitch_pushbutton.setText(_translate("MainWindow", "Fire Q-Switch"))
if __name__ == "__main__":
......
No preview for this file type
File added
File added
No preview for this file type
import cv2
import matplotlib.pyplot as plt
import numpy as np
image_loc = r'C:\Users\hedwa\Desktop\experiment_18_10_2017___16.12.30.872461\miscellaneous___18_10_2017___16.18.25.934712.jpg'
image = cv2.imread(image_loc)
figure, axes = plt.subplots(1,2)
image = cv2.cvtColor(image, cv2.COLOR_RGB2GRAY)
axes[0].set_yticks([])
axes[0].set_xticks([])
axes[0].imshow(image)
image = cv2.medianBlur(image,31)
kernel = np.ones((20,20),np.uint8)
image = cv2.dilate(image,kernel,iterations = 2)
image = cv2.erode(image,kernel,iterations = 2)
_,image = cv2.threshold(image, 60, 255, cv2.THRESH_BINARY)
axes[1].set_yticks([])
axes[1].set_xticks([])
axes[1].imshow(image)
plt.show()
\ No newline at end of file
import serial
import numpy as np
from utils import comment
from PyQt5 import QtCore
class laser_controller():
def __init__(self):
com = 'COM7'
baud = 9600
parity = serial.PARITY_NONE
self.ser = serial.Serial(com, baud, timeout=.25,
parity=parity)
self.ser.flushInput()
self.ser.flushOutput()
# we want to start simmering immediately if not already
self.ser.readline()
self.simmer()
self.set_delay(200)
def issue_command(self,command):
command_string = '{}\r\n'.format(command)
comment('sending command to laser:{}'.format(command_string.split('\r')[0]))
self.ser.write(command_string.encode('utf-8'))
def send_receive(self,command):
self.issue_command(command)
response = self.ser.readline()
comment('response received from laser:{}'.format(response))
return response
def simmer(self):
return self.send_receive('M')
def stop_flash(self):
return self.send_receive('S')
def fire_auto(self):
return self.send_receive('A')
def fire_qswitch(self):
return self.send_receive('OP')
def set_delay(self,delay):
self.send_receive('W {}'.format(delay))
class attenuator_controller():
def __init__(self):
com = 'COM5'
baud = 19200
parity = serial.PARITY_NONE
self.ser = serial.Serial(com, baud, timeout=.25,
parity=parity)
self.ser.flushInput()
self.ser.flushOutput()
# we always want the attenuator to be at 0.6
self.send_receive('TF 0.6')
def issue_command(self,command):
command_string = ';AT:{}\n'.format(command)
comment('sending command to attenuator:{}'.format(command_string.split('\n')[0]))
self.ser.write(command_string.encode('utf-8'))
def send_receive(self,command):
self.issue_command(command)
response = self.ser.readline()
comment('response received from attenuator:{}'.format(response))
return response
if __name__ == '__main__':
laser = laser_controller()
laser.simmer()
laser.send_receive('')
# attenuator = attenuator_controller()
# attenuator.send_receive('TF?')
......@@ -9,7 +9,7 @@ class stage_controller():
'''
open the serial port and check the status of the stage
'''
com = 'COM4'
com = 'COM6'
baud = 9600
parity = serial.PARITY_NONE
self.ser = serial.Serial(com, baud, timeout=.25,
......@@ -18,7 +18,7 @@ class stage_controller():
self.last_move_vector = np.zeros(2)
self.magnification = 4
self.microns_per_pixel = 50/14.5
self.calibration_factor = 1.45*4
self.calibration_factor = 1.25*4
self.calibration = calibration_manager()
self.key_control_dict = {
87:self.move_up,
......@@ -137,6 +137,7 @@ class stage_controller():
def handle_keypress(self,key):
if key in self.key_control_dict.keys():
# TODO: probably better to move this to the main file...
self.key_control_dict[key]()
@QtCore.pyqtSlot()
......
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