BioImager  4.9.0
A .NET microscopy imaging application based on Bio library. Supports various microscopes by using imported libraries & GUI automation. Supports XInput game controllers to move stage, take images, run ImageJ macros on images or Bio C# scripts.
Loading...
Searching...
No Matches
microscope.cameras.pvcam.PVCamera Class Reference
Inheritance diagram for microscope.cameras.pvcam.PVCamera:
microscope.abc.FloatingDeviceMixin microscope.abc.Camera microscope.abc.TriggerTargetMixin microscope.abc.DataDevice microscope.abc.Device

Public Member Functions

 __init__ (self, index=0, **kwargs)
 
 get_id (self)
 
 abort (self)
 
 initialize (self)
 
 set_readout_mode (self, index)
 
 set_exposure_time (self, value)
 
 get_exposure_time (self)
 
 get_cycle_time (self)
 
 soft_trigger (self)
 
microscope.TriggerMode trigger_mode (self)
 
microscope.TriggerType trigger_type (self)
 
None set_trigger (self, microscope.TriggerType ttype, microscope.TriggerMode tmode)
 
- Public Member Functions inherited from microscope.abc.FloatingDeviceMixin
- Public Member Functions inherited from microscope.abc.Camera
 get_transform (self)
 
 set_transform (self, transform)
 
typing.Tuple[int, int] get_sensor_shape (self)
 
microscope.Binning get_binning (self)
 
None set_binning (self, microscope.Binning binning)
 
microscope.ROI get_roi (self)
 
None set_roi (self, microscope.ROI roi)
 
- Public Member Functions inherited from microscope.abc.TriggerTargetMixin
None trigger (self)
 
- Public Member Functions inherited from microscope.abc.DataDevice
 __del__ (self)
 
None enable (self)
 
None disable (self)
 
None set_client (self, new_client)
 
None update_settings (self, settings, bool init=False)
 
None receiveClient (self, str client_uri)
 
 grab_next_data (self, bool soft_trigger=True)
 
None receiveData (self, data, timestamp)
 
- Public Member Functions inherited from microscope.abc.Device
bool get_is_enabled (self)
 
None shutdown (self)
 
None add_setting (self, name, dtype, get_func, set_func, values, typing.Optional[typing.Callable[[], bool]] readonly=None)
 
 get_setting (self, str name)
 
 get_all_settings (self)
 
None set_setting (self, str name, value)
 
 describe_setting (self, str name)
 
 describe_settings (self)
 

Public Attributes

 handle = None
 
tuple shape = (None, None)
 
tuple roi = (None, None, None, None)
 
 binning = microscope.Binning(1, 1)
 
float exposure_time = 0.001
 
float cycle_time = self.exposure_time
 
 set_exposure_time
 
dict roi = self._params[PARAM_READOUT_PORT].values
 
- Public Attributes inherited from microscope.abc.Camera
 get_roi
 
 set_roi
 
- Public Attributes inherited from microscope.abc.DataDevice
bool enabled = False
 
bool _fetch_thread = True
 
bool _dispatch_thread = True
 
None _fetch_thread_run = self._fetch_data()
 
- Public Attributes inherited from microscope.abc.Device
bool enabled = False
 

Static Public Attributes

list open_cameras = []
 
- Static Public Attributes inherited from microscope.abc.Camera
list ALLOWED_TRANSFORMS = [p for p in itertools.product(*3 * [[False, True]])]
 
- Static Public Attributes inherited from microscope.abc.DataDevice
 set_setting = keep_acquiring(Device.set_setting)
 

Protected Member Functions

 _region (self)
 
 _fetch_data (self)
 
 _do_enable (self)
 
 _do_disable (self)
 
None _do_shutdown (self)
 
 _get_sensor_shape (self)
 
 _get_binning (self)
 
 _set_binning (self, binning)
 
 _get_roi (self)
 
 _set_roi (self, roi)
 
None _do_trigger (self)
 
- Protected Member Functions inherited from microscope.abc.Camera
 _process_data (self, data)
 
 _set_readout_transform (self, new_transform)
 
- Protected Member Functions inherited from microscope.abc.TriggerTargetMixin
- Protected Member Functions inherited from microscope.abc.DataDevice
 _send_data (self, client, data, timestamp)
 
None _dispatch_loop (self)
 
None _fetch_loop (self)
 
 _client (self)
 
 _client (self, val)
 
None _put (self, data, timestamp)
 
- Protected Member Functions inherited from microscope.abc.Device

Protected Attributes

 _pv_name = None
 
 _trigger = TRIG_STROBED
 
 _buffer = None
 
dict _params = {}
 
int _circ_buffer_length = 10
 
bool _using_callback = True
 
 _eof_callback = CALLBACK(cb)
 
bool _acquiring = True
 
dict _cbs
 
list _readout_modes = []
 
list _readout_mode_parameters = []
 
 _readout_mode = index
 
- Protected Attributes inherited from microscope.abc.FloatingDeviceMixin
 _index = index
 
- Protected Attributes inherited from microscope.abc.Camera
list _readout_modes = ["default"]
 
int _readout_mode = 0
 
tuple _readout_transform = (False, False, False)
 
tuple _client_transform = (False, False, False)
 
tuple _transform = (False, False, False)
 
- Protected Attributes inherited from microscope.abc.DataDevice
 _fetch_thread = None
 
bool _fetch_thread_run = False
 
bool _using_callback = False
 
list _clientStack = []
 
 _liveClients = set()
 
 _dispatch_thread = None
 
 _dispatch_buffer = queue.Queue(maxsize=buffer_length)
 
bool _acquiring = False
 
 _new_data_condition = threading.Condition()
 
 _client = None
 
tuple _new_data = (data, timestamp)
 
- Protected Attributes inherited from microscope.abc.Device
dict _settings = {}
 

Detailed Description

Implements the CameraDevice interface for the pvcam library.

Definition at line 1404 of file pvcam.py.

Constructor & Destructor Documentation

◆ __init__()

microscope.cameras.pvcam.PVCamera.__init__ ( self,
index = 0,
** kwargs )

Reimplemented from microscope.abc.FloatingDeviceMixin.

Definition at line 1413 of file pvcam.py.

1413 def __init__(self, index=0, **kwargs):
1414 super().__init__(index=index, **kwargs)
1415 # Camera name in DLL.
1416 self._pv_name = None
1417 # Camera handle.
1418 self.handle = None
1419 # Sensor shape.
1420 self.shape = (None, None)
1421 # Region of interest.
1422 self.roi = (None, None, None, None)
1423 # Binning setting.
1424 self.binning = microscope.Binning(1, 1)
1425 self._trigger = TRIG_STROBED
1426 self.exposure_time = 0.001 # in seconds
1427 # Cycle time
1428 self.cycle_time = self.exposure_time
1429 # Data buffer.
1430 self._buffer = None
1431 # This devices PVCAM parameters.
1432 self._params = {}
1433 # Circular buffer length.
1434 self._circ_buffer_length = 10
1435
1436 # Add common settings.
1437 self.add_setting(
1438 "exposure time",
1439 "float",
1440 lambda: self.exposure_time,
1441 self.set_exposure_time,
1442 lambda: (1e-6, 1),
1443 )
1444 self.add_setting(
1445 "trigger mode",
1446 "enum",
1447 lambda: self._trigger,
1448 lambda value: setattr(self, "_trigger", value),
1449 {k: v.label for k, v in TRIGGER_MODES.items()},
1450 )
1451 self.add_setting(
1452 "circular buffer length",
1453 "int",
1454 lambda: self._circ_buffer_length,
1455 lambda value: setattr(self, "_circ_buffer_length", value),
1456 (2, 100),
1457 )
1458
1459 self.initialize()
1460

Member Function Documentation

◆ _do_disable()

microscope.cameras.pvcam.PVCamera._do_disable ( self)
protected
Disable the hardware for a short period of inactivity.

Reimplemented from microscope.abc.Device.

Definition at line 1613 of file pvcam.py.

1613 def _do_disable(self):
1614 """Disable the hardware for a short period of inactivity."""
1615 self.abort()
1616 _cam_deregister_callback(self.handle, PL_CALLBACK_EOF)
1617

◆ _do_enable()

microscope.cameras.pvcam.PVCamera._do_enable ( self)
protected
Enable the camera hardware and make ready to respond to triggers.

Return True if successful, False if not.

Reimplemented from microscope.abc.Device.

Definition at line 1480 of file pvcam.py.

1480 def _do_enable(self):
1481 """Enable the camera hardware and make ready to respond to triggers.
1482
1483 Return True if successful, False if not."""
1484 # Set exposure time resolution on camera and determine t_exp, the
1485 # integer value used to set exposure time on the hardware later.
1486 if self.exposure_time < 1e-3:
1487 self._params[PARAM_EXP_RES].set_value(EXP_RES_ONE_MICROSEC)
1488 t_exp = int(self.exposure_time * 1e6)
1489 else:
1490 self._params[PARAM_EXP_RES].set_value(EXP_RES_ONE_MILLISEC)
1491 t_exp = int(self.exposure_time * 1e3)
1492 # Determine the data type of the buffer
1493 # Kinetix has an 8 bit mode, may need more options for colour
1494 # cameras.
1495 buffer_dtype = "uint16"
1496 if self._params[PARAM_BIT_DEPTH].current == 8:
1497 buffer_dtype = "uint8"
1498 # Configure camera, allocate buffer, and register callback.
1499 if self._trigger == TRIG_SOFT:
1500 # Software triggering for single frames.
1501 # Set up callback.
1502 self._using_callback = True
1503
1504 def cb():
1505 """Soft trigger mode end-of-frame callback."""
1506 timestamp = time.time()
1507 frame = self._buffer.copy()
1508 _logger.debug("Fetched single frame.")
1509 _exp_finish_seq(self.handle, CCS_CLEAR)
1510 self._put(frame, timestamp)
1511 return
1512
1513 # Need to keep a reference to the callback.
1514 self._eof_callback = CALLBACK(cb)
1515 _cam_register_callback(
1516 self.handle, PL_CALLBACK_EOF, self._eof_callback
1517 )
1518 nbytes = _exp_setup_seq(
1519 self.handle,
1520 1,
1521 1, # cam, num epxosures, num regions
1522 self._region,
1523 TRIGGER_MODES[self._trigger].pv_mode,
1524 t_exp,
1525 )
1526 buffer_shape = (
1527 self.roi.height // self.binning.v,
1528 self.roi.width // self.binning.h,
1529 )
1530 self._buffer = np.require(
1531 np.empty(buffer_shape, dtype=buffer_dtype),
1532 requirements=["C_CONTIGUOUS", "ALIGNED", "OWNDATA"],
1533 )
1534 else:
1535 # Use a circular buffer.
1536 self._using_callback = True
1537
1538 # Determine the data type of the frame
1539 frame_type = uns16
1540 if buffer_dtype == "uint8":
1541 frame_type = uns8
1542
1543 def cb():
1544 """Circular buffer mode end-of-frame callback."""
1545 timestamp = time.time()
1546 frame_p = ctypes.cast(
1547 _exp_get_latest_frame(self.handle),
1548 ctypes.POINTER(frame_type),
1549 )
1550 frame = np.ctypeslib.as_array(
1551 frame_p, (self.roi[2], self.roi[3])
1552 ).copy()
1553 _logger.debug("Fetched frame from circular buffer.")
1554 self._put(frame, timestamp)
1555 return
1556
1557 # Need to keep a reference to the callback.
1558 self._eof_callback = CALLBACK(cb)
1559 _cam_register_callback(
1560 self.handle, PL_CALLBACK_EOF, self._eof_callback
1561 )
1562 buffer_shape = (
1563 self._circ_buffer_length,
1564 self.roi.height // self.binning.v,
1565 self.roi.width // self.binning.h,
1566 )
1567 self._buffer = np.require(
1568 np.empty(buffer_shape, dtype=buffer_dtype),
1569 requirements=["C_CONTIGUOUS", "ALIGNED", "OWNDATA"],
1570 )
1571 nbytes = _exp_setup_cont(
1572 self.handle,
1573 1,
1574 self._region,
1575 TRIGGER_MODES[self._trigger].pv_mode,
1576 t_exp,
1577 CIRC_OVERWRITE,
1578 ).value
1579
1580 # Read back exposure time.
1581 t_readback = self._params[PARAM_EXPOSURE_TIME].current
1582 t_resolution = self._params[PARAM_EXP_RES].current
1583 multipliers = {
1584 EXP_RES_ONE_SEC: 1.0,
1585 EXP_RES_ONE_MILLISEC: 1e-3,
1586 EXP_RES_ONE_MICROSEC: 1e-6,
1587 }
1588 if isinstance(t_resolution, tuple):
1589 self.exposure_time = t_readback * multipliers[t_resolution[0]]
1590 else:
1591 self.exposure_time = t_readback * multipliers[t_resolution]
1592 # Update cycle time. Exposure time in seconds; readout time in microseconds.
1593 self.cycle_time = (
1594 self.exposure_time
1595 + 1e-6 * self._params[PARAM_READOUT_TIME].current
1596 )
1597 # Set up exposure time for VARIABLE_TIMED_MODE, as according to documentation.
1598 # It doesn't seem to work.
1599 if self._trigger == TRIG_VARIABLE:
1600 self._params[PARAM_EXP_TIME].set_value(t_exp)
1601 # If using real triggering, start triggered acquisition.
1602 # (Software triggering will start acquisition in soft_trigger().)
1603 if self._trigger != TRIG_SOFT:
1604 _exp_start_cont(
1605 self.handle,
1606 self._buffer.ctypes.data_as(ctypes.c_void_p),
1607 self._buffer.nbytes,
1608 )
1609 # Done.
1610 self._acquiring = True
1611 return self._acquiring
1612

◆ _do_shutdown()

None microscope.cameras.pvcam.PVCamera._do_shutdown ( self)
protected
Disable the hardware for a prolonged period of inactivity.

Reimplemented from microscope.abc.Device.

Definition at line 1618 of file pvcam.py.

1618 def _do_shutdown(self) -> None:
1619 """Disable the hardware for a prolonged period of inactivity."""
1620 self.abort()
1621 _cam_close(self.handle)
1622 PVCamera.open_cameras.remove(self.handle)
1623 if not PVCamera.open_cameras:
1624 _logger.info("No more open cameras - calling _pvcam_uninit.")
1625 _pvcam_uninit()
1626

◆ _do_trigger()

None microscope.cameras.pvcam.PVCamera._do_trigger ( self)
protected
Actual trigger of the device.

Classes implementing this interface should implement this
method instead of `trigger`.

Reimplemented from microscope.abc.TriggerTargetMixin.

Definition at line 1893 of file pvcam.py.

1893 def _do_trigger(self) -> None:
1894 _exp_start_seq(
1895 self.handle, self._buffer.ctypes.data_as(ctypes.c_void_p)
1896 )

◆ _fetch_data()

microscope.cameras.pvcam.PVCamera._fetch_data ( self)
protected
Fetch data - for use in fetch_loop.

Reimplemented from microscope.abc.DataDevice.

Definition at line 1475 of file pvcam.py.

1475 def _fetch_data(self):
1476 """Fetch data - for use in fetch_loop."""
1477 # Not used: images fetched using callback.
1478 return None
1479

◆ _get_binning()

microscope.cameras.pvcam.PVCamera._get_binning ( self)
protected
Return the current binning (horizontal, vertical).

Reimplemented from microscope.abc.Camera.

Definition at line 1635 of file pvcam.py.

1635 def _get_binning(self):
1636 """Return the current binning (horizontal, vertical)."""
1637 return self.binning
1638

◆ _get_roi()

microscope.cameras.pvcam.PVCamera._get_roi ( self)
protected
Return the current ROI (left, top, width, height).

Reimplemented from microscope.abc.Camera.

Definition at line 1645 of file pvcam.py.

1645 def _get_roi(self):
1646 """Return the current ROI (left, top, width, height)."""
1647 return self.roi
1648

◆ _get_sensor_shape()

microscope.cameras.pvcam.PVCamera._get_sensor_shape ( self)
protected
Return the sensor shape (width, height).

Reimplemented from microscope.abc.Camera.

Definition at line 1631 of file pvcam.py.

1631 def _get_sensor_shape(self):
1632 """Return the sensor shape (width, height)."""
1633 return self.shape
1634

◆ _region()

microscope.cameras.pvcam.PVCamera._region ( self)
protected
Return a rgn_type for current roi and binning settings.

Definition at line 1462 of file pvcam.py.

1462 def _region(self):
1463 """Return a rgn_type for current roi and binning settings."""
1464 return rgn_type(
1465 self.roi.left,
1466 self.roi.left + self.roi.width - 1,
1467 self.binning.h,
1468 self.roi.top,
1469 self.roi.top + self.roi.height - 1,
1470 self.binning.v,
1471 )
1472

◆ _set_binning()

microscope.cameras.pvcam.PVCamera._set_binning ( self,
binning )
protected
Set binning to (h, v).

Reimplemented from microscope.abc.Camera.

Definition at line 1640 of file pvcam.py.

1640 def _set_binning(self, binning):
1641 """Set binning to (h, v)."""
1642 # The keep_acquiring decorator will cause recreation of buffers.
1643 self.binning = microscope.Binning(binning.h, binning.v)
1644

◆ _set_roi()

microscope.cameras.pvcam.PVCamera._set_roi ( self,
roi )
protected
Set the ROI to (left, tip, width, height).

Reimplemented from microscope.abc.Camera.

Definition at line 1650 of file pvcam.py.

1650 def _set_roi(self, roi):
1651 """Set the ROI to (left, tip, width, height)."""
1652 right = roi.left + roi.width
1653 bottom = roi.top + roi.height
1654 if (right, bottom) > self.shape:
1655 raise ValueError("ROI exceeds sensor area.")
1656 self.roi = roi
1657

◆ abort()

microscope.cameras.pvcam.PVCamera.abort ( self)
Abort acquisition.

This should put the camera into a state in which settings can
be modified.

Reimplemented from microscope.abc.DataDevice.

Definition at line 1664 of file pvcam.py.

1664 def abort(self):
1665 """Abort acquisition.
1666
1667 This should put the camera into a state in which settings can
1668 be modified."""
1669 if self._trigger == TRIG_SOFT:
1670 _exp_finish_seq(self.handle, CCS_CLEAR)
1671 else:
1672 _exp_stop_cont(self.handle, CCS_CLEAR)
1673 _exp_abort(self.handle, CCS_HALT)
1674 self._acquiring = False
1675

◆ get_cycle_time()

microscope.cameras.pvcam.PVCamera.get_cycle_time ( self)
Return the cycle time.

Just return self.cycle_time, which is updated with the real
value during _do_enable.

Reimplemented from microscope.abc.Camera.

Definition at line 1839 of file pvcam.py.

1839 def get_cycle_time(self):
1840 """Return the cycle time.
1841
1842 Just return self.cycle_time, which is updated with the real
1843 value during _do_enable."""
1844 return self.cycle_time
1845

◆ get_exposure_time()

microscope.cameras.pvcam.PVCamera.get_exposure_time ( self)
Return the current exposure time.

Just return self.exposure_time, which is updated with the real
value during _do_enable.

Reimplemented from microscope.abc.Camera.

Definition at line 1832 of file pvcam.py.

1832 def get_exposure_time(self):
1833 """Return the current exposure time.
1834
1835 Just return self.exposure_time, which is updated with the real
1836 value during _do_enable."""
1837 return self.exposure_time
1838

◆ get_id()

microscope.cameras.pvcam.PVCamera.get_id ( self)
Get hardware's unique identifier.

Reimplemented from microscope.abc.FloatingDeviceMixin.

Definition at line 1660 of file pvcam.py.

1660 def get_id(self):
1661 """Get hardware's unique identifier."""
1662 return self._params[PARAM_HEAD_SER_NUM_ALPHA].current
1663

◆ initialize()

microscope.cameras.pvcam.PVCamera.initialize ( self)
Initialise the camera.

Reimplemented from microscope.abc.Device.

Definition at line 1676 of file pvcam.py.

1676 def initialize(self):
1677 """Initialise the camera."""
1678 # Init the DLL if necessary.
1679 if not PVCamera.open_cameras:
1680 try:
1681 _pvcam_init()
1682 except:
1683 pass
1684 # If no cameras detected, need to deinit DLL so it can be reinited to update count.
1685 if _cam_get_total().value == 0:
1686 _pvcam_uninit()
1687 raise microscope.InitialiseError("No cameras detected.")
1688 # Connect to the camera.
1689 _logger.info("DLL version: %s", _pvcam_get_ver().value)
1690 self._pv_name = _cam_get_name(self._index).value
1691 _logger.info("Initializing %s", self._pv_name)
1692 self.handle = _cam_open(self._pv_name, OPEN_EXCLUSIVE)
1693 PVCamera.open_cameras.append(self.handle)
1694 # Set up event callbacks. Tried to use the resume callback to reinit camera
1695 # after power loss, but any attempt to close/reopen the camera or deinit the
1696 # DLL throws a Windows Error 0xE06D7363.
1697 def _cb(event):
1698 _logger.info("Received %s event.", event)
1699 if event == "removed":
1700 _logger.critical("Can not re-init hardware. Exiting.")
1701 exit(-1)
1702 return
1703
1704 self._cbs = {
1705 "check": CALLBACK(lambda: _cb("check")),
1706 "resumed": CALLBACK(lambda: _cb("resumed")),
1707 "removed": CALLBACK(lambda: _cb("removed")),
1708 }
1709 _cam_register_callback(
1710 self.handle, PL_CALLBACK_CHECK_CAMS, self._cbs["check"]
1711 )
1712 _cam_register_callback(
1713 self.handle, PL_CALLBACK_CAM_REMOVED, self._cbs["removed"]
1714 )
1715 _cam_register_callback(
1716 self.handle, PL_CALLBACK_CAM_RESUMED, self._cbs["resumed"]
1717 )
1718 # Repopulate _params.
1719 self._params = {}
1720 for (param_id, name) in _param_to_name.items():
1721 try:
1722 p = PVParam.factory(self, param_id)
1723 except:
1724 _logger.warn("Skipping unsupported parameter %s.", name)
1725 continue
1726 if not p.dtype or not p.available:
1727 continue
1728 self._params[param_id] = p
1729 name = name[6:]
1730
1731 try:
1732 p.current
1733 except KeyError:
1734 # Raise these here, as the message is a tuple, not a str.
1735 raise
1736 except Exception as err:
1737 # Test on err.args prevents indexing into empty tuple.
1738 if err.args and not err.args[0].startswith("pvcam error 49"):
1739 _logger.warn(
1740 "Skipping parameter %s: not supported" " in python.",
1741 p.name,
1742 )
1743 continue
1744 self.add_setting(
1745 p.name,
1746 p.dtype,
1747 lambda p=p: p.current,
1748 p.set_value
1749 if p.access in [ACC_READ_WRITE, ACC_WRITE_ONLY]
1750 else None,
1751 lambda p=p: p.values,
1752 )
1753 if PARAM_GAIN_MULT_FACTOR in self._params:
1754 self.add_setting(
1755 "gain",
1756 self._params[PARAM_GAIN_MULT_FACTOR].dtype,
1757 lambda: self._params[PARAM_GAIN_MULT_FACTOR].current,
1758 self._params[PARAM_GAIN_MULT_FACTOR].set_value,
1759 self._params[PARAM_GAIN_MULT_FACTOR].values,
1760 )
1761
1762 if PARAM_PMODE in self._params:
1763 self.add_setting(
1764 "frame transfer mode",
1765 self._params[PARAM_PMODE].dtype,
1766 lambda: self._params[PARAM_PMODE].current,
1767 self._params[PARAM_PMODE].set_value,
1768 self._params[PARAM_PMODE].values,
1769 )
1770
1771 self.shape = (
1772 self._params[PARAM_PAR_SIZE].current,
1773 self._params[PARAM_SER_SIZE].current,
1774 )
1775 self.roi = microscope.ROI(0, 0, self.shape[0], self.shape[1])
1776
1777 # Populate readout modes by iterating over readout ports and speed
1778 # table entries.
1779 ro_ports = self._params[PARAM_READOUT_PORT].values
1780 self._readout_modes = []
1781 self._readout_mode_parameters = []
1782 for i, port in ro_ports.items():
1783 self._params[PARAM_READOUT_PORT].set_value(i)
1784 ro_speeds = self._params[PARAM_SPDTAB_INDEX].values
1785 for j in range(ro_speeds[0], ro_speeds[1] + 1):
1786 self._params[PARAM_SPDTAB_INDEX].set_value(j)
1787 bit_depth = self._params[PARAM_BIT_DEPTH].current
1788 freq = 1e9 / self._params[PARAM_PIX_TIME].current
1789 if freq > 1e6:
1790 freq *= 1e-6
1791 prefix = "M"
1792 elif freq > 1e3:
1793 freq *= 1e-3
1794 prefix = "k"
1795 else:
1796 prefix = "Hz"
1797 mode_str = "%s, %s-bit, %s %sHz" % (
1798 port,
1799 bit_depth,
1800 freq,
1801 prefix,
1802 )
1803 self._readout_modes.append(mode_str)
1804 self._readout_mode_parameters.append(
1805 {"port": i, "spdtab_index": j}
1806 )
1807 # Set to default mode.
1808 self.set_readout_mode(0)
1809 self._params[PARAM_CLEAR_MODE].set_value(CLEAR_PRE_EXPOSURE_POST_SEQ)
1810

◆ set_exposure_time()

microscope.cameras.pvcam.PVCamera.set_exposure_time ( self,
value )
Set the exposure time to value.

Reimplemented from microscope.abc.Camera.

Definition at line 1828 of file pvcam.py.

1828 def set_exposure_time(self, value):
1829 """Set the exposure time to value."""
1830 self.exposure_time = value
1831

◆ set_readout_mode()

microscope.cameras.pvcam.PVCamera.set_readout_mode ( self,
index )
Set the readout mode and transform.

Reimplemented from microscope.abc.Camera.

Definition at line 1812 of file pvcam.py.

1812 def set_readout_mode(self, index):
1813 """Set the readout mode and transform."""
1814 params = self._readout_mode_parameters[index]
1815 self._params[PARAM_READOUT_PORT].set_value(params["port"])
1816 self._params[PARAM_SPDTAB_INDEX].set_value(params["spdtab_index"])
1817 self._readout_mode = index
1818 # Update transforms, if available.
1819 chip = self._params[PARAM_CHIP_NAME].current
1820 new_readout_transform = None
1821 readout_map = READOUT_TRANSFORMS.get(chip, None)
1822 if readout_map:
1823 new_readout_transform = readout_map.get(params["port"], None)
1824 if new_readout_transform:
1825 self._set_readout_transform(new_readout_transform)
1826

◆ set_trigger()

None microscope.cameras.pvcam.PVCamera.set_trigger ( self,
microscope.TriggerType ttype,
microscope.TriggerMode tmode )
Set device for a specific trigger.

Reimplemented from microscope.abc.TriggerTargetMixin.

Definition at line 1883 of file pvcam.py.

1885 ) -> None:
1886 try:
1887 self._trigger = TRIGGER_TO_PV_MODE[(ttype, tmode)]
1888 except KeyError:
1890 "no PVCam mode for %s and %s" % (ttype, tmode)
1891 )
1892

◆ soft_trigger()

microscope.cameras.pvcam.PVCamera.soft_trigger ( self)
Expose software triggering to a client.

Deprecated, use trigger().

Trigger an exposure in TRIG_SOFT mode.
Log some debugging stats in other trigger modes.

Definition at line 1847 of file pvcam.py.

1847 def soft_trigger(self):
1848 """Expose software triggering to a client.
1849
1850 Deprecated, use trigger().
1851
1852 Trigger an exposure in TRIG_SOFT mode.
1853 Log some debugging stats in other trigger modes."""
1854 if self._trigger == TRIG_SOFT:
1855 _logger.debug("Received soft trigger ...")
1856 _exp_start_seq(
1857 self.handle, self._buffer.ctypes.data_as(ctypes.c_void_p)
1858 )
1859 else:
1860 cstatus, cbytes, cframes = _exp_check_cont_status(self.handle)
1861 status, bytes = _exp_check_status(self.handle)
1862
1863 _logger.debug(
1864 "Status checks\n"
1865 "check_cont: %s \t bytes: %d\tframes: %d\n"
1866 "check_status: %s \t bytes: %d\t",
1867 STATUS_STRINGS[cstatus.value],
1868 cbytes.value,
1869 cframes.value,
1870 STATUS_STRINGS[status.value],
1871 bytes.value,
1872 )
1873 return
1874

◆ trigger_mode()

microscope.TriggerMode microscope.cameras.pvcam.PVCamera.trigger_mode ( self)

Reimplemented from microscope.abc.TriggerTargetMixin.

Definition at line 1876 of file pvcam.py.

1876 def trigger_mode(self) -> microscope.TriggerMode:
1877 return PV_MODE_TO_TRIGGER[self._trigger][1]
1878

◆ trigger_type()

microscope.TriggerType microscope.cameras.pvcam.PVCamera.trigger_type ( self)

Reimplemented from microscope.abc.TriggerTargetMixin.

Definition at line 1880 of file pvcam.py.

1880 def trigger_type(self) -> microscope.TriggerType:
1881 return PV_MODE_TO_TRIGGER[self._trigger][0]
1882

Member Data Documentation

◆ _acquiring

bool microscope.cameras.pvcam.PVCamera._acquiring = True
protected

Definition at line 1610 of file pvcam.py.

◆ _buffer

microscope.cameras.pvcam.PVCamera._buffer = None
protected

Definition at line 1430 of file pvcam.py.

◆ _cbs

dict microscope.cameras.pvcam.PVCamera._cbs
protected
Initial value:
= {
"check": CALLBACK(lambda: _cb("check")),
"resumed": CALLBACK(lambda: _cb("resumed")),
"removed": CALLBACK(lambda: _cb("removed")),
}

Definition at line 1704 of file pvcam.py.

◆ _circ_buffer_length

microscope.cameras.pvcam.PVCamera._circ_buffer_length = 10
protected

Definition at line 1434 of file pvcam.py.

◆ _eof_callback

microscope.cameras.pvcam.PVCamera._eof_callback = CALLBACK(cb)
protected

Definition at line 1514 of file pvcam.py.

◆ _params

dict microscope.cameras.pvcam.PVCamera._params = {}
protected

Definition at line 1432 of file pvcam.py.

◆ _pv_name

microscope.cameras.pvcam.PVCamera._pv_name = None
protected

Definition at line 1416 of file pvcam.py.

◆ _readout_mode

microscope.cameras.pvcam.PVCamera._readout_mode = index
protected

Definition at line 1817 of file pvcam.py.

◆ _readout_mode_parameters

list microscope.cameras.pvcam.PVCamera._readout_mode_parameters = []
protected

Definition at line 1781 of file pvcam.py.

◆ _readout_modes

list microscope.cameras.pvcam.PVCamera._readout_modes = []
protected

Definition at line 1780 of file pvcam.py.

◆ _trigger

microscope.cameras.pvcam.PVCamera._trigger = TRIG_STROBED
protected

Definition at line 1425 of file pvcam.py.

◆ _using_callback

bool microscope.cameras.pvcam.PVCamera._using_callback = True
protected

Definition at line 1502 of file pvcam.py.

◆ binning

microscope.cameras.pvcam.PVCamera.binning = microscope.Binning(1, 1)

Definition at line 1424 of file pvcam.py.

◆ cycle_time

float microscope.cameras.pvcam.PVCamera.cycle_time = self.exposure_time

Definition at line 1428 of file pvcam.py.

◆ exposure_time

microscope.cameras.pvcam.PVCamera.exposure_time = 0.001

Definition at line 1426 of file pvcam.py.

◆ handle

microscope.cameras.pvcam.PVCamera.handle = None

Definition at line 1418 of file pvcam.py.

◆ open_cameras

list microscope.cameras.pvcam.PVCamera.open_cameras = []
static

Definition at line 1411 of file pvcam.py.

◆ roi [1/2]

tuple microscope.cameras.pvcam.PVCamera.roi = (None, None, None, None)

Definition at line 1422 of file pvcam.py.

◆ roi [2/2]

dict microscope.cameras.pvcam.PVCamera.roi = self._params[PARAM_READOUT_PORT].values

Definition at line 1775 of file pvcam.py.

◆ set_exposure_time

microscope.cameras.pvcam.PVCamera.set_exposure_time

Definition at line 1441 of file pvcam.py.

◆ shape

tuple microscope.cameras.pvcam.PVCamera.shape = (None, None)

Definition at line 1420 of file pvcam.py.


The documentation for this class was generated from the following file: