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[]);
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 name,
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();
207 virtual void loadJsonFile(
const std::string& jsonString,
208 bool enableFederateInterfaceRegistration)
override;
210 virtual void loadTextFile(
const std::string& filename)
override;
214 void generatePublications();
216 void generateEndpoints();
218 void cleanUpPointList();
221 void sendInformation(
Time sendTime,
int iteration = 0);
227 helics::Time extractTime(std::string_view str,
int lineNumber = 0)
const;
230 std::vector<ValueSetter> points;
231 std::vector<MessageHolder> messages;
232 std::unordered_map<std::string, std::string> tags;
233 std::set<std::string> epts;
234 std::deque<Publication> publications;
235 std::deque<Endpoint> endpoints;
236 std::unordered_map<std::string_view, int> pubids;
237 std::unordered_map<std::string_view, int> eptids;
239 helics::DataType::HELICS_STRING;
240 size_t pointIndex = 0;
241 size_t messageIndex = 0;
242 time_units units = time_units::sec;
243 double timeMultiplier =
245 Time nextPrintTimeStep =
Definition: FederateInfo.hpp:29
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:113
auto endpointCount() const
Definition: Player.hpp:191
auto publicationCount() const
Definition: Player.hpp:189
auto pointCount() const
Definition: Player.hpp:185
const auto & getPoint(int index) const
Definition: Player.hpp:193
auto messageCount() const
Definition: Player.hpp:187
const auto & getMessage(int index) const
Definition: Player.hpp:195
Player & operator=(Player &&fed)=default
void addPoint(Time pubTime, std::string_view key, const valType &val)
Definition: Player.hpp:137
Player(Player &&other_player)=default
void addPoint(Time pubTime, int iteration, std::string_view key, const valType &val)
Definition: Player.hpp:152
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