 |
helics
3.3.0
|
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;
105 const std::vector<std::string>&
getStringData()
const {
return stringData; }
110 void clearStringData() { stringData.clear(); }
114 void setStringData(std::string_view string1)
116 stringData.resize(1);
117 stringData[0] = string1;
119 void setStringData(std::string_view string1, std::string_view string2)
121 stringData.resize(2);
122 stringData[0] = string1;
123 stringData[1] = string2;
125 void setStringData(std::string_view string1, std::string_view string2, std::string_view string3)
127 stringData.resize(3);
128 stringData[0] = string1;
129 stringData[1] = string2;
130 stringData[2] = string3;
132 void setStringData(std::string_view string1,
133 std::string_view string2,
134 std::string_view string3,
135 std::string_view string4)
137 stringData.resize(4);
138 stringData[0] = string1;
139 stringData[1] = string2;
140 stringData[2] = string3;
141 stringData[3] = string4;
143 const std::string& getString(
int index)
const;
145 void setString(
int index, std::string_view str);
173 int toByteArray(std::byte* data, std::size_t buffer_size)
const;
188 void to_vector(std::vector<char>& data)
const;
192 std::size_t
fromByteArray(
const std::byte* data, std::size_t buffer_size);
196 std::size_t
depacketize(
const void* data, std::size_t buffer_size);
204 std::size_t
from_vector(
const std::vector<char>& data);
210 inline bool operator<(
const ActionMessage& cmd,
const ActionMessage& cmd2)
212 return (cmd.actionTime < cmd2.actionTime);
228 return ((command.action() == CMD_PROTOCOL) || (command.action() == CMD_PROTOCOL_PRIORITY) ||
229 (command.action() == CMD_PROTOCOL_BIG));
237 inline bool isTimingCommand(
const ActionMessage& command) noexcept
239 switch (command.action()) {
241 case CMD_BROADCAST_DISCONNECT:
242 case CMD_DISCONNECT_CORE:
243 case CMD_DISCONNECT_BROKER:
244 case CMD_DISCONNECT_FED:
246 case CMD_TIME_REQUEST:
248 case CMD_EXEC_REQUEST:
249 case CMD_PRIORITY_DISCONNECT:
250 case CMD_TERMINATE_IMMEDIATELY:
252 case CMD_LOCAL_ERROR:
253 case CMD_GLOBAL_ERROR:
254 case CMD_TIMING_INFO:
261 inline bool isDependencyCommand(
const ActionMessage& command) noexcept
263 switch (command.action()) {
264 case CMD_ADD_DEPENDENCY:
265 case CMD_REMOVE_DEPENDENCY:
266 case CMD_ADD_DEPENDENT:
267 case CMD_REMOVE_DEPENDENT:
268 case CMD_ADD_INTERDEPENDENCY:
269 case CMD_REMOVE_INTERDEPENDENCY:
279 switch (command.action()) {
281 case CMD_DISCONNECT_CHECK:
282 case CMD_DISCONNECT_NAME:
283 case CMD_USER_DISCONNECT:
284 case CMD_DISCONNECT_FED:
285 case CMD_DISCONNECT_CORE:
286 case CMD_PRIORITY_DISCONNECT:
287 case CMD_TERMINATE_IMMEDIATELY:
288 case CMD_REMOVE_FILTER:
289 case CMD_REMOVE_ENDPOINT:
290 case CMD_DISCONNECT_FED_ACK:
291 case CMD_DISCONNECT_CORE_ACK:
292 case CMD_DISCONNECT_BROKER_ACK:
293 case CMD_DISCONNECT_BROKER:
294 case CMD_BROADCAST_DISCONNECT:
298 return (command.actionTime == Time::maxVal());
307 switch (command.action()) {
309 case CMD_LOCAL_ERROR:
310 case CMD_GLOBAL_ERROR:
325 switch (command.action()) {
329 case CMD_TIME_REQUEST:
330 case CMD_REQUEST_CURRENT_TIME:
350 std::ostream&
operator<<(std::ostream& os,
const ActionMessage& command);
356 int appendMessage(ActionMessage& m,
const ActionMessage& newMessage);
constexpr Time timeZero
Definition: helicsTime.hpp:31
@ cmd_remove_subscriber
cmd to remove a target from connection
@ cmd_disconnect_broker
disconnect a broker
InterfaceHandle source_handle
16 – for local handle or local code
Definition: ActionMessage.hpp:38
std::size_t size() const
Definition: SmallBuffer.hpp:316
std::size_t from_vector(const std::vector< char > &data)
Definition: ActionMessage.cpp:621
@ cmd_log
log a message with the root broker
@ cmd_disconnect_fed_ack
federate disconnect ack
void setExtraDestData(int32_t data)
Definition: ActionMessage.hpp:161
@ cmd_init
request entry to init mode
std::size_t fromByteArray(const std::byte *data, std::size_t buffer_size)
Definition: ActionMessage.cpp:400
@ cmd_disconnect
disconnect command
constexpr BaseType baseValue() const
Definition: GlobalFederateId.hpp:84
@ cmd_remove_named_publication
cmd to remove a publication from connection by name
void name(std::string_view name)
Definition: ActionMessage.hpp:107
@ cmd_remove_named_filter
cmd to remove a filter from connection by name
@ cmd_add_named_input
command to add a named input as a target
@ cmd_time_request
request a time or iteration
@ cmd_add_dependency
command to send a federate dependency information
std::ostream & operator<<(std::ostream &os, const ActionMessage &command)
Definition: ActionMessage.cpp:919
@ cmd_time_grant
grant a time or iteration
@ cmd_priority_disconnect
command to disconnect a broker from a higher level broker
@ cmd_remove_interdependency
command to remove a federate as both dependent and a dependency
@ cmd_remove_named_endpoint
cmd to remove an endpoint
@ cmd_fed_configure_time
command to update the configuration of a federate a time parameter
Definition: SmallBuffer.hpp:24
@ cmd_disconnect_name
disconnect a broker or core by name vs id
const std::vector< std::string > & getStringData() const
Definition: ActionMessage.hpp:105
action_t
Definition: ActionMessageDefintions.hpp:20
@ cmd_remove_dependent
command to remove a dependent from a federates consideration
@ cmd_filter_result
the results of a filter message going back to its originator
@ cmd_send_for_filter
send a message to be filtered and forward on to the destination
@ cmd_data_link
command to connect a publication with an endpoint
void setAction(action_message_def::action_t newAction)
Definition: ActionMessage.cpp:142
void assign(const void *start, const void *end)
Definition: SmallBuffer.hpp:177
@ cmd_ping
request for an Echo response
Definition: LocalFederateId.hpp:65
std::string packetize_json() const
Definition: ActionMessage.cpp:340
void to_string(std::string &data) const
Definition: ActionMessage.cpp:385
bool isErrorCommand(const ActionMessage &command) noexcept
Definition: ActionMessage.hpp:305
TimeRepresentation< count_time< 9 > > Time
Definition: helicsTime.hpp:27
@ cmd_filter_link
command to add a target to a filter
@ cmd_remove_publication
cmd to remove a publication from connection
Definition: GlobalFederateId.hpp:72
Definition: ActionMessage.hpp:30
std::string to_json_string() const
Definition: ActionMessage.cpp:297
@ cmd_error
indicate an error with a federate
constexpr GlobalBrokerId parent_broker_id
Definition: GlobalFederateId.hpp:64
@ cmd_time_barrier_request
request a time barrier
GlobalHandle getDest() const
Definition: ActionMessage.hpp:149
@ cmd_register_route
instructions to create a direct route to another federate
@ cmd_tick
command for a timer tick
int appendMessage(ActionMessage &m, const ActionMessage &newMessage)
Definition: ActionMessage.cpp:925
uint16_t counter
26 counter for filter tracking or message counter
Definition: ActionMessage.hpp:41
@ cmd_time_barrier_clear
clear a global time barrier
@ FORCE_ITERATION
force an iteration whether it is needed or not
std::string_view to_string() const
Definition: SmallBuffer.hpp:225
int32_t getExtraDestData() const
Definition: ActionMessage.hpp:163
@ cmd_ack
acknowledge command to for various purposes
@ cmd_add_dependent
command to add a dependent to a federate
@ cmd_remove_endpoint
cmd to remove an endpoint
InterfaceHandle handle
the interface handle component
Definition: GlobalFederateId.hpp:147
bool isValidCommand(const ActionMessage &command) noexcept
Definition: ActionMessage.hpp:338
InterfaceHandle dest_handle
24 local handle for a targeted message
Definition: ActionMessage.hpp:40
const char * commandErrorString(int errorCode)
Definition: ActionMessage.cpp:828
uint32_t sequenceID
32 a sequence number for ordering
Definition: ActionMessage.hpp:43
bool isIgnoreableCommand(const ActionMessage &command) noexcept
Definition: ActionMessage.hpp:317
@ cmd_add_named_publication
command to add a named publication as a target
@ cmd_time_unblock
clear a time block
@ cmd_invalid
indicates that command has generated an invalid state
@ cmd_query_reply
response to a query
@ cmd_exec_grant
grant entry to exec mode or iterate
@ cmd_terminate_immediately
immediate halt no-disconnect;
IterationRequest
Definition: CoreTypes.hpp:92
@ priority_null_info_command
@ cmd_priority_ack
doesn't do anything
@ cmd_init_grant
grant entry to initialization mode
@ cmd_fed_configure_int
command to update the configuration of a federate an int parameter
int32_t messageID
8 – message ID for a variety of purposes
Definition: ActionMessage.hpp:36
@ cmd_reg_end
register an endpoint
void setExtraData(int32_t data)
Definition: ActionMessage.hpp:157
void setActionFlag(FlagContainer &M, FlagIndex flag)
Definition: flagOperations.hpp:130
@ cmd_send_for_dest_filter_return
send a message to a destination filter for processing
std::vector< char > to_vector() const
Definition: ActionMessage.cpp:369
@ cmd_resend
command to resend some data
BaseType * getBaseTypePointer()
Definition: LocalFederateId.hpp:83
@ cmd_disconnect_core_ack
ack for core disconnect
std::size_t from_string(std::string_view data)
Definition: ActionMessage.cpp:576
@ ITERATE_IF_NEEDED
indicator that the iterations need to continue
@ cmd_broker_configure
command to update the configuration of a broker
@ cmd_warning
indicate some sort of warning
SmallBuffer payload
buffer to contain the data payload
Definition: ActionMessage.hpp:48
GlobalFederateId dest_id
20 fed_id for a targeted message
Definition: ActionMessage.hpp:39
@ cmd_fed_ack
a reply with the global id or an error if the fed registration failed
Time Te
48 event time
Definition: ActionMessage.hpp:45
@ cmd_send_route
command to define a route information
@ cmd_reg_pub
register a publication
@ cmd_add_named_endpoint
command to add a named endpoint as a target
@ cmd_reg_input
register an input interface
int serializedByteCount() const
Definition: ActionMessage.cpp:264
std::string prettyPrintString(const ActionMessage &command)
Definition: ActionMessage.cpp:846
@ cmd_disconnect_broker_ack
ack for broker disconnect
@ cmd_time_check
command to run a check on whether time can be granted
uint16_t flags
28 set of messageFlags
Definition: ActionMessage.hpp:42
bool isDisconnectCommand(const ActionMessage &command) noexcept
Definition: ActionMessage.hpp:277
constexpr BaseType baseValue() const
Definition: LocalFederateId.hpp:73
@ cmd_disconnect_core
disconnect a core
@ cmd_add_endpoint
notify of a source endpoint
@ cmd_send_message
send a message
bool from_json_string(std::string_view data)
Definition: ActionMessage.cpp:587
@ cmd_ping_reply
response to a ping request
friend std::unique_ptr< Message > createMessageFromCommand(const ActionMessage &cmd)
Definition: ActionMessage.cpp:633
int32_t getExtraData() const
Definition: ActionMessage.hpp:159
Time Tdemin
56 min dependent event time
Definition: ActionMessage.hpp:46
@ cmd_fed_configure_flag
command to update the configuration of a federate a flag parameter
Time actionTime
40 the time an action took place or will take place //32
Definition: ActionMessage.hpp:44
GlobalHandle getSource() const
Definition: ActionMessage.hpp:147
@ null_info_command
biggest command that doesn't have the info structure
@ cmd_send_for_filter_return
send a message back to its originator after filtering
Time Tso
64 the second order dependent time
Definition: ActionMessage.hpp:47
@ cmd_protocol_big
command used in the protocol stacks with the additional info
@ cmd_request_current_time
command to request the current time status of a federate
void setDestination(GlobalHandle hand)
Definition: ActionMessage.hpp:99
std::string_view name() const
Definition: ActionMessage.hpp:109
bool isProtocolCommand(const ActionMessage &command) noexcept
Definition: ActionMessage.hpp:226
@ cmd_add_publisher
notify of a publication
@ cmd_null_dest_message
used when a destination filter drops a message
the main namespace for the helics co-simulation library User functions will be in the helics namespac...
Definition: AsyncFedCallInfo.hpp:14
const char * actionMessageType(action_message_def::action_t action)
Definition: ActionMessage.cpp:811
@ cmd_null_message
used when a filter drops a message but it needs to return
@ cmd_user_disconnect
command specifying that a user has issued a disconnect signal
@ cmd_reg_fed
register a federate
@ cmd_reg_filter
register a filter
@ cmd_route_ack
acknowledge reply to a route registration
std::byte * data() const
Definition: SmallBuffer.hpp:147
@ cmd_add_interdependency
command to add a federate as both dependent and a dependency
@ iteration_requested_flag
Definition: flagOperations.hpp:23
bool checkActionFlag(uint16_t flags, FlagIndex flag)
Definition: flagOperations.hpp:138
@ cmd_protocol
command used in the protocol stacks and ignored by the core
std::unique_ptr< Message > createMessageFromCommand(const ActionMessage &cmd)
Definition: ActionMessage.cpp:633
ActionMessage() noexcept
Definition: ActionMessage.hpp:53
@ cmd_bye
message stating this is the last communication from a federate
@ cmd_add_named_filter
command to add named filter as a target
std::size_t depacketize(const void *data, std::size_t buffer_size)
Definition: ActionMessage.cpp:542
void swapSourceDest() noexcept
Definition: ActionMessage.hpp:151
@ use_json_serialization_flag
flag to indicate it should use the json packetization
Definition: flagOperations.hpp:79
@ cmd_close_interface
cmd to close all communications from an interface
@ required_flag
flag indicating that an action or match is required
Definition: flagOperations.hpp:45
@ cmd_exec_check
command to run a check on execution entry
Definition: GlobalFederateId.hpp:144
std::string packetize() const
Definition: ActionMessage.cpp:333
action_message_def::action_t action() const noexcept
Definition: ActionMessage.hpp:88
@ cmd_add_filter
notify of a destination filter
@ cmd_exec_request
request an iteration or entry to execution mode
@ error_flag
flag indicating an error condition associated with the command
Definition: flagOperations.hpp:17
@ cmd_query
send a query this is a priority command
@ cmd_init_not_ready
retract an init ready command
@ NO_ITERATIONS
indicator that the iterations have completed
int toByteArray(std::byte *data, std::size_t buffer_size) const
Definition: ActionMessage.cpp:180
@ cmd_time_block
prevent a federate from granting time until the block is cleared
bool isPriorityCommand(const ActionMessage &command) noexcept
Definition: ActionMessage.hpp:232
@ cmd_disconnect_fed
disconnect a federate
GlobalFederateId fed_id
the federate id component
Definition: GlobalFederateId.hpp:146
std::string errorMessageString(const ActionMessage &command)
Definition: ActionMessage.cpp:834
BaseType * getBaseTypePointer()
Definition: GlobalFederateId.hpp:121
void setSource(GlobalHandle hand)
Definition: ActionMessage.hpp:93
@ cmd_time_barrier
setup a global time barrier
@ cmd_remove_named_input
cmd to remove a target from connection by name
@ cmd_add_route
command to define a route
@ cmd_multi_message
cmd that encapsulates a bunch of messages in its payload
@ cmd_remove_filter
cmd to remove a filter from connection
@ cmd_protocol_priority
priority command used by protocol stacks and ignored by core
@ cmd_broadcast_disconnect
a broadcast disconnect message
@ cmd_reg_broker
for a broker to connect with a higher level broker
GlobalFederateId source_id
12 – for federate_id or route_id
Definition: ActionMessage.hpp:37
@ cmd_remove_dependency
command to remove a dependency
@ cmd_add_subscriber
notify of a subscription
ActionMessage & operator=(const ActionMessage &act)
Definition: ActionMessage.cpp:88
bool isValidIndex(sizeType testSize, const SizedDataType &vec)
Definition: core-data.hpp:171
void setIterationFlags(ActionMessage &command, IterationRequest iterate)
Definition: ActionMessage.cpp:936
std::string to_string() const
Definition: ActionMessage.cpp:284