-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: move component operative state management into a separate c…
…lass Signed-off-by: Valentin Dimov <[email protected]>
- Loading branch information
1 parent
a5d5766
commit d1e02ac
Showing
9 changed files
with
389 additions
and
251 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// Copyright 2020 - 2023 Pionix GmbH and Contributors to EVerest | ||
|
||
#pragma once | ||
|
||
#include <ocpp/v201/enums.hpp> | ||
#include "database_handler.hpp" | ||
|
||
namespace ocpp::v201 { | ||
|
||
struct FullConnectorStatus { | ||
OperationalStatusEnum individual_operational_status; | ||
bool faulted; | ||
bool reserved; | ||
bool occupied; | ||
|
||
ConnectorStatusEnum to_effective_status(); | ||
}; | ||
|
||
class ComponentStateManager { | ||
private: | ||
std::shared_ptr<DatabaseHandler> database; | ||
|
||
OperationalStatusEnum cs_individual_status; | ||
std::vector<std::pair<OperationalStatusEnum, std::vector<FullConnectorStatus>>> | ||
evse_and_connector_individual_statuses; | ||
|
||
void check_evse_id(int32_t evse_id); | ||
void check_evse_and_connector_id(int32_t evse_id, int32_t connector_id); | ||
|
||
public: | ||
explicit ComponentStateManager(const std::map<int32_t, int32_t>& evse_connector_structure, | ||
std::shared_ptr<DatabaseHandler> db_handler); | ||
|
||
OperationalStatusEnum get_cs_individual_operational_status(); | ||
OperationalStatusEnum get_evse_individual_operational_status(int32_t evse_id); | ||
OperationalStatusEnum get_connector_individual_operational_status(int32_t evse_id, int32_t connector_id); | ||
|
||
OperationalStatusEnum get_cs_persisted_operational_status(); | ||
OperationalStatusEnum get_evse_persisted_operational_status(int32_t evse_id); | ||
OperationalStatusEnum get_connector_persisted_operational_status(int32_t evse_id, int32_t connector_id); | ||
|
||
void set_cs_individual_operational_status(OperationalStatusEnum new_status, bool persist); | ||
void set_evse_individual_operational_status(int32_t evse_id, OperationalStatusEnum new_status, bool persist); | ||
void set_connector_individual_operational_status(int32_t evse_id, int32_t connector_id, | ||
OperationalStatusEnum new_status,bool persist); | ||
|
||
OperationalStatusEnum get_evse_effective_operational_status(int32_t evse_id); | ||
OperationalStatusEnum get_connector_effective_operational_status(int32_t evse_id, int32_t connector_id); | ||
ConnectorStatusEnum get_connector_effective_status(int32_t evse_id, int32_t connector_id); | ||
|
||
void set_connector_occupied(int32_t evse_id, int32_t connector_id, bool is_occupied); | ||
void set_connector_reserved(int32_t evse_id, int32_t connector_id, bool is_reserved); | ||
void set_connector_faulted(int32_t evse_id, int32_t connector_id, bool is_faulted); | ||
}; | ||
|
||
} // namespace ocpp::v201 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.