110 lines
4.0 KiB
C
110 lines
4.0 KiB
C
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
|
*
|
|
* Copyright (C) 2013 - 2024, nymea GmbH
|
|
* Copyright (C) 2024 - 2025, chargebyte austria GmbH
|
|
*
|
|
* This file is part of nymea-energy-plugin-nymea.
|
|
*
|
|
* nymea-energy-plugin-nymea.s free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* nymea-energy-plugin-nymea.s distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with nymea-energy-plugin-nymea. If not, see <https://www.gnu.org/licenses/>.
|
|
*
|
|
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
|
|
|
#ifndef LOADROLE_H
|
|
#define LOADROLE_H
|
|
|
|
#include <QString>
|
|
#include <QMap>
|
|
#include <QStringList>
|
|
|
|
#include "types/flexibleload.h"
|
|
|
|
// Installer-visible roles that can be assigned to nymea Things.
|
|
enum class LoadRole {
|
|
EVCharger,
|
|
DHW,
|
|
HeatPump,
|
|
Battery,
|
|
SolarMeter,
|
|
GridMeter
|
|
};
|
|
|
|
inline QString loadRoleToString(LoadRole role)
|
|
{
|
|
switch (role) {
|
|
case LoadRole::EVCharger: return QStringLiteral("EVCharger");
|
|
case LoadRole::DHW: return QStringLiteral("DHW");
|
|
case LoadRole::HeatPump: return QStringLiteral("HeatPump");
|
|
case LoadRole::Battery: return QStringLiteral("Battery");
|
|
case LoadRole::SolarMeter: return QStringLiteral("SolarMeter");
|
|
case LoadRole::GridMeter: return QStringLiteral("GridMeter");
|
|
}
|
|
return QStringLiteral("Unknown");
|
|
}
|
|
|
|
inline LoadRole loadRoleFromString(const QString &str)
|
|
{
|
|
if (str == QLatin1String("EVCharger")) return LoadRole::EVCharger;
|
|
if (str == QLatin1String("DHW")) return LoadRole::DHW;
|
|
if (str == QLatin1String("HeatPump")) return LoadRole::HeatPump;
|
|
if (str == QLatin1String("Battery")) return LoadRole::Battery;
|
|
if (str == QLatin1String("SolarMeter")) return LoadRole::SolarMeter;
|
|
if (str == QLatin1String("GridMeter")) return LoadRole::GridMeter;
|
|
return LoadRole::GridMeter; // fallback
|
|
}
|
|
|
|
// Required nymea interfaces for each role.
|
|
// A Thing must implement at least one of the listed interfaces to be eligible.
|
|
inline QMap<LoadRole, QStringList> loadRoleCompatibleInterfaces()
|
|
{
|
|
QMap<LoadRole, QStringList> map;
|
|
map.insert(LoadRole::EVCharger, QStringList() << QStringLiteral("evcharger"));
|
|
map.insert(LoadRole::DHW, QStringList() << QStringLiteral("smartmeterconsumer")
|
|
<< QStringLiteral("relay"));
|
|
map.insert(LoadRole::HeatPump, QStringList() << QStringLiteral("heating")
|
|
<< QStringLiteral("relay"));
|
|
map.insert(LoadRole::Battery, QStringList() << QStringLiteral("energystorage"));
|
|
map.insert(LoadRole::SolarMeter, QStringList() << QStringLiteral("energymeter"));
|
|
map.insert(LoadRole::GridMeter, QStringList() << QStringLiteral("energymeter"));
|
|
return map;
|
|
}
|
|
|
|
// Convenience mapping from LoadSource (scheduling domain) to LoadRole (installer domain).
|
|
inline LoadRole loadRoleFromLoadSource(LoadSource source)
|
|
{
|
|
switch (source) {
|
|
case LoadSource::SmartCharging: return LoadRole::EVCharger;
|
|
case LoadSource::HeatPump: return LoadRole::HeatPump;
|
|
case LoadSource::DHW: return LoadRole::DHW;
|
|
case LoadSource::Battery: return LoadRole::Battery;
|
|
default: return LoadRole::GridMeter;
|
|
}
|
|
}
|
|
|
|
// All installer roles, in display order.
|
|
inline QList<LoadRole> allLoadRoles()
|
|
{
|
|
return {
|
|
LoadRole::EVCharger,
|
|
LoadRole::DHW,
|
|
LoadRole::HeatPump,
|
|
LoadRole::Battery,
|
|
LoadRole::SolarMeter,
|
|
LoadRole::GridMeter
|
|
};
|
|
}
|
|
|
|
#endif // LOADROLE_H
|