deviceaccess.OneDRegisterAccessor
- class deviceaccess.OneDRegisterAccessor
Bases:
TransferElementBaseAccessor class to read and write registers transparently by using the accessor object like a numpy array.
Conversion to and from the UserType will be handled by a data converter matching the register description in the map (if applicable).
Note
Transfers between the device and the internal buffer need to be triggered using the read() and write() functions before reading from resp. after writing to the buffer.
- __init__(self: deviceaccess.OneDRegisterAccessor) None
Methods
__init__(self)dataValidity(self)Return current validity of the data.
get(self)Return the register data as an array (without a previous read).
getAccessModeFlags(self)Return the access mode flags that were used to create this accessor.
getAsCooked(self, element)Get the cooked values in case the accessor is a raw accessor (which does not do data conversion).
getDescription(self)Return the description of this variable/register.
getId(self)Obtain unique ID for the actual implementation of this accessor.
getNElements(self)Return number of elements/samples in the register.
getName(self)Return the name that identifies the process variable.
getUnit(self)Return the engineering unit.
getValueType(self)Return the numpy dtype for the value type of this accessor.
getVersionNumber(self)Return the version number that is associated with the last transfer.
interrupt(self)Interrupt a blocking read operation.
isInitialised(self)Check if the accessor is initialised.
isReadOnly(self)Check if accessor is read only.
isReadable(self)Check if accessor is readable.
isWriteable(self)Check if accessor is writeable.
read(self)Read the data from the device.
readAndGet(self)Convenience function to read and return the register data.
readLatest(self)Read the latest value, discarding any other update since the last read if present.
readNonBlocking(self)Read the next value, if available in the input buffer.
set(self, newValue, List[int], List[int], ...)Set the values of the array.
setAndWrite(self, newValue, List[int], ...)Convenience function to set and write new value.
setAsCooked(self, element, value, int, int, ...)Set the cooked values in case the accessor is a raw accessor (which does not do data conversion).
setDataValidity(self, validity)Set the data validity of the accessor.
write(self, versionNumber)Write the data to device.
writeDestructively(self, versionNumber)Just like write(), but allows the implementation to destroy the content of the user buffer in the process.
- __init__(self: deviceaccess.OneDRegisterAccessor) None
- dataValidity(self: deviceaccess.OneDRegisterAccessor) ChimeraTK::DataValidity
Return current validity of the data.
Will always return DataValidity.ok if the backend does not support it.
- Returns:
DataValidity: The current data validity state.
- get(self: deviceaccess.OneDRegisterAccessor) object
Return the register data as an array (without a previous read).
- Returns:
ndarray: Array containing the register data.
- getAccessModeFlags(self: deviceaccess.OneDRegisterAccessor) list
Return the access mode flags that were used to create this accessor.
This can be used to determine the setting of the raw and the wait_for_new_data flags.
- Returns:
list[AccessMode]: List of access mode flags.
- getAsCooked(self: deviceaccess.OneDRegisterAccessor, element: int) Union[ChimeraTK::Boolean, int, int, int, int, int, int, int, int, float, float, str]
Get the cooked values in case the accessor is a raw accessor (which does not do data conversion).
This returns the converted data from the user buffer. It does not do any read or write transfer.
- Args:
element (int): Element index to read.
- Returns:
int: The cooked value at the specified element.
- getDescription(self: deviceaccess.OneDRegisterAccessor) str
Return the description of this variable/register.
- Returns:
str: The description string.
- getId(self: deviceaccess.OneDRegisterAccessor) ChimeraTK::TransferElementID
Obtain unique ID for the actual implementation of this accessor.
This means that e.g. two instances of OneDRegisterAccessor created by the same call to Device.getOneDRegisterAccessor() will have the same ID, while two instances obtained by two different calls to Device.getOneDRegisterAccessor() will have a different ID even when accessing the very same register.
- Returns:
TransferElementID: The unique accessor ID.
- getNElements(self: deviceaccess.OneDRegisterAccessor) int
Return number of elements/samples in the register.
- Returns:
int: Number of elements in the register.
- getName(self: deviceaccess.OneDRegisterAccessor) str
Return the name that identifies the process variable.
- Returns:
str: The register name.
- getUnit(self: deviceaccess.OneDRegisterAccessor) str
Return the engineering unit.
If none was specified, it will default to ‘n./a.’.
- Returns:
str: The engineering unit string.
- getValueType(self: deviceaccess.OneDRegisterAccessor) dtype
Return the numpy dtype for the value type of this accessor.
This can be used to determine the type at runtime.
- Returns:
numpy.dtype: Type information object.
- getVersionNumber(self: deviceaccess.OneDRegisterAccessor) deviceaccess.VersionNumber
Return the version number that is associated with the last transfer.
This refers to the last read or write operation.
- Returns:
VersionNumber: The version number of the last transfer.
- interrupt(self: deviceaccess.OneDRegisterAccessor) None
Interrupt a blocking read operation.
This will cause a blocking read to return immediately and throw an InterruptedException.
- Returns:
None: This function does not return a value.
- isInitialised(self: deviceaccess.OneDRegisterAccessor) bool
Check if the accessor is initialised.
- Returns:
bool: True if initialised, false otherwise.
- isReadOnly(self: deviceaccess.OneDRegisterAccessor) bool
Check if accessor is read only.
This means it is readable but not writeable.
- Returns:
bool: True if read only, false otherwise.
- isReadable(self: deviceaccess.OneDRegisterAccessor) bool
Check if accessor is readable.
- Returns:
bool: True if readable, false otherwise.
- isWriteable(self: deviceaccess.OneDRegisterAccessor) bool
Check if accessor is writeable.
- Returns:
bool: True if writeable, false otherwise.
- read(self: deviceaccess.OneDRegisterAccessor) None
Read the data from the device.
If AccessMode.wait_for_new_data was set, this function will block until new data has arrived. Otherwise it still might block for a short time until the data transfer was complete.
- See Also:
readNonBlocking: Read without blocking if no data is available. readLatest: Read latest value while discarding intermediate updates. readAndGet: Convenience method combining read() and get().
- Returns:
None: This function does not return a value.
- readAndGet(self: deviceaccess.OneDRegisterAccessor) object
Convenience function to read and return the register data.
- Returns:
ndarray: Array containing the register data after reading.
- readLatest(self: deviceaccess.OneDRegisterAccessor) bool
Read the latest value, discarding any other update since the last read if present.
Otherwise this function is identical to readNonBlocking(), i.e. it will never wait for new values and it will return whether a new value was available if AccessMode.wait_for_new_data is set.
- Returns:
bool: True if new data was available, false otherwise.
- readNonBlocking(self: deviceaccess.OneDRegisterAccessor) bool
Read the next value, if available in the input buffer.
If AccessMode.wait_for_new_data was set, this function returns immediately and the return value indicates if a new value was available (true) or not (false).
If AccessMode.wait_for_new_data was not set, this function is identical to read(), which will still return quickly. Depending on the actual transfer implementation, the backend might need to transfer data to obtain the current value before returning. Also this function is not guaranteed to be lock free. The return value will be always true in this mode.
- Returns:
bool: True if new data was available, false otherwise.
- set(self: deviceaccess.OneDRegisterAccessor, newValue: Union[List[ChimeraTK::Boolean], List[int], List[int], List[int], List[int], List[int], List[int], List[int], List[int], List[float], List[float], List[str]]) None
Set the values of the array.
- Args:
newValue (list | ndarray): New values to set in the buffer.
- Returns:
None: This function does not return a value.
- setAndWrite(self: deviceaccess.OneDRegisterAccessor, newValue: Union[List[ChimeraTK::Boolean], List[int], List[int], List[int], List[int], List[int], List[int], List[int], List[int], List[float], List[float], List[str]], versionNumber: deviceaccess.VersionNumber = <PyVersionNumber(versionNumber=v0)>) None
Convenience function to set and write new value.
If versionNumber is not specified, a new version number is generated.
- Args:
newValue (list | ndarray): New values to set and write. versionNumber (VersionNumber): Optional version number for the write operation.
- Returns:
None: This function does not return a value.
- setAsCooked(self: deviceaccess.OneDRegisterAccessor, element: int, value: Union[ChimeraTK::Boolean, int, int, int, int, int, int, int, int, float, float, str]) None
Set the cooked values in case the accessor is a raw accessor (which does not do data conversion).
This converts to raw and writes the data to the user buffer. It does not do any read or write transfer.
- Args:
element (int): Element index to write. value (float): The cooked value to set.
- Returns:
None: This function does not return a value.
- setDataValidity(self: deviceaccess.OneDRegisterAccessor, validity: ChimeraTK::DataValidity) None
Set the data validity of the accessor.
- Args:
validity (DataValidity): The data validity state to set.
- Returns:
None: This function does not return a value.
- write(self: deviceaccess.OneDRegisterAccessor, versionNumber: deviceaccess.VersionNumberBase = <PyVersionNumber(versionNumber=v0)>) None
Write the data to device.
The return value is true if old data was lost on the write transfer (e.g. due to a buffer overflow). In case of an unbuffered write transfer, the return value will always be false.
- Args:
- versionNumber (VersionNumber): Version number to use for this write operation. If not specified,
a new version number is generated.
- Returns:
bool: True if data was lost, false otherwise.
- See Also:
setAndWrite: Convenience method combining set() and write(). writeDestructively: Optimized write that may destroy buffer.
- writeDestructively(self: deviceaccess.OneDRegisterAccessor, versionNumber: deviceaccess.VersionNumberBase = <PyVersionNumber(versionNumber=v0)>) None
Just like write(), but allows the implementation to destroy the content of the user buffer in the process.
This is an optional optimisation, hence there is a default implementation which just calls the normal write(). In any case, the application must expect the user buffer of the accessor to contain undefined data after calling this function.
- Args:
- versionNumber (VersionNumber): Version number to use for this write operation. If not specified,
a new version number is generated.
- Returns:
bool: True if data was lost, false otherwise.