* VE.Direct: return non-nullptr as a fallback the changed return statement was supposed to return a shared_ptr to a new and valid MPPT data struct as a fallback. however, it did return a new shared_ptr that was initialized to nullptr. * VE.Direct: make liveview total use total MPPT values this change makes the call to VictronMppt.getData() obsolete, which in turn will therefore not cause an error message on the console if VE.Direct (MPPT) is not enabled. this change also takes care that once multiple VE.Direct MPPT charge controllers are supported, the sums of the respective total values are used in the web app totals.
49 lines
1.3 KiB
C++
49 lines
1.3 KiB
C++
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
#pragma once
|
|
|
|
#include <mutex>
|
|
#include <memory>
|
|
|
|
#include "VeDirectMpptController.h"
|
|
|
|
class VictronMpptClass {
|
|
public:
|
|
VictronMpptClass() = default;
|
|
~VictronMpptClass() = default;
|
|
|
|
void init();
|
|
void loop();
|
|
|
|
bool isDataValid() const;
|
|
|
|
// returns the data age of all controllers,
|
|
// i.e, the youngest data's age is returned.
|
|
uint32_t getDataAgeMillis() const;
|
|
|
|
VeDirectMpptController::spData_t getData(size_t idx = 0) const;
|
|
|
|
// total output of all MPPT charge controllers in Watts
|
|
int32_t getPowerOutputWatts() const;
|
|
|
|
// total panel input power of all MPPT charge controllers in Watts
|
|
int32_t getPanelPowerWatts() const;
|
|
|
|
// sum of total yield of all MPPT charge controllers in kWh
|
|
double getYieldTotal() const;
|
|
|
|
// sum of today's yield of all MPPT charge controllers in kWh
|
|
double getYieldDay() const;
|
|
|
|
private:
|
|
VictronMpptClass(VictronMpptClass const& other) = delete;
|
|
VictronMpptClass(VictronMpptClass&& other) = delete;
|
|
VictronMpptClass& operator=(VictronMpptClass const& other) = delete;
|
|
VictronMpptClass& operator=(VictronMpptClass&& other) = delete;
|
|
|
|
mutable std::mutex _mutex;
|
|
using controller_t = std::unique_ptr<VeDirectMpptController>;
|
|
std::vector<controller_t> _controllers;
|
|
};
|
|
|
|
extern VictronMpptClass VictronMppt;
|