mpylab.device.multichannel_common module¶
Device-independent infrastructure for shared multi-channel drivers.
- class mpylab.device.multichannel_common.SharedController
Bases:
objectOwn one transport and register facades for one physical device.
- attach(client)
Register one facade and reject duplicate physical channels.
- Parameters:
client (SharedFacade) – Logical channel facade to register.
- Raises:
RuntimeError – If another facade already represents the same physical channel.
- close()
Close the physical transport once.
- invalidate_snapshot()
Discard a synchronized acquisition snapshot.
- read_by_acquisition_policy(channel, read_independent, read_synchronized)
Read one channel according to the configured acquisition policy.
In synchronized mode, one callback result is retained as a shared snapshot until every requested channel has consumed its entry.
- Parameters:
channel (int) – One-based physical channel number.
read_independent (callable) – Zero-argument callback that reads only the requested channel.
read_synchronized (callable) – Zero-argument callback that reads all channels into an indexable snapshot.
- Returns:
Value returned for the requested channel.
- Return type:
object
- Raises:
RuntimeError – If the configured acquisition policy is unsupported.
- release(client)
Detach a facade and close the transport after the final client.
- Parameters:
client (SharedFacade) – Logical channel facade to detach.
- Returns:
Trueif this was the final facade and the transport was closed.- Return type:
bool
- trigger()
Start a new logical synchronized acquisition generation.
- Returns:
Zero after invalidating the previous shared snapshot.
- Return type:
int
- class mpylab.device.multichannel_common.SharedFacade
Bases:
objectCommon lifecycle for logical facades sharing one controller.
- GetDescription()
Return the configured and physical instrument descriptions.
- Returns:
Status code and combined description string.
- Return type:
tuple of (int, str)
- Quit()
Release this facade and eventually close the shared transport.
- Returns:
Zero on success.
- Return type:
int
- classmethod reset_controllers()
Close and remove all shared controllers of this driver class.
- mpylab.device.multichannel_common.parse_acquisition(value, device_name, supported=frozenset({'independent', 'synchronized'}))
Normalize an acquisition policy and reject unsupported modes.
- Parameters:
value (str or None) – Requested acquisition policy. A missing value selects
independent.device_name (str) – Device name used in validation errors.
supported (collection of str, optional) – Acquisition policies supported by the concrete device.
- Returns:
Normalized acquisition policy.
- Return type:
str
- Raises:
ValueError – If the policy is unknown or unsupported by the device.
- mpylab.device.multichannel_common.retrigger_requested(value)
Normalize the boolean-like retrigger argument used by
GetDataNB.- Parameters:
value (bool, str, or None) – Boolean value or a common textual ON/OFF representation.
- Returns:
Normalized retrigger decision.
- Return type:
bool
- Raises:
ValueError – If value is not a recognized boolean representation.