git.stg.codes
/
stg.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fixed formatting.
[stg.git]
/
projects
/
stargazer
/
plugins
/
configuration
/
sgconfig
/
parser_tariff.cpp
diff --git
a/projects/stargazer/plugins/configuration/sgconfig/parser_tariff.cpp
b/projects/stargazer/plugins/configuration/sgconfig/parser_tariff.cpp
index aeb1c7832a293abd1f184916b1205a1c298b61c1..0e001b224a559fdfee6f94411275387e7ec62926 100644
(file)
--- a/
projects/stargazer/plugins/configuration/sgconfig/parser_tariff.cpp
+++ b/
projects/stargazer/plugins/configuration/sgconfig/parser_tariff.cpp
@@
-1,6
+1,7
@@
-//#include <stdio.h>
+#include <cstdio> // snprintf
#include <cstring>
#include <cstring>
+#include "stg/tariffs.h"
#include "parser.h"
const int pt_mega = 1024 * 1024;
#include "parser.h"
const int pt_mega = 1024 * 1024;
@@
-28,7
+29,7
@@
return -1;
//-----------------------------------------------------------------------------
void PARSER_GET_TARIFFS::CreateAnswer()
{
//-----------------------------------------------------------------------------
void PARSER_GET_TARIFFS::CreateAnswer()
{
-string s;
+st
d::st
ring s;
char vs[100];
int hd, hn, md, mn;
char vs[100];
int hd, hn, md, mn;
@@
-144,6
+145,8
@@
for (; it != dataList.end(); ++it)
break;
}
break;
}
+ answerList->push_back("<Period value=\"" + TARIFF::PeriodToString(it->tariffConf.period) + "\"/>");
+
answerList->push_back("</tariff>");
}
answerList->push_back("</Tariffs>");
answerList->push_back("</tariff>");
}
answerList->push_back("</Tariffs>");
@@
-185,7
+188,7
@@
if (tariffs->Add(tariffToAdd, currAdmin) == 0)
}
else
{
}
else
{
- string s;
+ st
d::st
ring s;
strprintf(&s, "<AddTariff Result=\"Error. %s\"/>", tariffs->GetStrError().c_str());
answerList->push_back(s);
}
strprintf(&s, "<AddTariff Result=\"Error. %s\"/>", tariffs->GetStrError().c_str());
answerList->push_back(s);
}
@@
-221,7
+224,7
@@
answerList->erase(answerList->begin(), answerList->end());
if (users->TariffInUse(tariffToDel))
{
if (users->TariffInUse(tariffToDel))
{
- string s;
+ st
d::st
ring s;
strprintf(&s, "<DelTariff Result=\"Error. Tariff \'%s\' cannot be deleted. Tariff in use.\"/>", tariffToDel.c_str());
answerList->push_back(s);
return;
strprintf(&s, "<DelTariff Result=\"Error. Tariff \'%s\' cannot be deleted. Tariff in use.\"/>", tariffToDel.c_str());
answerList->push_back(s);
return;
@@
-233,7
+236,7
@@
if (tariffs->Del(tariffToDel, currAdmin) == 0)
}
else
{
}
else
{
- string s;
+ st
d::st
ring s;
strprintf(&s, "<DelTariff Result=\"Error. %s\"/>", tariffs->GetStrError().c_str());
answerList->push_back(s);
}
strprintf(&s, "<DelTariff Result=\"Error. %s\"/>", tariffs->GetStrError().c_str());
answerList->push_back(s);
}
@@
-243,7
+246,7
@@
else
// CHG TARIFF
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// CHG TARIFF
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
-int PARSER_CHG_TARIFF::ParseSlashedIntParams(int paramsNum, const string & s, int * params)
+int PARSER_CHG_TARIFF::ParseSlashedIntParams(int paramsNum, const st
d::st
ring & s, int * params)
{
char * str = new char[s.size() + 1];
char * p;
{
char * str = new char[s.size() + 1];
char * p;
@@
-271,7
+274,7
@@
delete[] str;
return 0;
}
//-----------------------------------------------------------------------------
return 0;
}
//-----------------------------------------------------------------------------
-int PARSER_CHG_TARIFF::ParseSlashedDoubleParams(int paramsNum, const string & s, double * params)
+int PARSER_CHG_TARIFF::ParseSlashedDoubleParams(int paramsNum, const st
d::st
ring & s, double * params)
{
char * str = new char[s.size() + 1];
char * p;
{
char * str = new char[s.size() + 1];
char * p;
@@
-316,7
+319,7
@@
if (depth == 1)
}
else
{
}
else
{
- string s;
+ st
d::st
ring s;
if (strcasecmp(el, "PriceDayA") == 0)
{
if (strcasecmp(el, "PriceDayA") == 0)
{
@@
-387,7
+390,10
@@
else
snprintf(st, 50, "Time%d", j);
if (strcasecmp(el, st) == 0)
{
snprintf(st, 50, "Time%d", j);
if (strcasecmp(el, st) == 0)
{
- int h1, m1, h2, m2;
+ int h1 = 0;
+ int m1 = 0;
+ int h2 = 0;
+ int m2 = 0;
if (ParseTariffTimeStr(attr[1], h1, m1, h2, m2) == 0)
{
td.dirPrice[j].hDay = h1;
if (ParseTariffTimeStr(attr[1], h1, m1, h2, m2) == 0)
{
td.dirPrice[j].hDay = h1;
@@
-447,6
+453,12
@@
else
}
return 0;
}
}
return 0;
}
+
+ if (strcasecmp(el, "Period") == 0)
+ {
+ td.tariffConf.period = TARIFF::StringToPeriod(attr[1]);
+ return 0;
+ }
}
return -1;
}
}
return -1;
}
@@
-481,7
+493,7
@@
if (!td.tariffConf.name.data().empty())
}
else
{
}
else
{
- string s;
+ st
d::st
ring s;
strprintf(&s, "<SetTariff Result=\"Change tariff error! %s\"/>", tariffs->GetStrError().c_str());
answerList->push_back(s);
return;
strprintf(&s, "<SetTariff Result=\"Change tariff error! %s\"/>", tariffs->GetStrError().c_str());
answerList->push_back(s);
return;