9 #include "ActionMessageDefintions.hpp"
10 #include "SmallBuffer.hpp"
11 #include "basic_CoreTypes.hpp"
19 constexpr
int targetStringLoc{0};
20 constexpr
int sourceStringLoc{1};
21 constexpr
int unitStringLoc{1};
22 constexpr
int origSourceStringLoc{2};
23 constexpr
int origDestStringLoc{3};
24 constexpr
int typeStringLoc{0};
25 constexpr
int typeOutStringLoc{1};
27 constexpr int32_t cmd_info_basis{65536};
50 std::vector<std::string> stringData;
106 const std::vector<std::string>&
getStringData()
const {
return stringData; }
111 void clearStringData() { stringData.clear(); }
115 void setStringData(std::string_view string1)
117 stringData.resize(1);
118 stringData[0] = string1;
120 void setStringData(std::string_view string1, std::string_view string2)
122 stringData.resize(2);
123 stringData[0] = string1;
124 stringData[1] = string2;
126 void setStringData(std::string_view string1, std::string_view string2, std::string_view string3)
128 stringData.resize(3);
129 stringData[0] = string1;
130 stringData[1] = string2;
131 stringData[2] = string3;
133 void setStringData(std::string_view string1,
134 std::string_view string2,
135 std::string_view string3,
136 std::string_view string4)
138 stringData.resize(4);
139 stringData[0] = string1;
140 stringData[1] = string2;
141 stringData[2] = string3;
142 stringData[3] = string4;
144 const std::string& getString(
int index)
const;
146 void setString(
int index, std::string_view str);
174 int toByteArray(std::byte* data, std::size_t buffer_size)
const;
189 void to_vector(std::vector<char>& data)
const;
193 std::size_t
fromByteArray(
const std::byte* data, std::size_t buffer_size);
197 std::size_t
depacketize(
const void* data, std::size_t buffer_size);
205 std::size_t
from_vector(
const std::vector<char>& data);
211 inline bool operator<(
const ActionMessage& cmd,
const ActionMessage& cmd2)
213 return (cmd.actionTime < cmd2.actionTime);
229 return ((command.action() == CMD_PROTOCOL) || (command.action() == CMD_PROTOCOL_PRIORITY) ||
230 (command.action() == CMD_PROTOCOL_BIG));
238 inline bool isTimingCommand(
const ActionMessage& command) noexcept
240 switch (command.action()) {
242 case CMD_BROADCAST_DISCONNECT:
243 case CMD_DISCONNECT_CORE:
244 case CMD_DISCONNECT_BROKER:
245 case CMD_DISCONNECT_FED:
247 case CMD_TIME_REQUEST:
249 case CMD_EXEC_REQUEST:
250 case CMD_PRIORITY_DISCONNECT:
251 case CMD_TERMINATE_IMMEDIATELY:
253 case CMD_LOCAL_ERROR:
254 case CMD_GLOBAL_ERROR:
255 case CMD_TIMING_INFO:
262 inline bool isDependencyCommand(
const ActionMessage& command) noexcept
264 switch (command.action()) {
265 case CMD_ADD_DEPENDENCY:
266 case CMD_REMOVE_DEPENDENCY:
267 case CMD_ADD_DEPENDENT:
268 case CMD_REMOVE_DEPENDENT:
269 case CMD_ADD_INTERDEPENDENCY:
270 case CMD_REMOVE_INTERDEPENDENCY:
280 switch (command.action()) {
282 case CMD_DISCONNECT_CHECK:
283 case CMD_DISCONNECT_NAME:
284 case CMD_USER_DISCONNECT:
285 case CMD_DISCONNECT_FED:
286 case CMD_DISCONNECT_CORE:
287 case CMD_PRIORITY_DISCONNECT:
288 case CMD_TERMINATE_IMMEDIATELY:
289 case CMD_REMOVE_FILTER:
290 case CMD_REMOVE_ENDPOINT:
291 case CMD_DISCONNECT_FED_ACK:
292 case CMD_DISCONNECT_CORE_ACK:
293 case CMD_DISCONNECT_BROKER_ACK:
294 case CMD_DISCONNECT_BROKER:
295 case CMD_BROADCAST_DISCONNECT:
299 return (command.actionTime == Time::maxVal());
308 switch (command.action()) {
310 case CMD_LOCAL_ERROR:
311 case CMD_GLOBAL_ERROR:
326 switch (command.action()) {
330 case CMD_TIME_REQUEST:
331 case CMD_REQUEST_CURRENT_TIME:
351 std::ostream&
operator<<(std::ostream& out,
const ActionMessage& command);
357 int appendMessage(ActionMessage& multiMessage,
const ActionMessage& newMessage);
Definition: ActionMessage.hpp:30
void setExtraData(int32_t data)
Definition: ActionMessage.hpp:158
Time actionTime
40 the time an action took place or will take place //32
Definition: ActionMessage.hpp:44
Time Tso
64 the second order dependent time
Definition: ActionMessage.hpp:47
ActionMessage() noexcept
Definition: ActionMessage.hpp:53
int serializedByteCount() const
Definition: ActionMessage.cpp:263
std::size_t from_vector(const std::vector< char > &data)
Definition: ActionMessage.cpp:620
bool from_json_string(std::string_view data)
Definition: ActionMessage.cpp:586
uint16_t counter
26 counter for filter tracking or multiMessage counter
Definition: ActionMessage.hpp:41
ActionMessage & operator=(const ActionMessage &act)
Definition: ActionMessage.cpp:87
int32_t getExtraData() const
Definition: ActionMessage.hpp:160
void setSource(GlobalHandle hand)
Definition: ActionMessage.hpp:94
SmallBuffer payload
buffer to contain the data payload
Definition: ActionMessage.hpp:48
action_message_def::action_t action() const noexcept
Definition: ActionMessage.hpp:89
std::string_view name() const
Definition: ActionMessage.hpp:110
void swapSourceDest() noexcept
Definition: ActionMessage.hpp:152
InterfaceHandle source_handle
16 – for local handle or local code
Definition: ActionMessage.hpp:38
friend std::unique_ptr< Message > createMessageFromCommand(const ActionMessage &cmd)
Definition: ActionMessage.cpp:632
std::size_t depacketize(const void *data, std::size_t buffer_size)
Definition: ActionMessage.cpp:541
const std::vector< std::string > & getStringData() const
Definition: ActionMessage.hpp:106
void setDestination(GlobalHandle hand)
Definition: ActionMessage.hpp:100
std::vector< char > to_vector() const
Definition: ActionMessage.cpp:368
int32_t messageID
8 – multiMessage ID for a variety of purposes
Definition: ActionMessage.hpp:36
int toByteArray(std::byte *data, std::size_t buffer_size) const
Definition: ActionMessage.cpp:179
std::string packetize() const
Definition: ActionMessage.cpp:332
GlobalHandle getDest() const
Definition: ActionMessage.hpp:150
std::string to_json_string() const
Definition: ActionMessage.cpp:296
int32_t getExtraDestData() const
Definition: ActionMessage.hpp:164
uint32_t sequenceID
32 a sequence number for ordering
Definition: ActionMessage.hpp:43
void setAction(action_message_def::action_t newAction)
Definition: ActionMessage.cpp:141
std::string packetize_json() const
Definition: ActionMessage.cpp:339
Time Te
48 event time
Definition: ActionMessage.hpp:45
GlobalFederateId dest_id
20 fed_id for a targeted multiMessage
Definition: ActionMessage.hpp:39
GlobalHandle getSource() const
Definition: ActionMessage.hpp:148
std::size_t fromByteArray(const std::byte *data, std::size_t buffer_size)
Definition: ActionMessage.cpp:399
GlobalFederateId source_id
12 – for federate_id or route_id
Definition: ActionMessage.hpp:37
void name(std::string_view name)
Definition: ActionMessage.hpp:108
std::string to_string() const
Definition: ActionMessage.cpp:283
InterfaceHandle dest_handle
24 local handle for a targeted multiMessage
Definition: ActionMessage.hpp:40
uint16_t flags
28 set of messageFlags
Definition: ActionMessage.hpp:42
Time Tdemin
56 min dependent event time
Definition: ActionMessage.hpp:46
std::size_t from_string(std::string_view data)
Definition: ActionMessage.cpp:575
void setExtraDestData(int32_t data)
Definition: ActionMessage.hpp:162
Definition: GlobalFederateId.hpp:75
Definition: GlobalFederateId.hpp:147
GlobalFederateId fed_id
the federate id component
Definition: GlobalFederateId.hpp:149
InterfaceHandle handle
the interface handle component
Definition: GlobalFederateId.hpp:150
Definition: LocalFederateId.hpp:65
constexpr BaseType baseValue() const
Definition: LocalFederateId.hpp:73
Definition: SmallBuffer.hpp:25
std::string_view to_string() const
Definition: SmallBuffer.hpp:238
action_t
Definition: ActionMessageDefintions.hpp:20
@ cmd_invalid
indicates that command has generated an invalid state
the main namespace for the helics co-simulation library User functions will be in the helics namespac...
Definition: AsyncFedCallInfo.hpp:14
bool isValidCommand(const ActionMessage &command) noexcept
Definition: ActionMessage.hpp:339
bool isPriorityCommand(const ActionMessage &command) noexcept
Definition: ActionMessage.hpp:233
bool isDisconnectCommand(const ActionMessage &command) noexcept
Definition: ActionMessage.hpp:278
std::string prettyPrintString(const ActionMessage &command)
Definition: ActionMessage.cpp:845
constexpr Time timeZero
Definition: helicsTime.hpp:31
bool isErrorCommand(const ActionMessage &command) noexcept
Definition: ActionMessage.hpp:306
std::unique_ptr< Message > createMessageFromCommand(const ActionMessage &cmd)
Definition: ActionMessage.cpp:632
std::ostream & operator<<(std::ostream &out, const ActionMessage &command)
Definition: ActionMessage.cpp:918
std::string errorMessageString(const ActionMessage &command)
Definition: ActionMessage.cpp:833
IterationRequest
Definition: CoreTypes.hpp:102
int appendMessage(ActionMessage &multiMessage, const ActionMessage &newMessage)
Definition: ActionMessage.cpp:924
constexpr GlobalBrokerId parent_broker_id
Definition: GlobalFederateId.hpp:67
void setIterationFlags(ActionMessage &command, IterationRequest iterate)
Definition: ActionMessage.cpp:935
bool isIgnoreableCommand(const ActionMessage &command) noexcept
Definition: ActionMessage.hpp:318
TimeRepresentation< count_time< 9 > > Time
Definition: helicsTime.hpp:27
bool isProtocolCommand(const ActionMessage &command) noexcept
Definition: ActionMessage.hpp:227