MOBILISIS-Calculator/library/include/mobilisis/calculator_functions.h

68 lines
3.2 KiB
C
Raw Normal View History

#pragma once
#include <iostream>
#include "configuration.h"
2023-11-22 08:55:00 +01:00
#include "payment_method.h"
2023-05-15 14:05:55 +02:00
#include <QDateTime>
using namespace std;
class Calculator
{
public:
/// <summary>
/// Gets duration in seconds from cost
/// </summary>
/// <param name="tariff_cfg">Pointer to configuration</param>
/// <param name="vehicle_type">Type of vehicle</param>
/// <param name="start_datetime">Date/time of payment to be conducted in ISO8601 format (e.g. 2022-12-25T08:00:00Z)</param>
/// <param name="price"></param>
/// <returns>Returns duration in seconds (data type: double)</returns>
std::string GetDurationFromCost(Configuration* cfg, uint8_t vehicle_type, char const* start_datetime, double price, bool nextDay = false, bool prepaid = false);
/// <summary>
/// Gets cost from duration in seconds
/// </summary>
/// <param name="tariff_cfg">Pointer to configuration</param>
/// <param name="vehicle_type">Type of vehicle</param>
/// <param name="start_datetime">Date/time of payment 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>
/// <returns>Returns cost (data type: double)</returns>
2023-11-24 13:23:59 +01:00
double GetCostFromDuration(Configuration* cfg, uint8_t vehicle_type, const QDateTime start_datetime, QDateTime & end_datetime, int durationMin, bool nextDay = false, bool prepaid = false);
2023-05-15 14:05:55 +02:00
// Daily ticket
QDateTime GetDailyTicketDuration(Configuration* cfg, const QDateTime start_datetime, uint8_t payment_option, bool carry_over);
2023-11-22 08:55:00 +01:00
//
// helper function to find time steps for a tariff with PaymentMethod::Steps
// (e.g. Schoenau/Koenigsee)
//
QList<int> GetTimeSteps(Configuration *cfg) const;
2023-11-22 08:55:00 +01:00
private:
// Introduced for PaymentMethod::Steps (e.g. Schoenau)
// For tariff of following structure: only steps, no special days, nonstop.
uint32_t GetCostFromDuration(Configuration *cfg, QDateTime const &start, quint64 durationMinutes) const;
uint32_t GetCostFromDuration(Configuration *cfg, QDateTime const &start, QDateTime const &end) const;
2023-11-22 08:55:00 +01:00
PaymentMethod getPaymentMethodId(Configuration const *cfg);
int getMinimalParkingTime(Configuration const *cfg, PaymentMethod methodId);
int getMaximalParkingTime(Configuration const *cfg, PaymentMethod methodId);
uint32_t private_GetCostFromDuration(Configuration const* cfg,
QDateTime const &start,
QDateTime &end,
int durationMinutes,
bool nextDay = false,
bool prepaid = false,
bool overtime = false);
bool checkDurationMinutes(bool overTime,
int minParkingTime, int maxParkingTime,
int durationMinutes);
2023-11-22 08:55:00 +01:00
//
uint32_t GetPriceForTimeStep(Configuration *cfg, int timeStep) const;
uint32_t GetDurationForPrice(Configuration *cfg, int price) const;
2023-05-15 14:05:55 +02:00
};