-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
56a487e
commit 2879bce
Showing
5 changed files
with
373 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
from PyQt5.QtWidgets import QApplication, QMainWindow | ||
from PyQt5.QtCore import Qt | ||
from PyQt5.QtGui import QPainter, QPen | ||
import sys | ||
|
||
class CustomWindow(QMainWindow): | ||
def __init__(self): | ||
super().__init__() | ||
self.initUI() | ||
self.setMouseTracking(True) | ||
self.mouseX = None | ||
self.mouseY = None | ||
self.setWindowOpacity(0.7) | ||
|
||
def initUI(self): | ||
self.setGeometry(300, 300, 300, 200) | ||
self.setWindowTitle('Mouse Tracker') | ||
|
||
self.show() | ||
|
||
def mouseMoveEvent(self, event): | ||
self.mouseX = event.x() / 100 | ||
self.mouseY = event.y() / 100 | ||
print('Mouse coords: ( %d : %d )' % (event.x(), event.y())) | ||
|
||
def mousePressEvent(self, event): | ||
print('mouse pressed') | ||
|
||
def mouseReleaseEvent(self, event): | ||
print('mouse released') | ||
|
||
def paintEvent(self, event=None): | ||
painter = QPainter(self) | ||
|
||
# painter.setOpacity(0.5) | ||
painter.setBrush(Qt.white) | ||
painter.setPen(QPen(Qt.white)) | ||
painter.drawRect(self.rect()) | ||
|
||
if __name__ == "__main__": | ||
app = QApplication(sys.argv) | ||
window = CustomWindow() | ||
app.exec_() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,56 @@ | ||
|
||
#%% | ||
# %% | ||
from copylot.assemblies.photom.photom import PhotomAssembly | ||
from copylot.assemblies.photom.utils import affine_transform | ||
from copylot.hardware.mirrors.optotune.mirror import OptoMirror | ||
from copylot.assemblies.photom.photom_mock_devices import MockLaser, MockMirror | ||
import time | ||
|
||
#%% | ||
|
||
# %% | ||
# Mock imports for the mirror and the lasers | ||
laser = MockLaser('Mock Laser', power=0) | ||
mirror = OptoMirror(com_port='COM8') | ||
|
||
#%% | ||
mirror.position = (0.009,0.0090) | ||
# %% | ||
mirror.position = (0.000,0.000) | ||
|
||
# %% | ||
photom_device = PhotomAssembly(laser=[laser], mirror=[mirror], | ||
affine_matrix_path=[r'C:\Users\ZebraPhysics\Documents\GitHub\coPylot\copylot\assemblies\photom\demo\affine_T.yml'], | ||
) | ||
# %% | ||
photom_device? | ||
# %% | ||
# Test the moving of the mirrors | ||
mirror.position = (0.009, 0.0090) | ||
time.sleep(1) | ||
mirror.position = (0.000, 0.000) | ||
|
||
curr_pos = photom_device.get_position(mirror_index=0) | ||
print(curr_pos) | ||
#%% | ||
photom_device.set_position(mirror_index=0,position=[0.009,0.009]) | ||
assert curr_pos == (0.000, 0.000) | ||
# %% | ||
## Test using the photom_device | ||
camera_sensor_width = 1280 | ||
camera_sensor_height = 1280 | ||
|
||
photom_device = PhotomAssembly( | ||
laser=[laser], | ||
mirror=[mirror], | ||
affine_matrix_path=[ | ||
r'C:\Users\ZebraPhysics\Documents\GitHub\coPylot\copylot\assemblies\photom\demo\test_tmp.yml' | ||
], | ||
) | ||
photom_device.set_position( | ||
mirror_index=0, position=[camera_sensor_width // 2, camera_sensor_height // 2] | ||
) | ||
curr_pos = photom_device.get_position(mirror_index=0) | ||
print(curr_pos) | ||
|
||
|
||
# %% | ||
# TODO: Test the calibration without GUI | ||
import time | ||
|
||
start_time = time.time() | ||
center = 0.009 | ||
photom_device._calibrating = True | ||
while time.time() - start_time < 5: | ||
# Your code here | ||
elapsed_time = time.time() - start_time | ||
print(f'starttime: {start_time} elapsed_time: {elapsed_time}') | ||
photom_device.calibrate(mirror_index=0, rectangle_size_xy=[0.002, 0.002], center=[0.000,0.000]) | ||
photom_device.calibrate( | ||
mirror_index=0, rectangle_size_xy=[0.002, 0.002], center=[0.000, 0.000] | ||
) | ||
photom_device._calibrating = False | ||
|
||
# %% |
Oops, something went wrong.