ChimeraTK-ApplicationCore 04.06.00
Loading...
Searching...
No Matches
ConnectionMaker.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#include "FanOut.h"
6#include "Model.h"
8
9#include <list>
10
11namespace ChimeraTK {
12 class Application;
13 class TriggerFanOut;
14
15 /********************************************************************************************************************/
16
18 public:
19 explicit NetworkVisitor(Application& app) : _app(app) {}
20
21 void setDebugConnections(bool enable) { _debugConnections = enable; }
22
31
32 protected:
35
37 // Variables related to the current network
39 std::map<std::string, boost::shared_ptr<TriggerFanOut>> triggerImpl;
40 std::list<VariableNetworkNode> consumers;
41 const std::type_info* valueType{&typeid(AnyType)};
42 size_t valueLength{0};
43 std::string description;
44 std::string unit;
48 bool useExternalTrigger{false};
49 bool useReverseRecovery{false};
50 };
51 std::set<std::string> _triggerNetworks{};
52 std::map<std::string, NetworkInformation> _networks{};
53 bool _debugConnections{false};
54
55 NetworkInformation checkNetwork(Model::ProcessVariableProxy& proxy);
56 void finaliseNetwork(NetworkInformation& net);
58
59 template<typename UserType>
60 void createProcessVariable(const VariableNetworkNode& node, size_t length, const std::string& unit,
61 const std::string& description, AccessModeFlags flags);
62
63 template<typename... Args>
64 void debug(Args&&...);
65
66 // Map of control system PVs with decorator
67 template<typename UserType>
68 using AccessorMap = std::map<std::string, boost::shared_ptr<ChimeraTK::NDRegisterAccessor<UserType>>>;
69 mutable ChimeraTK::TemplateUserTypeMap<AccessorMap> _decoratedPvImpls;
70
72 };
73
74 /********************************************************************************************************************/
75
77 public:
79
86 void finalise();
87
91 void optimiseUnmappedVariables(const std::set<std::string>& names);
92
98 void connect();
99
100 private:
101 std::set<Model::ProcessVariableProxy, ProcessVariableComperator> _triggers;
102
103 void connectNetwork(Model::ProcessVariableProxy& proxy);
104
105 void makeDirectConnectionForFeederWithImplementation(NetworkInformation& net);
106 void makeFanOutConnectionForFeederWithImplementation(
107 NetworkInformation& net, const Model::DeviceModuleProxy& device, const Model::ProcessVariableProxy& trigger);
108 void makeConnectionForFeederWithoutImplementation(NetworkInformation& net);
109 void makeConnectionForConstantFeeder(NetworkInformation& net);
110
111 template<typename UserType>
112 boost::shared_ptr<ChimeraTK::NDRegisterAccessor<UserType>> getProcessVariable(const VariableNetworkNode& node);
113
114 template<typename UserType>
115 boost::shared_ptr<ChimeraTK::NDRegisterAccessor<UserType>> createDeviceVariable(VariableNetworkNode const& node);
116
117 template<typename UserType>
118 ConsumerImplementationPairs<UserType> setConsumerImplementations(NetworkInformation& net);
119
120 template<typename UserType>
121 std::pair<boost::shared_ptr<ChimeraTK::NDRegisterAccessor<UserType>>,
122 boost::shared_ptr<ChimeraTK::NDRegisterAccessor<UserType>>>
123 createApplicationVariable(VariableNetworkNode const& node, VariableNetworkNode const& consumer = {});
124 };
125
126 /********************************************************************************************************************/
127
128} // namespace ChimeraTK
Pseudo type to identify nodes which can have arbitrary types.
void finalise()
Finalise the model and register all PVs with the control system adapter.
ConnectionMaker(Application &app)
void connect()
Realise connections.
void optimiseUnmappedVariables(const std::set< std::string > &names)
Execute the optimisation request from the control system adapter (remove unused variables)
std::string getFullyQualifiedPath() const
Return the fully qualified path.
Definition Model.cc:25
std::map< std::string, boost::shared_ptr< ChimeraTK::NDRegisterAccessor< UserType > > > AccessorMap
void debug(Args &&...)
void setDebugConnections(bool enable)
ChimeraTK::TemplateUserTypeMap< AccessorMap > _decoratedPvImpls
std::set< std::string > _triggerNetworks
NetworkInformation checkAndFinaliseNetwork(Model::ProcessVariableProxy &proxy)
void createProcessVariable(const VariableNetworkNode &node, size_t length, const std::string &unit, const std::string &description, AccessModeFlags flags)
NetworkVisitor(Application &app)
void finaliseNetwork(NetworkInformation &net)
std::map< std::string, NetworkInformation > _networks
NetworkInformation checkNetwork(Model::ProcessVariableProxy &proxy)
Class describing a node of a variable network.
InvalidityTracer application module.
std::list< std::pair< boost::shared_ptr< ChimeraTK::NDRegisterAccessor< UserType > >, VariableNetworkNode > > ConsumerImplementationPairs
Definition FanOut.h:18
const Model::ProcessVariableProxy * proxy
std::map< std::string, boost::shared_ptr< TriggerFanOut > > triggerImpl
std::list< VariableNetworkNode > consumers
NetworkInformation(const Model::ProcessVariableProxy *p)
Helper predicate to put ProcessVariableProxies into std::set.
bool operator()(const Model::ProcessVariableProxy &a, const Model::ProcessVariableProxy &b) const