109 return "<ScalarAccessor(not initialized)>";
112 std::string rep{
"<ScalarAccessor(type="};
113 rep.append(py::cast<py::object>(py::cast(&acc).attr(
"getValueType")()).attr(
"__repr__")().cast<std::string>());
114 rep.append(
", name=");
115 rep.append(py::cast(&acc).attr(
"getName")().cast<std::string>());
116 rep.append(
", data=");
117 rep.append(py::cast<py::object>(py::cast(&acc).attr(
"__str__")()).cast<std::string>());
118 rep.append(
", versionNumber=");
119 rep.append(py::cast<py::object>(py::cast(&acc).attr(
"getVersionNumber")()).attr(
"__repr__")().cast<std::string>());
120 rep.append(
", dataValidity=");
121 rep.append(py::cast<py::object>(py::cast(&acc).attr(
"dataValidity")()).attr(
"__repr__")().cast<std::string>());
131 py::class_<PyScalarAccessor, PyTransferElementBase, std::unique_ptr<PyScalarAccessor, py::nodelete>> scalaracc(
132 m,
"ScalarAccessor", py::buffer_protocol());
133 scalaracc.def(py::init<>())
135 "Read the data from the device.\n\nIf AccessMode::wait_for_new_data was set, this function will block "
136 "until new data has arrived. Otherwise it still might block for a short time until the data transfer was "
139 "Read the next value, if available in the input buffer.\n\nIf AccessMode::wait_for_new_data was set, this "
140 "function returns immediately and the return value indicated if a new value was available (true) or not "
141 "(false).\n\nIf AccessMode::wait_for_new_data was not set, this function is identical to read(), which "
142 "will still return quickly. Depending on the actual transfer implementation, the backend might need to "
143 "transfer data to obtain the current value before returning. Also this function is not guaranteed to be "
144 "lock free. The return value will be always true in this mode.")
146 "Read the latest value, discarding any other update since the last read if present.\n\nOtherwise this "
147 "function is identical to readNonBlocking(), i.e. it will never wait for new values and it will return "
148 "whether a new value was available if AccessMode::wait_for_new_data is set.")
151 "Returns the engineering unit.\n\nIf none was specified, it will default to ' n./ a.'")
154 "Returns the std::type_info for the value type of this transfer element.\n\nThis can be used to determine "
155 "the type at runtime.")
157 "Returns the version number that is associated with the last transfer (i.e. last read or write)")
159 "Check if transfer element is read only, i.e. it is readable but not writeable.")
163 "Obtain unique ID for the actual implementation of this TransferElement.\n\nThis means that e.g. two "
164 "instances of ScalarRegisterAccessor created by the same call to Device::getScalarRegisterAccessor() (e.g. "
165 "by copying the accessor to another using NDRegisterAccessorBridge::replace()) will have the same ID, "
166 "while two instances obtained by to difference calls to Device::getScalarRegisterAccessor() will have a "
167 "different ID even when accessing the very same register.")
169 "Return current validity of the data.\n\nWill always return DataValidity.ok if the backend does not "
176 "Write the data to device.\n\nThe return value is true, old data was lost on the write transfer (e.g. due "
177 "to an buffer overflow). In case of an unbuffered write transfer, the return value will always be false.")
179 "Just like write(), but allows the implementation to destroy the content of the user buffer in the "
180 "process.\n\nThis is an optional optimisation, hence there is a default implementation which just calls "
181 "the normal doWriteTransfer(). In any case, the application must expect the user buffer of the "
182 "TransferElement to contain undefined data after calling this function.")
184 "Convenience function to set and write new value if it differes from the current value.\n\nThe given "
185 "version number is only used in case the value differs. If versionNumber == {nullptr}, a new version "
186 "number is generated only if the write actually takes place.",
189 "Convenience function to set and write new value.\n\nThe given version number. If versionNumber == {}, a "
190 "new version number is generated.",
196 return py::cast<py::object>(py::cast(acc).attr(
"get")()).attr(fn.c_str())(py::cast(other).attr(
"get")());
199 return py::cast<py::object>(py::cast(acc).attr(
"get")()).attr(fn.c_str())(other);
204 scalaracc.def(fn.c_str(),
205 [fn](
PyScalarAccessor& acc) {
return py::cast<py::object>(py::cast(acc).attr(
"get")()).attr(fn.c_str())(); });
213 [](ChimeraTK::DataType type,
VariableGroup& owner,
const std::string& name,
const std::string& unit,
214 const std::string& description) {
215 return dynamic_cast<PyOwningObject&
>(owner).make_child<PyScalarAccessor>(
218 py::return_value_policy::reference,
"");
225 [](ChimeraTK::DataType type,
VariableGroup& owner,
const std::string& name,
const std::string& unit,
226 const std::string& description) {
227 return dynamic_cast<PyOwningObject&
>(owner).make_child<PyScalarAccessor>(
230 py::return_value_policy::reference,
"");
237 [](ChimeraTK::DataType type,
VariableGroup& owner,
const std::string& name,
const std::string& unit,
238 const std::string& description) {
239 return dynamic_cast<PyOwningObject&
>(owner).make_child<PyScalarAccessor>(
242 py::return_value_policy::reference,
"");
249 [](ChimeraTK::DataType type,
VariableGroup& owner,
const std::string& name,
const std::string& unit,
250 const std::string& description) {
251 return dynamic_cast<PyOwningObject&
>(owner).make_child<PyScalarAccessor>(
254 py::return_value_policy::reference,
"");
260 "ScalarOutputPushRB",
261 [](ChimeraTK::DataType type,
VariableGroup& owner,
const std::string& name,
const std::string& unit,
262 const std::string& description) {
263 return dynamic_cast<PyOwningObject&
>(owner).make_child<PyScalarAccessor>(
266 py::return_value_policy::reference,
"");
272 "ScalarOutputReverseRecovery",
273 [](ChimeraTK::DataType type,
VariableGroup& owner,
const std::string& name,
const std::string& unit,
274 const std::string& description) {
275 return dynamic_cast<PyOwningObject&
>(owner).make_child<PyScalarAccessor>(
278 py::return_value_policy::reference,
"");