forked from EVerest/everest-core
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature/evsemanager persistent transactions (EVerest#789)
* Added SessionEventEnum SessionResumed to allow the evse_manager to indicate that a previous session has been resumed at startup * Added subscription to this event to OCPP module so that OCPP is aware that the EvseManager is aware of previous transactions. This allows OCPP to not terminate such transactions individually every time --------- Signed-off-by: Cornelius Claussen <[email protected]> Signed-off-by: pietfried <[email protected]> Signed-off-by: florinmihut <[email protected]> Signed-off-by: Piet Gömpel <[email protected]> Co-authored-by: pietfried <[email protected]> Co-authored-by: florinmihut <[email protected]> Co-authored-by: Piet Gömpel <[email protected]>
- Loading branch information
1 parent
2452ed7
commit f720edb
Showing
15 changed files
with
186 additions
and
12 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
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
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
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,44 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// Copyright 2023 Pionix GmbH and Contributors to EVerest | ||
|
||
#include "PersistentStore.hpp" | ||
|
||
namespace module { | ||
|
||
PersistentStore::PersistentStore(const std::vector<std::unique_ptr<kvsIntf>>& _r_store, const std::string module_id) : | ||
r_store(_r_store) { | ||
|
||
if (r_store.size() > 0) { | ||
active = true; | ||
} | ||
|
||
session_key = module_id + "_session"; | ||
} | ||
|
||
void PersistentStore::store_session(const std::string& session_uuid) { | ||
if (active) { | ||
r_store[0]->call_store(session_key, session_uuid); | ||
} | ||
} | ||
|
||
void PersistentStore::clear_session() { | ||
if (active) { | ||
r_store[0]->call_store(session_key, ""); | ||
} | ||
} | ||
|
||
std::string PersistentStore::get_session() { | ||
if (active) { | ||
auto r = r_store[0]->call_load(session_key); | ||
try { | ||
if (std::holds_alternative<std::string>(r)) { | ||
return std::get<std::string>(r); | ||
} | ||
} catch (...) { | ||
return {}; | ||
} | ||
} | ||
return {}; | ||
} | ||
|
||
} // namespace module |
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,33 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// Copyright 2020 - 2021 Pionix GmbH and Contributors to EVerest | ||
|
||
/* | ||
The Persistent Store class is an abstraction layer to store any persistent information | ||
(such as sessions) for the EvseManager. | ||
*/ | ||
|
||
#ifndef EVSE_MANAGER_PERSISTENT_STORE_H_ | ||
#define EVSE_MANAGER_PERSISTENT_STORE_H_ | ||
|
||
#include <generated/interfaces/kvs/Interface.hpp> | ||
|
||
namespace module { | ||
|
||
class PersistentStore { | ||
public: | ||
// We need the r_bsp reference to be able to talk to the bsp driver module | ||
explicit PersistentStore(const std::vector<std::unique_ptr<kvsIntf>>& r_store, const std::string module_id); | ||
|
||
void store_session(const std::string& session_uuid); | ||
void clear_session(); | ||
std::string get_session(); | ||
|
||
private: | ||
const std::vector<std::unique_ptr<kvsIntf>>& r_store; | ||
std::string session_key; | ||
bool active{false}; | ||
}; | ||
|
||
} // namespace module | ||
|
||
#endif // EVSE_MANAGER_PERSISTENT_STORE_H_ |
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.