helics
3.5.2
|
#include <CommsInterface.hpp>
Public Types | |
enum class | thread_generation { single , dual } |
Public Member Functions | |
CommsInterface ()=default | |
CommsInterface (thread_generation threads) | |
virtual | ~CommsInterface () |
virtual void | loadNetworkInfo (const NetworkBrokerData &netInfo) |
void | loadTargetInfo (std::string_view localTarget, std::string_view brokerTarget, gmlc::networking::InterfaceNetworks targetNetwork=gmlc::networking::InterfaceNetworks::LOCAL) |
void | transmit (route_id rid, const ActionMessage &cmd) |
void | transmit (route_id rid, ActionMessage &&cmd) |
void | addRoute (route_id rid, std::string_view routeInfo) |
void | removeRoute (route_id rid) |
bool | connect () |
void | disconnect () |
bool | reconnect () |
void | setName (const std::string &commName) |
void | setRequireBrokerConnection (bool requireBrokerConnection) |
void | setCallback (std::function< void(ActionMessage &&)> callback) |
void | setLoggingCallback (std::function< void(int level, std::string_view name, std::string_view message)> callback) |
void | setMessageSize (int maxMsgSize, int maxCount) |
bool | isConnected () const |
void | setTimeout (std::chrono::milliseconds timeOut) |
virtual void | setFlag (std::string_view flag, bool val) |
void | setServerMode (bool serverActive) |
void | logWarning (std::string_view message) const |
void | logError (std::string_view message) const |
void | logMessage (std::string_view message) const |
Protected Types | |
enum class | ConnectionStatus : int { STARTUP = -1 , CONNECTED = 0 , RECONNECTING = 1 , TERMINATED = 2 , ERRORED = 4 } |
Protected Member Functions | |
void | setTxStatus (ConnectionStatus status) |
void | setRxStatus (ConnectionStatus status) |
ConnectionStatus | getRxStatus () const |
ConnectionStatus | getTxStatus () const |
bool | propertyLock () |
void | propertyUnLock () |
void | join_tx_rx_thread () |
const std::string & | getRandomID () const |
Protected Attributes | |
gmlc::concurrency::TriggerVariable | rxTrigger |
std::string | name |
the name of the object | |
std::string | localTargetAddress |
the base for the receive address | |
std::string | brokerTargetAddress |
the base for the broker address | |
std::string | brokerName |
std::string | brokerInitString |
the initialization string for any automatically generated broker | |
bool | mRequireBrokerConnection |
specify that the comms should assume we have a broker More... | |
bool | serverMode {true} |
some comms have a server mode and non-server mode | |
bool | autoBroker {false} |
the broker should be automatically generated if needed | |
bool | useJsonSerialization {false} |
true to make all connections use JSON serialization | |
bool | observer {false} |
true for connections that are for observation only | |
std::chrono::milliseconds | connectionTimeout {4000} |
int | maxMessageSize = 16 * 1024 |
the maximum message size for the queues (if needed) | |
int | maxMessageCount = 512 |
the maximum number of message to buffer (if needed) | |
std::atomic< bool > | requestDisconnect {false} |
flag gets set when disconnect is called | |
std::function< void(ActionMessage &&)> | ActionCallback |
the callback for what to do with a received message | |
std::function< void(int level, std::string_view name, std::string_view message)> | loggingCallback |
callback for logging | |
gmlc::containers::BlockingPriorityQueue< std::pair< route_id, ActionMessage > > | txQueue |
set of messages waiting to be transmitted | |
std::atomic< bool > | disconnecting |
flag indicating that the comm system is in the process of disconnecting More... | |
gmlc::networking::InterfaceNetworks | interfaceNetwork |
implementation of a generic communications interface
|
strongprotected |
enumeration of the connection status flags for more immediate feedback from the processing threads
|
strong |
|
default |
default constructor
|
virtual |
destructor
void helics::CommsInterface::addRoute | ( | route_id | rid, |
std::string_view | routeInfo | ||
) |
add a new route assigned to the appropriate id
References helics::route_id::baseValue(), helics::ActionMessage::messageID, helics::ActionMessage::payload, and helics::ActionMessage::setExtraData().
bool helics::CommsInterface::connect | ( | ) |
connect the commsInterface
void helics::CommsInterface::disconnect | ( | ) |
disconnected the comms interface
Referenced by helics::inproc::InprocComms::~InprocComms(), helics::ipc::IpcComms::~IpcComms(), helics::mpi::MpiComms::~MpiComms(), helics::tcp::TcpComms::~TcpComms(), helics::tcp::TcpCommsSS::~TcpCommsSS(), helics::udp::UdpComms::~UdpComms(), helics::zeromq::ZmqComms::~ZmqComms(), and helics::zeromq::ZmqCommsSS::~ZmqCommsSS().
|
inlineprotected |
get the generated randomID for this comm interface
bool helics::CommsInterface::isConnected | ( | ) | const |
check if the commInterface is connected
|
protected |
function to join the processing threads
|
virtual |
load network information into the comms object
Reimplemented in helics::zeromq::ZmqCommsSS, helics::zeromq::ZmqComms, helics::udp::UdpComms, helics::tcp::TcpCommsSS, helics::tcp::TcpComms, helics::NetworkCommsInterface, helics::ipc::IpcComms, and helics::inproc::InprocComms.
References helics::NetworkBrokerData::autobroker, helics::NetworkBrokerData::brokerAddress, helics::NetworkBrokerData::brokerInitString, helics::NetworkBrokerData::brokerName, helics::NetworkBrokerData::connectionAddress, helics::NetworkBrokerData::localInterface, helics::NetworkBrokerData::maxMessageCount, helics::NetworkBrokerData::maxMessageSize, helics::NetworkBrokerData::observer, and helics::NetworkBrokerData::server_mode.
Referenced by helics::inproc::InprocComms::loadNetworkInfo(), helics::ipc::IpcComms::loadNetworkInfo(), and helics::NetworkCommsInterface::loadNetworkInfo().
void helics::CommsInterface::logError | ( | std::string_view | message | ) | const |
generate a log message as an error
References HELICS_LOG_LEVEL_ERROR.
void helics::CommsInterface::logMessage | ( | std::string_view | message | ) | const |
generate a log message as a level above warning or error
References HELICS_LOG_LEVEL_INTERFACES.
Referenced by helics::mpi::MpiComms::MpiComms().
void helics::CommsInterface::logWarning | ( | std::string_view | message | ) | const |
generate a log message as a warning
References HELICS_LOG_LEVEL_WARNING.
|
protected |
function to protect certain properties in a threaded environment these functions should be called in a pair
Referenced by helics::tcp::TcpCommsSS::addConnection(), helics::tcp::TcpCommsSS::addConnections(), helics::inproc::InprocComms::loadNetworkInfo(), helics::ipc::IpcComms::loadNetworkInfo(), helics::NetworkCommsInterface::loadNetworkInfo(), helics::tcp::TcpComms::loadNetworkInfo(), helics::tcp::TcpCommsSS::loadNetworkInfo(), helics::udp::UdpComms::loadNetworkInfo(), helics::zeromq::ZmqComms::loadNetworkInfo(), helics::zeromq::ZmqCommsSS::loadNetworkInfo(), helics::NetworkCommsInterface::setAutomaticPortStartPort(), helics::NetworkCommsInterface::setBrokerPort(), helics::NetworkCommsInterface::setFlag(), helics::tcp::TcpComms::setFlag(), helics::tcp::TcpCommsSS::setFlag(), and helics::NetworkCommsInterface::setPortNumber().
bool helics::CommsInterface::reconnect | ( | ) |
try reconnected from a mismatched or disconnection
void helics::CommsInterface::removeRoute | ( | route_id | rid | ) |
remove a route from use
References helics::route_id::baseValue(), helics::ActionMessage::messageID, and helics::ActionMessage::setExtraData().
void helics::CommsInterface::setCallback | ( | std::function< void(ActionMessage &&)> | callback | ) |
set the callback for processing the messages
|
virtual |
set a flag for the comms system
Reimplemented in helics::tcp::TcpCommsSS, helics::tcp::TcpComms, and helics::NetworkCommsInterface.
Referenced by helics::NetworkCommsInterface::setFlag().
void helics::CommsInterface::setLoggingCallback | ( | std::function< void(int level, std::string_view name, std::string_view message)> | callback | ) |
set the callback for processing the messages
void helics::CommsInterface::setMessageSize | ( | int | maxMsgSize, |
int | maxCount | ||
) |
set the max message size and max Queue size
void helics::CommsInterface::setName | ( | const std::string & | commName | ) |
set the name of the communicator
void helics::CommsInterface::setRequireBrokerConnection | ( | bool | requireBrokerConnection | ) |
set a flag indicating that a broker connection is required and all Connection fields are targeted at a broker
void helics::CommsInterface::setServerMode | ( | bool | serverActive | ) |
enable or disable the server mode for the comms
void helics::CommsInterface::setTimeout | ( | std::chrono::milliseconds | timeOut | ) |
set the timeout for the initial broker connection
timeOut | the value is in milliseconds |
void helics::CommsInterface::transmit | ( | route_id | rid, |
ActionMessage && | cmd | ||
) |
transmit a message along a particular route
References helics::isPriorityCommand().
void helics::CommsInterface::transmit | ( | route_id | rid, |
const ActionMessage & | cmd | ||
) |
transmit a message along a particular route
References helics::isPriorityCommand().
|
protected |
the identifier for the broker
|
protected |
timeout for the initial connection to a broker or to bind a broker port(in ms)
|
protected |
flag indicating that the comm system is in the process of disconnecting
Referenced by helics::zeromq::ZmqCommsSS::~ZmqCommsSS().
|
protected |
|
protected |
specify that the comms should assume we have a broker
Referenced by helics::NetworkCommsInterface::loadNetworkInfo().