-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Expose mappings of requirements, provides and modules to modules #206
Changes from 24 commits
630c48c
0105d03
b67b7b1
9dd6f7f
ad32fd1
557932c
9edf536
e90e60f
7d0b0e4
acac5bd
9877ce6
b130124
44baf44
501f01f
8c3feca
61b9281
5d542d3
26473f7
000efd5
cd20aab
6084d34
59644d3
2f45d45
aa53f89
87758ef
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -64,6 +64,50 @@ enum class QOS { | |
QOS2 ///< Exactly once delivery | ||
}; | ||
|
||
/// \brief A Mapping that can be used to map a module or implementation to a specific EVSE or optionally to a Connector | ||
struct Mapping { | ||
int evse; ///< The EVSE id | ||
std::optional<int> connector; ///< An optional Connector id | ||
|
||
Mapping(int evse) : evse(evse) { | ||
} | ||
|
||
Mapping(int evse, int connector) : evse(evse), connector(connector) { | ||
} | ||
}; | ||
|
||
/// \brief Writes the string representation of the given Mapping \p mapping to the given output stream \p os | ||
/// \returns an output stream with the Mapping written to | ||
inline std::ostream& operator<<(std::ostream& os, const Mapping& mapping) { | ||
os << "Mapping(evse: " << mapping.evse; | ||
if (mapping.connector.has_value()) { | ||
os << ", connector: " << mapping.connector.value(); | ||
} | ||
os << ")"; | ||
|
||
return os; | ||
} | ||
|
||
/// \brief Writes the string representation of the given Mapping \p mapping to the given output stream \p os | ||
/// \returns an output stream with the Mapping written to | ||
inline std::ostream& operator<<(std::ostream& os, const std::optional<Mapping>& mapping) { | ||
hikinggrass marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if (mapping.has_value()) { | ||
os << mapping.value(); | ||
} else { | ||
os << "Mapping(charging station)"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this default representation make any sense? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The feature (at the moment at least) is inspired by the 3-tier mappings from OCPP. So if you have no explicit mapping it's assumed that the module maps to the whole charging station, getting more specific by a mapping to an evse and/or connector There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see. Still I'm unsure, whether the string |
||
} | ||
|
||
return os; | ||
} | ||
|
||
/// \brief A 3 tier mapping for a module and its individual implementations | ||
struct ModuleTierMappings { | ||
std::optional<Mapping> module; ///< Mapping of the whole module to an EVSE id and optional Connector id. If this is | ||
///< absent the module is assumed to be mapped to the whole charging station | ||
std::unordered_map<std::string, std::optional<Mapping>> | ||
implementations; ///< Mappings for the individual implementations of the module | ||
}; | ||
|
||
struct ModuleInfo { | ||
struct Paths { | ||
std::filesystem::path etc; | ||
|
@@ -78,38 +122,36 @@ struct ModuleInfo { | |
Paths paths; | ||
bool telemetry_enabled; | ||
bool global_errors_enabled; | ||
std::optional<Mapping> mapping; | ||
}; | ||
|
||
struct TelemetryConfig { | ||
int id; | ||
}; | ||
|
||
/// \brief A Mapping that can be used to map a module or implementation to a specific EVSE or optionally to a Connector | ||
struct Mapping { | ||
int evse; ///< The EVSE id | ||
std::optional<int> connector; ///< An optional Connector id | ||
struct Requirement { | ||
std::string id; | ||
size_t index = 0; | ||
}; | ||
|
||
Mapping(int evse) : evse(evse) { | ||
} | ||
bool operator<(const Requirement& lhs, const Requirement& rhs); | ||
|
||
Mapping(int evse, int connector) : evse(evse), connector(connector) { | ||
} | ||
/// \brief A Fulfillment relates a Requirement to its connected implementation, identified via its module and | ||
/// implementation id. | ||
struct Fulfillment { | ||
std::string module_id; | ||
std::string implementation_id; | ||
Requirement requirement; | ||
hikinggrass marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}; | ||
|
||
/// \brief A 3 tier mapping for a module and its individual implementations | ||
struct ModuleTierMappings { | ||
std::optional<Mapping> module; ///< Mapping of the whole module to an EVSE id and optional Connector id. If this is | ||
///< absent the module is assumed to be mapped to the whole charging station | ||
std::unordered_map<std::string, std::optional<Mapping>> | ||
implementations; ///< Mappings for the individual implementations of the module | ||
/// \brief Contains everything that's needed to initialize a requirement in user code | ||
struct RequirementInitializer { | ||
Requirement requirement; | ||
Fulfillment fulfillment; | ||
std::optional<Mapping> mapping; | ||
}; | ||
|
||
struct Requirement { | ||
Requirement(const std::string& requirement_id_, size_t index_); | ||
bool operator<(const Requirement& rhs) const; | ||
std::string id; | ||
size_t index; | ||
}; | ||
using RequirementInitialization = std::map<std::string, std::vector<RequirementInitializer>>; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm uncertain with that name: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm open for suggestions 😄 that was the best I could come up with at the time 😅 |
||
|
||
struct ImplementationIdentifier { | ||
ImplementationIdentifier(const std::string& module_id_, const std::string& implementation_id_, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really doubt the value of these comments, you get exactly the same information if you look at the function signature.