reactor-c
C Runtime for Lingua Franca
Loading...
Searching...
No Matches
federate.h
Go to the documentation of this file.
1
12#ifndef FEDERATE_H
13#define FEDERATE_H
14
15#include <stdbool.h>
16
17#include "tag.h"
18#include "lf_types.h"
19#include "environment.h"
20#include "low_level_platform.h"
21
22#ifndef ADVANCE_MESSAGE_INTERVAL
23#define ADVANCE_MESSAGE_INTERVAL MSEC(10)
24#endif
25
27// Data types
28
187
188#ifdef FEDERATED_DECENTRALIZED
189typedef struct staa_t {
190 lf_action_base_t** actions;
191 size_t STAA;
192 size_t num_actions;
193} staa_t;
194#endif
195
202
204
206// Global variables
207
212
217
219// Public functions (in alphabetical order)
220
235
248void lf_connect_to_rti(const char* hostname, int port_number);
249
266void lf_create_server(int specified_port);
267
276
287
299
305
317
336int lf_send_message(int message_type, unsigned short port, unsigned short federate, const char* next_destination_str,
337 size_t length, unsigned char* message);
338
349
406tag_t lf_send_next_event_tag(environment_t* env, tag_t tag, bool wait_for_reply);
407
419void lf_send_port_absent_to_federate(environment_t* env, interval_t additional_delay, unsigned short port_ID,
420 unsigned short fed_ID);
421
431
464int lf_send_tagged_message(environment_t* env, interval_t additional_delay, int message_type, unsigned short port,
465 unsigned short federate, const char* next_destination_str, size_t length,
466 unsigned char* message);
467
472void lf_set_federation_id(const char* fid);
473
474#ifdef FEDERATED_DECENTRALIZED
481void lf_spawn_staa_thread(void);
482#endif
483
493
499
509
525bool lf_update_max_level(tag_t tag, bool is_provisional);
526
527#ifdef FEDERATED_DECENTRALIZED
539instant_t lf_wait_until_time(tag_t tag);
540#endif // FEDERATED_DECENTRALIZED
541
542#endif // FEDERATE_H
API for the environment data structure.
void lf_set_federation_id(const char *fid)
Set the federation_id of this federate.
int lf_send_tagged_message(environment_t *env, interval_t additional_delay, int message_type, unsigned short port, unsigned short federate, const char *next_destination_str, size_t length, unsigned char *message)
Send a tagged message to the specified port of the specified federate.
lf_mutex_t lf_outbound_socket_mutex
int lf_send_message(int message_type, unsigned short port, unsigned short federate, const char *next_destination_str, size_t length, unsigned char *message)
Send a message to another federate.
tag_t lf_send_next_event_tag(environment_t *env, tag_t tag, bool wait_for_reply)
Send a next event tag (NET) signal.
void lf_reset_status_fields_on_input_port_triggers()
Reset the status fields on network input ports to unknown or absent.
lf_cond_t lf_port_status_changed
void lf_send_port_absent_to_federate(environment_t *env, interval_t additional_delay, unsigned short port_ID, unsigned short fed_ID)
Send a port absent message.
void * lf_handle_p2p_connections_from_federates(void *)
Thread to accept connections from other federates.
struct federate_instance_t federate_instance_t
void lf_latest_tag_confirmed(tag_t)
Send a latest tag confirmed (LTC) signal to the RTI.
bool lf_update_max_level(tag_t tag, bool is_provisional)
Update the max level allowed to advance (MLAA).
void lf_connect_to_federate(uint16_t)
Connect to the federate with the specified id.
void lf_create_server(int specified_port)
Create a server to listen to incoming P2P connections.
void lf_connect_to_rti(const char *hostname, int port_number)
Connect to the RTI at the specified host and port.
void lf_synchronize_with_other_federates()
Synchronize the start with other federates via the RTI.
void lf_stall_advance_level_federation(environment_t *env, size_t level)
Wait until inputs statuses are known up to and including the specified level.
parse_rti_code_t
Definition federate.h:203
@ INVALID_USER
Definition federate.h:203
@ FAILED_TO_PARSE
Definition federate.h:203
@ SUCCESS
Definition federate.h:203
@ INVALID_PORT
Definition federate.h:203
@ INVALID_HOST
Definition federate.h:203
void lf_stall_advance_level_federation_locked(size_t level)
Version of lf_stall_advance_level_federation() that assumes the caller holds the mutex lock.
int lf_send_stop_request_to_rti(tag_t stop_tag)
Send a MSG_TYPE_STOP_REQUEST message to the RTI.
void lf_send_neighbor_structure_to_RTI(int)
Send information about connections to the RTI.
struct federation_metadata_t federation_metadata_t
void lf_enqueue_port_absent_reactions(environment_t *env)
Enqueue port absent reactions.
parse_rti_code_t lf_parse_rti_addr(const char *rti_addr)
Parse the address of the RTI and store them into the global federation_metadata struct.
void * lf_thread_t
Definition lf_arduino_support.h:120
void * lf_mutex_t
Definition lf_arduino_support.h:118
Type definitions that are widely used across different parts of the runtime.
Platform API support for the C target of Lingua Franca.
Execution environment. This struct contains information about the execution environment....
Definition environment.h:49
Definition federate.h:32
bool is_last_TAG_provisional
Definition federate.h:131
int server_socket
Definition federate.h:110
int sockets_for_inbound_p2p_connections[NUMBER_OF_FEDERATES]
Definition federate.h:79
size_t number_of_outbound_p2p_connections
Definition federate.h:64
int server_port
Definition federate.h:117
tag_t last_sent_NET
Definition federate.h:169
lf_thread_t RTI_socket_listener
Definition federate.h:43
bool has_upstream
Definition federate.h:137
size_t number_of_inbound_p2p_connections
Definition federate.h:50
instant_t min_delay_from_physical_action_to_federate_output
Definition federate.h:177
int sockets_for_outbound_p2p_connections[NUMBER_OF_FEDERATES]
Definition federate.h:94
tag_t last_TAG
Definition federate.h:124
int socket_TCP_RTI
Definition federate.h:38
lf_thread_t inbound_p2p_handling_thread_id
Definition federate.h:100
bool has_downstream
Definition federate.h:143
lf_thread_t * inbound_socket_listeners
Definition federate.h:57
tag_t last_sent_LTC
Definition federate.h:164
bool received_stop_request_from_rti
Definition federate.h:150
Definition federate.h:196
const char * federation_id
Definition federate.h:197
char * rti_host
Definition federate.h:198
char * rti_user
Definition federate.h:200
int rti_port
Definition federate.h:199
Definition lf_types.h:295
Definition lf_POSIX_threads_support.h:41
Definition tag.h:78
Time and tag definitions and functions for Lingua Franca.
int64_t instant_t
Definition tag.h:63
int64_t interval_t
Definition tag.h:68
#define NUMBER_OF_FEDERATES
Definition util.c:51