add files for fix

This commit is contained in:
Gerhard Hoffmann 2024-07-05 12:02:27 +02:00
parent b5f818848a
commit 8367eb9fa8
5 changed files with 92 additions and 11 deletions

View File

@ -115,7 +115,7 @@ public:
uint32_t GetCostFromDuration(Configuration *cfg, QDateTime const &start, quint64 durationMinutes, int paymentOptionIndex=0) const;
uint32_t GetCostFromDuration(Configuration *cfg, QDateTime const &start, QDateTime const &end, int paymentOptionIndex=0) const;
private:
// private:
Ticket private_GetCostFromDuration(Configuration const* cfg,
QDateTime const &start,
int durationMinutes,

View File

@ -28,6 +28,10 @@ public:
pop_carry_over_time_range_id = -1;
pop_carry_over_start_time_range = -1;
pop_carry_over_end_time_range = -1;
pop_prepay = false;
pop_prepay_time_range_id = -1;
pop_prepay_over_start_time_range = -1;
pop_prepay_end_time_range = -1;
pop_daily_card_price = -1;
pop_business_hours = -1;
pop_time_step_config = -1;
@ -48,6 +52,10 @@ public:
int pop_carry_over_time_range_id;
int pop_carry_over_start_time_range;
int pop_carry_over_end_time_range;
bool pop_prepay;
int pop_prepay_time_range_id;
int pop_prepay_over_start_time_range;
int pop_prepay_end_time_range;
int pop_daily_card_price;
uint64_t pop_business_hours;
int pop_time_step_config;

View File

@ -344,7 +344,7 @@ int CALCULATE_LIBRARY_API compute_next_timestep(parking_tariff_t *tariff, int cu
qCritical() << " compute_next_timestep() currentTimeMinutes: " << currentTimeMinutes;
qCritical() << " compute_next_timestep() up/down (1=up, 0=down): " << UpDown;
Configuration const *cfg = tariff;
Configuration *cfg = tariff;
// compute payment method id (e.g. Linear=3, Steps=4)
PaymentMethod const paymentMethodId = Utilities::getPaymentMethodId(cfg);
@ -372,16 +372,71 @@ int CALCULATE_LIBRARY_API compute_next_timestep(parking_tariff_t *tariff, int cu
// progressive tariff: e.g. Neuhauser, Kirchdorf (743)
(paymentMethodId == PaymentMethod::Progressive))
{
const QList<int> stepList = Calculator::GetInstance().GetTimeSteps(tariff);
QVector<QList<int>> stepListVec;
QList<int> const timeSteps = Calculator::GetInstance().GetTimeSteps(tariff);
qCritical() << " compute_next_timestep() time-steps: " << timeSteps;
int paymentOptionIndex = 0;
int const pop_time_step_config = tariff->getPaymentOptions(paymentOptionIndex).pop_time_step_config;
if (pop_time_step_config == (int)ATBTimeStepConfig::TimeStepConfig::DYNAMIC) {
QList<int> lst;
for (int index = 0; index < 5; ++index) {
lst.clear();
QListIterator<int> i(timeSteps);
while (i.hasNext()) {
switch (index) {
case 0:
lst.append(i.next());
break;
case 1:
lst.append(i.next() - 2);
break;
case 2:
lst.append(i.next() - 1);
break;
case 3:
lst.append(i.next() + 1);
break;
case 4:
lst.append(i.next() + 2);
break;
default:;
}
}
qCritical() << " compute_next_timestep() " << index << "list of time-steps" << lst;
stepListVec.append(lst);
}
}
int stepListIndex = -1;
for (int index = 0; index < stepListVec.size(); ++index) {
if (stepListVec[index].indexOf(currentTimeMinutes) != -1) {
stepListIndex = index;
break;
}
}
if (stepListIndex == -1) {
qCritical() << "compute_next_timestep() *NO STEP INDEX* for currentTimeMinutes (" << currentTimeMinutes << ")";
return currentTimeMinutes;
}
QList<int> const &stepList = stepListVec[stepListIndex];
qCritical() << " compute_next_timestep() index:" << stepListIndex;
qCritical() << " compute_next_timestep() timeSteps:" << stepList;
int currentStepIndex = stepList.indexOf(currentTimeMinutes);
int const currentStepIndex = stepList.indexOf(currentTimeMinutes); // must be currentStepIndex != -1
if (currentStepIndex == -1) {
qCritical() << "compute_next_timestep() *NO STEP* for currentTimeMinutes (" << currentTimeMinutes << ")";
return currentTimeMinutes;
}
cfg->getPaymentOptions(paymentOptionIndex).pop_min_time = stepList.first();
if (UpDown == 1) { // UP
if (stepList[currentStepIndex] == stepList.last()) {
qCritical() << "compute_next_timestep() *NO NEXT STEP* for currentTimeMinutes (" << currentTimeMinutes << ")";

View File

@ -2091,15 +2091,20 @@ QList<int> Calculator::GetPriceSteps(Configuration * /*cfg*/) const {
}
QList<int> Calculator::GetTimeSteps(Configuration *cfg, int paymentOptionIndex) const {
qCritical() << "(" << __func__ << ":" << __LINE__ << ")" << "paymentOptionIndex:" << paymentOptionIndex;
qCritical() << "(" << __func__ << ":" << __LINE__ << ")" << cfg << "paymentOptionIndex:" << paymentOptionIndex;
if (m_timeSteps.size() > paymentOptionIndex) {
//qCritical() << __PRETTY_FUNCTION__ << "timeSteps:" << m_timeSteps;
return m_timeSteps[paymentOptionIndex];
qCritical() << __func__ << ":" << __LINE__ << ")" << "timeSteps:" << m_timeSteps[m_timeSteps.size() - 1];
qCritical() << __func__ << ":" << __LINE__ << ")" << "timeSteps:" << m_timeSteps;
qCritical() << __func__ << ":" << __LINE__ << ")" << "timeSteps size:" << m_timeSteps.size();
return m_timeSteps[m_timeSteps.size() - 1];
} else {
m_timeSteps.push_back(QList<int>());
qCritical() << __func__ << ":" << __LINE__ << ")" << "timeSteps:" << m_timeSteps;
}
qCritical() << "(" << __func__ << ":" << __LINE__ << ")" << "m_timeSteps:" << m_timeSteps;
QDateTime start = QDateTime::currentDateTime();
start.setTime(QTime(start.time().hour(), start.time().minute(), 0));
@ -2123,6 +2128,8 @@ QList<int> Calculator::GetTimeSteps(Configuration *cfg, int paymentOptionIndex)
m_timeSteps[paymentOptionIndex].append(step);
}
} else {
qCritical() << "(" << __func__ << ":" << __LINE__ << ")";
uint16_t timeStepCompensation = 0;
if (pop_carry_over) {

View File

@ -45,12 +45,12 @@ extern "C" char* strptime(const char* s,
#define NEUHAUSER_KORNEUBURG (0)
#define NEUHAUSER_LINSINGER_MASCHINENBAU (0)
#define NEUHAUSER_NORDISCHES_AUSBILDUNGSZENTRUM (0)
#define NEUHAUSER_BILEXA_GALTUER (0)
#define NEUHAUSER_BILEXA_GALTUER (1)
#define BAD_NEUENAHR_AHRWEILER (0)
#define NEUHAUSER_CHRISTOPH_REISEN (0)
#define NEUHAUSER_PERNEGG_AN_DER_MUR (0)
#define NEUHAUSER_STOCKERAU (0)
#define KLEIPEDA_LITAUEN (1)
#define KLEIPEDA_LITAUEN (0)
#if NEUHAUSER_KIRCHDORF==1
static bool test_neuhauser_kirchdorf(int step, double cost) {
@ -924,6 +924,7 @@ void iuc_asynchpos_command_authorize(unsigned int vkPreis) {
iuc_asynchpos_send(packetType,message,uitemp,0x00);
}
int main() {
#if 0
@ -932,7 +933,7 @@ int main() {
msgHelp.createAuthorizeMessageChunksToSend(0x02);
qCritical() << "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" << endl;
qCritical() << "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" ssh -i ~/.ssh/id_ed25519_ptu5 root@10.0.15.175<< endl;
// unsigned static char terminalID[IUC_ASYNCHPOS_MIN_BASE_DATA_SIZE];
// unsigned static char terminalAPAK[IUC_ASYNCHPOS_MIN_BASE_DATA_SIZE];
@ -2771,7 +2772,17 @@ int main() {
qCritical() << timeSteps;
int Down = 0;
int Up = 1;
//compute_next_timestep(&cfg, )
QDateTime current = QDateTime::currentDateTime();
int minParkTime = get_minimal_parkingtime(&cfg, PERMIT_TYPE::DAY_TICKET, 0);
qCritical() << "minParkTime" << minParkTime;
qCritical() << "min_pop_time" << cfg.getPaymentOptions(0).pop_min_time;
int nextStep = compute_next_timestep(&cfg, minParkTime + 1, 1);
qCritical() << "nextStep" << nextStep;
return 0;
QDateTime const start = QDateTime::currentDateTime();
int paymentOptionIndex = cfg.getPaymentOptionIndex(start);