forked from matth-x/MicroOcpp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOcppModel.cpp
More file actions
110 lines (82 loc) · 3.04 KB
/
Copy pathOcppModel.cpp
File metadata and controls
110 lines (82 loc) · 3.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
// matth-x/ArduinoOcpp
// Copyright Matthias Akstaller 2019 - 2022
// MIT License
#include <ArduinoOcpp/Core/OcppModel.h>
#include <ArduinoOcpp/Tasks/Transactions/TransactionStore.h>
#include <ArduinoOcpp/Tasks/SmartCharging/SmartChargingService.h>
#include <ArduinoOcpp/Tasks/ChargePointStatus/ChargePointStatusService.h>
#include <ArduinoOcpp/Tasks/Metering/MeteringService.h>
#include <ArduinoOcpp/Tasks/FirmwareManagement/FirmwareService.h>
#include <ArduinoOcpp/Tasks/Diagnostics/DiagnosticsService.h>
#include <ArduinoOcpp/Tasks/Heartbeat/HeartbeatService.h>
#include <ArduinoOcpp/Debug.h>
using namespace ArduinoOcpp;
OcppModel::OcppModel(const OcppClock& system_clock)
: ocppTime{system_clock} {
}
OcppModel::~OcppModel() = default;
void OcppModel::loop() {
if (chargePointStatusService)
chargePointStatusService->loop();
if (smartChargingService)
smartChargingService->loop();
if (heartbeatService)
heartbeatService->loop();
if (meteringService)
meteringService->loop();
if (diagnosticsService)
diagnosticsService->loop();
if (firmwareService)
firmwareService->loop();
}
void OcppModel::setTransactionStore(std::unique_ptr<TransactionStore> ts) {
transactionStore = std::move(ts);
}
TransactionStore *OcppModel::getTransactionStore() {
return transactionStore.get();
}
void OcppModel::setSmartChargingService(std::unique_ptr<SmartChargingService> scs) {
smartChargingService = std::move(scs);
}
SmartChargingService* OcppModel::getSmartChargingService() const {
return smartChargingService.get();
}
void OcppModel::setChargePointStatusService(std::unique_ptr<ChargePointStatusService> cpss){
chargePointStatusService = std::move(cpss);
}
ChargePointStatusService *OcppModel::getChargePointStatusService() const {
return chargePointStatusService.get();
}
ConnectorStatus *OcppModel::getConnectorStatus(int connectorId) const {
if (getChargePointStatusService() == nullptr) return nullptr;
auto result = getChargePointStatusService()->getConnector(connectorId);
if (result == nullptr) {
AO_DBG_ERR("Cannot fetch connector with given connectorId. Return nullptr");
//no error catch
}
return result;
}
void OcppModel::setMeteringSerivce(std::unique_ptr<MeteringService> ms) {
meteringService = std::move(ms);
}
MeteringService* OcppModel::getMeteringService() const {
return meteringService.get();
}
void OcppModel::setFirmwareService(std::unique_ptr<FirmwareService> fws) {
firmwareService = std::move(fws);
}
FirmwareService *OcppModel::getFirmwareService() const {
return firmwareService.get();
}
void OcppModel::setDiagnosticsService(std::unique_ptr<DiagnosticsService> ds) {
diagnosticsService = std::move(ds);
}
DiagnosticsService *OcppModel::getDiagnosticsService() const {
return diagnosticsService.get();
}
void OcppModel::setHeartbeatService(std::unique_ptr<HeartbeatService> hs) {
heartbeatService = std::move(hs);
}
OcppTime& OcppModel::getOcppTime() {
return ocppTime;
}