diff --git a/.cproject b/.cproject
index 0649f5e..b616eb7 100644
--- a/.cproject
+++ b/.cproject
@@ -44,8 +44,8 @@
-
-
+
+
diff --git a/cmake/Pytest.cmake b/cmake/Pytest.cmake
index 43a1983..37b8c43 100644
--- a/cmake/Pytest.cmake
+++ b/cmake/Pytest.cmake
@@ -9,7 +9,7 @@ find_package(Python COMPONENTS Interpreter Development)
function(pytest_discover_tests)
cmake_parse_arguments(
PARSE_ARGV 0 "" ""
- "NAME;WORKING_DIRECTORY;TRIM_FROM_NAME;BUNDLE_TESTS"
+ "NAME;WORKING_DIRECTORY;BUNDLE_TESTS"
"LIBRARY_PATH_PREPEND;PYTHON_PATH_PREPEND;ENVIRONMENT"
)
@@ -66,9 +66,7 @@ function(pytest_discover_tests)
if (NOT _WORKING_DIRECTORY)
set(_WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/python)
endif()
- if (NOT _TRIM_FROM_NAME)
- set(_TRIM_FROM_NAME "^test_")
- endif()
+
# Override option by environment variable if available.
if (DEFINED ENV{BUNDLE_PYTHON_TESTS})
set(_BUNDLE_TESTS $ENV{BUNDLE_PYTHON_TESTS})
@@ -97,7 +95,6 @@ function(pytest_discover_tests)
" LIB_ENV_PATH" " [==[" "${LIB_ENV_PATH}" "]==]" "\n"
" LIBRARY_PATH" " [==[" "${libpath}" "]==]" "\n"
" PYTHON_PATH" " [==[" "${pythonpath}" "]==]" "\n"
- " TRIM_FROM_NAME" " [==[" "${_TRIM_FROM_NAME}" "]==]" "\n"
" WORKING_DIRECTORY" " [==[" "${_WORKING_DIRECTORY}" "]==]" "\n"
" ENVIRONMENT" " [==[" "${_ENVIRONMENT}" "]==]" "\n"
" CTEST_FILE" " [==[" "${ctest_tests_file}" "]==]" "\n"
diff --git a/cmake/PytestAddTests.cmake b/cmake/PytestAddTests.cmake
index 48a6ecd..07a73ef 100644
--- a/cmake/PytestAddTests.cmake
+++ b/cmake/PytestAddTests.cmake
@@ -6,7 +6,7 @@ function(pytest_discover_tests_impl)
cmake_parse_arguments(
""
""
- "PYTHON_EXECUTABLE;TEST_GROUP_NAME;BUNDLE_TESTS;LIB_ENV_PATH;LIBRARY_PATH;PYTHON_PATH;TRIM_FROM_NAME;WORKING_DIRECTORY;ENVIRONMENT;CTEST_FILE"
+ "PYTHON_EXECUTABLE;TEST_GROUP_NAME;BUNDLE_TESTS;LIB_ENV_PATH;LIBRARY_PATH;PYTHON_PATH;WORKING_DIRECTORY;ENVIRONMENT;CTEST_FILE"
""
${ARGN}
)
@@ -73,16 +73,17 @@ function(pytest_discover_tests_impl)
set(_class ${CMAKE_MATCH_3})
set(_func ${CMAKE_MATCH_4})
+
+ string(REGEX REPLACE "^test_?" "" _func "${_func}")
+
if (_class)
+ #string(REGEX REPLACE "^Test|Test$" "" _class "${_class}")
set(test_name "${_class}.${_func}")
else()
set(test_name "${_func}")
endif()
- if (_TRIM_FROM_NAME)
- string(REGEX REPLACE
- "${_TRIM_FROM_NAME}" "" test_name "${test_name}")
- endif()
+
set(test_name "${_TEST_GROUP_NAME}/${test_name}")
set(test_case "${_WORKING_DIRECTORY}/${test_case}")
@@ -128,7 +129,6 @@ if(CMAKE_SCRIPT_MODE_FILE)
LIB_ENV_PATH ${LIB_ENV_PATH}
LIBRARY_PATH ${LIBRARY_PATH}
PYTHON_PATH ${PYTHON_PATH}
- TRIM_FROM_NAME ${TRIM_FROM_NAME}
WORKING_DIRECTORY ${WORKING_DIRECTORY}
ENVIRONMENT ${ENVIRONMENT}
CTEST_FILE ${CTEST_FILE}
diff --git a/examples/project1/python/xsmp_example_project1/Example/__init__.py b/examples/project1/python/xsmp_example_project1/Example/__init__.py
index 7a02a6c..f9a9580 100644
--- a/examples/project1/python/xsmp_example_project1/Example/__init__.py
+++ b/examples/project1/python/xsmp_example_project1/Example/__init__.py
@@ -10,7 +10,7 @@
import ecss_smp
-class M1:
+class Counter:
uuid: ecss_smp.Smp.Uuid = ecss_smp.Smp.Uuid("2386045d-5cff-46b5-b6da-3ff6e2cfd792")
del ecss_smp
diff --git a/examples/project1/python/xsmp_example_project1/_test_xsmp_example_project1.py b/examples/project1/python/xsmp_example_project1/_test_Counter.py
similarity index 80%
rename from examples/project1/python/xsmp_example_project1/_test_xsmp_example_project1.py
rename to examples/project1/python/xsmp_example_project1/_test_Counter.py
index 717c7c1..8daa4ee 100644
--- a/examples/project1/python/xsmp_example_project1/_test_xsmp_example_project1.py
+++ b/examples/project1/python/xsmp_example_project1/_test_Counter.py
@@ -39,21 +39,18 @@ class __XsmpScheduler(ecss_smp.Smp.Services.IScheduler, ecss_smp.Smp.IDynamicInv
_Models: ecss_smp.Smp.IContainer
- class __name(ecss_smp.Smp.IModel, ecss_smp.Smp.IDynamicInvocation, ecss_smp.Smp.ILinkingComponent, ecss_smp.Smp.IComposite, ):
- class __integer1(ecss_smp.Smp.ISimpleField, ):
- pass
-
- integer1: __integer1
+ class __counter(ecss_smp.Smp.IModel, ecss_smp.Smp.IDynamicInvocation, ecss_smp.Smp.IEventConsumer, ecss_smp.Smp.ILinkingComponent, ecss_smp.Smp.IEntryPointPublisher, ):
+ def ResetCount(self, ): ...
+ Add: ecss_smp.Smp.IEventSink
- class __integer2(ecss_smp.Smp.ISimpleField, ):
+ class __count(ecss_smp.Smp.ISimpleField, ):
pass
- integer2: __integer2
-
- _subModels: ecss_smp.Smp.IContainer
+ count: __count
+ IncrementCount: ecss_smp.Smp.IEntryPoint
- name: __name
+ counter: __counter
diff --git a/examples/project1/python/xsmp_example_project1/test_Counter.py b/examples/project1/python/xsmp_example_project1/test_Counter.py
new file mode 100644
index 0000000..7664bd6
--- /dev/null
+++ b/examples/project1/python/xsmp_example_project1/test_Counter.py
@@ -0,0 +1,36 @@
+import ecss_smp
+import xsmp
+import xsmp_example_project1
+
+
+class TestCounter(xsmp.unittest.TestCase):
+ try:
+ sim: xsmp_example_project1._test_xsmp_example_project1.Simulator
+ except AttributeError:
+ pass
+
+ def loadAssembly(self, sim: ecss_smp.Smp.ISimulator):
+ sim.LoadLibrary("xsmp_example_project1")
+ sim.AddModel(sim.CreateInstance(xsmp_example_project1.Example.Counter.uuid, "counter", "", sim))
+
+ def test_Init(self):
+ self.assertEqual(self.sim.counter.count, 0, "Initial value of count is 0")
+
+ def test_IncrementCount(self):
+ self.sim.counter.IncrementCount()
+ self.assertEqual(self.sim.counter.count, 1, "Count incremented")
+
+ def test_ScheduleIncrementCount(self):
+ self.sim.GetScheduler().AddSimulationTimeEvent(self.sim.counter.IncrementCount, 0, 1_000_000_000, 5)
+ self.sim.Run(seconds=10)
+ self.assertEqual(self.sim.counter.count, 6, "Count incremented 6 times")
+
+ def test_ResetCount(self):
+ self.sim.counter.count = 10
+ self.sim.counter.ResetCount()
+ self.assertEqual(self.sim.counter.count, 0, "Count is reseted")
+
+ def test_Add(self):
+ self.sim.counter.Add(arg=10)
+ self.assertEqual(self.sim.counter.count, 10, "Add 10 to count")
+
diff --git a/examples/project1/python/xsmp_example_project1/test_xsmp_example_project1.py b/examples/project1/python/xsmp_example_project1/test_xsmp_example_project1.py
deleted file mode 100644
index 927f8aa..0000000
--- a/examples/project1/python/xsmp_example_project1/test_xsmp_example_project1.py
+++ /dev/null
@@ -1,21 +0,0 @@
-import ecss_smp
-import xsmp
-import xsmp_example_project1
-
-
-class TestXsmpExampleProject1(xsmp.unittest.TestCase):
- try:
- sim: xsmp_example_project1._test_xsmp_example_project1.Simulator
- except AttributeError:
- pass
-
- def loadAssembly(self, sim: ecss_smp.Smp.ISimulator):
- sim.LoadLibrary("xsmp_example_project1")
- sim.AddModel(sim.CreateInstance(xsmp_example_project1.Example.M1.uuid, "name", "", sim))
-
- def test_Init(self):
- pass
-
-
- def test_Init2(self):
- pass
\ No newline at end of file
diff --git a/examples/project1/smdl-gen/xsmp_example_project1.smpcat b/examples/project1/smdl-gen/xsmp_example_project1.smpcat
index cd0c972..1622e21 100644
--- a/examples/project1/smdl-gen/xsmp_example_project1.smpcat
+++ b/examples/project1/smdl-gen/xsmp_example_project1.smpcat
@@ -1,22 +1,29 @@
-
+
Catalogue xsmp_example_project1
-
+
-
+
+
+
+
+
-
-
-
+
+
-
-
-
+
+
+
+
+
+
-
-
+
+
+
diff --git a/examples/project1/smdl-gen/xsmp_example_project1.smppkg b/examples/project1/smdl-gen/xsmp_example_project1.smppkg
index de7d253..98d0030 100644
--- a/examples/project1/smdl-gen/xsmp_example_project1.smppkg
+++ b/examples/project1/smdl-gen/xsmp_example_project1.smppkg
@@ -1,5 +1,6 @@
-
+
Catalogue xsmp_example_project1
-
+
+
diff --git a/examples/project1/smdl/xsmp_example_project1.xsmpcat b/examples/project1/smdl/xsmp_example_project1.xsmpcat
index 25bb20d..e711bef 100644
--- a/examples/project1/smdl/xsmp_example_project1.xsmpcat
+++ b/examples/project1/smdl/xsmp_example_project1.xsmpcat
@@ -7,20 +7,24 @@
* Catalogue xsmp_example_project1
*
* @creator Y.Daveluy
- * @date 2023-06-02T17:08:16.000+0200
+ * @date 2024-01-04T10:37:00.000+0100
*/
catalogue xsmp_example_project1
namespace Example
{
+ /** @uuid f80c5d8e-deb4-492a-a5c0-4d37eadebe24 */
+ event CountEvent extends Int32
+
/** @uuid 2386045d-5cff-46b5-b6da-3ff6e2cfd792 */
- model M1
+ model Counter
{
- field Int8 integer1
- field Int16 integer2
+ field Int32 count = 0
- container M1[*] subModels
+ entrypoint IncrementCount
+ def void ResetCount ()
+ eventsink CountEvent Add
}
}
diff --git a/examples/project1/src-gen/Example/CounterGen.cpp b/examples/project1/src-gen/Example/CounterGen.cpp
new file mode 100644
index 0000000..485e402
--- /dev/null
+++ b/examples/project1/src-gen/Example/CounterGen.cpp
@@ -0,0 +1,121 @@
+// Copyright 2023 YOUR ORGANIZATION. All rights reserved.
+//
+// YOUR NOTICE
+
+// -----------------------------------------------------------------------------
+// File Name : CounterGen.cpp
+// Generated by : XsmpSdkGenerator-${qualifiedVersion}
+// -----------------------------------------------------------------------------
+/// @file Example/CounterGen.cpp
+// This file is auto-generated, Do not edit otherwise your changes will be lost
+
+// ----------------------------------------------------------------------------
+// ---------------------------- Include Header Files --------------------
+// ----------------------------------------------------------------------------
+
+#include
+#include
+#include
+#include
+#include
+#include
+
+namespace Example {
+//--------------------------- Constructor -------------------------
+CounterGen::CounterGen(::Smp::String8 name, ::Smp::String8 description,
+ ::Smp::IObject *parent, ::Smp::ISimulator *simulator) :
+ // Base class initialization
+ ::Xsmp::Model(name, description, parent, simulator),
+ // EntryPoint: IncrementCount
+ IncrementCount { new ::Xsmp::EntryPoint("IncrementCount", "", this,
+ std::bind(&CounterGen::_IncrementCount, this)) },
+ // Event Sink: Add
+ Add { new ::Xsmp::EventSink<::Smp::Int32>("Add", "", this,
+ std::bind(&CounterGen::_Add, this, std::placeholders::_1,
+ std::placeholders::_2),
+ ::Smp::PrimitiveTypeKind::PTK_Int32) },
+ // count initialization
+ count { 0 } {
+}
+
+/// Virtual destructor that is called by inherited classes as well.
+CounterGen::~CounterGen() {
+ delete IncrementCount;
+ IncrementCount = nullptr;
+ delete Add;
+ Add = nullptr;
+}
+
+void CounterGen::Publish(::Smp::IPublication *receiver) {
+ // Call parent class implementation first
+ ::Xsmp::Model::Publish(receiver);
+
+ // Publish field count
+ receiver->PublishField("count", "", &count, ::Smp::ViewKind::VK_None, true,
+ false, false);
+ {
+ // Publish operation ResetCount
+ receiver->PublishOperation("ResetCount", "", ::Smp::ViewKind::VK_None);
+ }
+ // Call user DoPublish if any
+ ::Xsmp::Component::Helper::Publish < ::Example::Counter > (this, receiver);
+}
+
+void CounterGen::Configure(::Smp::Services::ILogger *logger,
+ ::Smp::Services::ILinkRegistry *linkRegistry) {
+ // Call parent implementation first
+ ::Xsmp::Model::Configure(logger, linkRegistry);
+
+ // Call user DoConfigure if any
+ ::Xsmp::Component::Helper::Configure < ::Example::Counter
+ > (this, logger, linkRegistry);
+}
+
+void CounterGen::Connect(::Smp::ISimulator *simulator) {
+ // Call parent implementation first
+ ::Xsmp::Model::Connect(simulator);
+
+ // Call user DoConnect if any
+ ::Xsmp::Component::Helper::Connect < ::Example::Counter > (this, simulator);
+}
+
+void CounterGen::Disconnect() {
+ // Call user DoDisconnect if any
+ ::Xsmp::Component::Helper::Disconnect < ::Example::Counter > (this);
+
+ // Call parent implementation last, to remove references to the Simulator and its services
+ ::Xsmp::Model::Disconnect();
+}
+
+CounterGen::RequestHandlers CounterGen::requestHandlers = InitRequestHandlers();
+
+CounterGen::RequestHandlers CounterGen::InitRequestHandlers() {
+ RequestHandlers handlers;
+ if (handlers.find("ResetCount") == handlers.end()) {
+ handlers["ResetCount"] = [](CounterGen *cmp, ::Smp::IRequest*) {
+
+ /// Invoke ResetCount
+ cmp->ResetCount();
+
+ };
+ }
+ return handlers;
+}
+
+void CounterGen::Invoke(::Smp::IRequest *request) {
+ if (request == nullptr) {
+ return;
+ }
+ auto handler = requestHandlers.find(request->GetOperationName());
+ if (handler != requestHandlers.end()) {
+ handler->second(this, request);
+ } else {
+ // pass the request down to the base model
+ ::Xsmp::Model::Invoke(request);
+ }
+}
+
+const Smp::Uuid& CounterGen::GetUuid() const {
+ return Uuid_Counter;
+}
+} // namespace Example
diff --git a/examples/project1/src-gen/Example/M1Gen.h b/examples/project1/src-gen/Example/CounterGen.h
similarity index 60%
rename from examples/project1/src-gen/Example/M1Gen.h
rename to examples/project1/src-gen/Example/CounterGen.h
index 8f1cc81..c3d9d9b 100644
--- a/examples/project1/src-gen/Example/M1Gen.h
+++ b/examples/project1/src-gen/Example/CounterGen.h
@@ -3,25 +3,31 @@
// YOUR NOTICE
// -----------------------------------------------------------------------------
-// File Name : M1Gen.h
+// File Name : CounterGen.h
// Generated by : XsmpSdkGenerator-${qualifiedVersion}
// -----------------------------------------------------------------------------
-/// @file Example/M1Gen.h
+/// @file Example/CounterGen.h
// This file is auto-generated, Do not edit otherwise your changes will be lost
-#ifndef EXAMPLE_M1GEN_H_
-#define EXAMPLE_M1GEN_H_
+#ifndef EXAMPLE_COUNTERGEN_H_
+#define EXAMPLE_COUNTERGEN_H_
// ----------------------------------------------------------------------------
// ---------------------------- Include Header Files --------------------
// ----------------------------------------------------------------------------
-#include "Smp/ISimulator.h"
-#include "Smp/PrimitiveTypes.h"
-#include "Smp/Publication/ITypeRegistry.h"
-#include "Xsmp/Composite.h"
-#include "Xsmp/Container.h"
-#include "Xsmp/Model.h"
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include