summaryrefslogtreecommitdiff
path: root/src/protocol_17/input.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/protocol_17/input.cc')
-rw-r--r--src/protocol_17/input.cc117
1 files changed, 117 insertions, 0 deletions
diff --git a/src/protocol_17/input.cc b/src/protocol_17/input.cc
new file mode 100644
index 0000000..b35bf20
--- /dev/null
+++ b/src/protocol_17/input.cc
@@ -0,0 +1,117 @@
+// SPDX-License-Identifier: BSD-3-Clause
+
+#include "input.h"
+#include "defines.h"
+//#include "functions.h"
+#include "../util.h"
+
+namespace p17 {
+
+using namespace protocol;
+
+const std::map<std::string, CommandType> client_commands = {
+ {"get-protocol-id", CommandType::GetProtocolID},
+ {"get-date-time", CommandType::GetCurrentTime},
+ {"get-total-generated", CommandType::GetTotalGenerated},
+ {"get-year-generated", CommandType::GetYearGenerated},
+ {"get-month-generated", CommandType::GetMonthGenerated},
+ {"get-day-generated", CommandType::GetDayGenerated},
+ {"get-hour-generated", CommandType::GetHourGenerated},
+ {"get-series-number", CommandType::GetSeriesNumber},
+ {"get-cpu-version", CommandType::GetCPUVersion},
+ {"get-secondary-cpu-version", CommandType::GetSecondaryCPUVersion},
+ {"get-device-model", CommandType::GetDeviceModel},
+ {"get-rated", CommandType::GetRatedInformation},
+ {"get-general-status", CommandType::GetGeneralStatus},
+ {"get-power-status", CommandType::GetPowerStatus},
+ {"get-working-mode", CommandType::GetWorkingMode},
+ {"get-warnings", CommandType::GetWarningStatus},
+ {"get-flags", CommandType::GetFlags},
+ {"get-ac-input-voltage-range", CommandType::GetACInputVoltageRange},
+ {"get-ac-input-frequency-range", CommandType::GetACInputFrequencyRange},
+ {"get-max-grid-output-power", CommandType::GetMaximumGridOutputPower},
+ {"get-max-output-power", CommandType::GetMaximumOutputPower},
+ {"get-solar-input-mppt-range", CommandType::GetSolarInputMPPTRange},
+ {"get-solar-input-voltage-range", CommandType::GetSolarInputVoltageRange},
+ {"get-lcd-sleep-timeout", CommandType::GetLCDSleepTimeout},
+ {"get-defaults", CommandType::GetDefaults},
+ {"get-battery-settings", CommandType::GetBatterySettings},
+ {"get-machine-model", CommandType::GetMachineModel},
+ {"get-machine-adjustable-ranges", CommandType::GetMachineAdjustableRanges},
+ {"get-faults", CommandType::GetFaults},
+ {"get-faults-history", CommandType::GetFaultsHistory},
+ {"get-energy-control-status", CommandType::GetEnergyControlStatus},
+ {"get-ac-input-long-time-highest-average-voltage", CommandType::GetACInputLongTimeHighestAvgVoltage},
+ {"get-first-generated-energy-saved-time", CommandType::GetFirstGeneratedEnergySavedTime},
+ {"get-feed-wait-time", CommandType::GetFeedWaitTime},
+ {"get-ac-charging-time", CommandType::GetACChargingTimeBucket},
+ {"get-ac-loads-supply-time", CommandType::GetACLoadsSupplyTimeBucket},
+ {"get-feeding-grid-power-calibration", CommandType::GetFeedingGridPowerCalibration},
+ {"get-feed-in-power-factor", CommandType::GetFeedInPowerFactor},
+ {"get-auto-adjust-pf-with-power-info", CommandType::GetAutoAdjustPFWithPowerInformation},
+ {"get-allow-one-of-s-t-phase-loss-state", CommandType::GetAllowOneOfSTPhaseLossStatus},
+ {"set-loads", CommandType::SetLoads},
+ {"set-flag", CommandType::SetFlag},
+ {"set-date-time", CommandType::SetDateTime},
+ {"set-ac-input-highest-voltage-for-feeding-power", CommandType::SetACInputHighestVoltageForFeedingPower},
+ {"set-ac-input-lowest-voltage-for-feeding-power", CommandType::SetACInputLowestVoltageForFeedingPower},
+ {"set-ac-input-highest-frequency-for-feeding-power", CommandType::SetACInputHighestFrequencyForFeedingPower},
+ {"set-ac-input-lowest-frequency-for-feeding-power", CommandType::SetACInputLowestFrequencyForFeedingPower},
+ {"set-max-output-power", CommandType::SetMaxOutputPower},
+ {"set-max-feeding-grid-power", CommandType::SetMaxFeedingGridPower},
+ {"set-solar-input-highest-voltage", CommandType::SetSolarInputHighestVoltage},
+ {"set-solar-input-lowest-voltage", CommandType::SetSolarInputLowestVoltage},
+ {"set-solar-input-highest-mppt-voltage", CommandType::SetSolarInputHighestMPPTVoltage},
+ {"set-solar-input-lowest-mppt-voltage", CommandType::SetSolarInputLowestMPPTVoltage},
+ {"set-lcd-sleep-timeout", CommandType::SetLCDSleepTimeout},
+ {"set-battery-max-charging-current", CommandType::SetBatteryMaxChargingCurrent},
+ {"set-battery-max-ac-charging-current", CommandType::SetBatteryMaxACChargingCurrent},
+ {"set-battery-max-charging-voltage", CommandType::SetBatteryMaxChargingVoltage},
+ {"set-ac-input-long-time-highest-average-voltage", CommandType::SetACInputLongTimeHighestAverageVoltage},
+ {"set-battery-discharging-voltage", CommandType::SetBatteryDischargingVoltage},
+ {"set-solar-energy-distribution-of-priority", CommandType::SetSolarEnergyDistributionOfPriority},
+ {"set-energy-distribution", CommandType::SetEnergyDistribution},
+ {"set-battery-charger-application-in-floating-charging", CommandType::SetBatteryChargerApplicationInFloatingCharging},
+ {"set-machine-model", CommandType::SetMachineModel},
+ {"set-defaults", CommandType::SetDefaults},
+ {"set-ac-output-freq", CommandType::SetACOutputFreq},
+ {"set-ac-output-rated-voltage", CommandType::SetACOutputRatedVoltage},
+ {"set-feed-wait-time", CommandType::SetFeedWaitTime},
+ {"set-ac-charging-time", CommandType::SetACChargingTimeBucket},
+ {"set-ac-loads-supply-time", CommandType::SetACLoadsSupplyTimeBucket},
+ {"set-battery-type", CommandType::SetBatteryType},
+ {"set-battery-install-time", CommandType::SetBatteryInstallTime},
+ {"set-li-fe-battery-self-test", CommandType::SetLiFeBatterySelfTest},
+ {"set-ac-charger-keep-battery-voltage-setting", CommandType::SetACChargerKeepBatteryVoltageSetting},
+ {"set-battery-temp-sensor-compensation", CommandType::SetBatteryTempSensorCompensation},
+ {"set-feeding-grid-power-calibration", CommandType::SetFeedingGridPowerCalibration},
+ {"set-battery-max-discharging-current-in-hybrid-mode", CommandType::SetBatteryMaxDischargingCurrentInHybridMode},
+ {"set-feed-in-power-factor", CommandType::SetFeedInPowerFactor},
+ {"set-parallel-output", CommandType::SetParallelOutput},
+ {"set-r-phase-feeding-grid-power-calibration", CommandType::SetRPhaseFeedingGridPowerCalibration},
+ {"set-s-phase-feeding-grid-power-calibration", CommandType::SetSPhaseFeedingGridPowerCalibration},
+ {"set-t-phase-feeding-grid-power-calibration", CommandType::SetTPhaseFeedingGridPowerCalibration},
+ {"set-auto-adjust-pf-with-power-info", CommandType::SetAutoAdjustPFWithPowerInformation},
+ {"set-allow-one-of-s-t-phase-loss", CommandType::SetAllowOneOfSTPhaseLoss},
+ {"set-emergency-power-supply-control", CommandType::SetEmergencyPowerSupplyControl},
+};
+
+CommandType validate_input(std::string& command,
+ std::vector<std::string>& arguments,
+ void* input) {
+ auto it = client_commands.find(command);
+ if (it == client_commands.end())
+ throw std::invalid_argument("invalid command");
+
+ auto commandType = it->second;
+ switch (commandType) {
+
+
+ default:
+ break;
+ }
+
+ return commandType;
+}
+
+} \ No newline at end of file