Skip to content

Commit 4811e65

Browse files
committed
make SolarCharger methods const
1 parent 4de3cb1 commit 4811e65

File tree

2 files changed

+20
-20
lines changed

2 files changed

+20
-20
lines changed

include/SolarCharger.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,28 +14,28 @@ class SolarChargerClass {
1414

1515
// TODO(andreasboehm): below methods are taken from VictronMppt to start abstracting
1616
// solar chargers without breaking everything.
17-
size_t controllerAmount();
18-
uint32_t getDataAgeMillis();
19-
uint32_t getDataAgeMillis(size_t idx);
17+
size_t controllerAmount() const;
18+
uint32_t getDataAgeMillis() const;
19+
uint32_t getDataAgeMillis(size_t idx) const;
2020

2121
// total output of all MPPT charge controllers in Watts
22-
int32_t getOutputPowerWatts();
22+
int32_t getOutputPowerWatts() const;
2323

2424
// total panel input power of all MPPT charge controllers in Watts
25-
int32_t getPanelPowerWatts();
25+
int32_t getPanelPowerWatts() const;
2626

2727
// sum of total yield of all MPPT charge controllers in kWh
28-
float getYieldTotal();
28+
float getYieldTotal() const;
2929

3030
// sum of today's yield of all MPPT charge controllers in kWh
31-
float getYieldDay();
31+
float getYieldDay() const;
3232

3333
// minimum of all MPPT charge controllers' output voltages in V
34-
float getOutputVoltage();
34+
float getOutputVoltage() const;
3535

36-
std::optional<VeDirectMpptController::data_t> getData(size_t idx = 0);
36+
std::optional<VeDirectMpptController::data_t> getData(size_t idx = 0) const;
3737

38-
bool isDataValid();
38+
bool isDataValid() const;
3939

4040
private:
4141
void loop();

src/SolarCharger.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ void SolarChargerClass::loop()
5151
}
5252
}
5353

54-
size_t SolarChargerClass::controllerAmount()
54+
size_t SolarChargerClass::controllerAmount() const
5555
{
5656
std::lock_guard<std::mutex> lock(_mutex);
5757

@@ -62,7 +62,7 @@ size_t SolarChargerClass::controllerAmount()
6262
return 0;
6363
}
6464

65-
bool SolarChargerClass::isDataValid()
65+
bool SolarChargerClass::isDataValid() const
6666
{
6767
std::lock_guard<std::mutex> lock(_mutex);
6868

@@ -73,7 +73,7 @@ bool SolarChargerClass::isDataValid()
7373
return false;
7474
}
7575

76-
uint32_t SolarChargerClass::getDataAgeMillis()
76+
uint32_t SolarChargerClass::getDataAgeMillis() const
7777
{
7878
std::lock_guard<std::mutex> lock(_mutex);
7979

@@ -84,7 +84,7 @@ uint32_t SolarChargerClass::getDataAgeMillis()
8484
return 0;
8585
}
8686

87-
uint32_t SolarChargerClass::getDataAgeMillis(size_t idx)
87+
uint32_t SolarChargerClass::getDataAgeMillis(size_t idx) const
8888
{
8989
std::lock_guard<std::mutex> lock(_mutex);
9090

@@ -97,7 +97,7 @@ uint32_t SolarChargerClass::getDataAgeMillis(size_t idx)
9797

9898

9999
// total output of all MPPT charge controllers in Watts
100-
int32_t SolarChargerClass::getOutputPowerWatts()
100+
int32_t SolarChargerClass::getOutputPowerWatts() const
101101
{
102102
std::lock_guard<std::mutex> lock(_mutex);
103103

@@ -109,7 +109,7 @@ int32_t SolarChargerClass::getOutputPowerWatts()
109109
}
110110

111111
// total panel input power of all MPPT charge controllers in Watts
112-
int32_t SolarChargerClass::getPanelPowerWatts()
112+
int32_t SolarChargerClass::getPanelPowerWatts() const
113113
{
114114
std::lock_guard<std::mutex> lock(_mutex);
115115

@@ -121,7 +121,7 @@ int32_t SolarChargerClass::getPanelPowerWatts()
121121
}
122122

123123
// sum of total yield of all MPPT charge controllers in kWh
124-
float SolarChargerClass::getYieldTotal()
124+
float SolarChargerClass::getYieldTotal() const
125125
{
126126
std::lock_guard<std::mutex> lock(_mutex);
127127

@@ -133,7 +133,7 @@ float SolarChargerClass::getYieldTotal()
133133
}
134134

135135
// sum of today's yield of all MPPT charge controllers in kWh
136-
float SolarChargerClass::getYieldDay()
136+
float SolarChargerClass::getYieldDay() const
137137
{
138138
std::lock_guard<std::mutex> lock(_mutex);
139139

@@ -145,7 +145,7 @@ float SolarChargerClass::getYieldDay()
145145
}
146146

147147
// minimum of all MPPT charge controllers' output voltages in V
148-
float SolarChargerClass::getOutputVoltage()
148+
float SolarChargerClass::getOutputVoltage() const
149149
{
150150
std::lock_guard<std::mutex> lock(_mutex);
151151

@@ -156,7 +156,7 @@ float SolarChargerClass::getOutputVoltage()
156156
return 0;
157157
}
158158

159-
std::optional<VeDirectMpptController::data_t> SolarChargerClass::getData(size_t idx)
159+
std::optional<VeDirectMpptController::data_t> SolarChargerClass::getData(size_t idx) const
160160
{
161161
std::lock_guard<std::mutex> lock(_mutex);
162162

0 commit comments

Comments
 (0)