@@ -1471,3 +1471,108 @@ def data_func(self, frame_ids):
14711471 )
14721472
14731473 self .model .event_queue .put (("multiposition" , table_values ))
1474+
1475+ class SetCameraParameters :
1476+ """
1477+ SetCameraParameters class for modifying the parameters of a camera.
1478+
1479+ This class provides functionality to update the parameters of a camera.
1480+
1481+ Notes:
1482+ ------
1483+ - This class can set sensor_mode, readout_direction and rolling_shutter_with.
1484+
1485+ - If the value of a parameter is None it doesn't update the parameter value.
1486+ """
1487+
1488+ def __init__ (self , model , sensor_mode = "Normal" , readout_direction = None , rolling_shutter_width = None ):
1489+ """Initialize the ChangeResolution class.
1490+
1491+
1492+ Parameters:
1493+ ----------
1494+ model : MicroscopeModel
1495+ The microscope model object used for resolution mode changes.
1496+ sensor_mode : str, optional
1497+ The desired sensor mode to set for the camera. "Normal" or "Light-Sheet"
1498+ readout_direction : str, optional
1499+ The readout direction to set for the camera.
1500+ "Top-to-Bottom", "Bottom-to-Top", "Bidirectional" or "Rev. Bidirectional"
1501+ rolling_shutter_width : int, optional
1502+ The number of pixels for the rolling shutter.
1503+ """
1504+ #: MicroscopeModel: The microscope model associated with the resolution change.
1505+ self .model = model
1506+
1507+ #: dict: A dictionary defining the configuration for the resolution change
1508+ self .config_table = {
1509+ "signal" : {"main" : self .signal_func , "cleanup" : self .cleanup },
1510+ "node" : {"device_related" : True },
1511+ }
1512+
1513+ #: str: The desired sensor mode to set for the camera.
1514+ self .sensor_mode = sensor_mode
1515+
1516+ #: str: The reading direction to set for the microscope.
1517+ self .readout_direction = readout_direction
1518+
1519+ #: int: The number of pixels for the rolling shutter.
1520+ try :
1521+ self .rolling_shutter_width = int (rolling_shutter_width )
1522+ except ValueError :
1523+ self .rolling_shutter_width = None
1524+
1525+ def signal_func (self ):
1526+ """Perform actions to change the resolution mode and update the active
1527+ microscope.
1528+
1529+ This method carries out actions to change the resolution mode of the microscope
1530+ by reconfiguring the microscope settings, updating the active microscope, and
1531+ resuming data acquisition.
1532+
1533+ Returns:
1534+ -------
1535+ bool
1536+ A boolean value indicating the success of the resolution change process.
1537+ """
1538+ update_flag = False
1539+ update_sensor_mode = False
1540+ camera_parameters = self .model .configuration ["experiment" ]["CameraParameters" ]
1541+ camera_config = self .model .configuration ["configuration" ]["microscopes" ][
1542+ self .model .active_microscope_name
1543+ ]["camera" ]
1544+ updated_value = [None ] * 3
1545+ if self .sensor_mode in ["Normal" , "Light-Sheet" ] and self .sensor_mode != camera_parameters ["sensor_mode" ]:
1546+ update_flag = True
1547+ update_sensor_mode = True
1548+ camera_parameters ["sensor_mode" ] = self .sensor_mode
1549+ updated_value [0 ] = self .sensor_mode
1550+ if camera_parameters ["sensor_mode" ] == "Light-Sheet" :
1551+ if self .readout_direction in camera_config ["supported_readout_directions" ] and \
1552+ (update_sensor_mode or camera_parameters ["readout_direction" ] != self .readout_direction ):
1553+ update_flag = True
1554+ camera_parameters ["readout_direction" ] = self .readout_direction
1555+ updated_value [1 ] = self .readout_direction
1556+ if self .rolling_shutter_width and (update_sensor_mode or self .rolling_shutter_width != camera_parameters ["number_of_pixels" ]):
1557+ update_flag = True
1558+ camera_parameters ["number_of_pixels" ] = self .rolling_shutter_width
1559+ updated_value [2 ] = self .rolling_shutter_width
1560+
1561+ if not update_flag :
1562+ return True
1563+ # pause data thread
1564+ self .model .pause_data_thread ()
1565+ # end active microscope
1566+ self .model .active_microscope .end_acquisition ()
1567+ # set parameters and prepare active microscope
1568+ waveform_dict = self .model .active_microscope .prepare_acquisition ()
1569+ self .model .event_queue .put (("waveform" , waveform_dict ))
1570+ self .model .event_queue .put (("display_camera_parameters" , updated_value ))
1571+ # prepare channel
1572+ self .model .active_microscope .prepare_next_channel ()
1573+ # resume data thread
1574+ self .model .resume_data_thread ()
1575+ return True
1576+
1577+ def cleanup (self ):
1578+ self .model .resume_data_thread ()
0 commit comments