ChimeraTK-ApplicationCore 04.06.00
Loading...
Searching...
No Matches
ExampleApp.h
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#pragma once
4
5/*
6 * This example is explained as part of the \ref conceptualOverview. Please refere there for step-by-step explanations.
7 * Reading the full example might not be a good starting point for learning ApplicationCore as it can be overwelming
8 * and lacks important background information.
9 *
10 * Please ignore all comments of the format "//! [some name]", those are used for Doxygen to include code snippets in
11 * the documentation pages.
12 */
13
14#include "AverageCurrent.h"
15#include "Controller.h"
16#include "SetpointRamp.h"
17
18#include <ChimeraTK/ApplicationCore/ApplicationCore.h>
19#include <ChimeraTK/ApplicationCore/ConfigReader.h>
20#include <ChimeraTK/ApplicationCore/PeriodicTrigger.h>
21#include <ChimeraTK/ApplicationCore/ScriptedInitialisationHandler.h>
22#include <ChimeraTK/ApplicationCore/VersionInfoProvider.h>
23
24namespace ctk = ChimeraTK;
25
28 public:
29 using ctk::Application::Application;
30 ~ExampleApp() override;
31
32 private:
34 // Set the name of the DMAP file to define the devices. Must be done before instantiating any DeviceModule.
35 // Using the application name as a base helps for automated testing against different config files.
37 ctk::SetDMapFilePath dmapPath{getName() + ".dmap"};
39
40 // Provide version information from the `CMakeLists.txt` as process variables
41 // Apart from the line below and the inclusion of the
42 // `#include <ChimeraTK/ApplicationCore/VersionInfoProvider.h>` line,
43 // The server is also expected to have a module named "Application"
44 // with a variable named "configPatchVersion" of type "int32" in its "config.xml" file.
46
47 // Periodic trigger used to readout data from the device periodically.
49 ctk::PeriodicTrigger timer{this, "Timer", "Periodic timer for the controller"};
51
52 // Publish the content of the device "oven" defined in the DMAP file to the control system and to the application
53 // modules. The "tick" output of the PeriodicTimer "Timer" defined above is used as a readout trigger (for all
54 // poll-typed device registers).
56 ctk::DeviceModule oven{this, "oven", "/Timer/tick"};
58
59 // Initialisation handler: execute Python script to initialise oven device
61 ctk::ScriptedInitHandler ovenInit{this, "ovenInit", "Initialisation of oven device", "./ovenInit.py", oven};
63
65 struct ControlUnit : ctk::ModuleGroup {
66 using ctk::ModuleGroup::ModuleGroup;
67
69 // Instantiate the temperature controller module
70 Controller controller{this, "Controller", "The temperature controller"};
72
74 // Instantiate the heater current averaging module
75 AverageCurrent averageCurrent{this, "AverageCurrent", "Provide averaged heater current"};
77 };
78 ControlUnit controlUnit{this, "ControlUnit", "Unit for controlling the oven temperature"};
80
81 // Optionally instantiate the automated setpoint ramping module
82 SetpointRamp ramp{getConfigReader().get<ChimeraTK::Boolean>("Configuration/enableSetpointRamping") ?
83 SetpointRamp(this, "SetpointRamp", "Slow ramping of temperator setpoint") :
84 SetpointRamp()};
86};
[Snippet: Class Definition]
ConfigReader & getConfigReader()
const T & get(std::string variableName) const
Get value for given configuration variable.
const std::string & getName() const
Get the name of the module instance.
Definition EntityOwner.h:59
Helper class to set the DMAP file path.
This module can be added to applications to provide version information from the CMakeLists....
[Snippet: Class Definition]
Definition Controller.h:19
[Snippet: Class Definition Start]
Definition ExampleApp.h:27
~ExampleApp() override
[Snippet: Destructor]
Definition ExampleApp.cc:18
InvalidityTracer application module.
Simple periodic trigger that fires a variable once per second.
Initialisation handler which calls an external application (usually a script), captures its output (b...