X-Git-Url: https://git.stg.codes/stg.git/blobdiff_plain/3e32eb8e48a56bca543faa522909d3d83538c55d..9701b7ab4dc4cd709ad4dcaa750fc0021f15e231:/include/stg/tariff_conf.h diff --git a/include/stg/tariff_conf.h b/include/stg/tariff_conf.h new file mode 100644 index 00000000..30f19815 --- /dev/null +++ b/include/stg/tariff_conf.h @@ -0,0 +1,225 @@ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* + * Author : Boris Mikhailenko + */ + + /* + $Revision: 1.9 $ + $Date: 2010/10/05 20:41:11 $ + $Author: faust $ + */ + +#ifndef TARIFF_CONF_H +#define TARIFF_CONF_H + +#include +#include + +#include "resetable.h" +#include "stg_const.h" + +//----------------------------------------------------------------------------- +enum +{ + TRAFF_UP = 0, + TRAFF_DOWN, + TRAFF_UP_DOWN, + TRAFF_MAX +}; +//----------------------------------------------------------------------------- +struct DIRPRICE_DATA +{ + DIRPRICE_DATA() + : hDay(0), + mDay(0), + hNight(0), + mNight(0), + priceDayA(0), + priceNightA(0), + priceDayB(0), + priceNightB(0), + threshold(0), + singlePrice(0), + noDiscount(0) + {} + int hDay; + int mDay; + int hNight; + int mNight; + double priceDayA; + double priceNightA; + double priceDayB; + double priceNightB; + int threshold; + int singlePrice; // Do not use day/night division + int noDiscount; // Do not use threshold +}; +//----------------------------------------------------------------------------- +struct DIRPRICE_DATA_RES +{ + DIRPRICE_DATA_RES & operator= (const DIRPRICE_DATA & dpd) + { + hDay = dpd.hDay; + mDay = dpd.mDay; + hNight = dpd.hNight; + mNight = dpd.mNight; + priceDayA = dpd.priceDayA; + priceNightA = dpd.priceNightA; + priceDayB = dpd.priceDayB; + priceNightB = dpd.priceNightB; + threshold = dpd.threshold; + singlePrice = dpd.singlePrice; + noDiscount = dpd.noDiscount; + return *this; + }; + + DIRPRICE_DATA GetData() + { + DIRPRICE_DATA dd; + dd.hDay = hDay; + dd.hNight = hNight; + dd.mDay = mDay; + dd.mNight = mNight; + dd.noDiscount = noDiscount; + dd.priceDayA = priceDayA; + dd.priceDayB = priceDayB; + + dd.priceNightA = priceNightA; + dd.priceNightB = priceNightB; + dd.singlePrice = singlePrice; + dd.threshold = threshold; + return dd; + } + + RESETABLE hDay; + RESETABLE mDay; + RESETABLE hNight; + RESETABLE mNight; + RESETABLE priceDayA; + RESETABLE priceNightA; + RESETABLE priceDayB; + RESETABLE priceNightB; + RESETABLE threshold; + RESETABLE singlePrice; + RESETABLE noDiscount; +}; +//----------------------------------------------------------------------------- +struct TARIFF_CONF +{ + double fee; // ÷ÅÌÉÞÉÎÁ ÁÂÏÎÐÌÁÔÙ + double free; // îÁ ËÁËÕÀ ÓÕÍÍÕ ÄÅÎÅÇ ÀÚÅÒ ËÁÞÁÅÔ ÂÅÓÐÌÁÔÎÏ + int traffType; // UP, DOWN, UP+DOWN, MAX + double passiveCost; // óÔÏÉÍÏÓÔØ ÚÁÍÏÒÏÚËÉ + std::string name; + + TARIFF_CONF() + : fee(0), + free(0), + traffType(TRAFF_UP_DOWN), // UP-DOWN + passiveCost(0), + name() + {}; + + TARIFF_CONF(const std::string & n) + : fee(0), + free(0), + traffType(TRAFF_UP_DOWN), // UP-DOWN + passiveCost(0), + name(n) + {}; +}; +//----------------------------------------------------------------------------- +struct TARIFF_CONF_RES +{ + TARIFF_CONF_RES & operator=(const TARIFF_CONF & tc) + { + fee = tc.fee; + free = tc.free; + traffType = tc.traffType; + passiveCost = tc.passiveCost; + name = tc.name; + return *this; + }; + + TARIFF_CONF GetData() + { + TARIFF_CONF tc; + tc.fee = fee; + tc.free = free; + tc.name = name; + tc.passiveCost = passiveCost; + tc.traffType = traffType; + return tc; + } + + RESETABLE fee; + RESETABLE free; + RESETABLE traffType; + RESETABLE passiveCost; + RESETABLE name; +}; +//----------------------------------------------------------------------------- +struct TARIFF_DATA +{ + TARIFF_CONF tariffConf; + std::vector dirPrice; + + TARIFF_DATA() + : tariffConf(), + dirPrice(DIR_NUM) + {} + + TARIFF_DATA(const std::string & name) + : tariffConf(name), + dirPrice(DIR_NUM) + {} + + TARIFF_DATA(const TARIFF_DATA & td) + : tariffConf(td.tariffConf), + dirPrice(td.dirPrice) + {} + + TARIFF_DATA & operator=(const TARIFF_DATA & td) + { + tariffConf = td.tariffConf; + dirPrice = td.dirPrice; + return *this; + }; +}; +//----------------------------------------------------------------------------- +struct TARIFF_DATA_RES +{ + TARIFF_CONF_RES tariffConf; + std::vector dirPrice; + + TARIFF_DATA_RES() + : tariffConf(), + dirPrice(DIR_NUM) + {} + + TARIFF_DATA GetData() + { + TARIFF_DATA td; + td.tariffConf = tariffConf.GetData(); + for (int i = 0; i < DIR_NUM; i++) + td.dirPrice[i] = dirPrice[i].GetData(); + return td; + } +}; +//----------------------------------------------------------------------------- +#endif