Skip to content

Commit f279180

Browse files
committed
-fixed simObjects also for VxWorks
1 parent b612c7a commit f279180

File tree

7 files changed

+76
-8
lines changed

7 files changed

+76
-8
lines changed

Compiler/Template/CodegenCpp.tpl

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,18 @@ case SIMCODE(modelInfo=MODELINFO()) then
454454
return new SimData();
455455
}
456456

457+
shared_ptr<ISimData> createSimDataFunction()
458+
{
459+
shared_ptr<ISimData> data( new SimData() );
460+
return data;
461+
}
462+
463+
shared_ptr<ISimVars> createSimVarsFunction(size_t dim_real, size_t dim_int, size_t dim_bool, size_t dim_string, size_t dim_pre_vars, size_t dim_z, size_t z_i)
464+
{
465+
shared_ptr<ISimVars> var( new SimVars(dim_real, dim_int, dim_bool, dim_string, dim_pre_vars, dim_z, z_i) );
466+
return var;
467+
}
468+
457469
#elif defined (RUNTIME_STATIC_LINKING)
458470
#include <Core/System/FactoryExport.h>
459471
#include <Core/DataExchange/SimData.h>
@@ -1900,7 +1912,7 @@ extern "C" int initSimulation(ISimController* &controller, ISimData* &data, dou
19001912
PATH modelicaSystem_path = "";
19011913
shared_ptr<VxWorksFactory> factory = shared_ptr<VxWorksFactory>(new VxWorksFactory(libraries_path, modelicaSystem_path));
19021914
ISimController* sim_controller = createSimController(libraries_path, modelicaSystem_path);
1903-
shared_ptr<ISimObjects> simObjects= simulation.first->getSimObjects();
1915+
shared_ptr<ISimObjects> simObjects= sim_controller->getSimObjects();
19041916
weak_ptr<ISimData> simData = simObjects->LoadSimData("<%lastIdentOfPath(modelInfo.name)%>");
19051917
weak_ptr<ISimVars> simVars = simObjects->LoadSimVars("<%lastIdentOfPath(modelInfo.name)%>",<%numRealVars%>,<%numIntVars%>,<%numBoolVars%>,<%numStringVars%>,<%numPreVars%>,<%numStatevars(modelInfo)%>,<%numStateVarIndex(modelInfo)%>);
19061918
weak_ptr<IMixedSystem> system = sim_controller->LoadSystem("<%lastIdentOfPath(modelInfo.name)%>","<%lastIdentOfPath(modelInfo.name)%>");

SimulationRuntime/cpp/Core/DataExchange/FactoryExport.cpp

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,35 @@
22
#include <Core/Modelica.h>
33
#if defined(__TRICORE__) || defined(__vxworks)
44

5+
#include <Core/DataExchange/FactoryExport.h>
56
#include <Core/DataExchange/SimData.h>
6-
7+
#include <Core/DataExchange/XmlPropertyReader.h>
8+
#include <Core/DataExchange/Writer.h>
9+
#include <Core/DataExchange/Policies/TextfileWriter.h>
10+
#include <Core/DataExchange/Policies/MatfileWriter.h>
11+
#include <Core/DataExchange/Policies/BufferReaderWriter.h>
12+
#include <Core/DataExchange/Policies/DefaultWriter.h>
13+
#include <Core/DataExchange/HistoryImpl.h>
14+
shared_ptr<IHistory> createMatFileWriterFactory(IGlobalSettings& globalSettings,size_t dim)
15+
{
16+
shared_ptr<IHistory> writer= shared_ptr<IHistory>(new HistoryImpl<MatFileWriter >(globalSettings,dim) );
17+
return writer;
18+
}
19+
shared_ptr<IHistory> createTextFileWriterFactory(IGlobalSettings& globalSettings,size_t dim)
20+
{
21+
shared_ptr<IHistory> writer= shared_ptr<IHistory>(new HistoryImpl<TextFileWriter >(globalSettings,dim) );
22+
return writer;
23+
}
24+
shared_ptr<IHistory> createBufferReaderWriterFactory(IGlobalSettings& globalSettings,size_t dim)
25+
{
26+
shared_ptr<IHistory> writer= shared_ptr<IHistory>(new HistoryImpl<BufferReaderWriter >(globalSettings,dim) );
27+
return writer;
28+
}
29+
shared_ptr<IHistory> createDefaultWriterFactory(IGlobalSettings& globalSettings,size_t dim)
30+
{
31+
shared_ptr<IHistory> writer= shared_ptr<IHistory>(new HistoryImpl<DefaultWriter>(globalSettings,dim) );
32+
return writer;
33+
}
734
#elif defined(OMC_BUILD) && !defined(RUNTIME_STATIC_LINKING)
835
#include <Core/DataExchange/FactoryExport.h>
936
#include <Core/DataExchange/SimData.h>

SimulationRuntime/cpp/Core/SimController/FactoryExport.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,20 @@
88

99

1010

11+
#include <Core/SimController/ISimController.h>
1112
#include <Core/SimController/SimController.h>
13+
#include <Core/SimController/SimObjects.h>
1214

1315
extern "C" ISimController* createSimController(PATH library_path, PATH modelicasystem_path)
1416
{
1517
return new SimController(library_path, modelicasystem_path);
1618
}
1719

20+
shared_ptr<ISimObjects> createSimObjects(PATH library_path, PATH modelicasystem_path,IGlobalSettings* settings)
21+
{
22+
return shared_ptr<ISimObjects>(new SimObjects(library_path, modelicasystem_path,settings));
23+
}
24+
1825
#elif defined(SIMSTER_BUILD)
1926

2027

@@ -58,4 +65,4 @@ shared_ptr<ISimObjects> createSimObjects(PATH library_path, PATH modelicasystem_
5865
#else
5966
error "operating system not supported"
6067
#endif
61-
/** @} */ // end of coreSimcontroller
68+
/** @} */ // end of coreSimcontroller

SimulationRuntime/cpp/Core/System/FactoryExport.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,12 @@
99

1010
#include <SimCoreFactory/VxWorksFactory/VxWorksFactory.h>
1111
#include <Core/System/AlgLoopSolverFactory.h>
12-
extern "C" IAlgLoopSolverFactory* createAlgLoopSolverFactory(IGlobalSettings* globalSettings,PATH library_path,PATH modelicasystem_path)
12+
13+
extern "C" IAlgLoopSolverFactory* createAlgLoopSolverFactoryFunction(IGlobalSettings* globalSettings,PATH library_path,PATH modelicasystem_path)
14+
//shared_ptr<IAlgLoopSolverFactory> createAlgLoopSolverFactoryFunction(IGlobalSettings* globalSettings,PATH library_path,PATH modelicasystem_path)
1315
{
16+
//shared_ptr<IAlgLoopSolverFactory> algloopSolverFactory = shared_ptr<IAlgLoopSolverFactory>(new AlgLoopSolverFactory(globalSettings,library_path,modelicasystem_path));
17+
//return algloopSolverFactory;
1418
return new AlgLoopSolverFactory(globalSettings,library_path,modelicasystem_path);
1519
}
1620

SimulationRuntime/cpp/Include/SimCoreFactory/Policies/FactoryConfig.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#if defined(__vxworks)
66

77
/*Defines*/
8-
#define PATH string
8+
#define PATH std::string
99

1010
#include <Core/System/ISystemProperties.h>
1111
#include <Core/System/ISystemInitialization.h>
@@ -28,6 +28,7 @@
2828
#include <Core/System/ISimVars.h>
2929
#include <Core/DataExchange/ISimVar.h>
3030
#include <Core/SimController/ISimData.h>
31+
#include <Core/SimController/ISimObjects.h>
3132
#include <Core/SimulationSettings/ISimControllerSettings.h>
3233
#include <Core/SimController/ISimController.h>
3334

SimulationRuntime/cpp/Include/SimCoreFactory/Policies/FactoryPolicy.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,17 @@
1111
#include <SimCoreFactory/Policies/SolverSettingsVxWorksFactory.h>
1212
#include <SimCoreFactory/Policies/SystemVxWorksFactory.h>
1313
#include <SimCoreFactory/Policies/NonLinSolverVxWorksFactory.h>
14+
#include <SimCoreFactory/Policies/SimObjectVxWorksFactory.h>
1415
#include <SimCoreFactory/Policies/LinSolverVxWorksFactory.h>
1516
/*Policy defines*/
1617

1718
typedef VxWorksFactory BaseFactory;
1819
typedef SystemVxWorksFactory<BaseFactory> SimControllerPolicy;
1920
typedef SolverVxWorksFactory<BaseFactory> ConfigurationPolicy;
2021
//typedef LinSolverVxWorksFactory<BaseFactory> NonLinSolverPolicy;
22+
23+
typedef SimObjectVxWorksFactory<BaseFactory> SimObjectPolicy;
24+
2125
typedef NonLinSolverVxWorksFactory<BaseFactory> NonLinSolverPolicy;
2226
typedef SolverSettingsVxWorksFactory<BaseFactory> SolverSettingsPolicy;
2327
typedef LinSolverVxWorksFactory<BaseFactory> LinSolverPolicy;

SimulationRuntime/cpp/SimCoreFactory/VxWorksFactory/VxWorksFactory.cpp

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,13 @@
1010

1111
extern "C" ISimController* createSimController(PATH library_path, PATH modelicasystem_path);
1212
extern "C" ISettingsFactory* createSettingsFactory(PATH library_path,PATH modelicasystem_path);
13-
extern "C" IAlgLoopSolverFactory* createAlgLoopSolverFactory(IGlobalSettings* globalSettings,PATH library_path,PATH modelicasystem_path);
13+
14+
extern "C" IAlgLoopSolverFactory* createAlgLoopSolverFactoryFunction(IGlobalSettings* globalSettings,PATH library_path,PATH modelicasystem_path);
15+
16+
//shared_ptr<IAlgLoopSolverFactory> createAlgLoopSolverFactory(IGlobalSettings* globalSettings);
17+
18+
19+
1420
extern "C" ISimData* createSimData();
1521
extern "C" ISimVars* createSimVars(size_t dim_real,size_t dim_int,size_t dim_bool, size_t dim_string,size_t dim_pre_vars,size_t dim_z,size_t z_i);
1622
extern "C" ISolver* createRTEuler(IMixedSystem* system, ISolverSettings* settings);
@@ -50,12 +56,19 @@ shared_ptr<ISettingsFactory> VxWorksFactory::LoadSettingsFactory()
5056

5157
shared_ptr<IAlgLoopSolverFactory> VxWorksFactory::LoadAlgLoopSolverFactory(IGlobalSettings* globalSettings)
5258
{
53-
IAlgLoopSolverFactory* algloopsolverFactory = createAlgLoopSolverFactory(globalSettings, _library_path, _modelicasystem_path);
59+
IAlgLoopSolverFactory* algloopsolverFactory = createAlgLoopSolverFactoryFunction(globalSettings, _library_path, _modelicasystem_path);
5460
return shared_ptr<IAlgLoopSolverFactory>(algloopsolverFactory);
5561

5662
}
5763

58-
shared_ptr<IMixedSystem> VxWorksFactory::LoadSystem(IGlobalSettings* globalSettings, shared_ptr<IAlgLoopSolverFactory> nonlinsolver, shared_ptr<ISimObjects> simObjects)
64+
/*
65+
shared_ptr<IAlgLoopSolverFactory> VxWorksFactory::LoadAlgLoopSolverFactory(IGlobalSettings* globalSettings)
66+
{
67+
return createAlgLoopSolverFactory(globalSettings);
68+
}
69+
*/
70+
71+
shared_ptr<IMixedSystem> VxWorksFactory::LoadSystem(IGlobalSettings* globalSettings,shared_ptr<ISimObjects> simObjects)
5972
{
6073
IMixedSystem* system = createModelicaSystem(globalSettings, simObjects);
6174
return shared_ptr<IMixedSystem>(system);

0 commit comments

Comments
 (0)