qtics.instruments.oxford.proteox package#

Proteox cryostat driver (WAMP), asynchronous and synchronous.

Submodules#

qtics.instruments.oxford.proteox.proteox module#

Define proteox instrument object.

class qtics.instruments.oxford.proteox.proteox.AsyncProteox(url=None, realm=None, user=None, secret=None)[source]#

Bases: object

Asynchronous high-level API for interacting with Proteox over WAMP.

Missing connection parameters are read from the environment (after loading a .env file, if any): WAMP_ROUTER_URL, WAMP_REALM, WAMP_USER and WAMP_USER_SECRET.

async close()[source]#

Close the WAMP session.

async connect(timeout: float = 10)[source]#

Connect to the WAMP router and establish session.

async get_recognized_states()[source]#

Return all matched recognized states.

async get_sensor(uri, index=4)#
async how_to_go_to_recognized_state(target_state=None) → str[source]#

Return instructions to reach a state.

In particular: - the closest recognized state, if target_state is None - or a specific recognized state

async is_in_recognized_state() → bool[source]#

Return True if the cryostat is in a recognized state.

async is_in_remote() → bool[source]#

Check if Proteox is in remote mode, i.e. it can be controlled.

async set_sensor(uri, value=None)#
class qtics.instruments.oxford.proteox.proteox.Proteox(url: str | None = None, realm: str | None = None, user: str | None = None, secret: str | None = None, name: str = 'Proteox', timeout: float = 10)[source]#

Bases: Instrument

Synchronous Proteox driver.

Wraps AsyncProteox, which runs on an event loop in a daemon thread. The dynamic get_<KEY>() and set_<KEY>(value) methods of AsyncProteox are available as blocking calls. Exceptions raised in the coroutines propagate to the caller.

connect()[source]#

Start the event loop thread and open the WAMP session.

disconnect()[source]#

Close the WAMP session and stop the event loop thread.

get_recognized_states()[source]#

Return all matched recognized states.

how_to_go_to_recognized_state(target_state=None) → str[source]#

Return instructions to reach a recognized state, see AsyncProteox.

property is_connected: bool#

Whether the event loop thread is running and the session is open.

is_in_recognized_state() → bool[source]#

Return True if the cryostat is in a recognized state.

is_in_remote() → bool[source]#

Check if Proteox is in remote mode, i.e. it can be controlled.

qtics.instruments.oxford.proteox.session module#

Manager for WAMP session.

class qtics.instruments.oxford.proteox.session.InstrumentSession(config, instrument)[source]#

Bases: ApplicationSession

WAMP session class.

Manages the connection to the router and ensures the instrument has control of the system if in remote mode.

instrument#

Reference to the parent instrument instance.

Type:

Any

onChallenge(challenge)[source]#

Authenticate.

Parameters:

challenge (Challenge) – The challenge object containing auth parameters.

Returns:

Signature computed for the challenge.

Return type:

str

onConnect()[source]#

Join the realm using WAMP-CRA authentication.

async onDisconnect()[source]#

Forget the session and signal the instrument’s disconnect_event if set.

async onJoin(details)[source]#

Check the control mode of the system and claims control if no controller exists.

onLeave(details: CloseDetails)[source]#

Override standard onLeave to avoid not necessary warning.

qtics.instruments.oxford.proteox.session.wamp_call_handler_get()[source]#

Create the decorator for wrapping getters WAMP RPC calls.

Handles exceptions and extracts the item at index (default the 5th, the value of most records) from the call response.

Returns:

The wrapped function.

Return type:

Callable

qtics.instruments.oxford.proteox.session.wamp_call_handler_set()[source]#

Create the decorator for wrapping setters WAMP RPC calls.

Returns:

The wrapped function.

Return type:

Callable

qtics.instruments.oxford.proteox.states module#

Recognized state evaluator for Proteox.

This module evaluates whether the cryostat is in one of the recognized states defined by the Proteox truth table.

class qtics.instruments.oxford.proteox.states.Condition(key: str, label: str, evaluator: Callable[[dict[str, Any]], bool], suggestion_if_false: str, suggestion_if_true: str | None = None)[source]#

Bases: object

A boolean condition used to identify a recognized cryostat state.

evaluator: Callable[[dict[str, Any]], bool]#
key: str#
label: str#
suggestion_if_false: str#
suggestion_if_true: str | None = None#
class qtics.instruments.oxford.proteox.states.RecognizedStateManager(proteox)[source]#

Bases: object

Evaluates whether the cryostat is in a recognized state.

async evaluate_conditions() → dict[str, bool][source]#

Evaluate all defined conditions.

async get_closest_state() → StateMatch | None[source]#

Return the closest recognized state (minimum total mismatches).

async get_condition_report() → dict[str, dict[str, Any]][source]#

Return a diagnostic condition report.

Example:

{
    "PTR_IS_ON": {
        "label": "3CL-PTR-01 is On",
        "value": True,
    },
    ...
}
async get_recognized_states() → list[str][source]#

Return all currently matched recognized states.

async get_state_gap(target_state: str) → StateMatch[source]#

Return mismatches relative to a specific target state.

async get_transition_plan(target_state: str | None = None) → dict[str, Any][source]#

Return a structured transition plan.

Useful if you later want to drive a GUI or automatic action planner.

async how_to_go_to_recognized_state(target_state: str | None = None) → str[source]#

Return a human-readable suggestion to reach.

In particular: - the closest recognized state - or a user-requested target state

async is_in_recognized_state() → bool[source]#

Return True if current conditions match at least one recognized state.

async match_all_states() → list[qtics.instruments.oxford.proteox.states.StateMatch][source]#

Evaluate all recognized states using EXCLUSIVE matching.

async read_signals() → dict[str, Any][source]#

Collect all raw values needed to evaluate state conditions.

class qtics.instruments.oxford.proteox.states.StateMatch(state_name: str, matched: bool, missing_true_conditions: list[str], violating_false_conditions: list[str], satisfied_true_conditions: list[str], satisfied_false_conditions: list[str], mismatch_count: int)[source]#

Bases: object

Result for one candidate state.

matched: bool#
mismatch_count: int#
missing_true_conditions: list[str]#
satisfied_false_conditions: list[str]#
satisfied_true_conditions: list[str]#
state_name: str#
violating_false_conditions: list[str]#
qtics.instruments.oxford.proteox.states.build_conditions() → dict[str, qtics.instruments.oxford.proteox.states.Condition][source]#

Define all boolean conditions used by the Proteox recognized-state table.

You should adapt / refine these once the exact raw API signals are confirmed.

qtics.instruments.oxford.proteox.states.state(true_conditions: list[str]) → dict[str, list[str]][source]#

Exclusive-state helper.

Every condition not explicitly listed as True is assumed False. This is the correct interpretation if your Proteox truth table is exclusive.

qtics.instruments.oxford.proteox.uris module#

URI and state mapping.