9 #include "../application_api/Endpoints.hpp"
10 #include "../application_api/HelicsPrimaryTypes.hpp"
11 #include "../application_api/Publications.hpp"
12 #include "helicsApp.hpp"
18 #include <unordered_map>
24 Time time{Time::minVal()};
33 Time sendTime{Time::minVal()};
50 explicit Player(std::vector<std::string> args);
55 Player(
int argc,
char* argv[]);
67 Player(std::string_view name,
68 const std::shared_ptr<Core>& core,
81 Player(std::string_view appName,
const std::string& configString);
94 virtual void initialize()
override;
99 virtual void runTo(
Time stopTime_input)
override;
106 void addPublication(std::string_view name,
108 std::string_view pubUnits = std::string_view());
114 template<
class valType>
115 typename std::enable_if_t<helicsType<valType>() != DataType::HELICS_CUSTOM>
116 addPublication(std::string_view key, std::string_view pubUnits = std::string_view())
119 publications.emplace_back(
120 InterfaceVisibility::GLOBAL, fed.get(), key, helicsType<valType>(), pubUnits);
122 publications.emplace_back(fed.get(), key, helicsType<valType>(), pubUnits);
125 pubids[key] =
static_cast<int>(publications.size()) - 1;
132 void addEndpoint(std::string_view endpointName,
133 std::string_view endpointType = std::string_view());
139 template<
class valType>
142 points.resize(points.size() + 1);
143 points.back().time = pubTime;
144 points.back().pubName = key;
145 points.back().value = val;
154 template<
class valType>
155 void addPoint(
Time pubTime,
int iteration, std::string_view key,
const valType& val)
157 points.resize(points.size() + 1);
158 points.back().time = pubTime;
159 points.back().iteration = iteration;
160 points.back().pubName = key;
161 points.back().value = val;
169 void addMessage(
Time sendTime,
170 std::string_view src,
171 std::string_view dest,
172 std::string_view payload);
181 void addMessage(
Time sendTime,
183 std::string_view src,
184 std::string_view dest,
185 std::string_view payload);
196 const auto&
getPoint(
int index)
const {
return points[index]; }
198 const auto&
getMessage(
int index)
const {
return messages[index]; }
201 std::unique_ptr<helicsCLI11App> generateParser();
210 virtual void loadJsonFile(
const std::string& jsonString,
211 bool enableFederateInterfaceRegistration)
override;
213 virtual void loadTextFile(
const std::string& filename)
override;
217 void generatePublications();
219 void generateEndpoints();
221 void cleanUpPointList();
224 void sendInformation(
Time sendTime,
int iteration = 0);
230 helics::Time extractTime(std::string_view str,
int lineNumber = 0)
const;
233 std::vector<ValueSetter> points;
234 std::vector<MessageHolder> messages;
235 std::unordered_map<std::string, std::string> tags;
236 std::set<std::string> epts;
237 std::deque<Publication> publications;
238 std::deque<Endpoint> endpoints;
239 std::unordered_map<std::string_view, int> pubids;
240 std::unordered_map<std::string_view, int> eptids;
242 helics::DataType::HELICS_STRING;
243 size_t pointIndex = 0;
244 size_t messageIndex = 0;
245 time_units units = time_units::sec;
246 double timeMultiplier =
248 Time nextPrintTimeStep =
Definition: FederateInfo.hpp:28
Definition: core-data.hpp:29
Definition: helicsApp.hpp:32
Definition: Player.hpp:43
std::enable_if_t< helicsType< valType >) !=DataType::HELICS_CUSTOM > addPublication(std::string_view key, std::string_view pubUnits=std::string_view())
Definition: Player.hpp:116
auto endpointCount() const
Definition: Player.hpp:194
auto publicationCount() const
Definition: Player.hpp:192
auto pointCount() const
Definition: Player.hpp:188
const auto & getPoint(int index) const
Definition: Player.hpp:196
auto messageCount() const
Definition: Player.hpp:190
const auto & getMessage(int index) const
Definition: Player.hpp:198
Player & operator=(Player &&fed)=default
void addPoint(Time pubTime, std::string_view key, const valType &val)
Definition: Player.hpp:140
Player(Player &&other_player)=default
void addPoint(Time pubTime, int iteration, std::string_view key, const valType &val)
Definition: Player.hpp:155
the main namespace for the helics co-simulation library User functions will be in the helics namespac...
Definition: AsyncFedCallInfo.hpp:14
DataType
Definition: helicsTypes.hpp:273
constexpr Time timeZero
Definition: helicsTime.hpp:31
TimeRepresentation< count_time< 9 > > Time
Definition: helicsTime.hpp:27
std::variant< double, int64_t, std::string, std::complex< double >, std::vector< double >, std::vector< std::complex< double > >, NamedPoint > defV
Definition: HelicsPrimaryTypes.hpp:37
Definition: Player.hpp:32
Definition: Player.hpp:23