turn some bools in GS response into enums
This commit is contained in:
parent
e8ceb3b5d4
commit
b72a8d9e65
@ -4,7 +4,7 @@ cmake_minimum_required(VERSION 3.0)
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
add_compile_options(-Wno-psabi)
|
||||
|
||||
project(inverter-tools VERSION 1.0.3)
|
||||
project(inverter-tools VERSION 1.1.0)
|
||||
|
||||
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
|
||||
set(CMAKE_INSTALL_PREFIX /usr/local/bin)
|
||||
|
@ -243,4 +243,20 @@ ENUM_STR(ParallelConnectionStatus) {
|
||||
ENUM_STR_DEFAULT;
|
||||
}
|
||||
|
||||
ENUM_STR(LoadConnectionStatus) {
|
||||
switch (val) {
|
||||
case LoadConnectionStatus::Disconnected: return os << "Disconnected";
|
||||
case LoadConnectionStatus::Connected: return os << "Connected";
|
||||
}
|
||||
ENUM_STR_DEFAULT;
|
||||
}
|
||||
|
||||
ENUM_STR(ConfigurationStatus) {
|
||||
switch (val) {
|
||||
case ConfigurationStatus::Default: return os << "Default";
|
||||
case ConfigurationStatus::Changed: return os << "Changed";
|
||||
}
|
||||
ENUM_STR_DEFAULT;
|
||||
}
|
||||
|
||||
}
|
@ -372,10 +372,10 @@ void GeneralStatus::unpack() {
|
||||
pv2_input_power = stou(list[17]);
|
||||
pv1_input_voltage = stou(list[18]);
|
||||
pv2_input_voltage = stou(list[19]);
|
||||
settings_values_changed = list[20] == "1";
|
||||
configuration_status = static_cast<ConfigurationStatus>(stou(list[20]));
|
||||
mppt1_charger_status = static_cast<MPPTChargerStatus>(stou(list[21]));
|
||||
mppt2_charger_status = static_cast<MPPTChargerStatus>(stou(list[22]));
|
||||
load_connected = list[23] == "1";
|
||||
load_connected = static_cast<LoadConnectionStatus>(stou(list[23]));
|
||||
battery_power_direction = static_cast<BatteryPowerDirection>(stou(list[24]));
|
||||
dc_ac_power_direction = static_cast<DC_AC_PowerDirection>(stou(list[25]));
|
||||
line_power_direction = static_cast<LinePowerDirection>(stou(list[26]));
|
||||
@ -404,10 +404,10 @@ formattable_ptr GeneralStatus::format(formatter::Format format) {
|
||||
LINE("pv2_input_power", "PV2 input power", pv2_input_power, Unit::Wh),
|
||||
LINE("pv1_input_voltage", "PV1 input voltage", pv1_input_voltage / 10.0, Unit::V),
|
||||
LINE("pv2_input_voltage", "PV2 input voltage", pv2_input_voltage / 10.0, Unit::V),
|
||||
LINE("settings_values_changed", "Configuration state", std::string(settings_values_changed ? "Default" : "Custom")),
|
||||
LINE("configuration_status", "Configuration state", configuration_status),
|
||||
LINE("mppt1_charger_status", "MPPT1 charger status", mppt1_charger_status),
|
||||
LINE("mppt2_charger_status", "MPPT2 charger status", mppt2_charger_status),
|
||||
LINE("load_connected", "Load connection", std::string(load_connected ? "Connected" : "Disconnected")),
|
||||
LINE("load_connected", "Load connection", load_connected),
|
||||
LINE("battery_power_direction", "Battery power direction", battery_power_direction),
|
||||
LINE("dc_ac_power_direction", "DC/AC power direction", dc_ac_power_direction),
|
||||
LINE("line_power_direction", "LINE power direction", line_power_direction),
|
||||
@ -714,7 +714,7 @@ void ParallelGeneralStatus::unpack() {
|
||||
pv2_input_voltage = stou(list[21]);
|
||||
mppt1_charger_status = static_cast<MPPTChargerStatus>(stou(list[22]));
|
||||
mppt2_charger_status = static_cast<MPPTChargerStatus>(stou(list[23]));
|
||||
load_connected = stou(list[24]);
|
||||
load_connected = static_cast<LoadConnectionStatus>(stou(list[24]));
|
||||
battery_power_direction = static_cast<BatteryPowerDirection>(stou(list[25]));
|
||||
dc_ac_power_direction = static_cast<DC_AC_PowerDirection>(stou(list[26]));
|
||||
line_power_direction = static_cast<LinePowerDirection>(stou(list[27]));
|
||||
@ -745,7 +745,7 @@ formattable_ptr ParallelGeneralStatus::format(formatter::Format format) {
|
||||
LINE("pv2_input_voltage", "PV2 Input voltage", pv2_input_voltage / 10.0, Unit::V),
|
||||
LINE("mppt1_charger_status", "MPPT1 charger status", mppt1_charger_status),
|
||||
LINE("mppt2_charger_status", "MPPT2 charger status", mppt2_charger_status),
|
||||
LINE("load_connected", "Load connection", std::string(load_connected ? "Connected" : "Disconnected")),
|
||||
LINE("load_connected", "Load connection", load_connected),
|
||||
LINE("battery_power_direction", "Battery power direction", battery_power_direction),
|
||||
LINE("dc_ac_power_direction", "DC/AC power direction", dc_ac_power_direction),
|
||||
LINE("line_power_direction", "Line power direction", line_power_direction),
|
||||
|
@ -43,7 +43,9 @@ typedef std::variant<
|
||||
p18::OutputModelSetting,
|
||||
p18::ParallelConnectionStatus,
|
||||
p18::SolarPowerPriority,
|
||||
p18::WorkingMode
|
||||
p18::WorkingMode,
|
||||
p18::LoadConnectionStatus,
|
||||
p18::ConfigurationStatus
|
||||
> Variant;
|
||||
|
||||
class VariantHolder {
|
||||
@ -72,6 +74,8 @@ public:
|
||||
VariantHolder(p18::ParallelConnectionStatus v) : v_(v) {}
|
||||
VariantHolder(p18::SolarPowerPriority v) : v_(v) {}
|
||||
VariantHolder(p18::WorkingMode v) : v_(v) {}
|
||||
VariantHolder(p18::LoadConnectionStatus v) : v_(v) {}
|
||||
VariantHolder(p18::ConfigurationStatus v) : v_(v) {}
|
||||
|
||||
friend std::ostream &operator<<(std::ostream &os, VariantHolder const& ref) {
|
||||
std::visit([&os](const auto& elem) {
|
||||
@ -96,7 +100,9 @@ public:
|
||||
std::holds_alternative<p18::OutputModelSetting>(v_) ||
|
||||
std::holds_alternative<p18::ParallelConnectionStatus>(v_) ||
|
||||
std::holds_alternative<p18::SolarPowerPriority>(v_) ||
|
||||
std::holds_alternative<p18::WorkingMode>(v_);
|
||||
std::holds_alternative<p18::WorkingMode>(v_) ||
|
||||
std::holds_alternative<p18::LoadConnectionStatus>(v_) ||
|
||||
std::holds_alternative<p18::ConfigurationStatus>(v_);
|
||||
|
||||
std::visit([&j, &isEnum](const auto& elem) {
|
||||
if (isEnum)
|
||||
@ -302,14 +308,10 @@ public:
|
||||
unsigned pv2_input_power; /* unit: W */
|
||||
unsigned pv1_input_voltage; /* unit: 0.1V */
|
||||
unsigned pv2_input_voltage; /* unit: 0.1V */
|
||||
bool settings_values_changed; /* inverter returns:
|
||||
0: nothing changed
|
||||
1: something changed */
|
||||
p18::ConfigurationStatus configuration_status;
|
||||
p18::MPPTChargerStatus mppt1_charger_status;
|
||||
p18::MPPTChargerStatus mppt2_charger_status;
|
||||
bool load_connected; /* inverter returns:
|
||||
0: disconnected
|
||||
1: connected */
|
||||
p18::LoadConnectionStatus load_connected;
|
||||
p18::BatteryPowerDirection battery_power_direction;
|
||||
p18::DC_AC_PowerDirection dc_ac_power_direction;
|
||||
p18::LinePowerDirection line_power_direction;
|
||||
@ -458,9 +460,7 @@ public:
|
||||
unsigned pv2_input_voltage; /* unit: 0.1V */
|
||||
p18::MPPTChargerStatus mppt1_charger_status;
|
||||
p18::MPPTChargerStatus mppt2_charger_status;
|
||||
bool load_connected; /* inverter returns:
|
||||
0: disconnected
|
||||
1: connected */
|
||||
p18::LoadConnectionStatus load_connected;
|
||||
p18::BatteryPowerDirection battery_power_direction;
|
||||
p18::DC_AC_PowerDirection dc_ac_power_direction;
|
||||
p18::LinePowerDirection line_power_direction;
|
||||
|
@ -151,6 +151,18 @@ enum class ParallelConnectionStatus {
|
||||
};
|
||||
ENUM_STR(ParallelConnectionStatus);
|
||||
|
||||
enum class LoadConnectionStatus {
|
||||
Disconnected = 0,
|
||||
Connected = 1,
|
||||
};
|
||||
ENUM_STR(LoadConnectionStatus);
|
||||
|
||||
enum class ConfigurationStatus {
|
||||
Default = 0,
|
||||
Changed = 1,
|
||||
};
|
||||
ENUM_STR(ConfigurationStatus);
|
||||
|
||||
struct Flag {
|
||||
std::string flag;
|
||||
char letter;
|
||||
|
Loading…
x
Reference in New Issue
Block a user