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

removed some unused code

parent 89730265
No related branches found
No related tags found
No related merge requests found
......@@ -84,25 +84,6 @@ namespace ChimeraTK {
: _owner(owner), _name(name), _direction(direction), _unit(unit), _mode(mode), node{*this}
{}
/** Connect the accessor to another accessor */
template< typename UserType_o >
void connectTo(Accessor<UserType_o> &targetAccessor);
/** Publish the variable to the control system as a control-system-to-application variable under the given name */
void consumeFromControlSystem(const std::string& name);
/** Publish the variable to the control system as a application-to-control-system variable under the given name */
void feedToControlSystem(const std::string& name);
/** Connect variable to a device register and request that the variable will "consume" data from the register. */
void consumeFromDevice(const std::string &deviceAlias, const std::string &registerName, UpdateMode mode);
/** Connect variable to a device register and request that the variable will "feed" data to the register.*/
void feedToDevice(const std::string &deviceAlias, const std::string &registerName);
/** Add another accessor as an external trigger */
void addTrigger(AccessorBase &trigger);
virtual bool isFeeding();
VariableDirection getDirection() const {return _direction;}
......@@ -131,14 +112,6 @@ namespace ChimeraTK {
return node.operator>>(other);
}
/** Add a trigger */
VariableNetworkNode& operator+(const VariableNetworkNode &trigger) {
VariableNetwork &network = Application::getInstance().findOrCreateNetwork(this);
network.addNode(node);
network.addTrigger(trigger);
return node;
}
protected:
ApplicationModule *_owner;
......@@ -153,66 +126,11 @@ namespace ChimeraTK {
/*********************************************************************************************************************/
/** Connect the accessor to another accessor */
template< typename UserType >
template< typename UserType_o >
void Accessor<UserType>::connectTo(Accessor<UserType_o> &targetAccessor) {
Application::getInstance().connect(*this, targetAccessor);
}
/*********************************************************************************************************************/
template< typename UserType >
void Accessor<UserType>::feedToControlSystem(const std::string& name) {
VariableNetwork &network = Application::getInstance().findOrCreateNetwork(this);
network.addNode(*this);
network.addConsumingPublication(name);
}
/*********************************************************************************************************************/
template< typename UserType >
void Accessor<UserType>::consumeFromControlSystem(const std::string& name) {
VariableNetwork &network = Application::getInstance().findOrCreateNetwork(this);
network.addNode(*this);
network.addFeedingPublication(*this,name);
}
/*********************************************************************************************************************/
template< typename UserType >
bool Accessor<UserType>::isFeeding() {
return _direction == VariableDirection::feeding;
};
/*********************************************************************************************************************/
template< typename UserType >
void Accessor<UserType>::consumeFromDevice(const std::string &deviceAlias, const std::string &registerName,
UpdateMode mode) {
VariableNetwork &network = Application::getInstance().findOrCreateNetwork(this);
network.addNode(*this);
network.addFeedingDeviceRegister(*this, deviceAlias, registerName, mode);
}
/*********************************************************************************************************************/
template< typename UserType >
void Accessor<UserType>::feedToDevice(const std::string &deviceAlias, const std::string &registerName) {
VariableNetwork &network = Application::getInstance().findOrCreateNetwork(this);
network.addNode(*this);
network.addConsumingDeviceRegister(deviceAlias, registerName);
}
/*********************************************************************************************************************/
template< typename UserType >
void Accessor<UserType>::addTrigger(AccessorBase &trigger) {
VariableNetwork &network = Application::getInstance().findOrCreateNetwork(this);
network.addNode(*this);
network.addTrigger(trigger);
}
} /* namespace ChimeraTK */
#endif /* CHIMERATK_ACCESSOR_H */
......@@ -98,50 +98,9 @@ namespace ChimeraTK {
template<typename UserType>
void typedMakeConnection(VariableNetwork &network);
/** Register a connection between two Accessors */
//void connectAccessors(AccessorBase &a, AccessorBase &b);
/** Register a connection between two VariableNetworkNode */
VariableNetwork& connect(VariableNetworkNode a, VariableNetworkNode b);
/** Return a VariableNetworkNode for a device register with a not yet defined direction */
template<typename UserType>
VariableNetworkNode devReg(const std::string &deviceAlias, const std::string &registerName,
UpdateMode mode=UpdateMode::poll);
VariableNetworkNode devReg(const std::string &deviceAlias, const std::string &registerName,
UpdateMode mode=UpdateMode::poll, const std::type_info &valTyp=typeid(AnyType));
/** Return a VariableNetworkNode for a control system variable with a not yet defined direction */
template<typename UserType>
VariableNetworkNode ctrlVar(const std::string &publicName);
VariableNetworkNode ctrlVar(const std::string &publicName, const std::type_info &valTyp=typeid(AnyType));
/** Return a VariableNetworkNode for a feeding device register (i.e. a register that will be read by the application) */
template<typename UserType>
VariableNetworkNode feedingDevReg(const std::string &deviceAlias, const std::string &registerName, UpdateMode mode);
VariableNetworkNode feedingDevReg(const std::string &deviceAlias, const std::string &registerName, UpdateMode mode,
const std::type_info &valTyp=typeid(AnyType));
/** Return a VariableNetworkNode for a consuming control system variable */
template<typename UserType>
VariableNetworkNode consumingCtrlVar(const std::string &publicName);
VariableNetworkNode consumingCtrlVar(const std::string &publicName, const std::type_info &valTyp=typeid(AnyType));
/** Return a VariableNetworkNode for a consuming control system variable */
template<typename UserType>
VariableNetworkNode feedingCtrlVar(const std::string &publicName);
VariableNetworkNode feedingCtrlVar(const std::string &publicName, const std::type_info &valTyp=typeid(AnyType));
/** Register a connection between a device read-only register and the control system adapter */
template<typename UserType>
void feedDeviceRegisterToControlSystem(const std::string &deviceAlias, const std::string &registerName,
const std::string& publicName, AccessorBase &trigger=InvalidAccessor());
/** Register a connection between a device write-only register and the control system adapter */
template<typename UserType>
void consumeDeviceRegisterFromControlSystem(const std::string &deviceAlias, const std::string &registerName,
const std::string& publicName);
/** Perform the actual connection of an accessor to a device register */
template<typename UserType>
boost::shared_ptr<mtca4u::ProcessVariable> createDeviceAccessor(const std::string &deviceAlias,
......@@ -176,15 +135,6 @@ namespace ChimeraTK {
/** List of variable networks */
std::list<VariableNetwork> networkList;
/** Find the network containing one of the given registers. If no network has been found, create an empty one
* and add it to the networkList. */
VariableNetwork& findOrCreateNetwork(AccessorBase *a, AccessorBase *b);
VariableNetwork& findOrCreateNetwork(AccessorBase *a);
/** Find the network containing one of the given registers. If no network has been found, invalidNetwork
* is returned. */
VariableNetwork& findNetwork(AccessorBase *a);
/** Create a new, empty network */
VariableNetwork& createNetwork();
......
......@@ -44,28 +44,6 @@ namespace ChimeraTK {
/** Add an node to the network. */
void addNode(VariableNetworkNode &a);
/** Add control-system-to-device publication. The given accessor will be used to derive the requred value type.
* The name will be the name of the process variable visible in the control system adapter. */
void addFeedingPublication(AccessorBase &a, const std::string& name);
/** Add control-system-to-device publication. The given accessor will be used to derive the requred value type.
* The name will be the name of the process variable visible in the control system adapter. */
void addFeedingPublication(const std::type_info &typeInfo, const std::string& unit, const std::string& name);
/** Add device-to-control-system publication. */
void addConsumingPublication(const std::string& name);
/** Add a device register as a consuming node (i.e. which will be written by this network) */
void addConsumingDeviceRegister(const std::string &deviceAlias, const std::string &registerName);
/** Add a device register as a feeding node (i.e. which will be read from this network) */
void addFeedingDeviceRegister(AccessorBase &a, const std::string &deviceAlias, const std::string &registerName,
UpdateMode mode);
/** Add a device register as a feeding node (i.e. which will be read from this network) */
void addFeedingDeviceRegister(const std::type_info &typeInfo, const std::string& unit,
const std::string &deviceAlias, const std::string &registerName, UpdateMode mode);
/** Add a trigger receiver node */
void addTriggerReceiver(VariableNetwork *network);
......@@ -75,13 +53,6 @@ namespace ChimeraTK {
/** Count the number of consuming nodes in the network */
size_t countConsumingNodes() const;
/** Count the number of nodes requiring a fixed implementation */
size_t countFixedImplementations() const;
/** Check if either of the given accessors is part of this network. If the second argument is omitted, only
* the first accessor will be checked. */
bool hasAppNode(AccessorBase *a, AccessorBase *b=nullptr) const;
/** Obtain the type info of the UserType. If the network type has not yet been determined (i.e. if no output
* accessor has been assigned yet), the typeid of void will be returned. */
const std::type_info& getValueType() const {
......@@ -118,10 +89,9 @@ namespace ChimeraTK {
* has another trigger type, an exception will be thrown. */
VariableNetwork& getExternalTrigger();
/** Add an accessor belonging to another network as an external trigger to this network. Whenever the
* VariableNetwork of the given accessor will be fed with a new value, feeding of this network will be
/** Add an accessor belonging to another node as an external trigger to this network. Whenever the
* VariableNetwork of the given node will be fed with a new value, feeding of this network will be
* triggered as well. */
void addTrigger(VariableNetwork &trigger);
void addTrigger(VariableNetworkNode trigger);
/** Check if the network is legally configured */
......
......@@ -110,14 +110,6 @@ void Application::generateXML() {
/*********************************************************************************************************************/
/*void Application::connectAccessors(AccessorBase &a, AccessorBase &b) {
VariableNetwork &network = findOrCreateNetwork(&a,&b);
network.addNode(a);
network.addNode(b);
}*/
/*********************************************************************************************************************/
VariableNetwork& Application::connect(VariableNetworkNode a, VariableNetworkNode b) {
// if one of the nodes as the value type AnyType, set it to the type of the other
......@@ -153,92 +145,6 @@ VariableNetwork& Application::connect(VariableNetworkNode a, VariableNetworkNode
/*********************************************************************************************************************/
VariableNetworkNode Application::devReg(const std::string &deviceAlias, const std::string &registerName, UpdateMode mode,
const std::type_info &valTyp) {
return{deviceAlias, registerName, mode, VariableDirection::invalid, valTyp};
}
/*********************************************************************************************************************/
template<typename UserType>
VariableNetworkNode Application::devReg(const std::string &deviceAlias, const std::string &registerName, UpdateMode mode) {
return devReg(deviceAlias, registerName, mode, typeid(UserType));
}
template VariableNetworkNode Application::devReg<int8_t>(const std::string &deviceAlias, const std::string &registerName, UpdateMode mode);
template VariableNetworkNode Application::devReg<uint8_t>(const std::string &deviceAlias, const std::string &registerName, UpdateMode mode);
template VariableNetworkNode Application::devReg<int16_t>(const std::string &deviceAlias, const std::string &registerName, UpdateMode mode);
template VariableNetworkNode Application::devReg<uint16_t>(const std::string &deviceAlias, const std::string &registerName, UpdateMode mode);
template VariableNetworkNode Application::devReg<int32_t>(const std::string &deviceAlias, const std::string &registerName, UpdateMode mode);
template VariableNetworkNode Application::devReg<uint32_t>(const std::string &deviceAlias, const std::string &registerName, UpdateMode mode);
template VariableNetworkNode Application::devReg<float>(const std::string &deviceAlias, const std::string &registerName, UpdateMode mode);
template VariableNetworkNode Application::devReg<double>(const std::string &deviceAlias, const std::string &registerName, UpdateMode mode);
/*********************************************************************************************************************/
template<typename UserType>
VariableNetworkNode Application::ctrlVar(const std::string &publicName) {
return ctrlVar(publicName, typeid(UserType));
}
template VariableNetworkNode Application::ctrlVar<int8_t>(const std::string &publicName);
template VariableNetworkNode Application::ctrlVar<uint8_t>(const std::string &publicName);
template VariableNetworkNode Application::ctrlVar<int16_t>(const std::string &publicName);
template VariableNetworkNode Application::ctrlVar<uint16_t>(const std::string &publicName);
template VariableNetworkNode Application::ctrlVar<int32_t>(const std::string &publicName);
template VariableNetworkNode Application::ctrlVar<uint32_t>(const std::string &publicName);
template VariableNetworkNode Application::ctrlVar<float>(const std::string &publicName);
template VariableNetworkNode Application::ctrlVar<double>(const std::string &publicName);
/*********************************************************************************************************************/
VariableNetworkNode Application::ctrlVar(const std::string &publicName, const std::type_info &valTyp) {
return {publicName, VariableDirection::invalid, valTyp};
}
/*********************************************************************************************************************/
VariableNetworkNode Application::feedingDevReg(const std::string &deviceAlias, const std::string &registerName,
UpdateMode mode, const std::type_info &valTyp) {
return {deviceAlias, registerName, mode, VariableDirection::feeding, valTyp};
}
/*********************************************************************************************************************/
template<typename UserType>
VariableNetworkNode Application::feedingDevReg(const std::string &deviceAlias, const std::string &registerName,
UpdateMode mode) {
return feedingDevReg(deviceAlias, registerName, mode, typeid(UserType));
}
/*********************************************************************************************************************/
VariableNetworkNode Application::consumingCtrlVar(const std::string &publicName, const std::type_info &valTyp) {
return {publicName, VariableDirection::consuming, valTyp};
}
/*********************************************************************************************************************/
template<typename UserType>
VariableNetworkNode Application::consumingCtrlVar(const std::string &publicName) {
return consumingCtrlVar(publicName, typeid(UserType));
}
/*********************************************************************************************************************/
VariableNetworkNode Application::feedingCtrlVar(const std::string &publicName, const std::type_info &valTyp) {
return {publicName, VariableDirection::feeding, valTyp};
}
/*********************************************************************************************************************/
template<typename UserType>
VariableNetworkNode Application::feedingCtrlVar(const std::string &publicName) {
return feedingCtrlVar(publicName, typeid(UserType));
}
/*********************************************************************************************************************/
template<typename UserType>
boost::shared_ptr<mtca4u::ProcessVariable> Application::createDeviceAccessor(const std::string &deviceAlias,
const std::string &registerName, VariableDirection direction, UpdateMode mode) {
......@@ -550,117 +456,8 @@ void Application::typedMakeConnection(VariableNetwork &network) {
/*********************************************************************************************************************/
VariableNetwork& Application::findOrCreateNetwork(AccessorBase *a, AccessorBase *b) {
// search for a and b in the networkList
auto &na = findNetwork(a);
auto &nb = findNetwork(b);
// if both accessors are found, check if both are in the same network
if(na != invalidNetwork && nb != invalidNetwork) {
if(na == nb) {
return na;
}
else {
throw ApplicationExceptionWithID<ApplicationExceptionID::illegalParameter>(
"Trying to connect two accessors which already are part of a network.");
}
}
// if only one accessor is found, return its network
else if(na != invalidNetwork && nb == invalidNetwork) {
return na;
}
else if(na == invalidNetwork && nb != invalidNetwork) {
return nb;
}
// if no accessor is found, create a new network and add it to the list
networkList.emplace_back();
return networkList.back();
}
/*********************************************************************************************************************/
VariableNetwork& Application::findOrCreateNetwork(AccessorBase *a) {
// search in the networkList
auto &na = findNetwork(a);
// if the accessors is found, return its network
if(na != invalidNetwork) {
return na;
}
// if no accessor is found, create a new network and add it to the list
networkList.emplace_back();
return networkList.back();
}
/*********************************************************************************************************************/
VariableNetwork& Application::findNetwork(AccessorBase *a) {
// search for a and b in the networkList
auto r = find_if(networkList.begin(), networkList.end(),
[a](const VariableNetwork& n) { return n.hasAppNode(a); } );
// if no network found, create one
if(r == networkList.end()) {
return invalidNetwork;
}
// return the found network
return *r;
}
/*********************************************************************************************************************/
VariableNetwork& Application::createNetwork() {
networkList.emplace_back();
return networkList.back();
}
/*********************************************************************************************************************/
template<typename UserType>
void Application::feedDeviceRegisterToControlSystem(const std::string &deviceAlias, const std::string &registerName,
const std::string& publicName, AccessorBase &trigger) {
UpdateMode mode = UpdateMode::push;
if(dynamic_cast<InvalidAccessor*>(&trigger) == nullptr) mode = UpdateMode::poll;
//VariableNetworkNode n1{deviceAlias,registerName, mode, VariableDirection::feeding, typeid(UserType)};
auto &net = connect(feedingDevReg<UserType>(deviceAlias,registerName, mode),
consumingCtrlVar<UserType>(publicName));
if(dynamic_cast<InvalidAccessor*>(&trigger) == nullptr) net.addTrigger(findNetwork(&trigger));
}
template void Application::feedDeviceRegisterToControlSystem<int8_t>(const std::string &deviceAlias, const std::string &registerName, const std::string& publicName, AccessorBase &trigger);
template void Application::feedDeviceRegisterToControlSystem<uint8_t>(const std::string &deviceAlias, const std::string &registerName, const std::string& publicName, AccessorBase &trigger);
template void Application::feedDeviceRegisterToControlSystem<int16_t>(const std::string &deviceAlias, const std::string &registerName, const std::string& publicName, AccessorBase &trigger);
template void Application::feedDeviceRegisterToControlSystem<uint16_t>(const std::string &deviceAlias, const std::string &registerName, const std::string& publicName, AccessorBase &trigger);
template void Application::feedDeviceRegisterToControlSystem<int32_t>(const std::string &deviceAlias, const std::string &registerName, const std::string& publicName, AccessorBase &trigger);
template void Application::feedDeviceRegisterToControlSystem<uint32_t>(const std::string &deviceAlias, const std::string &registerName, const std::string& publicName, AccessorBase &trigger);
template void Application::feedDeviceRegisterToControlSystem<float>(const std::string &deviceAlias, const std::string &registerName, const std::string& publicName, AccessorBase &trigger);
template void Application::feedDeviceRegisterToControlSystem<double>(const std::string &deviceAlias, const std::string &registerName, const std::string& publicName, AccessorBase &trigger);
/*********************************************************************************************************************/
template<typename UserType>
void Application::consumeDeviceRegisterFromControlSystem(const std::string &deviceAlias, const std::string &registerName,
const std::string& publicName) {
networkList.emplace_back();
VariableNetwork& network = networkList.back();
network.addFeedingPublication(typeid(UserType), "arbitrary", publicName);
network.addConsumingDeviceRegister(deviceAlias, registerName);
}
template void Application::consumeDeviceRegisterFromControlSystem<int8_t>(const std::string &deviceAlias, const std::string &registerName, const std::string& publicName);
template void Application::consumeDeviceRegisterFromControlSystem<uint8_t>(const std::string &deviceAlias, const std::string &registerName, const std::string& publicName);
template void Application::consumeDeviceRegisterFromControlSystem<int16_t>(const std::string &deviceAlias, const std::string &registerName, const std::string& publicName);
template void Application::consumeDeviceRegisterFromControlSystem<uint16_t>(const std::string &deviceAlias, const std::string &registerName, const std::string& publicName);
template void Application::consumeDeviceRegisterFromControlSystem<int32_t>(const std::string &deviceAlias, const std::string &registerName, const std::string& publicName);
template void Application::consumeDeviceRegisterFromControlSystem<uint32_t>(const std::string &deviceAlias, const std::string &registerName, const std::string& publicName);
template void Application::consumeDeviceRegisterFromControlSystem<float>(const std::string &deviceAlias, const std::string &registerName, const std::string& publicName);
template void Application::consumeDeviceRegisterFromControlSystem<double>(const std::string &deviceAlias, const std::string &registerName, const std::string& publicName);
/*********************************************************************************************************************/
......@@ -15,20 +15,6 @@ namespace ChimeraTK {
/*********************************************************************************************************************/
bool VariableNetwork::hasAppNode(AccessorBase *a, AccessorBase *b) const {
// search for a and b in the nodeList
size_t c = std::count_if( nodeList.begin(), nodeList.end(),
[a,b](const VariableNetworkNode n) {
if(n.getType() != NodeType::Application) return false;
return a == &(n.getAppAccessor()) || ( b != nullptr && b == &(n.getAppAccessor()) );
} );
if(c > 0) return true;
return false;
}
/*********************************************************************************************************************/
bool VariableNetwork::hasFeedingNode() const {
auto n = std::count_if( nodeList.begin(), nodeList.end(),
[](const VariableNetworkNode n) {
......@@ -46,15 +32,6 @@ namespace ChimeraTK {
/*********************************************************************************************************************/
size_t VariableNetwork::countFixedImplementations() const {
return count_if( nodeList.begin(), nodeList.end(),
[](const VariableNetworkNode n) {
return n.hasImplementation();
} );
}
/*********************************************************************************************************************/
void VariableNetwork::addNode(VariableNetworkNode &a) {
if(a.hasOwner()) { // already in the network
assert( &(a.getOwner()) == this ); /// @todo TODO merge networks?
......@@ -86,64 +63,6 @@ namespace ChimeraTK {
/*********************************************************************************************************************/
void VariableNetwork::addConsumingPublication(const std::string& name) {
VariableNetworkNode node(name, VariableDirection::consuming);
node.setOwner(this);
nodeList.push_back(node);
}
/*********************************************************************************************************************/
void VariableNetwork::addFeedingPublication(AccessorBase &a, const std::string& name) {
addFeedingPublication(a.getValueType(), a.getUnit(), name);
}
/*********************************************************************************************************************/
void VariableNetwork::addFeedingPublication(const std::type_info &typeInfo, const std::string& unit, const std::string& name) {
if(hasFeedingNode()) {
throw ApplicationExceptionWithID<ApplicationExceptionID::illegalVariableNetwork>(
"Trying to add control-system-to-device publication to a network already having a feeding accessor.");
}
auto feeder = VariableNetworkNode(name, VariableDirection::feeding);
feeder.setOwner(this);
nodeList.push_back(feeder);
valueType = &typeInfo;
engineeringUnit = unit;
}
/*********************************************************************************************************************/
void VariableNetwork::addConsumingDeviceRegister(const std::string &deviceAlias, const std::string &registerName) {
VariableNetworkNode node(deviceAlias, registerName, UpdateMode::push, VariableDirection::consuming);
node.setOwner(this);
nodeList.push_back(node);
}
/*********************************************************************************************************************/
void VariableNetwork::addFeedingDeviceRegister(AccessorBase &a, const std::string &deviceAlias,
const std::string &registerName, UpdateMode mode) {
addFeedingDeviceRegister(a.getValueType(), a.getUnit(), deviceAlias, registerName, mode);
}
/*********************************************************************************************************************/
void VariableNetwork::addFeedingDeviceRegister(const std::type_info &typeInfo, const std::string& unit
, const std::string &deviceAlias, const std::string &registerName, UpdateMode mode) {
if(hasFeedingNode()) {
throw ApplicationExceptionWithID<ApplicationExceptionID::illegalVariableNetwork>(
"Trying to add a feeding device register to a network already having a feeding accessor.");
}
auto feeder = VariableNetworkNode(deviceAlias, registerName, mode, VariableDirection::feeding);
feeder.setOwner(this);
nodeList.push_back(feeder);
valueType = &typeInfo;
engineeringUnit = unit;
}
/*********************************************************************************************************************/
void VariableNetwork::dump(const std::string& linePrefix) const {
std::cout << linePrefix << "VariableNetwork {" << std::endl;
std::cout << linePrefix << " value type = " << valueType->name() << ", engineering unit = " << engineeringUnit << std::endl;
......@@ -190,24 +109,6 @@ namespace ChimeraTK {
/*********************************************************************************************************************/
void VariableNetwork::addTrigger(VariableNetwork &trigger) {
if(hasExternalTrigger) {
throw ApplicationExceptionWithID<ApplicationExceptionID::illegalVariableNetwork>(
"Only one external trigger per variable network is allowed.");
}
// add ourselves as a trigger receiver to the other network
trigger.addTriggerReceiver(this);
// set flag and store pointer to other network
hasExternalTrigger = true;
externalTrigger = &trigger;
}
/*********************************************************************************************************************/
void VariableNetwork::addTrigger(VariableNetworkNode trigger) {
if(hasExternalTrigger) {
......
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