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" 100 # define Dprintf(f) \ 101 do { if( SIMLIB_debug_flag ) \ 102 { _Print("DEBUG: T=%-10g ", SIMLIB_Time); \ 103 _Print f; _Print("\n"); \ 105 # define DEBUG(c,f) \ 106 do{ if( SIMLIB_debug_flag & (c) ) \ 107 { _Print("DEBUG: T=%-10g ", SIMLIB_Time); \ 108 _Print f; _Print("\n"); \ 111 # define DBG_ALL ~0UL // print all debugging info 112 # define DBG_NEW (1UL) // new/delete (memory allocation) 113 # define DBG_CTR (1UL<<1) // ctr/dtr (creation/destruction) 114 # define DBG_INIT (1UL<<2) // initialization 115 # define DBG_CHG (1UL<<3) // object changes 116 # define DBG_STEP (1UL<<4) // continuous step control 117 # define DBG_CONTI (1UL<<5) // continuous blocks 118 # define DBG_FACSTO (1UL<<6) // Enter,Leave,Seize,Release 119 # define DBG_PROCESS (1UL<<7) // Process 120 # define DBG_QUEUE (1UL<<8) // Queue operations 121 # define DBG_CALENDAR (1UL<<9) // Scheduling 122 # define DBG_SIMULATOR (1UL<<10) // Simulator actions - control 123 # define DBG_BEXPR (1UL<<11) // Block expressions 124 # define DBG_WU (1UL<<12) // WaitUntil 125 # define DBG_NUMINT (1UL<<13) // numerical integration methods 126 # define DBG_THREAD (1UL<<14) // Process-switching 127 # define DBG_MODULE (1UL<<15) // Module cleanup: id_string,... 128 # define DBG_ATEXIT (1UL<<16) // SIMLIB_atexit 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) () 285 inline double min(
double a,
double b) {
return ((a)>(b)?(b):(a)); }
286 inline double max(
double a,
double b) {
return ((a)>(b)?(a):(b)); }
294 bool old_value = (_flags & mask)!=0;
330 #endif //__SIMLIB__INTERNAL_H__
void unlock()
end checking for recursion
void SIMLIB_error(const enum _ErrEnum N)
print error message and abort program
void SIMLIB_Dynamic()
performs evaluation of integrators and status blocks
double SIMLIB_StepStartTime
last step time
double SIMLIB_ContractStep
requested step size
bool SIMLIB_ResetStatus
flag set if there is a need for integration method restart
void Get(Entity *e)
remove selected entity activation record from calendar
void SIMLIB_DoConditions()
bool SIMLIB_DynamicFlag
in dynamic section
AlgLoopDetector(aContiBlock *x)
Implementation of class CalendarList interface is static - using global functions in SQS namespace...
double max(double a, double b)
double SIMLIB_RelativeError
relative error
class for algebraic loop detection AlgLoopDetector object should be used in Value() method only it ch...
void SIMLIB_warning(const enum _ErrEnum N)
print warning message and continue
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 ...
abstract base class for active entities (Process, Event) instances of derived classes provide Behavio...
unsigned long SIMLIB_debug_flag
double SIMLIB_StepSize
actual step
void ScheduleAt(Entity *e, double t)
schedule entity e at given time t using scheduling priority from e
double min(double a, double b)
abstract base for continuous blocks with single output suitable for expression-tree building and eval...
double SIMLIB_AbsoluteError
absolute error
const SIMLIB_Phase_t & Phase
This variable contains the current phase of experiment (used for internal checking) ...
Entity * GetFirst()
remove entity with minimum activation time
SIMLIB_module & operator=(const SIMLIB_module &)
bool SIMLIB_ContractStepFlag
requests shorter step
void SIMLIB_ContinueInit()
static SIMLIB_module SIMLIB_module_id
Create single global registration object in each SIMLIB module.
bool Empty()
empty calendar predicate
SIMLIB_Phase_t
values indicate current phase of experiment
bool TestAndSetFlag(bool new_value, unsigned n)
internal method for flag manipulation is used for algebraic loop checking in continuous blocks ...
bool SIMLIB_ConditionFlag
void lock()
begin checking for recursion in Value() calling
double SIMLIB_MinStep
minimal step
SIMLIB_Phase_t SIMLIB_Phase
double SIMLIB_DeltaTime
Time-SIMLIB_StepStartTime.
void(* SIMLIB_atexit_function_t)()
Class for internal registration of modules.
void SIMLIB_atexit(SIMLIB_atexit_function_t p)
void(* VoidFunctionPtr)()
double SIMLIB_OptStep
optimal step
void Clear()
remove all scheduled entities
double SIMLIB_MaxStep
max. step