X-Git-Url: https://git.stg.codes/stg.git/blobdiff_plain/7c76b7dd8a7985dadc88c76b35f71f523749c12a..d8c45ce015fe9354a9293802405b2da0bff2399e:/projects/sgconf/tariffs.cpp diff --git a/projects/sgconf/tariffs.cpp b/projects/sgconf/tariffs.cpp index cf9f49c9..663536fb 100644 --- a/projects/sgconf/tariffs.cpp +++ b/projects/sgconf/tariffs.cpp @@ -112,7 +112,7 @@ return res; void Splice(std::vector & lhs, const std::vector & rhs) { -for (size_t i = 0; i < lhs.size(); ++i) +for (size_t i = 0; i < lhs.size() && i < rhs.size(); ++i) lhs[i].Splice(rhs[i]); } @@ -229,13 +229,13 @@ std::vector GetTariffParams() { std::vector params; params.push_back(SGCONF::API_ACTION::PARAM("fee", "", "\t\ttariff fee")); -params.push_back(SGCONF::API_ACTION::PARAM("free", "", "\tprepaid traff")); +params.push_back(SGCONF::API_ACTION::PARAM("free", "", "\tprepaid traffic")); params.push_back(SGCONF::API_ACTION::PARAM("passive-cost", "", "\tpassive cost")); -params.push_back(SGCONF::API_ACTION::PARAM("traff-type", "", "\ttraff type (up, dow, up+down, max)")); +params.push_back(SGCONF::API_ACTION::PARAM("traff-type", "", "\ttraffic type (up, down, up+down, max)")); params.push_back(SGCONF::API_ACTION::PARAM("period", "", "\ttarification period (daily, monthly)")); params.push_back(SGCONF::API_ACTION::PARAM("times", "", "coma-separated day time-spans for each direction")); params.push_back(SGCONF::API_ACTION::PARAM("day-prices", "", "coma-separated day prices for each direction")); -params.push_back(SGCONF::API_ACTION::PARAM("night-prices", "", "coma-separated day prices for each direction")); +params.push_back(SGCONF::API_ACTION::PARAM("night-prices", "", "coma-separated night prices for each direction")); params.push_back(SGCONF::API_ACTION::PARAM("thresholds", "", "coma-separated thresholds for each direction")); return params; } @@ -290,6 +290,8 @@ bool GetTariffsFunction(const SGCONF::CONFIG & config, { STG::SERVCONF proto(config.server.data(), config.port.data(), + config.localAddress.data(), + config.localPort.data(), config.userName.data(), config.userPass.data()); return proto.GetTariffs(GetTariffsCallback, NULL) == STG::st_ok; @@ -301,6 +303,8 @@ bool GetTariffFunction(const SGCONF::CONFIG & config, { STG::SERVCONF proto(config.server.data(), config.port.data(), + config.localAddress.data(), + config.localPort.data(), config.userName.data(), config.userPass.data()); // STG currently doesn't support . @@ -315,6 +319,8 @@ bool DelTariffFunction(const SGCONF::CONFIG & config, { STG::SERVCONF proto(config.server.data(), config.port.data(), + config.localAddress.data(), + config.localPort.data(), config.userName.data(), config.userPass.data()); return proto.DelTariff(arg, SimpleCallback, NULL) == STG::st_ok; @@ -346,6 +352,8 @@ for (size_t i = 0; i < conf.dirPrice.size(); ++i) } STG::SERVCONF proto(config.server.data(), config.port.data(), + config.localAddress.data(), + config.localPort.data(), config.userName.data(), config.userPass.data()); return proto.AddTariff(arg, conf, SimpleCallback, NULL) == STG::st_ok; @@ -377,6 +385,8 @@ for (size_t i = 0; i < conf.dirPrice.size(); ++i) } STG::SERVCONF proto(config.server.data(), config.port.data(), + config.localAddress.data(), + config.localPort.data(), config.userName.data(), config.userPass.data()); return proto.ChgTariff(conf, SimpleCallback, NULL) == STG::st_ok; @@ -391,6 +401,6 @@ blocks.Add("Tariff management options") .Add("get-tariffs", SGCONF::MakeAPIAction(commands, GetTariffsFunction), "\tget tariff list") .Add("get-tariff", SGCONF::MakeAPIAction(commands, "", GetTariffFunction), "get tariff") .Add("add-tariff", SGCONF::MakeAPIAction(commands, "", params, AddTariffFunction), "add tariff") - .Add("del-tariff", SGCONF::MakeAPIAction(commands, "", DelTariffFunction), "del tariff") + .Add("del-tariff", SGCONF::MakeAPIAction(commands, "", DelTariffFunction), "delete tariff") .Add("chg-tariff", SGCONF::MakeAPIAction(commands, "", params, ChgTariffFunction), "change tariff"); }