Skip to content
Snippets Groups Projects
Commit 7b7c4da3 authored by Martin Christoph Hierholzer's avatar Martin Christoph Hierholzer
Browse files

added ControlSystemModule to provide access to control system variables

parent 07ce870d
No related branches found
No related tags found
No related merge requests found
......@@ -96,26 +96,21 @@ class MyApp : public ctk::Application {
ControlLoopModule controlLoop;
SimulatorModule simulator;
ctk::DeviceModule dev{"Dummy0", "MyModule"};
ctk::ControlSystemModule cs{"MyLocation"};
void initialise() {
mtca4u::BackendFactory::getInstance().setDMapFilePath("dummy.dmap");
ctrlVar("MyLocation/setpoint") >> automation.operatorSetpoint;
automation.loopSetpoint >> controlLoop.setpoint
>> ctrlVar("MyLocation/setpoint_automation");
automation.loopSetpoint >> controlLoop.setpoint >> cs("setpoint_automation");
controlLoop.actuator >> dev("Variable")
>> ctrlVar("MyLocation/actuatorLoop");
controlLoop.actuator >> dev("Variable") >> cs("actuatorLoop");
dev("Variable") [ controlLoop.actuator ] >> simulator.actuator
>> ctrlVar("MyLocation/actuatorSimulator");
dev("Variable") [ controlLoop.actuator ] >> simulator.actuator >> cs("actuatorSimulator");
// this will create an independent variable network, thus also another accessor to the device
dev("Variable", typeid(double)) [ controlLoop.actuator ] >> ctrlVar("MyLocation/actuatorSimulator_direct");
dev("Variable", typeid(double)) [ controlLoop.actuator ] >> cs("actuatorSimulator_direct");
simulator.readback >> controlLoop.readback
>> ctrlVar("MyLocation/readback")
>> ctrlVar("MyLocation/readback_another_time");
simulator.readback >> controlLoop.readback >> cs("readback") >> cs("readback_another_time");
dumpConnections();
}
......
......@@ -12,6 +12,7 @@
#include "ScalarAccessor.h"
#include "ApplicationModule.h"
#include "DeviceModule.h"
#include "ControlSystemModule.h"
#ifndef CHIMERATK_APPLICATION_CORE_H
#define CHIMERATK_APPLICATION_CORE_H
......
/*
* ControlSystemModule.h
*
* Created on: Jun 28, 2016
* Author: Martin Hierholzer
*/
#ifndef CHIMERATK_CONTROL_SYSTEM_MODULE_H
#define CHIMERATK_CONTROL_SYSTEM_MODULE_H
#include <mtca4u/RegisterPath.h>
#include "VariableNetworkNode.h"
#include "Module.h"
namespace ChimeraTK {
class ControlSystemModule : public Module {
public:
/** Constructor: the optional variableNamePrefix will be prepended to all control system variable names
* (separated by a slash). */
ControlSystemModule(const std::string& variableNamePrefix="");
/** The subscript operator returns a VariableNetworkNode which can be used in the Application::initialise()
* function to connect the control system variable with another variable. */
VariableNetworkNode operator()(const std::string& variableName, const std::type_info &valueType=typeid(AnyType));
protected:
mtca4u::RegisterPath variableNamePrefix;
};
} /* namespace ChimeraTK */
#endif /* CHIMERATK_CONTROL_SYSTEM_MODULE_H */
......@@ -22,7 +22,8 @@ namespace ChimeraTK {
public:
/** Constructor: The device represented by this DeviceModule is identified by either the device alias found
* in the DMAP file or directly an URI. The given optional prefix will be prepended to all register names. */
* in the DMAP file or directly an URI. The given optional prefix will be prepended to all register names
* (separated by a slash). */
DeviceModule(const std::string& deviceAliasOrURI, const std::string& registerNamePrefix="");
/** The subscript operator returns a VariableNetworkNode which can be used in the Application::initialise()
......
/*
* ControlSystemModule.cc
*
* Created on: Jun 28, 2016
* Author: Martin Hierholzer
*/
#include "Application.h"
#include "ControlSystemModule.h"
namespace ChimeraTK {
ControlSystemModule::ControlSystemModule(const std::string& _variableNamePrefix)
: variableNamePrefix(_variableNamePrefix)
{
}
/*********************************************************************************************************************/
VariableNetworkNode ControlSystemModule::operator()(const std::string& variableName, const std::type_info &valueType) {
return{variableNamePrefix/variableName, VariableDirection::invalid, valueType};
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment