* fix compiler warning in SerialPortManager.cpp: function must not return void * clean up and simplify implementation of usesHwPort2() * make const * overrides are final * default implementation returns false * implement in header, as the implementation is very simple * rename PortManager to SerialPortManager. as "PortManager" is too generic, the static instance of the serial port manager is renamed to "SerialPortManager". the class is therefore renamed to SerialPortManagerClass, which is in line with other (static) classes withing OpenDTU(-OnBattery). * implement separate data ages for MPPT charge controllers * make sure MPPT data and live data time out * do not use invalid data of MPPT controlers for calculations * add :key binding to v-for iterating over MPPT instances
36 lines
808 B
C++
36 lines
808 B
C++
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
#pragma once
|
|
|
|
#include <memory>
|
|
#include <mutex>
|
|
#include <TaskSchedulerDeclarations.h>
|
|
|
|
#include "BatteryStats.h"
|
|
|
|
class BatteryProvider {
|
|
public:
|
|
// returns true if the provider is ready for use, false otherwise
|
|
virtual bool init(bool verboseLogging) = 0;
|
|
virtual void deinit() = 0;
|
|
virtual void loop() = 0;
|
|
virtual std::shared_ptr<BatteryStats> getStats() const = 0;
|
|
virtual bool usesHwPort2() const { return false; }
|
|
};
|
|
|
|
class BatteryClass {
|
|
public:
|
|
void init(Scheduler&);
|
|
void updateSettings();
|
|
|
|
std::shared_ptr<BatteryStats const> getStats() const;
|
|
|
|
private:
|
|
void loop();
|
|
|
|
Task _loopTask;
|
|
mutable std::mutex _mutex;
|
|
std::unique_ptr<BatteryProvider> _upProvider = nullptr;
|
|
};
|
|
|
|
extern BatteryClass Battery;
|