ChimeraTK-ApplicationCore  04.01.00
Status Monitor

To monitor a status of a varaible in an appplicaiton this group of modules provides different possiblites. It includes

  • MaxMonitor to monitor a value depending upon two MAX thresholds for warning and fault.
  • MinMonitor to monitor a value depending upon two MIN thresholds for warning and fault.
  • RangeMonitor to monitor a value depending upon two ranges of thresholds for warning and fault.
  • ExactMonitor to monitor a value which should be exactly same as required value. Depending upon the value and condition on of the four states are reported.
  • OFF, OK, WARNING, FAULT.

Checkout the status monitor example to see in detail how it works.

// SPDX-FileCopyrightText: Deutsches Elektronen-Synchrotron DESY, MSK, ChimeraTK Project <chimeratk-support@desy.de>
// SPDX-License-Identifier: LGPL-3.0-or-later
#include <ChimeraTK/ApplicationCore/ApplicationCore.h>
#include <ChimeraTK/ApplicationCore/EnableXMLGenerator.h>
#include <ChimeraTK/ApplicationCore/ModuleGroup.h>
#include <ChimeraTK/ApplicationCore/StatusMonitor.h>
namespace ctk = ChimeraTK;
// Just simulate a temperature going up and down
ctk::ScalarOutput<double> temperature{this, "temperature", "degC", "simulated temperature"};
void mainLoop() {
double direction = 1;
while(true) {
// go down with the temperature if too hot
if(temperature > 50) {
direction = -1;
}
// go up with the temperature if too cold
if(temperature < -50) {
direction = 1;
}
temperature += direction * 1; // one dregree steps
setCurrentVersionNumber({}); // We generate data without trigger or other input.
// So we must update the version number manually.
// This automatically updates the time stamp as well.
usleep(100000);
}
}
};
struct ExampleApp : public ctk::Application {
ExampleApp() : Application("exampleApp") {
// show how it looks in the application (C++ hierarchy)
dump();
// show how it looks on the cs side (virtual hierarchy)
// cs.dump();
// show how it is connected
dumpConnections();
}
// Create an instance of the simulation module. We name it "Simulation".
// There will be a variable /Simulation/temperature from this.
SimulationModule simulation{this, "Simulation", "temperature simulation"};
// Now we place a monitor next to the temperature variable. First we create a module group, also with the name
// "Simulation". Everything in it will be placed next to the variables from the simulation module.
struct : ctk::ModuleGroup {
// Inside the module group we place the monitor. In the constructor it gets the name of the variable to monitor, and
// the name of the output variable. The monitor automatically connects to the input variable that is in the same
// hierarchy level. We add output and parameter tags (STATUS and CONFIG, respectively) for easier connetion of the
// variables.
// ctk::RangeMonitor<double> temperatureMonitor{this, "TemperatureMonitor", "monitor for the simulated temperature",
// "temperature", "temperatureStatus", ctk::HierarchyModifier::none, {"STATUS"}, {"CONFIG"}, {}};
ctk::RangeMonitor<double> temperatureMonitor{this, "/TemperatureMonitor/temperature",
"/TemperatureMonitor/temperatureStatus", "/TemperatureMonitor", "monitor for the simulated temperature",
ctk::TAGS{"MON_OUTPUT"}, ctk::TAGS{"MON_PARAMS"}};
} simulationGroup{this, "Simulation", ""};
ctk::ConfigReader config{this, "Config", "demoStatusMonitor_config.xml"};
// ctk::ControlSystemModule cs;
// void defineConnections();
};
// void ExampleApp::defineConnections() {
// // Usually you set the dmap file here. This example does not have one.
// // Connect everything in the app to the cs. This makes the connection of temperature from Simulation to the input of
// // the monitor because they are the same variable in the CS module. Also the disable variable if the monitor is
// // connected to the CS. Try what happens if you disable the monitor.
// findTag(".*").connectTo(cs);
// /* The trick of connecting the temperature automatically only worked because we put the temperatureMonitor into the
// * correct place in the hierarchy by putting it into the variable group "Simulation". However, the threshold
// * parameters inside the monitor are not connected yet.
// *
// * When connecting the app, the config created the following variables:
// * /Config/TemperatureMonitor/lowerWarningThreshold
// * /Config/TemperatureMonitor/upperWarningThreshold
// * /Config/TemperatureMonitor/lowerFaultThreshold
// * /Config/TemperatureMonitor/upperFaultThreshold
// */
// // Now we connect the parameters of the temperature monitor to the control system, right into the Config directory so
// // the variable names match. Like this the parameters are connected to the values coming from the configuration.
// findTag("CONFIG").flatten().connectTo(cs["Config"]["TemperatureMonitor"]);
// // FIXME: At this point a status aggregator would connect everything with tag STATUS
// // show how it looks in the application (C++ hierarchy)
// dump();
// // show how it looks on the cs side (virtual hierarchy)
// cs.dump();
// // show how it is connected
// dumpConnections();
//}
ChimeraTK::ConfigReader
Generic module to read an XML config file and provide the defined values as constant variables.
Definition: ConfigReader.h:113
SimulationModule
Example to simulate the working and usage of StatusMonitor.
Definition: demoStatusMonitor.cc:18
ChimeraTK::Application::shutdown
void shutdown() override
This will remove the global pointer to the instance and allows creating another instance afterwards.
Definition: Application.cc:207
ExampleApp::~ExampleApp
~ExampleApp() override
[Snippet: Destructor]
Definition: ExampleApp.cc:18
ChimeraTK::EntityOwner::dump
void dump(const std::string &prefix="", std::ostream &stream=std::cout) const
Print the full hierarchy to given stream.
Definition: EntityOwner.cc:106
ExampleApp
[Snippet: Class Definition Start]
Definition: ExampleApp.h:27
theExampleApp
ExampleApp theExampleApp
Definition: demoStatusMonitor.cc:89
ChimeraTK::TAGS
const std::unordered_set< std::string > TAGS
Convenience type definition which can optionally be used as a shortcut for the type which defines a l...
Definition: EntityOwner.h:27
ChimeraTK::ModuleGroup
Definition: ModuleGroup.h:16
ChimeraTK::ModuleGroup::ModuleGroup
ModuleGroup()=default
Default constructor to allow late initialisation of module groups.
SimulationModule::mainLoop
void mainLoop()
To be implemented by the user: function called in a separate thread executing the main loop of the mo...
Definition: demoStatusMonitor.cc:24
ChimeraTK::ApplicationModule::setCurrentVersionNumber
void setCurrentVersionNumber(VersionNumber versionNumber) override
Set the current version number.
Definition: ApplicationModule.cc:89
ExampleApp::config
ctk::ConfigReader config
Definition: demoStatusMonitor.cc:84
ChimeraTK::ApplicationModule
Definition: ApplicationModule.h:24
ExampleApp::temperatureMonitor
ctk::RangeMonitor< double > temperatureMonitor
Definition: demoStatusMonitor.cc:78
SimulationModule::temperature
ctk::ScalarOutput< double > temperature
The value to be monitored.
Definition: demoStatusMonitor.cc:22
ExampleApp::ExampleApp
ExampleApp()
Definition: demoStatusMonitor.cc:51
ChimeraTK::ModuleGroup::Application
friend class Application
Definition: ModuleGroup.h:47
ChimeraTK::ScalarAccessor::write
bool write(ChimeraTK::VersionNumber versionNumber)=delete
ExampleApp::simulation
SimulationModule simulation
Definition: demoStatusMonitor.cc:65
ChimeraTK::ApplicationModule::ApplicationModule
ApplicationModule()=default
Default constructor: Allows late initialisation of modules (e.g.
ChimeraTK::RangeMonitor< double >
ChimeraTK
InvalidityTracer application module.
Definition: spec_dataValidityPropagation.dox:2
ChimeraTK::ScalarOutput< double >
ChimeraTK::Application
Definition: Application.h:48