Skip to content

Commit

Permalink
-fixed simObjects also for VxWorks
Browse files Browse the repository at this point in the history
  • Loading branch information
RuedKamp committed Nov 9, 2015
1 parent b612c7a commit f279180
Show file tree
Hide file tree
Showing 7 changed files with 76 additions and 8 deletions.
14 changes: 13 additions & 1 deletion Compiler/Template/CodegenCpp.tpl
Expand Up @@ -454,6 +454,18 @@ case SIMCODE(modelInfo=MODELINFO()) then
return new SimData();
}

shared_ptr<ISimData> createSimDataFunction()
{
shared_ptr<ISimData> data( new SimData() );
return data;
}

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)
{
shared_ptr<ISimVars> var( new SimVars(dim_real, dim_int, dim_bool, dim_string, dim_pre_vars, dim_z, z_i) );
return var;
}

#elif defined (RUNTIME_STATIC_LINKING)
#include <Core/System/FactoryExport.h>
#include <Core/DataExchange/SimData.h>
Expand Down Expand Up @@ -1900,7 +1912,7 @@ extern "C" int initSimulation(ISimController* &controller, ISimData* &data, dou
PATH modelicaSystem_path = "";
shared_ptr<VxWorksFactory> factory = shared_ptr<VxWorksFactory>(new VxWorksFactory(libraries_path, modelicaSystem_path));
ISimController* sim_controller = createSimController(libraries_path, modelicaSystem_path);
shared_ptr<ISimObjects> simObjects= simulation.first->getSimObjects();
shared_ptr<ISimObjects> simObjects= sim_controller->getSimObjects();
weak_ptr<ISimData> simData = simObjects->LoadSimData("<%lastIdentOfPath(modelInfo.name)%>");
weak_ptr<ISimVars> simVars = simObjects->LoadSimVars("<%lastIdentOfPath(modelInfo.name)%>",<%numRealVars%>,<%numIntVars%>,<%numBoolVars%>,<%numStringVars%>,<%numPreVars%>,<%numStatevars(modelInfo)%>,<%numStateVarIndex(modelInfo)%>);
weak_ptr<IMixedSystem> system = sim_controller->LoadSystem("<%lastIdentOfPath(modelInfo.name)%>","<%lastIdentOfPath(modelInfo.name)%>");
Expand Down
29 changes: 28 additions & 1 deletion SimulationRuntime/cpp/Core/DataExchange/FactoryExport.cpp
Expand Up @@ -2,8 +2,35 @@
#include <Core/Modelica.h>
#if defined(__TRICORE__) || defined(__vxworks)

#include <Core/DataExchange/FactoryExport.h>
#include <Core/DataExchange/SimData.h>

#include <Core/DataExchange/XmlPropertyReader.h>
#include <Core/DataExchange/Writer.h>
#include <Core/DataExchange/Policies/TextfileWriter.h>
#include <Core/DataExchange/Policies/MatfileWriter.h>
#include <Core/DataExchange/Policies/BufferReaderWriter.h>
#include <Core/DataExchange/Policies/DefaultWriter.h>
#include <Core/DataExchange/HistoryImpl.h>
shared_ptr<IHistory> createMatFileWriterFactory(IGlobalSettings& globalSettings,size_t dim)
{
shared_ptr<IHistory> writer= shared_ptr<IHistory>(new HistoryImpl<MatFileWriter >(globalSettings,dim) );
return writer;
}
shared_ptr<IHistory> createTextFileWriterFactory(IGlobalSettings& globalSettings,size_t dim)
{
shared_ptr<IHistory> writer= shared_ptr<IHistory>(new HistoryImpl<TextFileWriter >(globalSettings,dim) );
return writer;
}
shared_ptr<IHistory> createBufferReaderWriterFactory(IGlobalSettings& globalSettings,size_t dim)
{
shared_ptr<IHistory> writer= shared_ptr<IHistory>(new HistoryImpl<BufferReaderWriter >(globalSettings,dim) );
return writer;
}
shared_ptr<IHistory> createDefaultWriterFactory(IGlobalSettings& globalSettings,size_t dim)
{
shared_ptr<IHistory> writer= shared_ptr<IHistory>(new HistoryImpl<DefaultWriter>(globalSettings,dim) );
return writer;
}
#elif defined(OMC_BUILD) && !defined(RUNTIME_STATIC_LINKING)
#include <Core/DataExchange/FactoryExport.h>
#include <Core/DataExchange/SimData.h>
Expand Down
9 changes: 8 additions & 1 deletion SimulationRuntime/cpp/Core/SimController/FactoryExport.cpp
Expand Up @@ -8,13 +8,20 @@



#include <Core/SimController/ISimController.h>
#include <Core/SimController/SimController.h>
#include <Core/SimController/SimObjects.h>

extern "C" ISimController* createSimController(PATH library_path, PATH modelicasystem_path)
{
return new SimController(library_path, modelicasystem_path);
}

shared_ptr<ISimObjects> createSimObjects(PATH library_path, PATH modelicasystem_path,IGlobalSettings* settings)
{
return shared_ptr<ISimObjects>(new SimObjects(library_path, modelicasystem_path,settings));
}

#elif defined(SIMSTER_BUILD)


Expand Down Expand Up @@ -58,4 +65,4 @@ shared_ptr<ISimObjects> createSimObjects(PATH library_path, PATH modelicasystem_
#else
error "operating system not supported"
#endif
/** @} */ // end of coreSimcontroller
/** @} */ // end of coreSimcontroller
6 changes: 5 additions & 1 deletion SimulationRuntime/cpp/Core/System/FactoryExport.cpp
Expand Up @@ -9,8 +9,12 @@

#include <SimCoreFactory/VxWorksFactory/VxWorksFactory.h>
#include <Core/System/AlgLoopSolverFactory.h>
extern "C" IAlgLoopSolverFactory* createAlgLoopSolverFactory(IGlobalSettings* globalSettings,PATH library_path,PATH modelicasystem_path)

extern "C" IAlgLoopSolverFactory* createAlgLoopSolverFactoryFunction(IGlobalSettings* globalSettings,PATH library_path,PATH modelicasystem_path)
//shared_ptr<IAlgLoopSolverFactory> createAlgLoopSolverFactoryFunction(IGlobalSettings* globalSettings,PATH library_path,PATH modelicasystem_path)
{
//shared_ptr<IAlgLoopSolverFactory> algloopSolverFactory = shared_ptr<IAlgLoopSolverFactory>(new AlgLoopSolverFactory(globalSettings,library_path,modelicasystem_path));
//return algloopSolverFactory;
return new AlgLoopSolverFactory(globalSettings,library_path,modelicasystem_path);
}

Expand Down
Expand Up @@ -5,7 +5,7 @@
#if defined(__vxworks)

/*Defines*/
#define PATH string
#define PATH std::string

#include <Core/System/ISystemProperties.h>
#include <Core/System/ISystemInitialization.h>
Expand All @@ -28,6 +28,7 @@
#include <Core/System/ISimVars.h>
#include <Core/DataExchange/ISimVar.h>
#include <Core/SimController/ISimData.h>
#include <Core/SimController/ISimObjects.h>
#include <Core/SimulationSettings/ISimControllerSettings.h>
#include <Core/SimController/ISimController.h>

Expand Down
Expand Up @@ -11,13 +11,17 @@
#include <SimCoreFactory/Policies/SolverSettingsVxWorksFactory.h>
#include <SimCoreFactory/Policies/SystemVxWorksFactory.h>
#include <SimCoreFactory/Policies/NonLinSolverVxWorksFactory.h>
#include <SimCoreFactory/Policies/SimObjectVxWorksFactory.h>
#include <SimCoreFactory/Policies/LinSolverVxWorksFactory.h>
/*Policy defines*/

typedef VxWorksFactory BaseFactory;
typedef SystemVxWorksFactory<BaseFactory> SimControllerPolicy;
typedef SolverVxWorksFactory<BaseFactory> ConfigurationPolicy;
//typedef LinSolverVxWorksFactory<BaseFactory> NonLinSolverPolicy;

typedef SimObjectVxWorksFactory<BaseFactory> SimObjectPolicy;

typedef NonLinSolverVxWorksFactory<BaseFactory> NonLinSolverPolicy;
typedef SolverSettingsVxWorksFactory<BaseFactory> SolverSettingsPolicy;
typedef LinSolverVxWorksFactory<BaseFactory> LinSolverPolicy;
Expand Down
Expand Up @@ -10,7 +10,13 @@

extern "C" ISimController* createSimController(PATH library_path, PATH modelicasystem_path);
extern "C" ISettingsFactory* createSettingsFactory(PATH library_path,PATH modelicasystem_path);
extern "C" IAlgLoopSolverFactory* createAlgLoopSolverFactory(IGlobalSettings* globalSettings,PATH library_path,PATH modelicasystem_path);

extern "C" IAlgLoopSolverFactory* createAlgLoopSolverFactoryFunction(IGlobalSettings* globalSettings,PATH library_path,PATH modelicasystem_path);

//shared_ptr<IAlgLoopSolverFactory> createAlgLoopSolverFactory(IGlobalSettings* globalSettings);



extern "C" ISimData* createSimData();
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);
extern "C" ISolver* createRTEuler(IMixedSystem* system, ISolverSettings* settings);
Expand Down Expand Up @@ -50,12 +56,19 @@ shared_ptr<ISettingsFactory> VxWorksFactory::LoadSettingsFactory()

shared_ptr<IAlgLoopSolverFactory> VxWorksFactory::LoadAlgLoopSolverFactory(IGlobalSettings* globalSettings)
{
IAlgLoopSolverFactory* algloopsolverFactory = createAlgLoopSolverFactory(globalSettings, _library_path, _modelicasystem_path);
IAlgLoopSolverFactory* algloopsolverFactory = createAlgLoopSolverFactoryFunction(globalSettings, _library_path, _modelicasystem_path);
return shared_ptr<IAlgLoopSolverFactory>(algloopsolverFactory);

}

shared_ptr<IMixedSystem> VxWorksFactory::LoadSystem(IGlobalSettings* globalSettings, shared_ptr<IAlgLoopSolverFactory> nonlinsolver, shared_ptr<ISimObjects> simObjects)
/*
shared_ptr<IAlgLoopSolverFactory> VxWorksFactory::LoadAlgLoopSolverFactory(IGlobalSettings* globalSettings)
{
return createAlgLoopSolverFactory(globalSettings);
}
*/

shared_ptr<IMixedSystem> VxWorksFactory::LoadSystem(IGlobalSettings* globalSettings,shared_ptr<ISimObjects> simObjects)
{
IMixedSystem* system = createModelicaSystem(globalSettings, simObjects);
return shared_ptr<IMixedSystem>(system);
Expand Down

0 comments on commit f279180

Please sign in to comment.