 |
helics
3.3.0
|
9 #include "../application_api/Endpoints.hpp"
10 #include "../application_api/HelicsPrimaryTypes.hpp"
11 #include "../application_api/Publications.hpp"
12 #include "helicsApp.hpp"
50 explicit Player(std::vector<std::string> args);
55 Player(
int argc,
char* argv[]);
66 Player(std::string_view name,
const std::shared_ptr<Core>& core,
const FederateInfo& fi);
78 Player(std::string_view appName,
const std::string& configString);
91 virtual void initialize()
override;
96 virtual void runTo(
Time stopTime_input)
override;
103 void addPublication(std::string_view key,
105 std::string_view pubUnits = std::string_view());
111 template<
class valType>
112 typename std::enable_if_t<helicsType<valType>() != DataType::HELICS_CUSTOM>
113 addPublication(std::string_view key, std::string_view pubUnits = std::string_view())
116 publications.emplace_back(
117 InterfaceVisibility::GLOBAL, fed.get(), key, helicsType<valType>(), pubUnits);
119 publications.emplace_back(fed.get(), key, helicsType<valType>(), pubUnits);
122 pubids[key] =
static_cast<int>(publications.size()) - 1;
129 void addEndpoint(std::string_view endpointName,
130 std::string_view endpointType = std::string_view());
136 template<
class valType>
139 points.resize(points.size() + 1);
140 points.back().time = pubTime;
141 points.back().pubName = key;
142 points.back().value = val;
151 template<
class valType>
152 void addPoint(
Time pubTime,
int iteration, std::string_view key,
const valType& val)
154 points.resize(points.size() + 1);
155 points.back().time = pubTime;
156 points.back().iteration = iteration;
157 points.back().pubName = key;
158 points.back().value = val;
166 void addMessage(
Time sendTime,
167 std::string_view src,
168 std::string_view dest,
169 std::string_view payload);
178 void addMessage(
Time sendTime,
180 std::string_view src,
181 std::string_view dest,
182 std::string_view payload);
193 const auto&
getPoint(
int index)
const {
return points[index]; }
195 const auto&
getMessage(
int index)
const {
return messages[index]; }
198 std::unique_ptr<helicsCLI11App> generateParser();
204 virtual void loadJsonFile(
const std::string& jsonString)
override;
206 virtual void loadTextFile(
const std::string& filename)
override;
210 void generatePublications();
212 void generateEndpoints();
214 void cleanUpPointList();
217 void sendInformation(
Time sendTime,
int iteration = 0);
223 helics::Time extractTime(std::string_view str,
int lineNumber = 0)
const;
226 std::vector<ValueSetter> points;
227 std::vector<MessageHolder> messages;
228 std::map<std::string, std::string> tags;
229 std::set<std::string> epts;
230 std::deque<Publication> publications;
231 std::deque<Endpoint> endpoints;
232 std::map<std::string_view, int> pubids;
233 std::map<std::string_view, int> eptids;
235 helics::DataType::HELICS_STRING;
236 size_t pointIndex = 0;
237 size_t messageIndex = 0;
238 time_units units = time_units::sec;
239 double timeMultiplier =
241 Time nextPrintTimeStep =
constexpr Time timeZero
Definition: helicsTime.hpp:31
std::variant< double, int64_t, std::string, std::complex< double >, std::vector< double >, std::vector< std::complex< double > >, NamedPoint > defV
Definition: HelicsPrimaryTypes.hpp:34
std::enable_if_t< helicsType< valType >) !=DataType::HELICS_CUSTOM > addPublication(std::string_view key, std::string_view pubUnits=std::string_view())
Definition: Player.hpp:113
Definition: Player.hpp:43
Definition: Player.hpp:32
const auto & getPoint(int index) const
Definition: Player.hpp:193
const auto & getMessage(int index) const
Definition: Player.hpp:195
TimeRepresentation< count_time< 9 > > Time
Definition: helicsTime.hpp:27
@ HELICS_FLAG_SOURCE_ONLY
Definition: helics_enums.h:107
DataType getTypeFromString(std::string_view typeName)
Definition: helicsTypes.cpp:238
Definition: Player.hpp:23
@ FORCE_ITERATION
force an iteration whether it is needed or not
std::string masterFileName
the name of the master file used to do the construction
Definition: helicsApp.hpp:132
DataType
Definition: helicsTypes.hpp:273
void loadJsonFileConfiguration(const std::string &appName, const std::string &jsonString)
Definition: helicsApp.cpp:158
void addMessage(Time sendTime, std::string_view src, std::string_view dest, std::string_view payload)
Definition: Player.cpp:148
virtual void initialize() override
Definition: Player.cpp:624
Definition: FederateInfo.hpp:24
void addPublication(std::string_view key, DataType type, std::string_view pubUnits=std::string_view())
Definition: Player.cpp:739
auto endpointCount() const
Definition: Player.hpp:191
virtual void loadTextFile(const std::string &textFile)
Definition: helicsApp.cpp:133
the main namespace for the helics co-simulation library User functions will be in the helics namespac...
Definition: AsyncFedCallInfo.hpp:14
virtual void runTo(Time stopTime_input) override
Definition: Player.cpp:668
std::shared_ptr< CombinationFederate > fed
the federate created for the Player
Definition: helicsApp.hpp:130
auto publicationCount() const
Definition: Player.hpp:189
Definition: helicsApp.hpp:29
Time loadTimeFromString(std::string_view timeString)
Definition: timeOperations.cpp:21
void addPoint(Time pubTime, int iteration, std::string_view key, const valType &val)
Definition: Player.hpp:152
auto pointCount() const
Definition: Player.hpp:185
void loadFile(const std::string &filename)
Definition: helicsApp.cpp:123
void addEndpoint(std::string_view endpointName, std::string_view endpointType=std::string_view())
Definition: Player.cpp:761
void addPoint(Time pubTime, std::string_view key, const valType &val)
Definition: Player.hpp:137
Definition: core-data.hpp:29
bool isValidIndex(sizeType testSize, const SizedDataType &vec)
Definition: core-data.hpp:171
auto messageCount() const
Definition: Player.hpp:187