reactor-c 1.0
C Runtime for Lingua Franca
Loading...
Searching...
No Matches
federate.h File Reference

Data structures and functions for federated Lingua Franca programs. More...

#include <stdbool.h>
#include "tag.h"
#include "lf_types.h"
#include "environment.h"
#include "low_level_platform.h"
#include "socket_common.h"

Go to the source code of this file.

Data Structures

struct  federate_instance_t
 Structure that a federate instance uses to keep track of its own state. More...
 Structure for federation metadata. More...
struct  staa_t
 Structure for STAA (safe to assume absent). More...

Macros

#define ADVANCE_MESSAGE_INTERVAL   MSEC(10)

Typedefs

typedef struct federate_instance_t federate_instance_t
 Structure that a federate instance uses to keep track of its own state.
typedef struct federation_metadata_t federation_metadata_t
 Structure for federation metadata.
typedef enum parse_rti_code_t parse_rti_code_t
 Code returned by lf_parse_rti_addr().
typedef struct staa_t staa_t
 Structure for STAA (safe to assume absent).

Enumerations

enum  parse_rti_code_t {
  SUCCESS , INVALID_PORT , INVALID_HOST , INVALID_USER ,
  FAILED_TO_PARSE
}
 Code returned by lf_parse_rti_addr(). More...

Functions

void lf_connect_to_federate (uint16_t remote_federate_id)
 Connect to the federate with the specified id.
void lf_connect_to_rti (const char *hostname, int port_number)
 Connect to the RTI at the specified host and port.
void lf_create_server (int specified_port)
 Create a server to listen to incoming P2P connections.
void lf_enqueue_port_absent_reactions (environment_t *env)
 Enqueue port absent reactions.
void * lf_handle_p2p_connections_from_federates (void *ignored)
 Thread to accept connections from other federates.
void lf_latest_tag_confirmed (tag_t tag_to_send)
 Send a latest tag confirmed (LTC) signal to the RTI.
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_reset_status_fields_on_input_port_triggers (void)
 Reset the status fields on network input ports to unknown or absent.
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.
void lf_send_neighbor_structure_to_RTI (int socket_TCP_RTI)
 Send information about connections to the RTI.
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_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.
int lf_send_stop_request_to_rti (tag_t stop_tag)
 Send a MSG_TYPE_STOP_REQUEST message to the RTI.
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.
void lf_set_federation_id (const char *fid)
 Set the federation_id of this federate.
void lf_spawn_staa_thread (void)
 Spawn a thread to iterate through STAA structs.
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.
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.
void lf_synchronize_with_other_federates (void)
 Synchronize the start with other federates via the RTI.
bool lf_update_max_level (tag_t tag, bool is_provisional)
 Update the max level allowed to advance (MLAA).
instant_t lf_wait_until_time (tag_t tag)
 Return the physical time that we should wait until before advancing to the specified tag.

Variables

lf_mutex_t lf_outbound_socket_mutex
 Mutex lock held while performing outbound socket write and close operations.
lf_cond_t lf_port_status_changed
 Condition variable for blocking on unkonwn federate input ports.

Detailed Description

Data structures and functions for federated Lingua Franca programs.

Author
Soroush Bateni
Peter Donovan
Edward A. Lee
Anirudh Rengarajsm

This file defines the core data structures and functions used in federated Lingua Franca programs. It includes the federate instance structure that tracks the state of a federate, including its connections to the RTI and other federates, message handling, and coordination mechanisms. The file also provides functions for managing these connections, sending and receiving messages, and handling various aspects of federated execution.

Macro Definition Documentation

◆ ADVANCE_MESSAGE_INTERVAL

#define ADVANCE_MESSAGE_INTERVAL   MSEC(10)