qmi.instruments.adwin.adwin
Instrument driver for the Adwin.
This driver requires that the ADwin library and ADwin Python module are installed on the system.
On Linux, the ADwin system library must be at least version 5.0.13. Earlier versions do not correctly support double-precision floating point data from the Adwin T12. On Windows, library version 6.0.x should be used.
Classes
|
Instrument driver base class for the Adwin real-time microcontrollers. |
- class qmi.instruments.adwin.adwin.Adwin_Base(context: QMI_Context, name: str, device_no: int)
Instrument driver base class for the Adwin real-time microcontrollers. ADwin.py has fixed maximum number of parameters and data that are dependent on processor type. The ‘MAX_m’ values here are valid for at least the T11, T12 and T12.1 processor types. The maximum number of slots instead is dependent on the enclosure type of the ADwin.
- reboot() None
Reboot the Adwin system, clear data and restart programs.
This function must be called after power-on before communication with the Adwin is possible. This function may be called again to perform a full reset.
This function boots the Adwin, removes all processes and data.
- check_ready() None
Raise an exception if the Adwin is not ready.
- get_processor_type() str
Returns the ADwin processor type.
- get_workload() int
Return average processor workload in percent since the last call.
- load_process(bin_file: str) None
Load the specified Adwin process but do not start it yet.
- Parameters:
bin_file – Path to binary file to load into the Adwin.
- start_process(slot: int) None
Start the specified Adwin process.
The process must already have been loaded by calling load_process().
- Parameters:
slot – Adwin process slot index (range 1 to MAX_PROCESS_NO).
- stop_process(slot: int) None
Stop the specified Adwin process.
- Parameters:
slot – Adwin process slot index (range 1 to MAX_PROCESS_NO).
- wait_for_process(slot: int, timeout: float) None
Wait until the specified Adwin process has stopped.
- Parameters:
slot – Adwin process slot index (range 1 to MAX_PROCESS_NO).
timeout – Maximum time to wait (seconds).
- Raises:
QMI_TimeoutException – If the process does not stop before timeout occurs.
- is_process_running(slot: int) bool
Return True if the specified Adwin process is currently running.
- Parameters:
slot – Adwin process slot index (range 1 to MAX_PROCESS_NO).
- get_par(par_idx: int) int
Return the current value of the specified global parameter.
- Parameters:
par_idx – Index into the global Par array (range 1 to MAX_PAR).
- Returns:
Value of the parameter.
- get_fpar(par_idx: int) float
Return the current value of the specified global parameter.
- Parameters:
par_idx – Index into the global FPar array (range 1 to MAX_PAR).
- Returns:
Value of the parameter.
- get_par_block(par_first: int, par_count: int) ndarray
Return the current values of a block of global parameters.
- Parameters:
par_first – First index into the global Par array (range 1 to MAX_PAR).
par_count – Number of parameters to get.
- Returns:
1D Numpy array with the parameter values.
- get_fpar_block(par_first: int, par_count: int) ndarray
Return the current values of a block of global parameters.
- Parameters:
par_first – First index into the global FPar array (range 1 to MAX_PAR).
par_count – Number of parameters to get.
- Returns:
1D Numpy array with the parameter values.
- set_par(par_idx: int, value: int) None
Change the value of the specified global parameter.
- Parameters:
par_idx – Index into the global Par array (range 1 to MAX_PAR).
value – New value to write to the parameter (signed 32-bit integer).
- set_fpar(par_idx: int, value: float) None
Change the value of the specified global parameter.
- Parameters:
par_idx – Index into the global FPar array (range 1 to MAX_PAR).
value – New value to write to the parameter.
- get_data_length(data_idx: int) int
Return the length of the specified global Data array.
- Parameters:
data_idx – Index into the global list of Data arrays (range 1 to MAX_DATA).
- Returns:
Length of the data array (maximum valid array index).
- get_data(data_idx: int, first_index: int, count: int) ndarray
Read values from a global Data array.
- Parameters:
data_idx – Index into the global list of Data arrays (range 1 to MAX_DATA).
first_index – First index into the data array (>= 1).
count – Number of elements to read from the data array.
- Returns:
1D Numpy array with data values. Element 0 of the returned array will correspond with first_index into the Adwin array.
- get_full_data(data_idx: int) ndarray
Read all elements from a global DATA array.
- Parameters:
data_idx – Index into the global list of Data arrays (range 1 to MAX_DATA).
- Returns:
1D Numpy array with data values. Element 0 of the returned array will correspond with element 1 into the Adwin array.
- set_data(data_idx: int, first_index: int, value: ndarray | List[int] | List[float]) None
Write values to a global Data array.
- Parameters:
data_idx – Index into the global list of Data arrays (range 1 to MAX_DATA).
first_index – First index into the Data array (>= 1).
value – List of values to write to the Data array.
- get_fifo_filled(data_idx: int) int
Return the number of values waiting in the FIFO.
- Parameters:
data_idx – Index into the global list of Data arrays (range 1 to MAX_DATA).
- Returns:
Number of FIFO entries currently in use.
- get_fifo_room(data_idx: int) int
Return the number of values that can be added to the FIFO without overflowing it.
- Parameters:
data_idx – Index into the global list of Data arrays (range 1 to MAX_DATA).
- Returns:
Number of empty FIFO entries available.
- read_fifo(data_idx: int, count: int) ndarray
Read data from a global FIFO variable.
- Parameters:
data_idx – Index into the global list of Data arrays (range 1 to MAX_DATA).
count – Number of values to read from the FIFO.
- Returns:
1D Numpy array containing the FIFO elements.
- write_fifo(data_idx: int, value: ndarray | List[int] | List[float]) None
Write data to a global FIFO variable.
- Parameters:
data_idx – Index into the global list of Data arrays (range 1 to MAX_DATA).
value – Array of values to write to the FIFO.
- close() None
Close the connection to the instrument hardware and release associated resources.
When this method returns, the instrument must not be used again unless it is first re-opened by calling the open() method.
Subclasses can extend this method if they have specific resources to close. If they do, they should call
super().close()as a last statement.
- force_unlock() None
Forcefully unlock the remote object.
This unlocks the object, regardless of who owns the lock. This allows you to unlock an object if the locking proxy has been destroyed without unlocking.
Use this with care.
Do not override this stub method in subclasses. It has already been implemented in QMI_RpcProxy.
- classmethod get_category() str | None
Return the optional name of the category this object belongs to.
A category name is a free-form string that has no special significance. Its purpose is to distinguish between groups of RPC objects that fulfill similar roles.
- get_name() str
Return the name of this object.
- Returns:
name attribute.
- get_signals() list[SignalDescription]
Return a list of signals that can be published by this object.
- Returns:
List consisting of qmi_signals attributes.
- is_locked() bool
Query if the remote object is locked.
Do not override this stub method in subclasses. It has already been implemented in QMI_RpcProxy.
- is_open() bool
Return True if the instrument is open (ready for interaction).
- lock(timeout: float = 0.0, lock_token: str | None = None) bool
Lock the remote object. If timeout is given, try every 0.1s within the given timeout value. The remote object can be locked with an optional custom lock token by giving a string into lock_token keyword argument.
If successful, this proxy is the only proxy that can invoke RPC methods on the remote object; other proxies will receive an “object is locked” response. The return value indicates if the lock was granted; a denied lock means the object was already locked by another proxy.
Do not override this stub method in subclasses. It has already been implemented in QMI_RpcProxy.
- open() None
Connect to the instrument hardware.
When this method returns, the instrument must be ready for interaction via calls to instrument-specific methods.
Subclasses can extend this method to implement instrument-specific initialization. If they do, they should call
super().open()as a last statement.
- release_rpc_object() None
Give a warning if the instrument is removed while still open.
- set_file_to_data(data_idx: int, first_index: int, file_path: str) None
Upload the file at file_path to the specified array. This method is used to load binary programs into TiCo modules at ADwin runtime.
- Parameters:
data_idx – Index into the global list of Data arrays (range 1 to MAX_DATA).
first_index – First index into the Data array (>= 1).
file_path – Path of the file to upload.
- unlock(lock_token: str | None = None) bool
Unlock the remote object.
Without optional parameters, this is only allowed by the proxy that initially locked the object. By giving the lock token as an input parameter, the specific object locked by this token can be unlocked. The return value indicates if the unlocking was successful.
Do not override this stub method in subclasses. It has already been implemented in QMI_RpcProxy.