forked from matth-x/MicroOcpp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathModel.cpp
More file actions
174 lines (129 loc) · 4.28 KB
/
Copy pathModel.cpp
File metadata and controls
174 lines (129 loc) · 4.28 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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
// matth-x/ArduinoOcpp
// Copyright Matthias Akstaller 2019 - 2023
// MIT License
#include <ArduinoOcpp/Model/Model.h>
#include <ArduinoOcpp/Model/Transactions/TransactionStore.h>
#include <ArduinoOcpp/Model/SmartCharging/SmartChargingService.h>
#include <ArduinoOcpp/Model/ChargeControl/ChargeControlCommon.h>
#include <ArduinoOcpp/Model/Metering/MeteringService.h>
#include <ArduinoOcpp/Model/FirmwareManagement/FirmwareService.h>
#include <ArduinoOcpp/Model/Diagnostics/DiagnosticsService.h>
#include <ArduinoOcpp/Model/Heartbeat/HeartbeatService.h>
#include <ArduinoOcpp/Model/Authorization/AuthorizationService.h>
#include <ArduinoOcpp/Model/Reservation/ReservationService.h>
#include <ArduinoOcpp/Model/Boot/BootService.h>
#include <ArduinoOcpp/Model/Reset/ResetService.h>
#include <ArduinoOcpp/Debug.h>
using namespace ArduinoOcpp;
Model::Model(uint16_t bootNr) : bootNr(bootNr) {
}
Model::~Model() = default;
void Model::loop() {
if (bootService) {
bootService->loop();
}
if (!runTasks) {
return;
}
for (auto& connector : connectors) {
connector.loop();
}
if (chargeControlCommon)
chargeControlCommon->loop();
if (smartChargingService)
smartChargingService->loop();
if (heartbeatService)
heartbeatService->loop();
if (meteringService)
meteringService->loop();
if (diagnosticsService)
diagnosticsService->loop();
if (firmwareService)
firmwareService->loop();
if (reservationService)
reservationService->loop();
if (resetService)
resetService->loop();
}
void Model::setTransactionStore(std::unique_ptr<TransactionStore> ts) {
transactionStore = std::move(ts);
}
TransactionStore *Model::getTransactionStore() {
return transactionStore.get();
}
void Model::setSmartChargingService(std::unique_ptr<SmartChargingService> scs) {
smartChargingService = std::move(scs);
}
SmartChargingService* Model::getSmartChargingService() const {
return smartChargingService.get();
}
void Model::setChargeControlCommon(std::unique_ptr<ChargeControlCommon> ccs) {
chargeControlCommon = std::move(ccs);
}
ChargeControlCommon *Model::getChargeControlCommon() {
return chargeControlCommon.get();
}
void Model::setConnectors(std::vector<Connector>&& connectors) {
this->connectors = std::move(connectors);
}
unsigned int Model::getNumConnectors() const {
return connectors.size();
}
Connector *Model::getConnector(unsigned int connectorId) {
if (connectorId >= connectors.size()) {
AO_DBG_ERR("connector with connectorId %u does not exist", connectorId);
return nullptr;
}
return &connectors[connectorId];
}
void Model::setMeteringSerivce(std::unique_ptr<MeteringService> ms) {
meteringService = std::move(ms);
}
MeteringService* Model::getMeteringService() const {
return meteringService.get();
}
void Model::setFirmwareService(std::unique_ptr<FirmwareService> fws) {
firmwareService = std::move(fws);
}
FirmwareService *Model::getFirmwareService() const {
return firmwareService.get();
}
void Model::setDiagnosticsService(std::unique_ptr<DiagnosticsService> ds) {
diagnosticsService = std::move(ds);
}
DiagnosticsService *Model::getDiagnosticsService() const {
return diagnosticsService.get();
}
void Model::setHeartbeatService(std::unique_ptr<HeartbeatService> hs) {
heartbeatService = std::move(hs);
}
void Model::setAuthorizationService(std::unique_ptr<AuthorizationService> as) {
authorizationService = std::move(as);
}
AuthorizationService *Model::getAuthorizationService() {
return authorizationService.get();
}
void Model::setReservationService(std::unique_ptr<ReservationService> rs) {
reservationService = std::move(rs);
}
ReservationService *Model::getReservationService() {
return reservationService.get();
}
void Model::setBootService(std::unique_ptr<BootService> bs){
bootService = std::move(bs);
}
BootService *Model::getBootService() const {
return bootService.get();
}
void Model::setResetService(std::unique_ptr<ResetService> rs) {
this->resetService = std::move(rs);
}
ResetService *Model::getResetService() const {
return resetService.get();
}
Clock& Model::getClock() {
return clock;
}
uint16_t Model::getBootNr() {
return bootNr;
}