X-Git-Url: https://git.stg.codes/stg.git/blobdiff_plain/17ff5a9b76609419b4f129d22f537d70db40ad82..cd4be4497c82b49b78567956755727408fe34c1e:/projects/sgconf/tariffs.cpp diff --git a/projects/sgconf/tariffs.cpp b/projects/sgconf/tariffs.cpp index 6d386278..3d63d2a8 100644 --- a/projects/sgconf/tariffs.cpp +++ b/projects/sgconf/tariffs.cpp @@ -40,17 +40,17 @@ switch (period) return "unknown"; } -std::string TraffTypeToString(int traffType) +std::string TraffTypeToString(TARIFF::TRAFF_TYPE traffType) { switch (traffType) { - case TRAFF_UP: + case TARIFF::TRAFF_UP: return "upload"; - case TRAFF_DOWN: + case TARIFF::TRAFF_DOWN: return "download"; - case TRAFF_UP_DOWN: + case TARIFF::TRAFF_UP_DOWN: return "upload + download"; - case TRAFF_MAX: + case TARIFF::TRAFF_MAX: return "max(upload, download)"; } return "unknown"; @@ -67,18 +67,18 @@ else throw SGCONF::ACTION::ERROR("Period should be 'daily' or 'monthly'. Got: '" + value + "'"); } -void ConvTraffType(const std::string & value, RESETABLE & res) +void ConvTraffType(const std::string & value, RESETABLE & res) { std::string lowered = ToLower(value); lowered.erase(std::remove(lowered.begin(), lowered.end(), ' '), lowered.end()); if (lowered == "upload") - res = TRAFF_UP; + res = TARIFF::TRAFF_UP; else if (lowered == "download") - res = TRAFF_DOWN; + res = TARIFF::TRAFF_DOWN; else if (lowered == "upload+download") - res = TRAFF_UP_DOWN; + res = TARIFF::TRAFF_UP_DOWN; else if (lowered.substr(0, 3) == "max") - res = TRAFF_MAX; + res = TARIFF::TRAFF_MAX; else throw SGCONF::ACTION::ERROR("Traff type should be 'upload', 'download', 'upload + download' or 'max'. Got: '" + value + "'"); } @@ -235,7 +235,7 @@ params.push_back(SGCONF::API_ACTION::PARAM("traff-type", "", "\ttraffic ty 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;