Compare commits
3 Commits
2.0.0
...
d765997ca5
Author | SHA1 | Date | |
---|---|---|---|
d765997ca5 | |||
d2664fdb95 | |||
36478e111e |
@@ -27,7 +27,7 @@ public:
|
|||||||
/// <param name="end_datetime">Date/time of park end to be conducted in ISO8601 format (e.g. 2022-12-25T08:00:00Z) </param>
|
/// <param name="end_datetime">Date/time of park end to be conducted in ISO8601 format (e.g. 2022-12-25T08:00:00Z) </param>
|
||||||
/// <param name="durationMin">Duration of parking in minutes</param>
|
/// <param name="durationMin">Duration of parking in minutes</param>
|
||||||
/// <returns>Returns cost (data type: double)</returns>
|
/// <returns>Returns cost (data type: double)</returns>
|
||||||
double GetCostFromDuration(Configuration* cfg, uint8_t vehicle_type, const QDateTime start_datetime, QDateTime & end_datetime, double durationMin, bool nextDay = false, bool prepaid = false);
|
double GetCostFromDuration(Configuration* cfg, uint8_t vehicle_type, const QDateTime start_datetime, QDateTime & end_datetime, int durationMin, bool nextDay = false, bool prepaid = false);
|
||||||
|
|
||||||
// Daily ticket
|
// Daily ticket
|
||||||
QDateTime GetDailyTicketDuration(Configuration* cfg, const QDateTime start_datetime, uint8_t payment_option, bool carry_over);
|
QDateTime GetDailyTicketDuration(Configuration* cfg, const QDateTime start_datetime, uint8_t payment_option, bool carry_over);
|
||||||
|
@@ -1,17 +1,28 @@
|
|||||||
// #pragma once
|
|
||||||
#ifndef TARIFF_TIME_RANGE_H_INCLUDED
|
#ifndef TARIFF_TIME_RANGE_H_INCLUDED
|
||||||
#define TARIFF_TIME_RANGE_H_INCLUDED
|
#define TARIFF_TIME_RANGE_H_INCLUDED
|
||||||
|
|
||||||
#include <ctime>
|
#include <QTime>
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Time range definition
|
/// Time range definition
|
||||||
/// </summary>
|
/// </summary>
|
||||||
class TariffTimeRange {
|
class TariffTimeRange {
|
||||||
|
QTime m_time_from;
|
||||||
|
QTime m_time_until;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
time_t time_from;
|
|
||||||
time_t time_to;
|
TariffTimeRange()
|
||||||
TariffTimeRange() : time_from(0), time_to(0) {}
|
: m_time_from(QTime())
|
||||||
|
, m_time_until(QTime()) {}
|
||||||
|
|
||||||
|
void setTimeRange(QTime const& from, QTime const &until) {
|
||||||
|
m_time_from = from;
|
||||||
|
m_time_until = until;
|
||||||
|
}
|
||||||
|
|
||||||
|
QTime const &getTimeFrom() const { return m_time_from; }
|
||||||
|
QTime const &getTimeUntil() const { return m_time_until; }
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // TARIFF_TIME_RANGE_H_INCLUDED
|
#endif // TARIFF_TIME_RANGE_H_INCLUDED
|
||||||
|
File diff suppressed because it is too large
Load Diff
@@ -36,7 +36,7 @@ extern "C" char* strptime(const char* s,
|
|||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
|
|
||||||
std::ifstream input(QDir::homePath().append("/tariff01.json").toStdString());
|
std::ifstream input("/tmp/tariff_korneuburg.json");
|
||||||
std::stringstream sstr;
|
std::stringstream sstr;
|
||||||
while(input >> sstr.rdbuf());
|
while(input >> sstr.rdbuf());
|
||||||
std::string json(sstr.str());
|
std::string json(sstr.str());
|
||||||
@@ -47,14 +47,12 @@ int main() {
|
|||||||
bool isParsed = cfg.ParseJson(&cfg, json.c_str());
|
bool isParsed = cfg.ParseJson(&cfg, json.c_str());
|
||||||
cout << endl;
|
cout << endl;
|
||||||
|
|
||||||
char const *startDate = "";
|
|
||||||
|
|
||||||
if (isParsed)
|
if (isParsed)
|
||||||
{
|
{
|
||||||
startDate = "2023-05-10T13:52:18.665Z";
|
QDateTime start = QDateTime::fromString("2023-05-11T08:00:00",Qt::ISODate);
|
||||||
std::string duration = calculator.GetDurationFromCost(&cfg, 3, (char *)startDate, 33, false, true);
|
QDateTime end = start.addSecs(120);
|
||||||
cout << "---> startDate " << startDate << " _price_ = " << 33
|
calculator.GetCostFromDuration(&cfg, 3, start, end, 60);
|
||||||
<< " Total duration is: " << duration << endl;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@@ -69,6 +67,7 @@ int main() {
|
|||||||
if (init_tariff(&tariff, "/etc/psa_tariff/")) {
|
if (init_tariff(&tariff, "/etc/psa_tariff/")) {
|
||||||
struct price_t price;
|
struct price_t price;
|
||||||
memset(&price, 0x00, sizeof(price));
|
memset(&price, 0x00, sizeof(price));
|
||||||
|
|
||||||
QDateTime start = QDateTime::fromString("2023-05-11T07:50:00",Qt::ISODate); //QDateTime::currentDateTime();
|
QDateTime start = QDateTime::fromString("2023-05-11T07:50:00",Qt::ISODate); //QDateTime::currentDateTime();
|
||||||
time_t start_parking_time = start.toSecsSinceEpoch() / 60;
|
time_t start_parking_time = start.toSecsSinceEpoch() / 60;
|
||||||
time_t end_parking_time = start_parking_time + 615;
|
time_t end_parking_time = start_parking_time + 615;
|
||||||
|
160
test-files/tariff_korneuburg.json
Normal file
160
test-files/tariff_korneuburg.json
Normal file
@@ -0,0 +1,160 @@
|
|||||||
|
{
|
||||||
|
"Project" : "Korneuburg",
|
||||||
|
"Version" : "1.0.0",
|
||||||
|
"Info" : "",
|
||||||
|
"Currency": [
|
||||||
|
{
|
||||||
|
"pcu_id": 2,
|
||||||
|
"pcu_sign": "€",
|
||||||
|
"pcu_major": "EUR",
|
||||||
|
"pcu_minor": "",
|
||||||
|
"pcu_active": true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"PaymentMethod": [
|
||||||
|
{
|
||||||
|
"pme_id": 1,
|
||||||
|
"pme_label": "progressive"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"pme_id": 2,
|
||||||
|
"pme_label": "degressive"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"pme_id": 3,
|
||||||
|
"pme_label": "linear"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"pme_id": 4,
|
||||||
|
"pme_label": "steps"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"PaymentOption": [
|
||||||
|
{
|
||||||
|
"pop_id": 1049,
|
||||||
|
"pop_label": "Zone 1",
|
||||||
|
"pop_payment_method_id": 3,
|
||||||
|
"pop_day_end_time": "00:00:00",
|
||||||
|
"pop_day_night_end_time": "00:00:00",
|
||||||
|
"pop_price_night": 0,
|
||||||
|
"pop_min_time": 30,
|
||||||
|
"pop_max_time": 180,
|
||||||
|
"pop_min_price": 60,
|
||||||
|
"pop_carry_over": 0,
|
||||||
|
"pop_daily_card_price": 0
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"PaymentRate": [
|
||||||
|
{
|
||||||
|
"pra_payment_option_id": 1049,
|
||||||
|
"pra_payment_unit_id": 1,
|
||||||
|
"pra_price": 10
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"Duration": [
|
||||||
|
{
|
||||||
|
"pun_id": 1,
|
||||||
|
"pun_label": "5 min",
|
||||||
|
"pun_duration": 5
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"pun_id": 3,
|
||||||
|
"pun_label": "15 min",
|
||||||
|
"pun_duration": 15
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"pun_id": 4,
|
||||||
|
"pun_label": "1 min",
|
||||||
|
"pun_duration": 1
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"WeekDaysWorktime": [
|
||||||
|
{
|
||||||
|
"pwd_id": 621,
|
||||||
|
"pwd_period_week_day_id": 36,
|
||||||
|
"pwd_period_day_in_week_id": 1,
|
||||||
|
"pwd_time_from": "08:00:00",
|
||||||
|
"pwd_time_to": "12:00:00"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"pwd_id": 621,
|
||||||
|
"pwd_period_week_day_id": 36,
|
||||||
|
"pwd_period_day_in_week_id": 1,
|
||||||
|
"pwd_time_from": "14:00:00",
|
||||||
|
"pwd_time_to": "18:00:00"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"pwd_id": 622,
|
||||||
|
"pwd_period_week_day_id": 36,
|
||||||
|
"pwd_period_day_in_week_id": 2,
|
||||||
|
"pwd_time_from": "08:00:00",
|
||||||
|
"pwd_time_to": "12:00:00"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"pwd_id": 622,
|
||||||
|
"pwd_period_week_day_id": 36,
|
||||||
|
"pwd_period_day_in_week_id": 2,
|
||||||
|
"pwd_time_from": "14:00:00",
|
||||||
|
"pwd_time_to": "18:00:00"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"pwd_id": 623,
|
||||||
|
"pwd_period_week_day_id": 36,
|
||||||
|
"pwd_period_day_in_week_id": 3,
|
||||||
|
"pwd_time_from": "08:00:00",
|
||||||
|
"pwd_time_to": "12:00:00"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"pwd_id": 623,
|
||||||
|
"pwd_period_week_day_id": 36,
|
||||||
|
"pwd_period_day_in_week_id": 3,
|
||||||
|
"pwd_time_from": "14:00:00",
|
||||||
|
"pwd_time_to": "18:00:00"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"pwd_id": 624,
|
||||||
|
"pwd_period_week_day_id": 36,
|
||||||
|
"pwd_period_day_in_week_id": 4,
|
||||||
|
"pwd_time_from": "08:00:00",
|
||||||
|
"pwd_time_to": "12:00:00"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"pwd_id": 624,
|
||||||
|
"pwd_period_week_day_id": 36,
|
||||||
|
"pwd_period_day_in_week_id": 4,
|
||||||
|
"pwd_time_from": "14:00:00",
|
||||||
|
"pwd_time_to": "18:00:00"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"pwd_id": 625,
|
||||||
|
"pwd_period_week_day_id": 36,
|
||||||
|
"pwd_period_day_in_week_id": 5,
|
||||||
|
"pwd_time_from": "08:00:00",
|
||||||
|
"pwd_time_to": "12:00:00"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"pwd_id": 625,
|
||||||
|
"pwd_period_week_day_id": 36,
|
||||||
|
"pwd_period_day_in_week_id": 5,
|
||||||
|
"pwd_time_from": "14:00:00",
|
||||||
|
"pwd_time_to": "18:00:00"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"pwd_id": 626,
|
||||||
|
"pwd_period_week_day_id": 36,
|
||||||
|
"pwd_period_day_in_week_id": 6,
|
||||||
|
"pwd_time_from": "08:00:00",
|
||||||
|
"pwd_time_to": "12:00:00"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"PeriodYear": [
|
||||||
|
{
|
||||||
|
"pye_id": 8,
|
||||||
|
"pye_label": "Whole year",
|
||||||
|
"pye_start_month": 1,
|
||||||
|
"pye_start_day": 1,
|
||||||
|
"pye_end_month": 12,
|
||||||
|
"pye_end_day": 31
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
Reference in New Issue
Block a user