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";
throw SGCONF::ACTION::ERROR("Period should be 'daily' or 'monthly'. Got: '" + value + "'");
}
-void ConvTraffType(const std::string & value, RESETABLE<int> & res)
+void ConvTraffType(const std::string & value, RESETABLE<TARIFF::TRAFF_TYPE> & 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 + "'");
}
{
std::vector<SGCONF::API_ACTION::PARAM> params;
params.push_back(SGCONF::API_ACTION::PARAM("fee", "<fee>", "\t\ttariff fee"));
-params.push_back(SGCONF::API_ACTION::PARAM("free", "<free mb>", "\tprepaid traff"));
+params.push_back(SGCONF::API_ACTION::PARAM("free", "<free mb>", "\tprepaid traffic"));
params.push_back(SGCONF::API_ACTION::PARAM("passive-cost", "<cost>", "\tpassive cost"));
-params.push_back(SGCONF::API_ACTION::PARAM("traff-type", "<type>", "\ttraff type (up, down, up+down, max)"));
+params.push_back(SGCONF::API_ACTION::PARAM("traff-type", "<type>", "\ttraffic type (up, down, up+down, max)"));
params.push_back(SGCONF::API_ACTION::PARAM("period", "<period>", "\ttarification period (daily, monthly)"));
params.push_back(SGCONF::API_ACTION::PARAM("times", "<hh:mm-hh:mm, ...>", "coma-separated day time-spans for each direction"));
params.push_back(SGCONF::API_ACTION::PARAM("day-prices", "<price/price, ...>", "coma-separated day prices for each direction"));
-params.push_back(SGCONF::API_ACTION::PARAM("night-prices", "<price/price, ...>", "coma-separated day prices for each direction"));
+params.push_back(SGCONF::API_ACTION::PARAM("night-prices", "<price/price, ...>", "coma-separated night prices for each direction"));
params.push_back(SGCONF::API_ACTION::PARAM("thresholds", "<threshold, ...>", "coma-separated thresholds for each direction"));
return params;
}
{
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;
{
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 <GetTariff name="..."/>.
{
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;
}
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;
}
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;
.Add("get-tariffs", SGCONF::MakeAPIAction(commands, GetTariffsFunction), "\tget tariff list")
.Add("get-tariff", SGCONF::MakeAPIAction(commands, "<name>", GetTariffFunction), "get tariff")
.Add("add-tariff", SGCONF::MakeAPIAction(commands, "<name>", params, AddTariffFunction), "add tariff")
- .Add("del-tariff", SGCONF::MakeAPIAction(commands, "<name>", DelTariffFunction), "del tariff")
+ .Add("del-tariff", SGCONF::MakeAPIAction(commands, "<name>", DelTariffFunction), "delete tariff")
.Add("chg-tariff", SGCONF::MakeAPIAction(commands, "<name>", params, ChgTariffFunction), "change tariff");
}