20#ifndef REACTOR_COMMON_H
21#define REACTOR_COMMON_H
81#define MIN_SLEEP_DURATION USEC(10)
95#ifdef FEDERATED_DECENTRALIZED
424void usage(
int argc,
const char* argv[]);
API for the environment data structure.
int64_t instant_t
Time instant.
Definition tag.h:101
int64_t interval_t
Interval of time.
Definition tag.h:107
int process_user_args(int argc, const char *argv[], int *newargc, const char **newargv)
Process user-defined main reactor parameters from the command line.
void lf_recycle_event(environment_t *env, event_t *e)
Recycle the given event.
void _lf_trigger_shutdown_reactions(environment_t *env)
Trigger all the shutdown reactions in the specified environment.
void lf_set_default_command_line_options(void)
Generated function that optionally sets default command-line options.
int trigger_handle_t
Handles for scheduled triggers.
Definition lf_types.h:146
bool _lf_initialize_timers(environment_t *env)
Initialize all the timers in the environment.
void lf_replace_token(event_t *event, lf_token_t *token)
Replace the token on the specified event with the specified token and free the old token.
void _lf_pop_events(environment_t *env)
Pop all events from event_q with tag equal to current tag.
void initialize_global()
Initialize global variables and start tracing before calling the _lf_initialize_trigger_objects() fun...
pqueue_pri_t index_t
Topological order index for reactions.
Definition lf_types.h:166
void _lf_advance_tag(environment_t *env, tag_t next_tag)
Advance from the current tag to the next.
void _lf_initialize_trigger_objects()
Generated function that produces a table containing all triggers (i.e., inputs, timers,...
bool _lf_initialize_timer(environment_t *env, trigger_t *timer)
Initialize the given timer.
event_t * _lf_create_dummy_events(environment_t *env, tag_t tag)
Create a dummy event with the specified tag.
index_t lf_combine_deadline_and_level(interval_t deadline, int level)
Combine a deadline and a level into a single index for sorting in the reaction queue.
trigger_handle_t _lf_schedule_token(environment_t *env, void *action, interval_t extra_delay, lf_token_t *token)
Schedule the specified action at a later tag with the specified token as a payload.
void _lf_invoke_reaction(environment_t *env, reaction_t *reaction, int worker)
Invoke the specified reaction on the specified worker in the specified environment.
int process_args(int argc, const char *argv[])
Process the command-line arguments.
trigger_handle_t _lf_schedule_at_tag(environment_t *env, trigger_t *trigger, tag_t tag, lf_token_t *token)
Schedule an event at a specific tag (time, microstep).
void lf_free(struct allocation_record_t **head)
Free memory on the specified allocation record (a self struct).
void termination(void)
Perform final wrap-up on exit.
void _lf_start_time_step(environment_t *env)
Perform whatever is needed to start a time step.
lf_cli_type_t
Type tag for a user-defined CLI parameter.
Definition reactor_common.h:38
void lf_terminate_execution(environment_t *env)
Function that is called when the program is about to exit.
void schedule_output_reactions(environment_t *env, reaction_t *reaction, int worker)
Schedule the output reactions for the specified reaction in the specified environment.
trigger_handle_t _lf_insert_reactions_for_trigger(environment_t *env, trigger_t *trigger, lf_token_t *token)
Insert reactions triggered by trigger to the reaction queue.
event_t * lf_get_new_event(environment_t *env)
Get a new event.
void lf_create_environments(void)
Create and initialize the required number of environments for the program.
trigger_handle_t _lf_schedule_copy(environment_t *env, void *action, interval_t offset, void *value, size_t length)
Schedule an action to occur with the specified value and time offset with a copy of the specified val...
void _lf_trigger_reaction(environment_t *env, reaction_t *reaction, int worker_number)
Trigger the specified reaction on the specified worker in the specified environment.
void _lf_trigger_startup_reactions(environment_t *env)
Trigger all the startup reactions in the specified environment.
@ CLI_TIME
interval_t, parsed as value + units (e.g., "500 msec").
Definition reactor_common.h:39
@ CLI_STRING
const char*, set directly from the argument string.
Definition reactor_common.h:44
@ CLI_INT
int, parsed with atoi.
Definition reactor_common.h:40
@ CLI_DOUBLE
double, parsed with strtod.
Definition reactor_common.h:41
@ CLI_BOOL
bool, parsed as "true"/"false" or "1"/"0".
Definition reactor_common.h:43
@ CLI_FLOAT
float, parsed with strtof.
Definition reactor_common.h:42
void usage()
Print a usage message.
Type definitions that are widely used across different parts of the runtime.
Header file of the runtime infrastructure for modes in the C target of Lingua Franca.
Support for optimizing sparse input through multiports.
Priority queue definitions for queues where the priority is a number that can be compared with ordina...
unsigned int _lf_number_of_workers
interval_t lf_fed_STA_offset
bool _lf_normal_termination
lf_cli_param_t * _lf_cli_params
const char ** default_argv
struct allocation_record_t * _lf_reactors_to_free
Allocation record to keep track of dynamically-allocated memory.
Definition lf_types.h:499
Execution environment.
Definition environment.h:52
Event activation record to push onto the event queue.
Definition lf_types.h:354
Descriptor for a user-defined main reactor parameter overridable from the command line.
Definition reactor_common.h:55
const char * name
Parameter name (e.g., "period").
Definition reactor_common.h:56
bool is_width
True if this parameter is used for multiport/bank widths (not overridable).
Definition reactor_common.h:61
bool * given
Pointer to a bool that is set to true when the arg is provided.
Definition reactor_common.h:59
lf_cli_type_t type
The type of the parameter value.
Definition reactor_common.h:57
void * value
Pointer to the storage variable.
Definition reactor_common.h:58
const char * description
Description for the help message (e.g., "time value (default: 1 sec)").
Definition reactor_common.h:60
Token type for dynamically allocated arrays and structs sent as messages.
Definition lf_token.h:99
Reaction activation record to push onto the reaction queue.
Definition lf_types.h:195
A tag is a time, microstep pair.
Definition tag.h:119
Trigger struct representing an output, timer, action, or input.
Definition lf_types.h:391
Time and tag definitions and functions for Lingua Franca.
Core utility functions for Lingua Franca.