29#ifndef ADVANCE_MESSAGE_INTERVAL
30#define ADVANCE_MESSAGE_INTERVAL MSEC(10)
202#ifdef FEDERATED_DECENTRALIZED
211#ifdef FEDERATED_DECENTRALIZED
386int lf_send_message(
int message_type,
unsigned short port,
unsigned short federate,
const char* next_destination_str,
387 size_t length,
unsigned char* message);
474 unsigned short fed_ID);
521 unsigned short federate,
const char* next_destination_str,
size_t length,
522 unsigned char* message);
532#ifdef FEDERATED_DECENTRALIZED
591#ifdef FEDERATED_DECENTRALIZED
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
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.
void lf_send_neighbor_structure_to_RTI(int socket_TCP_RTI)
Send information about connections to the RTI.
lf_mutex_t lf_outbound_socket_mutex
Mutex lock held while performing outbound socket write and close operations.
void lf_connect_to_federate(uint16_t remote_federate_id)
Connect to the federate with the specified id.
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_synchronize_with_other_federates(void)
Synchronize the start with other federates via the RTI.
void lf_spawn_staa_thread(void)
Spawn a thread to iterate through STAA structs.
lf_cond_t lf_port_status_changed
Condition variable for blocking on unkonwn federate input ports.
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_latest_tag_confirmed(tag_t tag_to_send)
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_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_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
Code returned by lf_parse_rti_addr().
Definition federate.h:238
instant_t lf_wait_until_time(tag_t tag)
Return the physical time that we should wait until before advancing to the specified tag.
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_reset_status_fields_on_input_port_triggers(void)
Reset the status fields on network input ports to unknown or absent.
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.
#define NUMBER_OF_FEDERATES
The number of federates.
Definition socket_common.h:27
void * lf_handle_p2p_connections_from_federates(void *ignored)
Thread to accept connections from other federates.
@ INVALID_USER
Definition federate.h:238
@ FAILED_TO_PARSE
Definition federate.h:238
@ SUCCESS
Definition federate.h:238
@ INVALID_PORT
Definition federate.h:238
@ INVALID_HOST
Definition federate.h:238
Type definitions that are widely used across different parts of the runtime.
Common socket operations and utilities for federated Lingua Franca programs.
Execution environment.
Definition environment.h:52
Structure that a federate instance uses to keep track of its own state.
Definition federate.h:40
bool is_last_TAG_provisional
Indicates whether the last TAG received is provisional or an ordinary TAG.
Definition federate.h:139
int server_socket
A socket descriptor for the socket server of the federate.
Definition federate.h:118
size_t number_of_outbound_p2p_connections
Number of outbound peer-to-peer connections from the federate.
Definition federate.h:72
int server_port
The port used for the server socket to listen for messages from other federates.
Definition federate.h:125
tag_t last_sent_NET
A record of the most recently sent NET (next event tag) signal.
Definition federate.h:177
lf_thread_t RTI_socket_listener
Thread listening for incoming TCP messages from the RTI.
Definition federate.h:51
bool has_upstream
Indicator of whether this federate has upstream federates.
Definition federate.h:145
size_t number_of_inbound_p2p_connections
Number of inbound physical connections to the federate.
Definition federate.h:58
tag_t last_DNET
A record of the most recent DNET (downstream next event tag) signal.
Definition federate.h:192
lf_thread_t staaSetter
Thread responsible for setting ports to absent by an STAA offset if they aren't already known.
Definition federate.h:207
instant_t min_delay_from_physical_action_to_federate_output
For use in federates with centralized coordination, the minimum time delay between a physical action ...
Definition federate.h:200
int sockets_for_outbound_p2p_connections[1]
An array that holds the socket descriptors for outbound direct connections to each remote federate.
Definition federate.h:102
tag_t last_TAG
Most recent tag advance grant (TAG) received from the RTI, or NEVER if none has been received.
Definition federate.h:132
bool received_any_DNET
Indicator of whether this federate has received any DNET (downstream next event tag) signal.
Definition federate.h:187
int socket_TCP_RTI
The TCP socket descriptor for this federate to communicate with the RTI.
Definition federate.h:46
lf_thread_t inbound_p2p_handling_thread_id
Thread ID for a thread that accepts sockets and then supervises listening to those sockets for incomi...
Definition federate.h:108
bool has_downstream
Indicator of whether this federate has downstream federates.
Definition federate.h:151
int sockets_for_inbound_p2p_connections[1]
An array that holds the socket descriptors for inbound connections from each federate.
Definition federate.h:87
lf_thread_t * inbound_socket_listeners
Array of thread IDs for threads that listen for incoming messages.
Definition federate.h:65
tag_t last_sent_LTC
A record of the most recently sent LTC (latest tag confirmed) message.
Definition federate.h:172
bool received_stop_request_from_rti
Used to prevent the federate from sending a REQUEST_STOP message if it has already received a stop re...
Definition federate.h:158
tag_t last_skipped_NET
A record of the most recently skipped NET (next event tag) signal.
Definition federate.h:182
Base type for actions.
Definition lf_types.h:583
Structure for STAA (safe to assume absent).
Definition federate.h:216
size_t STAA
Definition federate.h:218
size_t num_actions
Definition federate.h:219
lf_action_base_t ** actions
Definition federate.h:217
A tag is a time, microstep pair.
Definition tag.h:119
Time and tag definitions and functions for Lingua Franca.