Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
dc1b361
introducing the delays parameters into the interface
smgag8 Aug 7, 2025
2f2d6e6
start class delaysController
smgag8 Aug 7, 2025
8ed423e
start kinesisDevice class
smgag8 Aug 7, 2025
96c03f6
Merge branch 'main' into automated-delays
dccote Aug 7, 2025
b915e1c
interface and test modification for the delay
smgag8 Aug 8, 2025
86bb903
Merge branch 'automated-delays' of https://github.com/DCC-Lab/PyMicro…
smgag8 Aug 8, 2025
87f2dd0
complete KinesisDevice class
smgag8 Aug 8, 2025
83beb34
channel change in kinesisDevice
smgag8 Aug 8, 2025
f709aa4
action Home, introducing in pymicroscope
smgag8 Aug 8, 2025
8aec46e
interface ajustement, enabled buttons
smgag8 Aug 8, 2025
ea01f19
user_clicked_ajustement_placement button made
smgag8 Aug 11, 2025
467ceeb
ajustement made with test on a window computer
smgag8 Aug 11, 2025
bd71ba8
interface ajustement to be able making Action fonction from button wo…
smgag8 Aug 12, 2025
3f92364
starting delay/wavelenght equation integration in the interface
smgag8 Aug 12, 2025
6e3fe18
associate a_value and b_value of the linear relation between the dela…
smgag8 Aug 13, 2025
41c1a44
comment fonction
smgag8 Aug 13, 2025
3891770
interface ajustement, comment, implamentation of the x and y dimensio…
smgag8 Aug 13, 2025
ab0055f
do home and interface ajustement
smgag8 Aug 13, 2025
2dba3a9
introducing a fonction who will return the position delay at 0 when t…
smgag8 Aug 13, 2025
df1290c
Merge branch 'main' into automated-delays
dccote Aug 14, 2025
cd5c998
cleaning, delet clear action
smgag8 Aug 14, 2025
79408ed
Merge branch 'main' into automated-delays
dccote Aug 21, 2025
a0f3b66
Reorganized the files and renamed files.
dccote Aug 21, 2025
09edfab
Cleaned up KinesisDevice initalization, KinesisDevice
dccote Aug 21, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions src/pymicroscope/base/mapcontroller.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
from mytk import *
import math
from typing import Tuple, Optional
from typing import Any

class MapController(Bindable):
'''Giving all the position to create a map of all the sample'''
def __init__(self, device, *args, **kwargs):
super().__init__(*args, **kwargs)
self.device = device

self.z_image_number = 1
self.microstep_pixel = 0.16565
self.z_range = 1
self.x_dimension = 1000
self.y_dimension = 500

self.parameters: dict[str, Optional[Tuple[int, int, int]]] = {
"Upper left corner": None,
"Upper right corner": None,
"Lower left corner": None,
"Lower right corner": None,
}

def create_positions_for_map(self):
'''Giving all the deplacement position according to the x and y image dimension'''
positions_list = []

corner1 = self.parameters["Upper left corner"]
corner2 = self.parameters["Upper right corner"]
corner3 = self.parameters["Lower left corner"]
corner4 = self.parameters["Lower right corner"]

x_image_dimension = self.x_dimension*self.microstep_pixel
y_image_dimension = self.y_dimension*self.microstep_pixel
z_image_dimension = self.z_range*self.microstep_pixel

if all(x != (0.0, 0.0, 0.0) for x in self.parameters.values()):
number_of_x_image = math.ceil((corner2[0] - corner1[0]) / (0.9*x_image_dimension))
number_of_y_image = math.ceil((corner2[1] - corner4[1])/ (0.9*y_image_dimension))
else:
number_of_x_image = 1
number_of_y_image = 1


for z in range(self.z_image_number):
z_position = z*z_image_dimension
for y in range(number_of_y_image):
y_position = y*y_image_dimension*0.9
for x in range(number_of_x_image):
x_position = x*x_image_dimension*0.9
positions_list.append((x_position, y_position, z_position))


return positions_list
143 changes: 0 additions & 143 deletions src/pymicroscope/base/position_and_mapcontroller.py

This file was deleted.

20 changes: 13 additions & 7 deletions src/pymicroscope/experiment/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,19 @@ def __init__(
def do_perform(self, results=None) -> dict[str, Any] | None:
self.device.moveInMicronsBy(self.d_position)
return {"displacement": self.d_position}

class ActionHome(Action):
def __init__(
self,
linear_motion_device: LinearMotionDevice,
*args,
**kwargs,
):
super().__init__(*args, **kwargs)
self.device: LinearMotionDevice = linear_motion_device

def do_perform(self, results=None) -> None:
self.device.home()


class ActionFunctionCall(Action):
Expand Down Expand Up @@ -296,10 +309,3 @@ def do_perform(self, results=None) -> dict[str, Any] | None:

self.output = filepath


class ActionClear(Action):
def __init__(self, filepath: Path, *args, **kwargs):
super().__init__(*args, **kwargs)
self.filepath = filepath
for file in self.filepath:
self.filepath[file] = None
82 changes: 82 additions & 0 deletions src/pymicroscope/hardware/kinesisdevice.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
from hardwarelibrary.physicaldevice import *
from hardwarelibrary.motion.linearmotiondevice import *
from hardwarelibrary.communication.communicationport import *
from hardwarelibrary.communication.usbport import USBPort
from hardwarelibrary.communication.serialport import SerialPort
from hardwarelibrary.communication.commands import DataCommand
from hardwarelibrary.communication.debugport import DebugPort

import time
from struct import *

from pyftdi.ftdi import Ftdi #FIXME: should not be here.
from mytk import *
from pylablib.devices.Thorlabs import kinesis

class KinesisDevice(LinearMotionDevice):
#SERIAL_NUMBER = "83849018"

def __init__(self, serialNumber: str = None, channel: int = 1):
super().__init__(serialNumber=serialNumber, idVendor=self.classIdVendor, idProduct=self.classIdProduct)
self.thorlabs_device = None
self.channel =channel
self.nativeStepsPerMicrons = 128


# All values are in native units (i.e. microsteps)
self.xMinLimit = 0
self.xMaxLimit = 857599

def __del__(self):
try:
self.thorlabs_device.close()
except:
return

def doInitializeDevice(self):
available_devices = kinesis.KinesisDevice.list_devices()
available_serial_numbers = [ device[0] for device in available_devices]

if self.serialNumber not in available_serial_numbers:
raise RuntimeError("Kinesis Device with serial number {0} not found.".format(self.serialNumber))

'''Connect the right Kinesis Motor, open the port, set the channel and the reference position'''
self.thorlabs_device = kinesis.KinesisMotor(conn=self.serialNumber)
if self.thorlabs_device is None:
raise PhysicalDevice.UnableToInitialize("Cannot allocate port {0}".format(self.thorlabs_device))
else:
self.thorlabs_device.open()
self.thorlabs_device.set_supported_channels(channels= self.channel)
self.thorlabs_device.set_position_reference() #set the initilal point

def doShutdownDevice(self):
self.thorlabs_device.close()
self.thorlabs_device = None

def position(self) -> int: # for 1D compatibility
position_tuple = super().position()
return position_tuple[0]

def doGetPosition(self) -> tuple:
return (self.thorlabs_device.get_position(),)

def doMoveTo(self, position):
self.thorlabs_device.move_to(position=position[0])
if self.thorlabs_device.is_moving() is False:
raise Exception("unable to move the device.")
else:
self.thorlabs_device.wait_move()

def doMoveBy(self, displacement):
self.thorlabs_device.move_by(distance=displacement[0])
if self.thorlabs_device.is_moving() is False:
raise Exception("unable to move the device.")
else:
self.thorlabs_device.wait_move()

def doHome(self):
self.thorlabs_device.move_to(position=0)
if self.thorlabs_device.is_moving() is False:
raise Exception("unable to move the device to home.")
else:
self.thorlabs_device.wait_for_stop()
Loading