![]() |
helics
3.0.1
|
#include <CommsInterface.hpp>
Public Types | |
enum | thread_generation { single, dual } |
Public Member Functions | |
CommsInterface ()=default | |
CommsInterface (thread_generation threads) | |
virtual | ~CommsInterface () |
virtual void | loadNetworkInfo (const NetworkBrokerData &netInfo) |
void | loadTargetInfo (const std::string &localTarget, const std::string &brokerTarget, InterfaceNetworks targetNetwork=InterfaceNetworks::LOCAL) |
void | transmit (route_id rid, const ActionMessage &cmd) |
void | transmit (route_id rid, ActionMessage &&cmd) |
void | addRoute (route_id rid, const std::string &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, const std::string &name, const std::string &message)> callback) |
void | setMessageSize (int maxMsgSize, int maxCount) |
bool | isConnected () const |
void | setTimeout (std::chrono::milliseconds timeOut) |
virtual void | setFlag (const std::string &flag, bool val) |
void | setServerMode (bool serverActive) |
void | logWarning (const std::string &message) const |
void | logError (const std::string &message) const |
void | logMessage (const std::string &message) const |
Protected Types | |
enum | connection_status : int { connection_status::startup = -1, connection_status::connected = 0, connection_status::reconnecting = 1, connection_status::terminated = 2, connection_status::error = 4 } |
Protected Member Functions | |
void | setTxStatus (connection_status txStatus) |
void | setRxStatus (connection_status rxStatus) |
connection_status | getRxStatus () const |
connection_status | 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 |
the identifier for the broker | |
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, const std::string &name, const std::string &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... | |
InterfaceNetworks | interfaceNetwork = InterfaceNetworks::LOCAL |
implementation of a generic communications interface
|
strongprotected |
enumeration of the connection status flags for more immediate feedback from the processing threads
|
strong |
enumeration of whether the threading system should generate a single thread or multiple threads
|
default |
default constructor
|
virtual |
destructor
void helics::CommsInterface::addRoute | ( | route_id | rid, |
const std::string & | 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::NetworkCommsInterface, helics::tcp::TcpComms, helics::zeromq::ZmqCommsSS, helics::udp::UdpComms, helics::zeromq::ZmqComms, helics::inproc::InprocComms, and helics::ipc::IpcComms.
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::ipc::IpcComms::loadNetworkInfo(), helics::inproc::InprocComms::loadNetworkInfo(), and helics::NetworkCommsInterface::loadNetworkInfo().
void helics::CommsInterface::logError | ( | const std::string & | message | ) | const |
generate a log message as an error
References HELICS_LOG_LEVEL_ERROR.
void helics::CommsInterface::logMessage | ( | const std::string & | 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 | ( | const std::string & | 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::ipc::IpcComms::loadNetworkInfo(), helics::inproc::InprocComms::loadNetworkInfo(), helics::udp::UdpComms::loadNetworkInfo(), helics::zeromq::ZmqComms::loadNetworkInfo(), helics::zeromq::ZmqCommsSS::loadNetworkInfo(), helics::tcp::TcpComms::loadNetworkInfo(), helics::NetworkCommsInterface::loadNetworkInfo(), helics::NetworkCommsInterface::setAutomaticPortStartPort(), helics::NetworkCommsInterface::setBrokerPort(), helics::tcp::TcpComms::setFlag(), helics::tcp::TcpCommsSS::setFlag(), helics::NetworkCommsInterface::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::NetworkCommsInterface, helics::tcp::TcpCommsSS, and helics::tcp::TcpComms.
Referenced by helics::NetworkCommsInterface::setFlag().
void helics::CommsInterface::setLoggingCallback | ( | std::function< void(int level, const std::string &name, const std::string &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 |
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 |
specify that the comms should assume we have a broker
Referenced by helics::NetworkCommsInterface::loadNetworkInfo().