ChimeraTK-ApplicationCore  04.01.00
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 
24 namespace ctk = ChimeraTK;
25 
27 class ExampleApp : public ctk::Application {
28  public:
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.
45  ctk::VersionInfoProvider vip{this};
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 {
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 };
ChimeraTK::VersionInfoProvider
This module can be added to applications to provide version information from the CMakeLists....
Definition: VersionInfoProvider.h:23
ChimeraTK::ConfigReader::get
const T & get(const std::string &variableName) const
Get value for given configuration variable.
Definition: ConfigReader.h:248
AverageCurrent
[Snippet: Class Definition]
Definition: AverageCurrent.h:19
ExampleApp::~ExampleApp
~ExampleApp() override
[Snippet: Destructor]
Definition: ExampleApp.cc:18
ChimeraTK::ScriptedInitHandler
Initialisation handler which calls an external application (usually a script), captures its output (b...
Definition: ScriptedInitialisationHandler.h:34
ExampleApp
[Snippet: Class Definition Start]
Definition: ExampleApp.h:27
ChimeraTK::ModuleGroup
Definition: ModuleGroup.h:16
Controller.h
ChimeraTK::ModuleGroup::ModuleGroup
ModuleGroup()=default
Default constructor to allow late initialisation of module groups.
ChimeraTK::DeviceModule
Definition: DeviceModule.h:20
ChimeraTK::Application::getConfigReader
ConfigReader & getConfigReader()
Definition: Application.h:189
Controller
[Snippet: Class Definition]
Definition: Controller.h:19
ChimeraTK::SetDMapFilePath
Helper class to set the DMAP file path.
Definition: DeviceModule.h:94
AverageCurrent.h
ovenInit
Definition: ovenInit.py:1
SetpointRamp.h
ChimeraTK::ModuleGroup::Application
friend class Application
Definition: ModuleGroup.h:47
SetpointRamp
Definition: SetpointRamp.h:18
ChimeraTK
InvalidityTracer application module.
Definition: spec_dataValidityPropagation.dox:2
ChimeraTK::EntityOwner::getName
const std::string & getName() const
Get the name of the module instance.
Definition: EntityOwner.h:59
ChimeraTK::Application
Definition: Application.h:48
ChimeraTK::PeriodicTrigger
Simple periodic trigger that fires a variable once per second.
Definition: PeriodicTrigger.h:16