![]() |
helics
3.0.1
|
#include <NetworkCommsInterface.hpp>
Public Member Functions | |
NetworkCommsInterface (InterfaceTypes type, CommsInterface::thread_generation threads=CommsInterface::thread_generation::dual) noexcept | |
virtual void | loadNetworkInfo (const NetworkBrokerData &netInfo) override |
void | setBrokerPort (int brokerPortNumber) |
void | setPortNumber (int localPortNumber) |
int | getPortNumber () const |
void | setAutomaticPortStartPort (int startingPort) |
virtual void | setFlag (const std::string &flag, bool val) override |
int | findOpenPort (int count, const std::string &host) |
ActionMessage | generateReplyToIncomingMessage (ActionMessage &cmd) |
int | getPort () const |
std::string | getAddress () const |
virtual int | getDefaultBrokerPort () const =0 |
![]() | |
CommsInterface ()=default | |
CommsInterface (thread_generation threads) | |
virtual | ~CommsInterface () |
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) |
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 Member Functions | |
ActionMessage | generatePortRequest (int cnt=1) const |
void | loadPortDefinitions (const ActionMessage &cmd) |
![]() | |
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 | |
int | brokerPort {-1} |
standardized broker port to use for connection to the brokers | |
std::atomic< int > | PortNumber {-1} |
port to use for the local connection | |
bool | autoPortNumber {true} |
use an automatic port numbering based on broker responses | |
bool | useOsPortAllocation {false} |
use the operating system to allocate a port number | |
bool | appendNameToAddress {false} |
flag to append the name to the network address | |
bool | noAckConnection {false} |
flag to bypass the connection acknowledge requirement | |
const InterfaceTypes | networkType |
InterfaceNetworks | network {InterfaceNetworks::IPV4} |
std::atomic< bool > | hasBroker {false} |
int | maxRetries {5} |
![]() | |
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 |
Additional Inherited Members | |
![]() | |
enum | thread_generation { single, dual } |
![]() | |
enum | connection_status : int { connection_status::startup = -1, connection_status::connected = 0, connection_status::reconnecting = 1, connection_status::terminated = 2, connection_status::error = 4 } |
implementation for the communication interface that uses ZMQ messages to communicate
|
explicitnoexcept |
default constructor
int helics::NetworkCommsInterface::findOpenPort | ( | int | count, |
const std::string & | host | ||
) |
find an open port for a subBroker
References getDefaultBrokerPort(), and PortNumber.
Referenced by generateReplyToIncomingMessage().
ActionMessage helics::NetworkCommsInterface::generateReplyToIncomingMessage | ( | ActionMessage & | cmd | ) |
for protocol messages some require an immediate reply from the comms interface itself
References helics::ActionMessage::counter, findOpenPort(), helics::isProtocolCommand(), helics::ActionMessage::messageID, PortNumber, helics::ActionMessage::setExtraData(), and helics::ActionMessage::source_id.
std::string helics::NetworkCommsInterface::getAddress | ( | ) | const |
get the network address of the comms interface
References appendNameToAddress, helics::CommsInterface::localTargetAddress, helics::makePortAddress(), helics::CommsInterface::name, PortNumber, and helics::CommsInterface::serverMode.
Referenced by helics::MultiBroker::generateLocalAddressString().
|
pure virtual |
return the default Broker port
Referenced by findOpenPort().
|
inline |
get the port number of the comms object to push message to
References PortNumber.
|
inline |
get the local port number to use for incoming connections
References PortNumber.
|
overridevirtual |
load network information into the comms interface object
load network information into the comms object
Reimplemented from helics::CommsInterface.
Reimplemented in helics::tcp::TcpComms, helics::zeromq::ZmqCommsSS, helics::udp::UdpComms, and helics::zeromq::ZmqComms.
References appendNameToAddress, helics::NetworkBrokerData::appendNameToAddress, autoPortNumber, helics::NetworkBrokerData::brokerPort, brokerPort, helics::CommsInterface::brokerTargetAddress, helics::NetworkBrokerData::connectionPort, helics::generateMatchingInterfaceAddress(), helics::CommsInterface::loadNetworkInfo(), helics::LOCAL, helics::CommsInterface::localTargetAddress, helics::NetworkBrokerData::maxRetries, helics::CommsInterface::mRequireBrokerConnection, noAckConnection, helics::NetworkBrokerData::noAckConnection, helics::NetworkBrokerData::portNumber, PortNumber, helics::NetworkBrokerData::portStart, helics::CommsInterface::propertyLock(), helics::removeProtocol(), helics::stripProtocol(), helics::TCP, helics::UDP, helics::NetworkBrokerData::use_os_port, helics::NetworkBrokerData::useJsonSerialization, helics::CommsInterface::useJsonSerialization, and useOsPortAllocation.
Referenced by helics::udp::UdpComms::loadNetworkInfo(), helics::zeromq::ZmqComms::loadNetworkInfo(), helics::zeromq::ZmqCommsSS::loadNetworkInfo(), and helics::tcp::TcpComms::loadNetworkInfo().
void helics::NetworkCommsInterface::setAutomaticPortStartPort | ( | int | startingPort | ) |
set the automatic port numbering starting port
References helics::CommsInterface::propertyLock().
void helics::NetworkCommsInterface::setBrokerPort | ( | int | brokerPortNumber | ) |
set the port numbers for the local ports
References brokerPort, and helics::CommsInterface::propertyLock().
|
overridevirtual |
set a flag on the communication system
Reimplemented from helics::CommsInterface.
Reimplemented in helics::tcp::TcpCommsSS, and helics::tcp::TcpComms.
References noAckConnection, helics::CommsInterface::propertyLock(), helics::CommsInterface::setFlag(), and useOsPortAllocation.
Referenced by helics::tcp::TcpComms::setFlag(), and helics::tcp::TcpCommsSS::setFlag().
void helics::NetworkCommsInterface::setPortNumber | ( | int | localPortNumber | ) |
set the local port number to use for incoming connections
References autoPortNumber, PortNumber, and helics::CommsInterface::propertyLock().