Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- outsourced object creation in own classes - changed some interface method names - removed unused interface methods - add get/set method to IContinuous for simulation variables - adapted cpp template - adapted cpp fmu template - added SimManager for time events and removed time event handling from solver - added SimController class to start stop simulation, create Modelica system git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@16796 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
- Loading branch information
Showing
107 changed files
with
4,348 additions
and
2,001 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
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
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,23 @@ | ||
cmake_minimum_required (VERSION 2.6) | ||
|
||
project(${DataExchangeName}) | ||
|
||
add_library(${DataExchangeName} SHARED SimData.cpp FactoryExport.cpp ) | ||
target_link_libraries (${DataExchangeName} ${Boost_LIBRARIES} ) | ||
|
||
add_library(${DataExchangeName}_static STATIC SimData.cpp ) | ||
target_link_libraries (${DataExchangeName}_static ${Boost_LIBRARIES} ) | ||
|
||
install (TARGETS ${DataExchangeName} DESTINATION lib/omc/${LIBINSTALLEXT}) | ||
install (TARGETS ${DataExchangeName}_static DESTINATION lib/omc/${LIBINSTALLEXT}) | ||
|
||
install (FILES ${CMAKE_SOURCE_DIR}/Include/Core/DataExchange/IHistory.h | ||
${CMAKE_SOURCE_DIR}/Include/Core/DataExchange/ISimVar.h | ||
${CMAKE_SOURCE_DIR}/Include/Core/DataExchange/SimData.h | ||
DESTINATION include/omc/cpp/Core/DataExchange) | ||
|
||
|
||
|
||
|
||
|
||
|
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,31 @@ | ||
#pragma once | ||
|
||
#if defined(__vxworks) | ||
|
||
|
||
|
||
#elif defined(OMC_BUILD) | ||
#include "stdafx.h" | ||
#include <DataExchange/SimData.h> | ||
|
||
/* OMC factory*/ | ||
using boost::extensions::factory; | ||
|
||
BOOST_EXTENSION_TYPE_MAP_FUNCTION { | ||
types.get<std::map<std::string, factory<ISimData > > >() | ||
["SimData"].set<SimData>(); | ||
} | ||
#elif defined(SIMSTER_BUILD) | ||
#include "stdafx.h" | ||
#include <DataExchange/SimData.h> | ||
|
||
/*Simster factory*/ | ||
extern "C" void BOOST_EXTENSION_EXPORT_DECL extension_export_dataExchange(boost::extensions::factory_map & fm) | ||
{ | ||
fm.get<ISimData,int>()[1].set<SimData>(); | ||
} | ||
#else | ||
error "operating system not supported" | ||
#endif | ||
|
||
|
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,85 @@ | ||
#include "StdAfx.h" | ||
#include <DataExchange/SimData.h> | ||
|
||
|
||
|
||
/*Vxworks | ||
* extern "C" ISimData* createSimData() | ||
{ | ||
return new SimData(); | ||
} | ||
*/ | ||
|
||
SimData::SimData(void) | ||
{ | ||
} | ||
|
||
|
||
SimData::~SimData(void) | ||
{ | ||
} | ||
void SimData::Add(string key,boost::shared_ptr<ISimVar> var) | ||
{ | ||
std::pair<string,boost::shared_ptr<ISimVar> > elem(key,var); | ||
std::pair<Objects_type::iterator,bool> p = _sim_vars.insert(elem); | ||
} | ||
ISimVar* SimData::Get(string key) | ||
{ | ||
Objects_type::const_iterator iter =_sim_vars.find(key); | ||
|
||
//Prüfen ob das Simobjekt in Liste ist. | ||
if(iter!=_sim_vars.end()) | ||
{ | ||
boost::shared_ptr<ISimVar> obj= iter->second; | ||
return obj.get(); | ||
} | ||
else | ||
throw std::invalid_argument("There is no such sim variable " + key); | ||
} | ||
|
||
void SimData::addOutputResults(string name,ublas::vector<double> v) | ||
{ | ||
std::pair<string,ublas::vector<double> > elem(name,v); | ||
std::pair<OutputResults_type::iterator,bool> p = _result_vars.insert(elem); | ||
|
||
} | ||
void SimData::getTimeEntries(vector<double>& time_entries) | ||
{ | ||
time_entries = boost::ref(_time_entries); | ||
} | ||
|
||
|
||
void SimData::addTimeEntries(vector<double> time_entries) | ||
{ | ||
_time_entries = time_entries; | ||
} | ||
|
||
void SimData::destroy() | ||
{ | ||
delete this; | ||
} | ||
void SimData::clearResults() | ||
{ | ||
_result_vars.clear(); | ||
_time_entries.clear(); | ||
} | ||
|
||
|
||
void SimData::clearVars() | ||
{ | ||
_sim_vars.clear(); | ||
} | ||
void SimData::getOutputResults(string name,ublas::vector<double>& v) | ||
{ | ||
OutputResults_type::const_iterator iter =_result_vars.find(name); | ||
|
||
//Prüfen ob die Ergebnisse in Liste ist. | ||
if(iter!=_result_vars.end()) | ||
{ | ||
|
||
v = boost::ref(iter->second); | ||
} | ||
else | ||
throw std::invalid_argument("There is no such output variable " + name); | ||
} | ||
|
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,99 @@ | ||
// stdafx.h : Includedatei für Standardsystem-Includedateien, | ||
// oder projektspezifische Includedateien, die häufig benutzt, aber | ||
// in unregelmäßigen Abständen geändert werden. | ||
// | ||
|
||
#pragma once | ||
#ifndef BOOST_THREAD_USE_DLL | ||
#define BOOST_THREAD_USE_DLL | ||
#endif | ||
#ifndef BOOST_ALL_DYN_LINK | ||
#define BOOST_ALL_DYN_LINK | ||
#endif | ||
|
||
#define WIN32_LEAN_AND_MEAN | ||
|
||
|
||
#include <vector> | ||
#include <map> | ||
#include <string> | ||
#include <ostream> // Use stream for output | ||
|
||
#include <boost/ref.hpp> | ||
#include <boost/bind.hpp> | ||
//vxworks #include <boost/function.hpp> | ||
#define BOOST_UBLAS_SHALLOW_ARRAY_ADAPTOR | ||
#include <boost/numeric/ublas/storage.hpp> | ||
#include <boost/numeric/ublas/vector.hpp> | ||
#include <boost/numeric/ublas/io.hpp> | ||
#include <boost/numeric/ublas/matrix.hpp> | ||
#include <boost/numeric/ublas/matrix_proxy.hpp> | ||
#include <boost/numeric/ublas/matrix_sparse.hpp> | ||
#include <boost/numeric/ublas/vector.hpp> | ||
#include <boost/numeric/ublas/io.hpp> | ||
#include <boost/serialization/nvp.hpp> | ||
#include <boost/tuple/tuple.hpp> | ||
#include <boost/shared_ptr.hpp> | ||
#include <boost/weak_ptr.hpp> | ||
//vxworks #include <boost/algorithm/string.hpp> | ||
#include <boost/foreach.hpp> | ||
#include <boost/unordered_map.hpp> | ||
#include <boost/any.hpp> | ||
#include <boost/range/adaptor/map.hpp> | ||
#include <boost/range/algorithm/copy.hpp> | ||
#include <boost/math/tools/real_cast.hpp> | ||
using std::vector; | ||
using std::map; | ||
using std::string; | ||
using std::string; | ||
using std::ostream; | ||
using boost::tuple; | ||
using boost::tie; | ||
using namespace boost::numeric; | ||
using namespace std; | ||
using boost::shared_ptr; | ||
using boost::weak_ptr; | ||
using boost::get; | ||
using boost::unordered_map; | ||
typedef ublas::shallow_array_adaptor<double> adaptor_t; | ||
typedef ublas::vector<double, adaptor_t> shared_vector_t; | ||
typedef ublas::matrix<double, adaptor_t> shared_matrix_t; | ||
#include <Policies/FactoryConfig.h> | ||
#include <Math/Constants.h> | ||
#include <Object/IObject.h> | ||
#include <Object/Object.h> | ||
#include <Solver/ISolverSettings.h> | ||
#include <Solver/ISolver.h> | ||
#include <System/IMixedSystem.h> | ||
#include <SimulationSettings/ISettingsFactory.h> | ||
#include <SimulationSettings/ISimControllerSettings.h> | ||
#include <SimulationSettings/IGlobalSettings.h> | ||
#include <System/IAlgloopSolverFactory.h> | ||
#include <System/IMixedSystem.h> | ||
#include <System/ISystemProperties.h> | ||
#include <System/ISystemInitialization.h> | ||
#include <System/IContinuous.h> | ||
#include <System/ITime.h> | ||
#include <System/IEvent.h> | ||
#include <System/IAlgLoop.h> | ||
#include <System/ICoupledSystem.h> | ||
#include <Solver/INonLinSolverSettings.h> | ||
#include <Solver/IAlgLoopSolver.h> | ||
#include <System/IAlgLoopSolverFactory.h> | ||
#include <SimController/ISimController.h> | ||
#include <SimController/ISimData.h> | ||
#include <Extensions/IModelicaCompiler.h> | ||
#include <DataExchange/IHistory.h> | ||
#include <SimController/ISimdata.h> | ||
#include "DataExchange/IHistory.h" | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
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,21 @@ | ||
#pragma once | ||
|
||
#if defined(__vxworks) | ||
|
||
#define BOOST_EXTENSION_SYSTEM_DECL | ||
#define BOOST_EXTENSION_EVENTHANDLING_DECL | ||
#define BOOST_EXTENSION_ALGLOOPDEFAULTIMPL_DECL | ||
|
||
|
||
#elif defined(OMC_BUILD) || defined(SIMSTER_BUILD) | ||
|
||
#define BOOST_EXTENSION_SYSTEM_DECL BOOST_EXTENSION_EXPORT_DECL | ||
#define BOOST_EXTENSION_EVENTHANDLING_DECL BOOST_EXTENSION_EXPORT_DECL | ||
#define BOOST_EXTENSION_ALGLOOPDEFAULTIMPL_DECL BOOST_EXTENSION_EXPORT_DECL | ||
|
||
#else | ||
error "operating system not supported" | ||
#endif | ||
|
||
|
||
|
Oops, something went wrong.