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

allow specifying the array length for direct connections between device and...

allow specifying the array length for direct connections between device and control system (as the type is already defined in this case)
parent 879c6b13
No related branches found
No related tags found
No related merge requests found
...@@ -25,7 +25,8 @@ namespace ChimeraTK { ...@@ -25,7 +25,8 @@ namespace ChimeraTK {
/** The subscript operator returns a VariableNetworkNode which can be used in the Application::initialise() /** The subscript operator returns a VariableNetworkNode which can be used in the Application::initialise()
* function to connect the control system variable with another variable. */ * function to connect the control system variable with another variable. */
VariableNetworkNode operator()(const std::string& variableName, const std::type_info &valueType=typeid(AnyType)); VariableNetworkNode operator()(const std::string& variableName, const std::type_info &valueType=typeid(AnyType),
size_t nElements=0);
protected: protected:
......
...@@ -29,10 +29,10 @@ namespace ChimeraTK { ...@@ -29,10 +29,10 @@ namespace ChimeraTK {
/** The subscript operator returns a VariableNetworkNode which can be used in the Application::initialise() /** The subscript operator returns a VariableNetworkNode which can be used in the Application::initialise()
* function to connect the register with another variable. */ * function to connect the register with another variable. */
VariableNetworkNode operator()(const std::string& registerName, UpdateMode mode=UpdateMode::poll, VariableNetworkNode operator()(const std::string& registerName, UpdateMode mode=UpdateMode::poll,
const std::type_info &valueType=typeid(AnyType)); const std::type_info &valueType=typeid(AnyType), size_t nElements=0);
VariableNetworkNode operator()(const std::string& registerName, const std::type_info &valueType, VariableNetworkNode operator()(const std::string& registerName, const std::type_info &valueType,
UpdateMode mode=UpdateMode::poll) { size_t nElements=0, UpdateMode mode=UpdateMode::poll) {
return operator()(registerName, mode, valueType); return operator()(registerName, mode, valueType, nElements);
} }
/** Prepare the device for usage (i.e. open it) */ /** Prepare the device for usage (i.e. open it) */
......
...@@ -42,11 +42,11 @@ namespace ChimeraTK { ...@@ -42,11 +42,11 @@ namespace ChimeraTK {
/** Constructor for a Device node */ /** Constructor for a Device node */
VariableNetworkNode(const std::string &deviceAlias, const std::string &registerName, UpdateMode mode, VariableNetworkNode(const std::string &deviceAlias, const std::string &registerName, UpdateMode mode,
VariableDirection direction, const std::type_info &valTyp=typeid(AnyType)); VariableDirection direction, const std::type_info &valTyp=typeid(AnyType), size_t nElements=0);
/** Constructor for a ControlSystem node */ /** Constructor for a ControlSystem node */
VariableNetworkNode(std::string publicName, VariableDirection direction, VariableNetworkNode(std::string publicName, VariableDirection direction,
const std::type_info &valTyp=typeid(AnyType)); const std::type_info &valTyp=typeid(AnyType), size_t nElements=0);
/** Constructor for a TriggerReceiver node triggering the data transfer of another network. The additional dummy /** Constructor for a TriggerReceiver node triggering the data transfer of another network. The additional dummy
* argument is only there to discriminate the signature from the copy constructor and will be ignored. */ * argument is only there to discriminate the signature from the copy constructor and will be ignored. */
......
...@@ -17,8 +17,9 @@ namespace ChimeraTK { ...@@ -17,8 +17,9 @@ namespace ChimeraTK {
/*********************************************************************************************************************/ /*********************************************************************************************************************/
VariableNetworkNode ControlSystemModule::operator()(const std::string& variableName, const std::type_info &valueType) { VariableNetworkNode ControlSystemModule::operator()(const std::string& variableName, const std::type_info &valueType,
return{variableNamePrefix/variableName, VariableDirection::invalid, valueType}; size_t nElements) {
return{variableNamePrefix/variableName, VariableDirection::invalid, valueType, nElements};
} }
} }
...@@ -20,8 +20,8 @@ namespace ChimeraTK { ...@@ -20,8 +20,8 @@ namespace ChimeraTK {
/*********************************************************************************************************************/ /*********************************************************************************************************************/
VariableNetworkNode DeviceModule::operator()(const std::string& registerName, UpdateMode mode, VariableNetworkNode DeviceModule::operator()(const std::string& registerName, UpdateMode mode,
const std::type_info &valueType) { const std::type_info &valueType, size_t nElements) {
return{deviceAliasOrURI, registerNamePrefix/registerName, mode, VariableDirection::invalid, valueType}; return{deviceAliasOrURI, registerNamePrefix/registerName, mode, VariableDirection::invalid, valueType, nElements};
} }
/*********************************************************************************************************************/ /*********************************************************************************************************************/
......
...@@ -45,7 +45,7 @@ namespace ChimeraTK { ...@@ -45,7 +45,7 @@ namespace ChimeraTK {
/*********************************************************************************************************************/ /*********************************************************************************************************************/
VariableNetworkNode::VariableNetworkNode(const std::string &devAlias, const std::string &regName, UpdateMode mod, VariableNetworkNode::VariableNetworkNode(const std::string &devAlias, const std::string &regName, UpdateMode mod,
VariableDirection dir, const std::type_info &valTyp) VariableDirection dir, const std::type_info &valTyp, size_t nElements)
: pdata(new data) : pdata(new data)
{ {
pdata->type = NodeType::Device; pdata->type = NodeType::Device;
...@@ -54,11 +54,13 @@ namespace ChimeraTK { ...@@ -54,11 +54,13 @@ namespace ChimeraTK {
pdata->valueType = &valTyp; pdata->valueType = &valTyp;
pdata->deviceAlias = devAlias; pdata->deviceAlias = devAlias;
pdata->registerName = regName; pdata->registerName = regName;
pdata->nElements = nElements;
} }
/*********************************************************************************************************************/ /*********************************************************************************************************************/
VariableNetworkNode::VariableNetworkNode(std::string pubName, VariableDirection dir, const std::type_info &valTyp) VariableNetworkNode::VariableNetworkNode(std::string pubName, VariableDirection dir, const std::type_info &valTyp,
size_t nElements)
: pdata(new data) : pdata(new data)
{ {
pdata->type = NodeType::ControlSystem; pdata->type = NodeType::ControlSystem;
...@@ -66,6 +68,7 @@ namespace ChimeraTK { ...@@ -66,6 +68,7 @@ namespace ChimeraTK {
pdata->direction = dir; pdata->direction = dir;
pdata->valueType = &valTyp; pdata->valueType = &valTyp;
pdata->publicName = pubName; pdata->publicName = pubName;
pdata->nElements = nElements;
} }
/*********************************************************************************************************************/ /*********************************************************************************************************************/
...@@ -95,7 +98,7 @@ namespace ChimeraTK { ...@@ -95,7 +98,7 @@ namespace ChimeraTK {
/*********************************************************************************************************************/ /*********************************************************************************************************************/
void VariableNetworkNode::dump() const { void VariableNetworkNode::dump() const {
if(pdata->type == NodeType::Application) std::cout << " type = Application"; if(pdata->type == NodeType::Application) std::cout << " type = Application ('" << pdata->appNode->getName() << "')";
if(pdata->type == NodeType::ControlSystem) std::cout << " type = ControlSystem ('" << pdata->publicName << "')"; if(pdata->type == NodeType::ControlSystem) std::cout << " type = ControlSystem ('" << pdata->publicName << "')";
if(pdata->type == NodeType::Device) std::cout << " type = Device (" << pdata->deviceAlias << ": " << pdata->registerName << ")"; if(pdata->type == NodeType::Device) std::cout << " type = Device (" << pdata->deviceAlias << ": " << pdata->registerName << ")";
if(pdata->type == NodeType::TriggerReceiver) std::cout << " type = TriggerReceiver"; if(pdata->type == NodeType::TriggerReceiver) std::cout << " type = TriggerReceiver";
...@@ -105,6 +108,7 @@ namespace ChimeraTK { ...@@ -105,6 +108,7 @@ namespace ChimeraTK {
if(pdata->mode == UpdateMode::poll) std::cout << " polling"; if(pdata->mode == UpdateMode::poll) std::cout << " polling";
std::cout << " data type: " << pdata->valueType->name(); std::cout << " data type: " << pdata->valueType->name();
std::cout << " length: " << pdata->nElements;
std::cout << std::endl; std::cout << std::endl;
} }
......
...@@ -147,7 +147,8 @@ BOOST_AUTO_TEST_CASE_TEMPLATE( testTriggerDevToCS, T, test_types ) { ...@@ -147,7 +147,8 @@ BOOST_AUTO_TEST_CASE_TEMPLATE( testTriggerDevToCS, T, test_types ) {
app.testModule.feedingToDevice >> dev("/MyModule/Variable"); app.testModule.feedingToDevice >> dev("/MyModule/Variable");
dev("/MyModule/Variable", typeid(T)) [ app.testModule.theTrigger ] >> cs("myCSVar"); dev("/MyModule/Variable", typeid(T), 1) [ app.testModule.theTrigger ] >> cs("myCSVar");
app.run(); app.run();
BOOST_CHECK_EQUAL(pvManagers.first->getAllProcessVariables().size(), 1); BOOST_CHECK_EQUAL(pvManagers.first->getAllProcessVariables().size(), 1);
...@@ -194,7 +195,7 @@ BOOST_AUTO_TEST_CASE_TEMPLATE( testTriggerByCS, T, test_types ) { ...@@ -194,7 +195,7 @@ BOOST_AUTO_TEST_CASE_TEMPLATE( testTriggerByCS, T, test_types ) {
app.testModule.feedingToDevice >> dev("/MyModule/Variable"); app.testModule.feedingToDevice >> dev("/MyModule/Variable");
dev("/MyModule/Variable", typeid(T)) [ cs("theTrigger", typeid(T)) ] >> cs("myCSVar"); dev("/MyModule/Variable", typeid(T), 1) [ cs("theTrigger", typeid(T), 1) ] >> cs("myCSVar");
app.run(); app.run();
BOOST_CHECK_EQUAL(pvManagers.first->getAllProcessVariables().size(), 2); BOOST_CHECK_EQUAL(pvManagers.first->getAllProcessVariables().size(), 2);
......
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