Skip to content

Commit

Permalink
Opcua 3226 initialise source variable thread pool from smd (#330)
Browse files Browse the repository at this point in the history
* added devicelogic to handle SourceVariableThreadPool instances in SMD element in config.xml

* fixed code gen for all parent/child combinations of with/without devicelogic

* added new Meta header and implementation device handler files for source var thread pool
---------

Co-authored-by: Ben Farnham <[email protected]>
  • Loading branch information
ben-farnham and Ben Farnham authored Oct 31, 2024
1 parent 2625506 commit 3f57166
Show file tree
Hide file tree
Showing 6 changed files with 178 additions and 3 deletions.
4 changes: 2 additions & 2 deletions Device/templates/designToDeviceBaseHeader.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@

{% macro get_parent_struct(class_name) %}
{% set parent_class_name = designInspector.get_parent(class_name) %}
{%- if parent_class_name != None and designInspector.class_has_legit_device_parent(parent_class_name) -%}
D{{parent}}
{%- if parent_class_name != None and designInspector.class_has_legit_device_parent(class_name) -%}
D{{parent_class_name}}
{%- else -%}
struct{/*No Device Logic for parent {{parent_class_name}} of {{class_name}}*/}
{%- endif -%}
Expand Down
6 changes: 6 additions & 0 deletions FrameworkInternals/original_files.txt
Original file line number Diff line number Diff line change
Expand Up @@ -887,6 +887,9 @@
"DLogLevel.h": {
"use_defaults": "file_defaults_of_directory"
},
"DSourceVariableThreadPool.h": {
"use_defaults": "file_defaults_of_directory"
},
"MetaBuildInfo.h": {
"use_defaults": "file_defaults_of_directory"
},
Expand All @@ -910,6 +913,9 @@
"DLogLevel.cpp": {
"use_defaults": "file_defaults_of_directory"
},
"DSourceVariableThreadPool.cpp": {
"use_defaults": "file_defaults_of_directory"
},
"MetaBuildInfo.cpp": {
"use_defaults": "file_defaults_of_directory"
},
Expand Down
7 changes: 6 additions & 1 deletion Meta/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,12 @@
# The reason that MetaBuildInfo.cpp is not amalgamated is that it depends on a file which is regenerated at each build
# and there is no reason to rebuild amalgamated files without the factual reason!

add_library (Meta OBJECT src/meta.cpp src/MetaBuildInfo.cpp src/metaBackwardsCompatibilityUtils.cpp src/DLogLevel.cpp)
add_library (Meta OBJECT
src/meta.cpp
src/MetaBuildInfo.cpp
src/metaBackwardsCompatibilityUtils.cpp
src/DLogLevel.cpp
src/DSourceVariableThreadPool.cpp)

file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/generated)

Expand Down
1 change: 1 addition & 0 deletions Meta/design/meta-design.xml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ class sources are provided (statically) in the Meta module.
</d:class>

<d:class name="SourceVariableThreadPool" defaultInstanceName="SourceVariableThreadPool">
<d:devicelogic/>
<d:cachevariable name="maxThreads" addressSpaceWrite="forbidden" dataType="UaString" initializeWith="configuration" nullPolicy="nullForbidden"/>
<d:cachevariable name="minThreads" addressSpaceWrite="forbidden" dataType="UaString" initializeWith="configuration" nullPolicy="nullForbidden"/>
</d:class>
Expand Down
69 changes: 69 additions & 0 deletions Meta/include/DSourceVariableThreadPool.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@

/* © Copyright CERN, 2015. All rights not expressly granted are reserved.
The stub of this file was generated by quasar (https://github.com/quasar-team/quasar/)
Quasar is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public Licence as published by
the Free Software Foundation, either version 3 of the Licence.
Quasar is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public Licence for more details.
You should have received a copy of the GNU Lesser General Public License
along with Quasar. If not, see <http://www.gnu.org/licenses/>.
*/


#ifndef __DSourceVariableThreadPool__H__
#define __DSourceVariableThreadPool__H__

#include <Base_DSourceVariableThreadPool.h>

namespace Device
{

class
DSourceVariableThreadPool
: public Base_DSourceVariableThreadPool
{

public:
/* sample constructor */
explicit DSourceVariableThreadPool (
const Configuration::SourceVariableThreadPool& config,
Parent_DSourceVariableThreadPool* parent
) ;
/* sample dtr */
~DSourceVariableThreadPool ();

/* delegators for
cachevariables and sourcevariables */


/* delegators for methods */

private:
/* Delete copy constructor and assignment operator */
DSourceVariableThreadPool( const DSourceVariableThreadPool& other );
DSourceVariableThreadPool& operator=(const DSourceVariableThreadPool& other);

// ----------------------------------------------------------------------- *
// - CUSTOM CODE STARTS BELOW THIS COMMENT. *
// - Don't change this comment, otherwise merge tool may be troubled. *
// ----------------------------------------------------------------------- *

public:

private:



};

}

#endif // __DSourceVariableThreadPool__H__
94 changes: 94 additions & 0 deletions Meta/src/DSourceVariableThreadPool.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@

/* © Copyright CERN, 2015. All rights not expressly granted are reserved.
The stub of this file was generated by quasar (https://github.com/quasar-team/quasar/)
Quasar is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public Licence as published by
the Free Software Foundation, either version 3 of the Licence.
Quasar is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public Licence for more details.
You should have received a copy of the GNU Lesser General Public License
along with Quasar. If not, see <http://www.gnu.org/licenses/>.
*/


#include <Configuration.hxx> // TODO; should go away, is already in Base class for ages

#include <DSourceVariableThreadPool.h>
#include <ASSourceVariableThreadPool.h>

#include <SourceVariables.h>

namespace Device
{
// 1111111111111111111111111111111111111111111111111111111111111111111111111
// 1 GENERATED CODE STARTS HERE AND FINISHES AT SECTION 2 1
// 1 Users don't modify this code!!!! 1
// 1 If you modify this code you may start a fire or a flood somewhere,1
// 1 and some human being may possible cease to exist. You don't want 1
// 1 to be charged with that! 1
// 1111111111111111111111111111111111111111111111111111111111111111111111111






// 2222222222222222222222222222222222222222222222222222222222222222222222222
// 2 SEMI CUSTOM CODE STARTS HERE AND FINISHES AT SECTION 3 2
// 2 (code for which only stubs were generated automatically) 2
// 2 You should add the implementation but dont alter the headers 2
// 2 (apart from constructor, in which you should complete initializati2
// 2 on list) 2
// 2222222222222222222222222222222222222222222222222222222222222222222222222

/* sample ctr */
DSourceVariableThreadPool::DSourceVariableThreadPool (
const Configuration::SourceVariableThreadPool& config,
Parent_DSourceVariableThreadPool* parent
):
Base_DSourceVariableThreadPool( config, parent)

/* fill up constructor initialization list here */
{
/* fill up constructor body here */
#ifndef BACKEND_OPEN62541
try
{
const std::string minThreads = config.minThreads();
const std::string maxThreads = config.maxThreads();
LOG(Log::INF) << __FUNCTION__ << " starting source variable thread pool with min threads ["<<minThreads<<"] max threads ["<<maxThreads<<"]";
AddressSpace::SourceVariables_initSourceVariablesThreadPool (std::stoi(minThreads), std::stoi(maxThreads));
}
catch(const std::exception& e)
{
LOG(Log::ERR) << __FUNCTION__ << " failed to start source variable thread pool, error: " << e.what();
throw e;
}
#endif
}

/* sample dtr */
DSourceVariableThreadPool::~DSourceVariableThreadPool ()
{
}

/* delegates for cachevariables */



/* delegators for methods */

// 3333333333333333333333333333333333333333333333333333333333333333333333333
// 3 FULLY CUSTOM CODE STARTS HERE 3
// 3 Below you put bodies for custom methods defined for this class. 3
// 3 You can do whatever you want, but please be decent. 3
// 3333333333333333333333333333333333333333333333333333333333333333333333333

}

0 comments on commit 3f57166

Please sign in to comment.