helics  3.3.0
UdpComms.h
1 /*
2 Copyright (c) 2017-2022,
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 namespace helics {
16 namespace udp {
18  class UdpComms final: public NetworkCommsInterface {
19  public:
21  UdpComms();
23  ~UdpComms();
24 
25  virtual void loadNetworkInfo(const NetworkBrokerData& netInfo) override;
26 
27  private:
28  virtual int getDefaultBrokerPort() const override;
29  virtual void queue_rx_function() override;
30  virtual void queue_tx_function() override;
31  virtual void closeReceiver() override;
32 
33  // promise and future for communicating port number from tx_thread to rx_thread
34  std::promise<int> promisePort;
35  std::future<int> futurePort;
36 
37  public:
38  };
39 
40 } // namespace udp
41 } // 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:18
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::CommsInterface::disconnecting
std::atomic< bool > disconnecting
flag indicating that the comm system is in the process of disconnecting
Definition: CommsInterface.hpp:158
helics::udp::UdpComms::UdpComms
UdpComms()
Definition: UdpComms.cpp:24
helics::NetworkCommsInterface::PortNumber
std::atomic< int > PortNumber
port to use for the local connection
Definition: NetworkCommsInterface.hpp:60
helics::CommsInterface::brokerInitString
std::string brokerInitString
the initialization string for any automatically generated broker
Definition: CommsInterface.hpp:128
helics::NetworkBrokerData
Definition: NetworkBrokerData.hpp:23
helics::CommsInterface::connectionTimeout
std::chrono::milliseconds connectionTimeout
Definition: CommsInterface.hpp:146
helics::NetworkCommsInterface::generateReplyToIncomingMessage
ActionMessage generateReplyToIncomingMessage(ActionMessage &cmd)
Definition: NetworkCommsInterface.cpp:226
helics::CommsInterface::logError
void logError(std::string_view message) const
Definition: CommsInterface.cpp:581
HELICS_CORE_TYPE_UDP
@ HELICS_CORE_TYPE_UDP
Definition: helics_enums.h:41
helics::CommsInterface::txQueue
gmlc::containers::BlockingPriorityQueue< std::pair< route_id, ActionMessage > > txQueue
set of messages waiting to be transmitted
Definition: CommsInterface.hpp:155
helics::isValidCommand
bool isValidCommand(const ActionMessage &command) noexcept
Definition: ActionMessage.hpp:338
helics::CommsInterface::logMessage
void logMessage(std::string_view message) const
Definition: CommsInterface.cpp:563
helics::NetworkCommsInterface::autoPortNumber
bool autoPortNumber
use an automatic port numbering based on broker responses
Definition: NetworkCommsInterface.hpp:61
helics::CommsInterface::ActionCallback
std::function< void(ActionMessage &&)> ActionCallback
the callback for what to do with a received message
Definition: CommsInterface.hpp:151
helics::CommsInterface::ConnectionStatus::ERRORED
@ ERRORED
some ERRORED 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::CommsInterface::ConnectionStatus::TERMINATED
@ TERMINATED
the connection has been TERMINATED
helics::CommsInterface::logWarning
void logWarning(std::string_view message) const
Definition: CommsInterface.cpp:572
helics::NetworkCommsInterface::brokerPort
int brokerPort
standardized broker port to use for connection to the brokers
Definition: NetworkCommsInterface.hpp:59
helics::CommsInterface::localTargetAddress
std::string localTargetAddress
the base for the receive address
Definition: CommsInterface.hpp:124
helics::CommsInterface::brokerName
std::string brokerName
Definition: CommsInterface.hpp:126
helics::prettyPrintString
std::string prettyPrintString(const ActionMessage &command)
Definition: ActionMessage.cpp:846
helics::udp::UdpComms::loadNetworkInfo
virtual void loadNetworkInfo(const NetworkBrokerData &netInfo) override
Definition: UdpComms.cpp:35
helics::isDisconnectCommand
bool isDisconnectCommand(const ActionMessage &command) noexcept
Definition: ActionMessage.hpp:277
helics::CommsInterface::requestDisconnect
std::atomic< bool > requestDisconnect
flag gets set when disconnect is called
Definition: CommsInterface.hpp:149
helics::NetworkCommsInterface::loadNetworkInfo
virtual void loadNetworkInfo(const NetworkBrokerData &netInfo) override
Definition: NetworkCommsInterface.cpp:97
helics::NetworkCommsInterface::noAckConnection
bool noAckConnection
flag to bypass the connection acknowledge requirement
Definition: NetworkCommsInterface.hpp:64
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::NetworkCommsInterface
Definition: NetworkCommsInterface.hpp:18
helics::udp::UdpComms::~UdpComms
~UdpComms()
Definition: UdpComms.cpp:48
helics::CommsInterface::ConnectionStatus::CONNECTED
@ CONNECTED
we are CONNECTED