 |
helics
2.8.1
|
9 #include "ActionMessageDefintions.hpp"
10 #include "basic_core_types.hpp"
18 constexpr
int targetStringLoc{0};
19 constexpr
int sourceStringLoc{1};
20 constexpr
int unitStringLoc{1};
21 constexpr
int origSourceStringLoc{2};
22 constexpr
int origDestStringLoc{3};
23 constexpr
int typeStringLoc{0};
24 constexpr
int typeOutStringLoc{1};
26 constexpr int32_t cmd_info_basis{65536};
51 std::vector<std::string> stringData;
106 const std::vector<std::string>&
getStringData()
const {
return stringData; }
108 void clearStringData() { stringData.clear(); }
112 void setStringData(
const std::string& string1)
114 stringData.resize(1);
115 stringData[0] = string1;
117 void setStringData(
const std::string& string1,
const std::string& string2)
119 stringData.resize(2);
120 stringData[0] = string1;
121 stringData[1] = string2;
123 void setStringData(
const std::string& string1,
124 const std::string& string2,
125 const std::string& string3)
127 stringData.resize(3);
128 stringData[0] = string1;
129 stringData[1] = string2;
130 stringData[2] = string3;
132 void setStringData(
const std::string& string1,
133 const std::string& string2,
134 const std::string& string3,
135 const std::string& 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,
const std::string& str);
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:
260 inline bool isDependencyCommand(
const ActionMessage& command) noexcept
262 switch (command.action()) {
263 case CMD_ADD_DEPENDENCY:
264 case CMD_REMOVE_DEPENDENCY:
265 case CMD_ADD_DEPENDENT:
266 case CMD_REMOVE_DEPENDENT:
267 case CMD_ADD_INTERDEPENDENCY:
268 case CMD_REMOVE_INTERDEPENDENCY:
278 switch (command.action()) {
280 case CMD_DISCONNECT_CHECK:
281 case CMD_DISCONNECT_NAME:
282 case CMD_USER_DISCONNECT:
283 case CMD_DISCONNECT_FED:
284 case CMD_DISCONNECT_CORE:
285 case CMD_PRIORITY_DISCONNECT:
286 case CMD_TERMINATE_IMMEDIATELY:
287 case CMD_REMOVE_FILTER:
288 case CMD_REMOVE_ENDPOINT:
289 case CMD_DISCONNECT_FED_ACK:
290 case CMD_DISCONNECT_CORE_ACK:
291 case CMD_DISCONNECT_BROKER_ACK:
292 case CMD_DISCONNECT_BROKER:
293 case CMD_BROADCAST_DISCONNECT:
297 return (command.actionTime == Time::maxVal());
306 switch (command.action()) {
308 case CMD_LOCAL_ERROR:
309 case CMD_GLOBAL_ERROR:
329 std::ostream&
operator<<(std::ostream& os,
const ActionMessage& command);
335 int appendMessage(ActionMessage& m,
const ActionMessage& newMessage);
constexpr Time timeZero
Definition: helics-time.hpp:31
std::string generateJsonString(const Json::Value &block)
Definition: JsonProcessingFunctions.cpp:97
@ data
print timing+data transmissions
Definition: loggingHelper.hpp:30
@ cmd_remove_subscriber
cmd to remove a target from connection
@ cmd_disconnect_broker
disconnect a broker
global_handle getDest() const
Definition: ActionMessage.hpp:149
std::size_t from_vector(const std::vector< char > &data)
Definition: ActionMessage.cpp:617
@ cmd_log
log a message with the root broker
global_federate_id source_id
12 – for federate_id or route_id
Definition: ActionMessage.hpp:36
@ cmd_disconnect_fed_ack
federate disconnect ack
void setExtraDestData(int32_t data)
Definition: ActionMessage.hpp:161
@ cmd_init
request entry to init mode
@ cmd_disconnect
disconnect command
@ cmd_remove_named_publication
cmd to remove a publication from connection by name
@ 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
void setSource(global_handle hand)
Definition: ActionMessage.hpp:94
std::ostream & operator<<(std::ostream &os, const ActionMessage &command)
Definition: ActionMessage.cpp:933
interface_handle dest_handle
24 local handle for a targeted message
Definition: ActionMessage.hpp:39
@ cmd_time_grant
grant a time or iteration
@ cmd_priority_disconnect
command to disconnect a broker from a higher level broker
int toByteArray(char *data, int buffer_size) const
Definition: ActionMessage.cpp:177
@ 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
iteration_request
Definition: core-types.hpp:90
@ cmd_disconnect_name
disconnect a broker or core by name vs id
const std::vector< std::string > & getStringData() const
Definition: ActionMessage.hpp:106
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
constexpr base_type baseValue() const
Definition: federate_id.hpp:73
interface_handle source_handle
16 – for local handle or local code
Definition: ActionMessage.hpp:37
@ cmd_send_for_filter
send a message to be filtered and forward on to the destination
Definition: global_federate_id.hpp:68
@ cmd_data_link
command to connect a publication with an endpoint
void setAction(action_message_def::action_t newAction)
Definition: ActionMessage.cpp:140
int depacketize(const char *data, int buffer_size)
Definition: ActionMessage.cpp:540
void setIterationFlags(ActionMessage &command, iteration_request iterate)
Definition: ActionMessage.cpp:950
@ cmd_ping
request for an Echo response
constexpr global_broker_id parent_broker_id
Definition: global_federate_id.hpp:60
std::string packetize_json() const
Definition: ActionMessage.cpp:338
void to_string(std::string &data) const
Definition: ActionMessage.cpp:383
bool isErrorCommand(const ActionMessage &command) noexcept
Definition: ActionMessage.hpp:304
TimeRepresentation< count_time< 9 > > Time
Definition: helics-time.hpp:27
@ cmd_filter_link
command to add a target to a filter
@ cmd_remove_publication
cmd to remove a publication from connection
Definition: ActionMessage.hpp:29
std::string to_json_string() const
Definition: ActionMessage.cpp:295
@ cmd_error
indicate an error with a federate
@ cmd_time_barrier_request
request a time barrier
@ cmd_register_route
instructions to create a direct route to another federate
@ force_iteration
force an iteration whether it is needed or not
@ iteration_requested_flag
indicator that an iteration has been requested
Definition: flagOperations.hpp:16
@ cmd_tick
command for a timer tick
int appendMessage(ActionMessage &m, const ActionMessage &newMessage)
Definition: ActionMessage.cpp:939
uint16_t counter
26 counter for filter tracking or message counter
Definition: ActionMessage.hpp:40
@ cmd_time_barrier_clear
clear a global time barrier
int32_t getExtraDestData() const
Definition: ActionMessage.hpp:163
@ cmd_ack
acknowledge command to for various purposes
bool checkActionFlag(uint16_t flags, FlagIndex flag)
Definition: flagOperations.hpp:75
@ cmd_add_dependent
command to add a dependent to a federate
@ cmd_remove_endpoint
cmd to remove an endpoint
bool isValidCommand(const ActionMessage &command) noexcept
Definition: ActionMessage.hpp:317
global_federate_id fed_id
the federate id component
Definition: global_federate_id.hpp:130
interface_handle handle
the interface handle component
Definition: global_federate_id.hpp:131
const char * commandErrorString(int errorCode)
Definition: ActionMessage.cpp:837
uint32_t sequenceID
a sequence number for ordering
Definition: ActionMessage.hpp:42
@ iterate_if_needed
indicator that the iterations need to continue
@ cmd_add_named_publication
command to add a named publication as a target
@ no_iterations
indicator that the iterations have completed
@ cmd_time_unblock
clear a time block
@ cmd_invalid
indicates that command has generated an invalid state
@ cmd_query_reply
response to a query
std::string payload
Definition: ActionMessage.hpp:44
@ cmd_exec_grant
grant entry to exec mode or iterate
Definition: global_federate_id.hpp:128
constexpr base_type baseValue() const
Definition: global_federate_id.hpp:83
@ cmd_terminate_immediately
immediate halt no-disconnect;
@ priority_null_info_command
bool from_json_string(const std::string &data)
Definition: ActionMessage.cpp:583
@ 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:35
@ cmd_reg_end
register an endpoint
void setExtraData(int32_t data)
Definition: ActionMessage.hpp:157
Json::Value loadJsonStr(const std::string &jsonString)
Definition: JsonProcessingFunctions.cpp:50
std::vector< char > to_vector() const
Definition: ActionMessage.cpp:367
@ cmd_resend
command to resend some data
@ use_json_serialization_flag
flag to indicate it should use the json packetization
Definition: flagOperations.hpp:22
@ cmd_disconnect_core_ack
ack for core disconnect
@ cmd_broker_configure
command to update the configuration of a broker
void setActionFlag(FlagContainer &M, FlagIndex flag)
Definition: flagOperations.hpp:67
@ cmd_warning
indicate some sort of warning
Definition: federate_id.hpp:65
@ 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:47
@ 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:262
std::string prettyPrintString(const ActionMessage &command)
Definition: ActionMessage.cpp:861
global_handle getSource() const
Definition: ActionMessage.hpp:147
@ 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:41
bool isDisconnectCommand(const ActionMessage &command) noexcept
Definition: ActionMessage.hpp:276
@ cmd_disconnect_core
disconnect a core
@ cmd_add_endpoint
notify of a source endpoint
@ cmd_send_message
send a message
@ error_flag
flag indicating an error condition associated with the command
Definition: flagOperations.hpp:20
@ cmd_ping_reply
response to a ping request
friend std::unique_ptr< Message > createMessageFromCommand(const ActionMessage &cmd)
Definition: ActionMessage.cpp:628
int32_t getExtraData() const
Definition: ActionMessage.hpp:159
Time Tdemin
56 min dependent event time
Definition: ActionMessage.hpp:48
@ 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:43
@ 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:49
@ cmd_protocol_big
command used in the protocol stacks with the additional info
bool isProtocolCommand(const ActionMessage &command) noexcept
Definition: ActionMessage.hpp:226
@ cmd_add_publisher
notify of a publication
the main namespace for the helics co-simulation library User functions will be in the helics namespac...
Definition: AsyncFedCallInfo.hpp:14
@ required_flag
flag indicating that an action or match is required
Definition: flagOperations.hpp:18
const char * actionMessageType(action_message_def::action_t action)
Definition: ActionMessage.cpp:808
@ 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 destination filter
@ cmd_route_ack
acknowledge reply to a route registration
@ cmd_add_interdependency
command to add a federate as both dependent and a dependency
@ cmd_protocol
command used in the protocol stacks and ignored by the core
std::unique_ptr< Message > createMessageFromCommand(const ActionMessage &cmd)
Definition: ActionMessage.cpp:628
ActionMessage() noexcept
Definition: ActionMessage.hpp:54
@ cmd_bye
message stating this is the last communication from a federate
@ cmd_add_named_filter
command to add named filter as a target
void swapSourceDest() noexcept
Definition: ActionMessage.hpp:151
@ cmd_close_interface
cmd to close all communications from an interface
void setDestination(global_handle hand)
Definition: ActionMessage.hpp:100
std::size_t from_string(const std::string &data)
Definition: ActionMessage.cpp:572
@ cmd_exec_check
command to run a check on execution entry
global_federate_id dest_id
20 fed_id for a targeted message
Definition: ActionMessage.hpp:38
std::string packetize() const
Definition: ActionMessage.cpp:331
action_message_def::action_t action() const noexcept
Definition: ActionMessage.hpp:89
@ cmd_add_filter
notify of a destination filter
@ cmd_exec_request
request an iteration or entry to execution mode
@ cmd_query
send a query this is a priority command
int fromByteArray(const char *data, int buffer_size)
Definition: ActionMessage.cpp:398
@ cmd_init_not_ready
retract an init ready command
@ 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
std::string errorMessageString(const ActionMessage &command)
Definition: ActionMessage.cpp:849
@ cmd_time_barrier
setup a global time barrier
@ cmd_remove_named_input
cmd to remove a target from connection by name
std::string & name
alias payload to a name reference for registration functions
Definition: ActionMessage.hpp:46
@ 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
@ cmd_remove_dependency
command to remove a dependency
@ cmd_add_subscriber
notify of a subscription
ActionMessage & operator=(const ActionMessage &act)
Definition: ActionMessage.cpp:86
bool isValidIndex(sizeType testSize, const SizedDataType &vec)
Definition: core-data.hpp:249
std::string to_string() const
Definition: ActionMessage.cpp:282