ChimeraTK-DeviceAccess
03.18.00
read_temperature_doocs_zmq.cpp
Go to the documentation of this file.
1
// SPDX-FileCopyrightText: Deutsches Elektronen-Synchrotron DESY, MSK, ChimeraTK Project <chimeratk-support@desy.de>
2
// SPDX-License-Identifier: LGPL-3.0-or-later
3
4
/* Unfortunately the DeviceAccess base package does not have a demo push type accessor we can use.
5
* That's why this code uses the Doocs backend. Use it together with example2 from ApplicationCore.
6
* You have to activate the zmq sending in the ApplicationCore example2 by using the configuration files
7
* demoApp2-DoocsVariableConfig.xml and demo_example2.conf, which are provided with this example.
8
*
9
* Compile this file by linking directly with the Doocs backend (for instance directly on the command line):
10
* g++ read_temperature_doocs_zmq.cpp -o read_temperature_doocs_zmq `ChimeraTK-DeviceAccess-config --cppflags
11
* --ldflags` -lpthread -Wl,--no-as-needed -lChimeraTK-DeviceAccess-DoocsBackend
12
*/
13
#include <ChimeraTK/Device.h>
14
15
#include <iostream>
16
17
int
main
() {
18
ChimeraTK::Device
d;
19
d.
open
(
"(doocs:TEST.DOOCS/LOCALHOST_610498009/Bakery)"
);
20
21
// You have to activate the receiving of asynchronousy send data before an accessor with AccessMode::wait_for_new_data
22
// will receive anything. You can first create all accessors and then activate all of them at the same point in time
23
// with this.
24
d.
activateAsyncRead
();
25
26
// The third argument is a list of ChimeraTK::AccessMode. We only have one argument in it:
27
// AccessMode::wait_for_new_data.
28
auto
temperature =
29
d.
getScalarRegisterAccessor
<
float
>(
"Oven.temperatureReadback"
, 0, {
ChimeraTK::AccessMode::wait_for_new_data
});
30
31
// The read now blocks until data is received. You can use it to syncrchonise your code to incoming data. No need for
32
// additional sleeps etc.
33
while
(
true
) {
34
temperature.read();
35
std ::cout <<
"The temperature is "
<< temperature <<
" degC. "
<< std ::endl;
36
}
37
}
ChimeraTK::Device::activateAsyncRead
void activateAsyncRead() noexcept
Activate asyncronous read for all transfer elements where AccessMode::wait_for_new_data is set.
Definition:
Device.cc:91
ChimeraTK::AccessMode::wait_for_new_data
@ wait_for_new_data
Make any read blocking until new data has arrived since the last read.
ChimeraTK::Device
Class allows to read/write registers from device.
Definition:
Device.h:39
ChimeraTK::Device::open
void open(std::string const &aliasName)
Open a device by the given alias name from the DMAP file.
Definition:
Device.cc:58
ChimeraTK::Device::getScalarRegisterAccessor
ScalarRegisterAccessor< UserType > getScalarRegisterAccessor(const RegisterPath ®isterPathName, size_t wordOffsetInRegister=0, const AccessModeFlags &flags=AccessModeFlags({})) const
Get a ScalarRegisterObject object for the given register.
Definition:
Device.h:263
main
int main()
Definition:
read_temperature_doocs_zmq.cpp:17
sources
ChimeraTK-DeviceAccess
examples
wait_for_new_data
read_temperature_doocs_zmq.cpp
Generated by
1.8.17