helics 3.7.0
Loading...
Searching...
No Matches
ZmqRequestSets.h
1/*
2Copyright (c) 2017-2026,
3Battelle Memorial Institute; Lawrence Livermore National Security, LLC; Alliance for Energy
4Innovation LLC. See the top-level NOTICE for additional details. All rights reserved.
5SPDX-License-Identifier: BSD-3-Clause
6*/
7#pragma once
8
9#include "../../core/ActionMessage.hpp"
10#include "ZmqContextManager.h"
11#include "cppzmq/zmq.hpp"
12
13#include <deque>
14#include <map>
15#include <memory>
16#include <optional>
17#include <string>
18#include <utility>
19#include <vector>
20
21namespace helics {
22namespace zeromq {
25 public:
26 int route = 0;
27 std::uint16_t loops = 0;
28 bool waiting = false;
30 };
31
39 public:
43 void addRoutes(int routeNumber, const std::string& routeInfo);
45 bool transmit(int routeNumber, const ActionMessage& command);
47 bool waiting() const;
50 int checkForMessages();
53 int checkForMessages(std::chrono::milliseconds timeout);
55 bool hasMessages() const;
57 std::optional<ActionMessage> getMessage();
59 void close();
60
61 private:
63 void SendDelayedMessages();
64
65 private:
66 std::map<int, std::unique_ptr<zmq::socket_t>> routes;
67 std::map<int, bool> routes_waiting;
68 std::vector<zmq::pollitem_t> active_routes;
69 std::vector<WaitingResponse> active_messages;
70 std::vector<std::pair<int, ActionMessage>>
71 waiting_messages;
72 std::deque<ActionMessage> Responses;
74 std::shared_ptr<ZmqContextManager> ctx;
75 };
76} // namespace zeromq
77} // namespace helics
Definition ActionMessage.hpp:30
Definition ZmqRequestSets.h:24
ActionMessage txmsg
the most recently sent message
Definition ZmqRequestSets.h:29
std::uint16_t loops
the number of loops
Definition ZmqRequestSets.h:27
int route
the route identifier for the socket
Definition ZmqRequestSets.h:26
bool waiting
whether the response is waiting
Definition ZmqRequestSets.h:28
Definition ZmqRequestSets.h:38
void close()
Definition ZmqRequestSets.cpp:138
int checkForMessages()
Definition ZmqRequestSets.cpp:69
bool transmit(int routeNumber, const ActionMessage &command)
Definition ZmqRequestSets.cpp:39
bool hasMessages() const
Definition ZmqRequestSets.cpp:64
ZmqRequestSets()
Definition ZmqRequestSets.cpp:17
void addRoutes(int routeNumber, const std::string &routeInfo)
Definition ZmqRequestSets.cpp:18
bool waiting() const
Definition ZmqRequestSets.cpp:59
std::optional< ActionMessage > getMessage()
Definition ZmqRequestSets.cpp:149
the main namespace for the helics co-simulation library User functions will be in the helics namespac...
Definition AsyncFedCallInfo.hpp:14