Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[OMSICpp] improved error handling for zeromq simulation
- Loading branch information
Showing
12 changed files
with
611 additions
and
212 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
15 changes: 15 additions & 0 deletions
15
OMCompiler/SimulationRuntime/OMSICpp/omcWrapper/omcZeroMQ/include/IOMCZeromq.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,15 @@ | ||
#include "zhelpers.hpp" | ||
#include <string> | ||
#include <vector> | ||
#include <thread> | ||
#include <memory> | ||
#include <functional> | ||
#include <iostream> | ||
#include <string> | ||
#include "OMC.h" | ||
#define GC_THREADS | ||
#include "gc.h" | ||
|
||
using std::string; | ||
static std::exception_ptr globalSimulationExceptionPtr = nullptr; | ||
static std::exception_ptr globalZeroMQTaskExceptionPtr = nullptr; |
179 changes: 179 additions & 0 deletions
179
OMCompiler/SimulationRuntime/OMSICpp/omcWrapper/omcZeroMQ/include/Modelica.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,179 @@ | ||
#pragma once | ||
/** @addtogroup core | ||
* | ||
* @{ | ||
*/ | ||
|
||
#include <string> | ||
#include <vector> | ||
#include <algorithm> | ||
#include <deque> | ||
#include <map> | ||
#include <cmath> | ||
#include <numeric> | ||
#include <functional> | ||
#include <iostream> | ||
#include <iterator> | ||
|
||
/*Namespaces*/ | ||
using std::abs; | ||
using std::ios; | ||
using std::endl; | ||
using std::cout; | ||
using std::cerr; | ||
using std::ostream_iterator; | ||
using std::map; | ||
using std::pair; | ||
using std::make_pair; | ||
using std::max; | ||
using std::min; | ||
using std::string; | ||
using std::ostream; | ||
using std::ostringstream; | ||
using std::stringstream; | ||
using std::vector; | ||
using std::deque; | ||
using std::copy; | ||
using std::exception; | ||
using std::runtime_error; | ||
|
||
|
||
|
||
#if !defined(USE_CPP_03) && !defined(__vxworks) | ||
#include <array> | ||
#include <tuple> | ||
#include <memory> | ||
#include <unordered_map> | ||
#include <unordered_set> | ||
#include <chrono> | ||
using namespace std::chrono; | ||
#define USE_CHRONO | ||
#if defined(USE_THREAD) | ||
#include <thread> | ||
#include <atomic> | ||
#include <mutex> | ||
#include <condition_variable> | ||
using std::thread; | ||
using std::atomic; | ||
using std::mutex; | ||
using std::memory_order_release; | ||
using std::memory_order_relaxed; | ||
using std::condition_variable; | ||
using std::unique_lock; | ||
#endif //USE_THREAD | ||
|
||
// builtin range based for loop | ||
#define FOREACH(element, range) for(element : range) | ||
|
||
// builtin list initializers | ||
#define LIST_OF { | ||
#define LIST_SEP , | ||
#define LIST_END } | ||
#define MAP_LIST_OF {{ | ||
#define MAP_LIST_SEP },{ | ||
#define MAP_LIST_END }} | ||
#define TUPLE_LIST_OF {std::make_tuple( | ||
#define TUPLE_LIST_SEP ),std::make_tuple( | ||
#define TUPLE_LIST_END )} | ||
|
||
/** namespace for generated code to avoid name clashes */ | ||
namespace omcpp | ||
{ | ||
using std::ref; | ||
using std::trunc; | ||
using std::to_string; | ||
} | ||
|
||
using std::bind; | ||
using std::function; | ||
using std::make_tuple; | ||
using std::array; | ||
using std::isfinite; | ||
using std::minmax_element; | ||
using std::get; | ||
using std::tuple; | ||
using std::unordered_map; | ||
using std::unordered_set; | ||
using std::shared_ptr; | ||
using std::weak_ptr; | ||
using std::dynamic_pointer_cast; | ||
using std::to_string; | ||
#else | ||
#if defined(_MSC_VER) | ||
#include <tuple> | ||
using std::get; | ||
using std::tuple; | ||
using std::make_tuple; | ||
using std::minmax_element; | ||
#else | ||
#include <boost/tuple/tuple.hpp> | ||
#include <boost/algorithm/minmax_element.hpp> | ||
using boost::get; | ||
using boost::tuple; | ||
using boost::make_tuple; | ||
using boost::minmax_element; | ||
#endif | ||
#include <boost/foreach.hpp> | ||
#include <boost/lexical_cast.hpp> | ||
#include <boost/assign/list_of.hpp> | ||
#include <boost/array.hpp> | ||
#include <boost/math/special_functions/fpclassify.hpp> | ||
#include <boost/math/special_functions/trunc.hpp> | ||
#include <boost/unordered_map.hpp> | ||
#include <boost/unordered_set.hpp> | ||
#include <boost/ref.hpp> | ||
#include <boost/shared_ptr.hpp> | ||
#include <boost/weak_ptr.hpp> | ||
|
||
#if defined(USE_THREAD) | ||
#include <boost/thread.hpp> | ||
#include <boost/atomic.hpp> | ||
#include <boost/thread/mutex.hpp> | ||
#include <boost/bind.hpp> | ||
using boost::bind; | ||
using boost::function; | ||
using boost::thread; | ||
using boost::atomic; | ||
using boost::mutex; | ||
using boost::memory_order_release; | ||
using boost::memory_order_relaxed; | ||
using boost::condition_variable; | ||
using boost::unique_lock; | ||
#endif //USE_THREAD | ||
|
||
// boost range based for loop | ||
#define FOREACH BOOST_FOREACH | ||
|
||
// boost list initializers | ||
#define LIST_OF boost::assign::list_of( | ||
#define LIST_SEP )( | ||
#define LIST_END ) | ||
#define MAP_LIST_OF boost::assign::map_list_of( | ||
#define MAP_LIST_SEP )( | ||
#define MAP_LIST_END ) | ||
#define TUPLE_LIST_OF boost::assign::tuple_list_of( | ||
#define TUPLE_LIST_SEP )( | ||
#define TUPLE_LIST_END ) | ||
|
||
/** namespace for generated code to avoid name clashes */ | ||
namespace omcpp { | ||
using boost::ref; | ||
using boost::math::trunc; | ||
template <typename T> | ||
std::string to_string(T val) { | ||
return boost::lexical_cast<std::string>(val); | ||
} | ||
} | ||
using boost::array; | ||
using boost::math::isfinite; | ||
using boost::unordered_map; | ||
using boost::unordered_set; | ||
using boost::shared_ptr; | ||
using boost::weak_ptr; | ||
using boost::dynamic_pointer_cast; | ||
using omcpp::to_string; | ||
using namespace boost::lambda; | ||
#endif //!USE_CPP_03 | ||
|
||
|
||
/** @} */ // end of group1 |
97 changes: 97 additions & 0 deletions
97
OMCompiler/SimulationRuntime/OMSICpp/omcWrapper/omcZeroMQ/include/ModelicaDefine.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,97 @@ | ||
/** @addtogroup core | ||
* | ||
* @{ | ||
*/ | ||
|
||
typedef double modelica_real; | ||
typedef int modelica_integer; | ||
typedef bool modelica_boolean; | ||
typedef bool edge_rettype; | ||
typedef bool sample_rettype; | ||
typedef double cos_rettype; | ||
typedef double cosh_rettype; | ||
typedef double sin_rettype; | ||
typedef double sinh_rettype; | ||
typedef double log_rettype; | ||
typedef double tan_rettype; | ||
typedef double atan_rettype; | ||
typedef double tanh_rettype; | ||
typedef double exp_rettype; | ||
typedef double sqrt_rettype; | ||
typedef double abs_rettype; | ||
typedef double max_rettype; | ||
typedef double min_rettype; | ||
typedef double arctan_rettype; | ||
typedef double floorRetType; | ||
typedef double asinRetType; | ||
typedef double tan_rettype; | ||
typedef double tanhRetType; | ||
typedef double acosRetType; | ||
typedef double logRetType; | ||
typedef double coshRetType; | ||
|
||
#ifndef FORCE_INLINE | ||
#if defined(_MSC_VER) | ||
#define FORCE_INLINE __forceinline | ||
#else | ||
#define FORCE_INLINE __attribute__((always_inline)) inline | ||
#endif | ||
#endif | ||
|
||
#ifndef PREFETCH | ||
#if defined(_MSC_VER) | ||
#define PREFETCH(add, rw, locality) | ||
#else | ||
#define PREFETCH(add, rw, locality) __builtin_prefetch(add, rw, locality) | ||
#endif | ||
#endif | ||
|
||
#ifndef VAR_ALIGN_PRE | ||
#ifdef __GNUC__ | ||
#define VAR_ALIGN_PRE | ||
#define VAR_ALIGN_POST __attribute__((aligned(0x40))) | ||
#elif defined _MSC_VER | ||
#define VAR_ALIGN_PRE __declspec(align(64)) | ||
#define VAR_ALIGN_POST | ||
#else | ||
#define VAR_ALIGN_PRE | ||
#define VAR_ALIGN_POST | ||
#endif | ||
#endif | ||
|
||
|
||
#ifndef BOOST_THREAD_USE_DLL | ||
#define BOOST_THREAD_USE_DLL | ||
#endif | ||
#ifndef BOOST_STATIC_LINKING | ||
#ifndef BOOST_ALL_DYN_LINK | ||
#define BOOST_ALL_DYN_LINK | ||
#endif | ||
#endif | ||
|
||
|
||
// Visual C++ 2015 by default does not link the CRT if the entry point is overriden. Force linking. Macros according to | ||
// "MSDN — Predefined Macros"; library names according to "Visual C++ Team Blog — Introducing the Universal CRT". | ||
#if _MSC_VER >= 1900 | ||
# if _DEBUG | ||
# if _DLL | ||
# pragma comment(lib, "vcruntimed") | ||
# pragma comment(lib, "ucrtd") | ||
# else | ||
# pragma comment(lib, "libvcruntimed") | ||
# pragma comment(lib, "libucrtd") | ||
# endif | ||
# else | ||
# if _DLL | ||
# pragma comment(lib, "vcruntime") | ||
# pragma comment(lib, "ucrt") | ||
# else | ||
# pragma comment(lib, "libvcruntime") | ||
# pragma comment(lib, "libucrt") | ||
# endif | ||
# endif | ||
#endif | ||
|
||
|
||
|
||
/** @} */ // end of core |
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
Oops, something went wrong.