Hase++ is a library for C++ which provides discrete event simulations with entities running in separate threads. It is part of the HASE simulation environment, but may be used by itself. The interface is based on that of Jade's SIM++.
To define the behaviour of an entity, Hase++ must define a class
inheriting from class sim_entity.
It is allowed to use any C++-compatible code when describing this
behaviour. The user can obviouly use any public method
defined by the class sim_entity. Additionally, the user can use
the services provided by the simulation system.
Finally, to simplify the syntax, some macro instructions
are provided.
Each entity lives as an independent thread, scheduled by the scheduler.
All entities in a single project are executed in the same system process.
Hase++ uses predicates to filter and select incoming events and a number of pre-defined predicates are provided.
virtual void body() = 0
void sim_get_next(sim_event & event)
event
is filled with the content of the incoming event
(tag and value if relevant).
void sim_get_next(sim_predicate & p, sim_event & event)
p
The predicate that expresses the condition the event
has to match before resuming the entity.
event
is filled with the content of the incoming event
(tag and value if relevant).
bool sim_get_next_before(sim_predicate & pred, sim_event & event, sim_time timeout)
pred
the predicate, which an event must match before timeout for the method to return true.
event
is filled with the content of the incoming event
(tag and value if relevant) iif the timeout did not elapse.
timeout
relative simulation time before which the method returns
even if no event arrived.
bool sim_get_next_before(sim_event & event, sim_time timeout)
event
is filled with the content of the incoming event
(tag and value if relevant) iif the timeout did not elapse.
timeout
relative simulation time before which the method returns
even if no event arrived.
void sim_hold(sim_time delay)
delay
This is a simulation time.
void sim_schedule(sim_port & port, sim_time delay, int ev_type, void *ev_buf=0, int ev_len=0)
port:
port which is used to send the event.
delay:
delay after which the event is sent.
This is delay must be expressed in simulation time. 0 means in the next micro-cycle.
ev_type:
tag used to make a distinction between events.
ev_buf:
a pointer to the value which has to be sent.
If not specified, the event is just a tag and has no value.
ev_len:
the length of the buffer containing the value.
If not specified, the event is considered to have no value.
void sim_reply(sim_event & event, sim_time delay, int ev_type, void *ev_buf=0, int ev_len=0)
event
arrived. The event will go back to the sender of the event. This mechanism can be used to acknowledge
request without knowing the request sender.
event:
event that has to be ackowledged
delay:
delay after which the acknowledgment is sent.
This is delay must be expressed in simulation time. 0 means in the next micro-cycle.
ev_type:
tag used to make a distinction between events.
ev_buf:
a pointer to the value which has to be sent.
If not specified, the acknowledgment is just a tag and has no value.
ev_len:
the length of the buffer containing the value.
If not specified, the acknowledgment is considered to have no value.
void sim_select(sim_predicate & p, sim_event & event)
p
The predicate that the event has to match before resuming
the entity.
event
is filled with the content of the incoming event
(tag and value if relevant).
void sim_trace(int level, char *msg)
level
The level of importance for the message.
The sim_system::set_trc_level(int) method allows the user to choose which
messages are actually to be dumped into the trace file.
msg
msg to be printed into the trace file.
int sim_waiting(sim_predicate & p)
p
The predicate which has to be matched.
int sim_waiting(sim_event & event, sim_predicate & p)
p
The predicate which has to be matched.
event
is filled with the content of the incoming event
(tag and value if relevant).
sim_time sim_clock()