return dash ? std::string(level * 4 - 2, ' ') + "- " : std::string(level * 4, ' ');
}
+std::string ChangePolicyToString(TARIFF::CHANGE_POLICY changePolicy)
+{
+switch (changePolicy)
+ {
+ case ALLOW: return "allow";
+ case TO_CHEAP: return "to_cheap";
+ case TO_EXPENSIVE: return "to_expensive";
+ case DENY: return "deny";
+ }
+return "unknown";
+}
+
std::string PeriodToString(TARIFF::PERIOD period)
{
switch (period)
<< Indent(level) << "free mb: " << conf.free << "\n"
<< Indent(level) << "passive cost: " << conf.passiveCost << "\n"
<< Indent(level) << "traff type: " << TraffTypeToString(conf.traffType) << "\n"
- << Indent(level) << "period: " << PeriodToString(conf.period) << "\n";
+ << Indent(level) << "period: " << PeriodToString(conf.period) << "\n"
+ << Indent(level) << "change policy: " << CyangePolicyToString(conf.changePolicy) << "\n";
}
void PrintTariff(const STG::GET_TARIFF::INFO & info, size_t level = 0)
params.push_back(SGCONF::API_ACTION::PARAM("passive-cost", "<cost>", "\tpassive cost"));
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("change-policy", "<change-policy>", "\ttarification change-policy (allow, to_cheap, to_expensive, deny)"));
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 night prices for each direction"));
SGCONF::MaybeSet(options, "passive-cost", conf.tariffConf.passiveCost);
SGCONF::MaybeSet(options, "traff-type", conf.tariffConf.traffType, ConvTraffType);
SGCONF::MaybeSet(options, "period", conf.tariffConf.period, ConvPeriod);
+SGCONF::MaybeSet(options, "change-policy", conf.tariffConf.changePolicy, ConvChangePolicy);
SGCONF::MaybeSet(options, "times", conf.dirPrice, ConvTimes);
SGCONF::MaybeSet(options, "day-prices", conf.dirPrice, ConvDayPrices);
SGCONF::MaybeSet(options, "night-prices", conf.dirPrice, ConvNightPrices);
SGCONF::MaybeSet(options, "passive-cost", conf.tariffConf.passiveCost);
SGCONF::MaybeSet(options, "traff-type", conf.tariffConf.traffType, ConvTraffType);
SGCONF::MaybeSet(options, "period", conf.tariffConf.period, ConvPeriod);
+SGCONF::MaybeSet(options, "change-policy", conf.tariffConf.changePolicy, ConvChangePolicy);
SGCONF::MaybeSet(options, "times", conf.dirPrice, ConvTimes);
SGCONF::MaybeSet(options, "day-prices", conf.dirPrice, ConvDayPrices);
SGCONF::MaybeSet(options, "night-prices", conf.dirPrice, ConvNightPrices);
return true;
}
+bool GetChangePolicy(const char ** attr, T & value, const std::string & attrName)
+{
+if (!CheckValue(attr, attrName))
+ return false;
+std::string type(attr[1]);
+switch (type)
+ {
+ case "allow":
+ value = TARIFF::ALLOW;
+ break;
+ case "to_cheap":
+ value = TARIFF::TO_CHEAP;
+ break;
+ case "to_expensive":
+ value = TARIFF::TO_EXPENSIVE;
+ break;
+ case "deny":
+ value = TARIFF::DENY;
+ break;
+ default:
+ return false;
+ }
+return true;
+}
+
template <typename A, typename T>
bool GetSlashedValue(const char ** attr, A & array, T A::value_type:: * field)
{
AddParser(propertyParsers, "free", info.tariffConf.free);
AddParser(propertyParsers, "traffType", info.tariffConf.traffType, GetTraffType);
AddParser(propertyParsers, "period", info.tariffConf.period, GetPeriod);
+ AddParser(propertyParsers, "changePolicy", info.tariffConf.changePolicy, GetChangePolicy);
for (size_t i = 0; i < DIR_NUM; ++i)
AddParser(propertyParsers, "time" + unsigned2str(i), info.dirPrice[i], GetTimeSpan);
AddAOSParser(propertyParsers, "priceDayA", info.dirPrice, &DIRPRICE_DATA::priceDayA, GetSlashedValue);