-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
29 changed files
with
345 additions
and
231 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
examples/project1/python/xsmp_example_project1/test_Counter.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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") | ||
|
21 changes: 0 additions & 21 deletions
21
examples/project1/python/xsmp_example_project1/test_xsmp_example_project1.py
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,29 @@ | ||
<?xml version="1.0" encoding="ASCII"?> | ||
<Catalogue:Catalogue xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:Catalogue="http://www.ecss.nl/smp/2019/Smdl/Catalogue" xmlns:xlink="http://www.w3.org/1999/xlink" Id="_xsmp_example_project1" Name="xsmp_example_project1" Date="2023-06-02T15:08:16.000Z" Creator="Y.Daveluy"> | ||
<Catalogue:Catalogue xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:Catalogue="http://www.ecss.nl/smp/2019/Smdl/Catalogue" xmlns:Types="http://www.ecss.nl/smp/2019/Core/Types" xmlns:xlink="http://www.w3.org/1999/xlink" Id="_xsmp_example_project1" Name="xsmp_example_project1" Date="2024-01-04T09:37:00.000Z" Creator="Y.Daveluy"> | ||
<Description>Catalogue xsmp_example_project1</Description> | ||
<Namespace Id="Example" Name="Example"> | ||
<Description></Description> | ||
<Type xsi:type="Catalogue:Model" Id="Example.M1" Name="M1" Uuid="2386045d-5cff-46b5-b6da-3ff6e2cfd792"> | ||
<Type xsi:type="Catalogue:EventType" Id="Example.CountEvent" Name="CountEvent" Uuid="f80c5d8e-deb4-492a-a5c0-4d37eadebe24"> | ||
<Description></Description> | ||
<Field Id="Example.M1.integer1" Name="integer1" State="true" Input="false" Output="false"> | ||
<EventArgs xlink:title="Int32" xlink:href="http://www.ecss.nl/smp/2019/Smdl#Smp.Int32"/> | ||
</Type> | ||
<Type xsi:type="Catalogue:Model" Id="Example.Counter" Name="Counter" Uuid="2386045d-5cff-46b5-b6da-3ff6e2cfd792"> | ||
<Description></Description> | ||
<Operation Id="Example.Counter.ResetCount" Name="ResetCount"> | ||
<Description></Description> | ||
<Type xlink:title="Int8" xlink:href="http://www.ecss.nl/smp/2019/Smdl#Smp.Int8"/> | ||
</Field> | ||
<Field Id="Example.M1.integer2" Name="integer2" State="true" Input="false" Output="false"> | ||
</Operation> | ||
<EntryPoint Id="Example.Counter.IncrementCount" Name="IncrementCount"> | ||
<Description></Description> | ||
<Type xlink:title="Int16" xlink:href="http://www.ecss.nl/smp/2019/Smdl#Smp.Int16"/> | ||
</Field> | ||
<Container Id="Example.M1.subModels" Name="subModels" Lower="0" Upper="-1"> | ||
</EntryPoint> | ||
<EventSink Id="Example.Counter.Add" Name="Add"> | ||
<Description></Description> | ||
<Type xlink:title="CountEvent" xlink:href="#Example.CountEvent"/> | ||
</EventSink> | ||
<Field Id="Example.Counter.count" Name="count" State="true" Input="false" Output="false"> | ||
<Description></Description> | ||
<Type xlink:title="M1" xlink:href="#Example.M1"/> | ||
</Container> | ||
<Type xlink:title="Int32" xlink:href="http://www.ecss.nl/smp/2019/Smdl#Smp.Int32"/> | ||
<Default xsi:type="Types:Int32Value" Value="0"/> | ||
</Field> | ||
</Type> | ||
</Namespace> | ||
</Catalogue:Catalogue> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
<?xml version="1.0" encoding="ASCII"?> | ||
<Package:Package xmlns:Catalogue="http://www.ecss.nl/smp/2019/Smdl/Catalogue" xmlns:Package="http://www.ecss.nl/smp/2019/Smdl/Package" xmlns:xlink="http://www.w3.org/1999/xlink" Id="_xsmp_example_project1" Name="xsmp_example_project1" Date="2023-06-02T15:08:16.000Z" Creator="Y.Daveluy"> | ||
<Package:Package xmlns:Catalogue="http://www.ecss.nl/smp/2019/Smdl/Catalogue" xmlns:Package="http://www.ecss.nl/smp/2019/Smdl/Package" xmlns:xlink="http://www.w3.org/1999/xlink" Id="_xsmp_example_project1" Name="xsmp_example_project1" Date="2024-01-04T09:37:00.000Z" Creator="Y.Daveluy"> | ||
<Description>Catalogue xsmp_example_project1</Description> | ||
<Implementation xlink:title="M1" xlink:href="Catalogue:Model xsmp_example_project1.smpcat#Example.M1"/> | ||
<Implementation xlink:title="CountEvent" xlink:href="Catalogue:EventType xsmp_example_project1.smpcat#Example.CountEvent"/> | ||
<Implementation xlink:title="Counter" xlink:href="Catalogue:Model xsmp_example_project1.smpcat#Example.Counter"/> | ||
</Package:Package> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 <Example/Counter.h> | ||
#include <Smp/IPublication.h> | ||
#include <Xsmp/ComponentHelper.h> | ||
#include <Xsmp/EntryPoint.h> | ||
#include <Xsmp/EventSink.h> | ||
#include <Xsmp/Request.h> | ||
|
||
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 |
Oops, something went wrong.