helics  3.0.1
UdpComms.h
1 /*
2 Copyright (c) 2017-2021,
3 Battelle Memorial Institute; Lawrence Livermore National Security, LLC; Alliance for Sustainable
4 Energy, LLC. See the top-level NOTICE for additional details. All rights reserved.
5 SPDX-License-Identifier: BSD-3-Clause
6 */
7 #pragma once
8 
9 #include "../NetworkCommsInterface.hpp"
10 #include "helics/helics-config.h"
11 
12 #include <future>
13 #include <set>
14 
15 class AsioContextManager;
16 namespace asio {
17 class io_context;
18 } // namespace asio
19 
20 namespace helics {
21 namespace udp {
23  class UdpComms final: public NetworkCommsInterface {
24  public:
26  UdpComms();
28  ~UdpComms();
29 
30  virtual void loadNetworkInfo(const NetworkBrokerData& netInfo) override;
31 
32  private:
33  virtual int getDefaultBrokerPort() const override;
34  virtual void queue_rx_function() override;
35  virtual void queue_tx_function() override;
36  virtual void closeReceiver() override;
37 
38  // promise and future for communicating port number from tx_thread to rx_thread
39  std::promise<int> promisePort;
40  std::future<int> futurePort;
41 
42  public:
43  };
44 
45 } // namespace udp
46 } // namespace helics
helics::CommsInterface::brokerTargetAddress
std::string brokerTargetAddress
the base for the broker address
Definition: CommsInterface.hpp:125
helics::CommsInterface::propertyLock
bool propertyLock()
Definition: CommsInterface.cpp:153
helics::udp::UdpComms
Definition: UdpComms.h:23
helics::InterfaceNetworks
InterfaceNetworks
Definition: NetworkBrokerData.hpp:16
helics::CoreType::UDP
@ UDP
use UDP packets to send the data
helics::message_process_result::processed
@ processed
the message was used to update the current state
helics::InterfaceNetworks::IPV6
@ IPV6
use external ipv6 ports
helics::extractInterfaceandPortString
std::pair< std::string, std::string > extractInterfaceandPortString(const std::string &address)
Definition: NetworkBrokerData.cpp:251
AsioContextManager::getContextPointer
static std::shared_ptr< AsioContextManager > getContextPointer(const std::string &contextName=std::string())
Definition: AsioContextManager.cpp:38
helics::CommsInterface::connection_status::terminated
@ terminated
the connection has been terminated
helics::CommsInterface::logWarning
void logWarning(const std::string &message) const
Definition: CommsInterface.cpp:571
helics::extractInterfaceandPort
std::pair< std::string, int > extractInterfaceandPort(const std::string &address)
Definition: NetworkBrokerData.cpp:227
helics::CommsInterface::disconnecting
std::atomic< bool > disconnecting
flag indicating that the comm system is in the process of disconnecting
Definition: CommsInterface.hpp:157
helics::udp::UdpComms::UdpComms
UdpComms()
Definition: UdpComms.cpp:25
helics::CommsInterface::logError
void logError(const std::string &message) const
Definition: CommsInterface.cpp:580
helics::NetworkCommsInterface::PortNumber
std::atomic< int > PortNumber
port to use for the local connection
Definition: NetworkCommsInterface.hpp:57
helics::CommsInterface::brokerInitString
std::string brokerInitString
the initialization string for any automatically generated broker
Definition: CommsInterface.hpp:128
helics::NetworkBrokerData
Definition: NetworkBrokerData.hpp:36
helics::CommsInterface::connectionTimeout
std::chrono::milliseconds connectionTimeout
Definition: CommsInterface.hpp:145
helics::NetworkCommsInterface::generateReplyToIncomingMessage
ActionMessage generateReplyToIncomingMessage(ActionMessage &cmd)
Definition: NetworkCommsInterface.cpp:194
helics::CommsInterface::txQueue
gmlc::containers::BlockingPriorityQueue< std::pair< route_id, ActionMessage > > txQueue
set of messages waiting to be transmitted
Definition: CommsInterface.hpp:154
helics::isValidCommand
bool isValidCommand(const ActionMessage &command) noexcept
Definition: ActionMessage.hpp:317
AsioContextManager
Definition: AsioContextManager.h:32
helics::NetworkCommsInterface::autoPortNumber
bool autoPortNumber
use an automatic port numbering based on broker responses
Definition: NetworkCommsInterface.hpp:58
helics::CommsInterface::ActionCallback
std::function< void(ActionMessage &&)> ActionCallback
the callback for what to do with a received message
Definition: CommsInterface.hpp:150
helics::CommsInterface::connection_status::error
@ error
some error occurred on the connection
helics::CommsInterface::disconnect
void disconnect()
Definition: CommsInterface.cpp:385
helics::CommsInterface::transmit
void transmit(route_id rid, const ActionMessage &cmd)
Definition: CommsInterface.cpp:170
helics::NetworkCommsInterface::brokerPort
int brokerPort
standardized broker port to use for connection to the brokers
Definition: NetworkCommsInterface.hpp:56
helics::CommsInterface::localTargetAddress
std::string localTargetAddress
the base for the receive address
Definition: CommsInterface.hpp:124
helics::CommsInterface::brokerName
std::string brokerName
the identifier for the broker
Definition: CommsInterface.hpp:126
helics::prettyPrintString
std::string prettyPrintString(const ActionMessage &command)
Definition: ActionMessage.cpp:841
helics::udp::UdpComms::loadNetworkInfo
virtual void loadNetworkInfo(const NetworkBrokerData &netInfo) override
Definition: UdpComms.cpp:34
helics::isDisconnectCommand
bool isDisconnectCommand(const ActionMessage &command) noexcept
Definition: ActionMessage.hpp:276
helics::CommsInterface::requestDisconnect
std::atomic< bool > requestDisconnect
flag gets set when disconnect is called
Definition: CommsInterface.hpp:148
helics::NetworkCommsInterface::loadNetworkInfo
virtual void loadNetworkInfo(const NetworkBrokerData &netInfo) override
Definition: NetworkCommsInterface.cpp:77
helics::NetworkCommsInterface::noAckConnection
bool noAckConnection
flag to bypass the connection acknowledge requirement
Definition: NetworkCommsInterface.hpp:61
helics::isProtocolCommand
bool isProtocolCommand(const ActionMessage &command) noexcept
Definition: ActionMessage.hpp:226
helics
the main namespace for the helics co-simulation library User functions will be in the helics namespac...
Definition: AsyncFedCallInfo.hpp:14
helics::makePortAddress
std::string makePortAddress(const std::string &networkInterface, int portNumber)
Definition: NetworkBrokerData.cpp:217
helics::NetworkCommsInterface
Definition: NetworkCommsInterface.hpp:18
helics::InterfaceTypes
InterfaceTypes
Definition: NetworkBrokerData.hpp:24
helics::udp::UdpComms::~UdpComms
~UdpComms()
Definition: UdpComms.cpp:47
helics::CommsInterface::connection_status::connected
@ connected
we are connected
helics::CommsInterface::logMessage
void logMessage(const std::string &message) const
Definition: CommsInterface.cpp:562