49#ifndef __SIMLIB__INTERNAL_H__
50#define __SIMLIB__INTERNAL_H__
53# error "simlib.h should be included first"
66 int Init(
const char *s);
98# define DEBUG_INFO "/debug"
101 do { if( SIMLIB_debug_flag ) \
102 { _Print("DEBUG: T=%-10g ", SIMLIB_Time); \
103 _Print f; _Print("\n"); \
106 do{ if( SIMLIB_debug_flag & (c) ) \
107 { _Print("DEBUG: T=%-10g ", SIMLIB_Time); \
108 _Print f; _Print("\n"); \
112# define DBG_NEW (1UL)
113# define DBG_CTR (1UL<<1)
114# define DBG_INIT (1UL<<2)
115# define DBG_CHG (1UL<<3)
116# define DBG_STEP (1UL<<4)
117# define DBG_CONTI (1UL<<5)
118# define DBG_FACSTO (1UL<<6)
119# define DBG_PROC (1UL<<7)
120# define DBG_QUEUE (1UL<<8)
121# define DBG_CALENDAR (1UL<<9)
122# define DBG_SIMULATOR (1UL<<10)
123# define DBG_BEXPR (1UL<<11)
124# define DBG_WU (1UL<<12)
125# define DBG_NUMINT (1UL<<13)
126# define DBG_PROCESS (1UL<<14)
127# define DBG_MODULE (1UL<<15)
128# define DBG_ATEXIT (1UL<<16)
135#define SIMLIB_IMPLEMENTATION \
136 _Pragma("GCC diagnostic push") \
137 _Pragma("GCC diagnostic ignored \"-Wunused-variable\"") \
138 static int SIMLIB_module_num = \
139 SIMLIB_module_id.Init( \
141 ", SIMLIB-" SIMLIB_VERSION DEBUG_INFO \
143 "/" SIMLIB_COMPILER \
144 ", " __DATE__ " " __TIME__ \
147 _Pragma("GCC diagnostic pop")
166[[noreturn]]
void SIMLIB_error(
const char *file,
const int line);
167#define SIMLIB_internal_error() SIMLIB_error(__FILE__, __LINE__)
228#define _SetTime(t,x) (SIMLIB_##t = x)
246#define HOOK_PTR_NAME(id) SIMLIB_Hook_Ptr_##id
247#define HOOK_INST_NAME(id) SIMLIB_Install_hook_##id
255#define INSTALL_HOOK(name,function) do {\
256 void HOOK_INST_NAME(name) (void (*f)()); \
257 HOOK_INST_NAME(name)(function); \
267#define DEFINE_HOOK(name) \
268 static void (* HOOK_PTR_NAME(name) )() = 0; \
269 void HOOK_INST_NAME(name)(void (*f)()) { HOOK_PTR_NAME(name) = f; }
278#define CALL_HOOK(name) \
279 if( HOOK_PTR_NAME(name) ) HOOK_PTR_NAME(name) ()
285inline double min(
double a,
double b) {
return ((a)>(b)?(b):(a)); }
286inline double max(
double a,
double b) {
return ((a)>(b)?(a):(b)); }
294 bool old_value = (
_flags & mask)!=0;
class for algebraic loop detection AlgLoopDetector object should be used in Value() method only it ch...
void unlock()
end checking for recursion
void lock()
begin checking for recursion in Value() calling
AlgLoopDetector(aContiBlock *x)
abstract base class for active entities (Process, Event) instances of derived classes provide Behavio...
Class for internal registration of modules.
SIMLIB_module & operator=(const SIMLIB_module &)
SIMLIB_module(const SIMLIB_module &)
bool TestAndSetFlag(bool new_value, unsigned n)
internal method for flag manipulation is used for algebraic loop checking in continuous blocks
unsigned _flags
bool flags for internal use (TODO bitfield?)
abstract base for continuous blocks with single output suitable for expression-tree building and eval...
void Get(Entity *e)
remove selected entity activation record from calendar
Entity * GetFirst()
remove entity with minimum activation time
void ScheduleAt(Entity *e, double t)
schedule entity e at given time t using scheduling priority from e
void Clear()
remove all scheduled entities
bool Empty()
empty calendar predicate
Implementation of class CalendarList interface is static - using global functions in SQS namespace.
void SIMLIB_ContinueInit()
bool SIMLIB_DynamicFlag
in dynamic section
bool SIMLIB_ConditionFlag
void SIMLIB_error(const enum _ErrEnum N)
print error message and abort program
double SIMLIB_RelativeError
relative error
double SIMLIB_OptStep
optimal step
const SIMLIB_Phase_t & Phase
This variable contains the current phase of experiment (used for internal checking)
SIMLIB_Phase_t
values indicate current phase of experiment
bool SIMLIB_ContractStepFlag
requests shorter step
void(* SIMLIB_atexit_function_t)()
std::string SIMLIB_create_tmp_name(const char *fmt,...)
printf-like function to create temporary name (the length of temporary names is limited) used only ...
static SIMLIB_module SIMLIB_module_id
Create single global registration object in each SIMLIB module.
void SIMLIB_Dynamic()
performs evaluation of integrators and status blocks
bool SIMLIB_ResetStatus
flag set if there is a need for integration method restart
void SIMLIB_atexit(SIMLIB_atexit_function_t p)
unsigned long SIMLIB_debug_flag
void SIMLIB_DoConditions()
double min(double a, double b)
double max(double a, double b)
void SIMLIB_warning(const enum _ErrEnum N)
print warning message and continue
void(* VoidFunctionPtr)()
double SIMLIB_AbsoluteError
absolute error
double SIMLIB_MinStep
minimal step
SIMLIB_Phase_t SIMLIB_Phase
double SIMLIB_MaxStep
max. step
double SIMLIB_ContractStep
requested step size
double SIMLIB_StepStartTime
last step time
double SIMLIB_StepSize
actual step
double SIMLIB_DeltaTime
Time-SIMLIB_StepStartTime.