pyccapt.control.devices package

Submodules

pyccapt.control.devices.camera module

class pyccapt.control.devices.camera.CameraWorker(*args: Any, **kwargs: Any)[source]

Bases: QObject

Drives Basler camera capture with hot-reconnect support.

The worker keeps a fixed number of slots (one per logical camera in the GUI) and binds each slot to a physical camera by serial number the first time it sees one. If a camera disappears, its slot is freed and the worker keeps trying to (re)attach it. Other slots keep streaming.

connect_serial(serial)[source]

Permit serial to attach again and force a reconcile pass.

disconnect_serial(serial)[source]

Close any open slot bound to serial and prevent auto-reattach.

Use connect_serial() to re-enable it.

initialize_cameras()[source]
light_switch()[source]
list_cameras()[source]

Return one dict per currently-detected Basler camera.

Each dict has serial, model, slot (or None when the device is detected but not bound), attached (bool), and user_disabled (bool — user explicitly disconnected it).

set_auto_exposure_time()
set_default_exposure_time()
set_exposure_time_1(exposure_time)
set_exposure_time_2(exposure_time)
set_exposure_time_3(exposure_time)
start_capturing()[source]
stop_capturing()[source]
update_cameras()[source]
RECONNECT_INTERVAL = 3.0
SLOT_COUNT = 2
pyccapt.control.devices.camera.check_camera_availability(required_cameras: int = 1) tuple[bool, str][source]

Compatibility wrapper.

Older call sites used this to gate whether the camera GUI could open at all. The GUI now always opens when the backend is loaded and the worker handles missing/disconnected cameras dynamically, so this just forwards to check_camera_backend().

pyccapt.control.devices.camera.check_camera_backend() tuple[bool, str][source]

Return whether the Basler camera backend is usable on this host.

A True result means we can enumerate Basler cameras at runtime. The actual number of connected cameras is allowed to fluctuate while the GUI is running, so the worker handles that dynamically; this check is only about whether pypylon itself is available.

pyccapt.control.devices.edwards_tic module

Driver for Edwards TIC / Active Gauge Controller (AGC) vacuum gauges.

Vendor / origin

The serial command set used here (!C910, !C904, ?V911, ?V940, etc.) is defined and owned by Edwards Vacuum for their TIC / AGC vacuum-controller family. This file is a thin Python wrapper around that ASCII serial protocol; the protocol itself is Edwards’ property. Refer to Edwards’ Active Gauge Controller manual for the authoritative command reference.

class pyccapt.control.devices.edwards_tic.EdwardsAGC(port, variables)[source]

Bases: object

Primitive driver for Edwards Active Gauge Controller. Complete manual found at http://www.idealvac.com/files/brochures/Edwards_AGC_D386-52-880_IssueM.pdf

The constructor function to initialize serial lib parameters.

Parameters:
  • port (str) – Port on which serial communication is established.

  • variables – Variable container for shared variables.

Returns:

None

comm(command)[source]

This class method implements serial communication using the serial library. Reads the raw data through the serial line and returns it.

Parameters:

command (str) – Command to be written on the serial line.

Returns:

String read through the serial.

Return type:

str

pyccapt.control.devices.email_send module

Experiment-finished email notification.

Configuration lives in pyccapt/files/email_credentials.toml (TOML). That file is gitignored. A checked-in template email_credentials.example.toml documents the schema; users copy it to the real name and fill in their SMTP account.

Backwards compatibility: if the TOML file is absent but the legacy email_pass.txt exists, the password is read from there and the rest of the SMTP config falls back to the historical Gmail defaults.

Failures (missing config, missing recipient, SMTP errors) raise rather than silently swallow, so callers can log them via apt.log.

exception pyccapt.control.devices.email_send.EmailNotConfigured[source]

Bases: RuntimeError

Raised when no usable credentials file is present.

pyccapt.control.devices.email_send.send_email(email: str, subject: str, message: str, variables=None) list[str][source]

Send the experiment-finished email.

Parameters:
  • email – Recipient address (the operator’s address from the GUI).

  • subject – Email subject.

  • message – Plain-text body.

  • variables – Optional shared experiment variables; if provided, the experiment’s apt.log and parameters.txt are attached.

Returns:

List of attached filenames (may be empty).

Raises:
  • EmailNotConfigured – if no credentials file is set up.

  • ValueError – if the recipient address is empty.

  • smtplib.SMTPException / OSError – on SMTP/network failure.

pyccapt.control.devices.initialize_devices module

class pyccapt.control.devices.initialize_devices.bcolors[source]

Bases: object

BOLD = '\x1b[1m'
ENDC = '\x1b[0m'
FAIL = '\x1b[91m'
HEADER = '\x1b[95m'
OKBLUE = '\x1b[94m'
OKCYAN = '\x1b[96m'
OKGREEN = '\x1b[92m'
UNDERLINE = '\x1b[4m'
WARNING = '\x1b[93m'
pyccapt.control.devices.initialize_devices.command_cryovac(cmd, com_port_cryovac)[source]

Execute a command on Cryovac through serial communication.

Vendor / origin

The CLI command set used here (getOutput, getOutputNames, Out1Cryo.PID.Setpoint, Out2LL.PID.Setpoint, e_mlp-style queries, etc.) is defined and owned by CryoVac GmbH for their TIC 500 programmable temperature controller. This function and its siblings (initialize_cryovac etc.) are thin wrappers around that ASCII serial protocol; the protocol itself is CryoVac’s property. Refer to the CryoVac TIC 500 manual (e.g. document 5984591) for the authoritative reference.

param cmd:

Command to be executed.

param com_port_cryovac:

Serial communication object.

returns:

Response code after executing the command.

pyccapt.control.devices.initialize_devices.command_edwards(conf, variables, cmd, E_AGC, status=None)[source]

Execute commands and set flags based on parameters.

Parameters:
  • conf – Configuration parameters.

  • variables – Variables instance.

  • cmd – Command to be executed.

  • E_AGC – EdwardsAGC instance.

  • status – Status of the lock.

Returns:

Response code after executing the command.

pyccapt.control.devices.initialize_devices.initialize_cryovac(com_port_cryovac, variables)[source]

Initialize the communication port of Cryovac.

Parameters:
  • com_port_cryovac – Serial communication object.

  • variables – Variables instance.

Returns:

None

pyccapt.control.devices.initialize_devices.initialize_edwards_tic_buffer_chamber(conf, variables)[source]

Initialize TIC buffer chamber parameters.

Parameters:
  • conf – Configuration parameters.

  • variables – Variables instance.

Returns:

None

pyccapt.control.devices.initialize_devices.initialize_edwards_tic_cryo_load_lock(conf, variables)[source]

Initialize TIC cryo load lock parameters.

Parameters:
  • conf – Configuration parameters.

  • variables – Variables instance.

Returns:

None

pyccapt.control.devices.initialize_devices.initialize_edwards_tic_load_lock(conf, variables)[source]

Initialize TIC load lock parameters.

Parameters:
  • conf – Configuration parameters.

  • variables – Variables instance.

Returns:

None

pyccapt.control.devices.initialize_devices.initialize_pfeiffer_gauges(variables)[source]

Initialize Pfeiffer gauge parameters.

Parameters:

variables – Variables instance.

Returns:

None

pyccapt.control.devices.initialize_devices.log_vacuum_levels(main_chamber, buffer_chamber, buffer_chamber_pre, load_lock, load_lock_pre, cryo_load_lock, cryo_load_lock_pre)[source]

Log vacuum levels to a text file and a CSV file.

Parameters:
  • main_chamber (float) – Vacuum level of the main chamber.

  • buffer_chamber (float) – Vacuum level of the buffer chamber.

  • buffer_chamber_pre (float) – Vacuum level of the buffer chamber backing pump.

  • load_lock (float) – Vacuum level of the load lock.

  • load_lock_pre (float) – Vacuum level of the load lock backing pump.

  • cryo_load_lock (float) – Vacuum level of the cryo load lock.

  • cryo_load_lock_pre (float) – Vacuum level of the cryo load lock backing pump.

Returns:

None

pyccapt.control.devices.initialize_devices.state_update(conf, variables, emitter)[source]

Read gauge parameters and update variables.

Parameters:
  • conf – Configuration parameters.

  • variables – Variables instance.

  • emitter – Emitter instance.

Returns:

None

pyccapt.control.devices.pfeiffer_gauges module

Driver for Pfeiffer TPG 362 (and family) vacuum-gauge controllers.

Vendor / origin

The mnemonic command set used in this module (PR1, PR2, UNI, ETX, ENQ, gauge-status codes, etc.) is defined and owned by Pfeiffer Vacuum GmbH for their TPG 26x / TPG 36x series single- and dual-channel vacuum measurement and control units. This file is a thin Python wrapper around that ASCII serial protocol.

See Pfeiffer’s “TPG 261 / 262 Communication Protocol” and “TPG 361 / 362 Operating Instructions” for the authoritative specification.

class pyccapt.control.devices.pfeiffer_gauges.TPG26x(port='/dev/ttyUSB0', baudrate=9600)[source]

Bases: object

Abstract class that implements the common driver for the TPG 261 and TPG 262 dual channel measurement and control unit.

Initialize the TPG26x driver.

Parameters:
  • port (str or int) – The COM port to open.

  • baudrate (int) – Data transmission rate.

gauge_identification()[source]

Return the gauge identification.

Returns:

Identification codes and messages for both gauges.

Return type:

tuple

pressure_gauge(gauge=1)[source]

Return the pressure measured by gauge X.

Parameters:

gauge (int) – The gauge number, 1 or 2.

Returns:

The value of pressure along with status code and message.

Return type:

tuple

pressure_gauges()[source]

Return the pressures measured by the gauges.

Returns:

The values of both gauges along with their status codes and messages.

Return type:

tuple

pressure_unit()[source]

Return the pressure unit.

Returns:

The pressure unit.

Return type:

str

program_number()[source]

Return the firmware version.

Returns:

The firmware version.

Return type:

str

rs232_communication_test()[source]

Test the RS232 communication.

Returns:

The status of the communication test.

Return type:

bool

ACK = '\x06'
CR = '\r'
ENQ = '\x05'
ETX = '\x03'
LF = '\n'
NAK = '\x15'
class pyccapt.control.devices.pfeiffer_gauges.TPG362(port='/dev/ttyUSB0', baudrate=9600)[source]

Bases: TPG26x

Driver for the TPG 261 dual channel measurement and control unit. Inherits from TPG26x.

Initialize the TPG362 driver.

Parameters:
  • port (str or int) – The COM port to open.

  • baudrate (int) – Data transmission rate.

pyccapt.control.devices.signal_generator module

pyccapt.control.devices.signal_generator.change_frequency_signal_generator(variables, freq)[source]

Change the frequency of the signal generator.

Parameters:
  • variables – Instance of variables class.

  • freq – Frequency at which signal needs to be generated.

Returns:

None

pyccapt.control.devices.signal_generator.initialize_signal_generator(variables, freq)[source]

Initialize the signal generator.

Parameters:
  • variables – Instance of variables class.

  • freq – Frequency at which signal needs to be generated.

Returns:

None

pyccapt.control.devices.signal_generator.turn_off_signal_generator()[source]

Turn off the signal generator.

Returns:

None

Module contents