helics  3.5.2
CoreTypes.hpp
Go to the documentation of this file.
1 /*
2 Copyright (c) 2017-2024,
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 "../helics_enums.h"
10 
11 #include <cstdint>
12 #include <string>
13 #include <string_view>
14 
19 namespace helics {
21 enum class FederateStates : std::uint8_t {
22  CREATED,
23  INITIALIZING,
25  EXECUTING,
26  TERMINATING,
27  ERRORED,
28  FINISHED,
29  UNKNOWN,
30 };
31 
33 enum class CoreThreading : std::uint8_t {
40 };
41 
43 const std::string& fedStateString(FederateStates state);
44 
46 enum class CoreType : int {
69  UNRECOGNIZED = 22,
70  MULTI = 45
71 };
72 
74 enum class MessageProcessingResult : std::int8_t {
75 
76  CONTINUE_PROCESSING = -2,
77  DELAY_MESSAGE = -1,
78  NEXT_STEP = 0,
79  ITERATING = 2,
80  HALTED = 3,
82  USER_RETURN = 5,
83  ERROR_RESULT = 7,
84  REPROCESS_MESSAGE = 8, // indicator that the message needs to be processed again
85  BUSY = 10, // indicator that processing could not be done since the resource was busy
86 };
89 {
90  return (result >= MessageProcessingResult::NEXT_STEP);
91 }
93 enum class IterationResult : signed char {
94  NEXT_STEP = 0,
96  ITERATING = 2,
97  HALTED = 3,
98  ERROR_RESULT = 7
99 };
100 
102 enum class IterationRequest : signed char {
103  NO_ITERATIONS = 0,
104  FORCE_ITERATION = 1,
105  ITERATE_IF_NEEDED = 2,
106  HALT_OPERATIONS = 3,
107  ERROR_CONDITION = 7
108 };
109 
111 enum class InterfaceType : char {
112  UNKNOWN = 'u',
113  PUBLICATION = 'p',
114  INPUT = 'i',
115  ENDPOINT = 'e',
116  FILTER = 'f',
117  TRANSLATOR = 't',
118  SINK = 's'
119 };
120 
121 std::string_view interfaceTypeName(InterfaceType type) noexcept;
122 
123 } // namespace helics
constexpr auto ITERATION_COMPLETE
simplified alias to indicate that iterations have concluded
Definition: CoreTypes.hpp:125
constexpr auto FORCE_ITERATION
simplified alias to force an iteration
Definition: CoreTypes.hpp:129
constexpr auto ITERATE_IF_NEEDED
simplified alias to indicate that helics should iterate if warranted
Definition: CoreTypes.hpp:131
constexpr auto NO_ITERATION
simplified alias to indicate that no iterations are needed
Definition: CoreTypes.hpp:127
@ HELICS_CORE_TYPE_MPI
Definition: helics_enums.h:28
@ HELICS_CORE_TYPE_WEBSOCKET
Definition: helics_enums.h:51
@ HELICS_CORE_TYPE_HTTP
Definition: helics_enums.h:49
@ HELICS_CORE_TYPE_TCP_SS
Definition: helics_enums.h:47
@ HELICS_CORE_TYPE_INTERPROCESS
Definition: helics_enums.h:33
@ HELICS_CORE_TYPE_NNG
Definition: helics_enums.h:45
@ HELICS_CORE_TYPE_TCP
Definition: helics_enums.h:39
@ HELICS_CORE_TYPE_DEFAULT
Definition: helics_enums.h:24
@ HELICS_CORE_TYPE_ZMQ
Definition: helics_enums.h:26
@ HELICS_CORE_TYPE_ZMQ_SS
Definition: helics_enums.h:43
@ HELICS_CORE_TYPE_IPC
Definition: helics_enums.h:37
@ HELICS_CORE_TYPE_UDP
Definition: helics_enums.h:41
@ HELICS_CORE_TYPE_TEST
Definition: helics_enums.h:30
@ HELICS_CORE_TYPE_INPROC
Definition: helics_enums.h:55
@ HELICS_CORE_TYPE_NULL
Definition: helics_enums.h:58
@ HELICS_CORE_TYPE_EMPTY
Definition: helics_enums.h:61
@ HELICS_FLAG_SINGLE_THREAD_CORE
Definition: helics_enums.h:134
@ HELICS_FLAG_MULTI_THREAD_CORE
Definition: helics_enums.h:132
the main namespace for the helics co-simulation library User functions will be in the helics namespac...
Definition: AsyncFedCallInfo.hpp:14
IterationResult
Definition: CoreTypes.hpp:93
@ ITERATING
indicator that the iterations need to continue
@ ERROR_RESULT
indicator that an error has occurred
@ HALTED
indicator that the simulation has been halted
FederateStates
Definition: CoreTypes.hpp:21
@ FINISHED
the federation has finished its execution
@ UNKNOWN
unknown state
@ EXECUTING
the federation has entered execution state and it now advancing in time
@ TERMINATING
the federate is in the process of shutting down
@ ERRORED
the federation has encountered an error
MessageProcessingResult
Definition: CoreTypes.hpp:74
@ NEXT_STEP
indicator that the iterations have completed
@ CONTINUE_PROCESSING
the current loop should continue
@ ITERATING
indicator that the iterations need to continue
@ ERROR_RESULT
indicator that an error has occurred
@ USER_RETURN
indicator that there was a return request but no other conditions or issues
@ DELAY_MESSAGE
delay the current message and continue processing
bool returnableResult(MessageProcessingResult result)
Definition: CoreTypes.hpp:88
CoreType
Definition: CoreTypes.hpp:46
@ TEST
use the Test core if all federates are in the same process
@ NULLCORE
explicit core type that doesn't exist
@ INTERPROCESS
use when all federates are on the same machine
@ INPROC
core/broker using a stripped down in process core type
@ HTTP
core/broker using web traffic
@ NNG
reserved for future Nanomsg implementation
@ ZMQ
use the Zero MQ networking protocol
@ MPI
use MPI for operation on a parallel cluster
@ DEFAULT
ZMQ if available or UDP.
@ TCP
use a generic TCP protocol message stream to send messages
@ EMPTY
core type that does nothing and can't communicate
@ IPC
same as INTERPROCESS
@ UNRECOGNIZED
unknown
@ MULTI
use the multi-broker
@ UDP
use UDP packets to send the data
@ WEBSOCKET
core/broker using web sockets
CoreThreading
Definition: CoreTypes.hpp:33
const std::string & fedStateString(FederateStates state)
Definition: FederateState.cpp:2453
IterationRequest
Definition: CoreTypes.hpp:102
@ ITERATE_IF_NEEDED
indicator that the iterations need to continue
@ FORCE_ITERATION
force an iteration whether it is needed or not
@ NO_ITERATIONS
indicator that the iterations have completed
@ ERROR_CONDITION
indicator that the federate has errored and co-simulation should stop
@ HALT_OPERATIONS
indicator that the federate should halt
InterfaceType
Definition: CoreTypes.hpp:111
@ ENDPOINT
handle to an endpoint
@ PUBLICATION
handle to output interface
@ TRANSLATOR
handle to a translator object
@ SINK
handle to a data sink
@ INPUT
handle to a input interface
@ FILTER
handle to a filter