Fix: Read PTU zone info
This commit is contained in:
		@@ -16,7 +16,10 @@ int CALCULATE_LIBRARY_API get_zone_nr() {
 | 
			
		||||
        QFileInfo finfo(zone);
 | 
			
		||||
        if (finfo.size() <= 4) { // decimal 000\n
 | 
			
		||||
            if (zone.open(QIODevice::ReadOnly | QIODevice::Text)) {
 | 
			
		||||
                return zone.readLine().toInt();
 | 
			
		||||
 | 
			
		||||
                QTextStream in(&zone);
 | 
			
		||||
                return in.readLine(100).toInt();
 | 
			
		||||
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
@@ -27,7 +30,12 @@ bool CALCULATE_LIBRARY_API init_tariff(parking_tariff_t **tariff, char const *co
 | 
			
		||||
    *tariff = new Configuration();
 | 
			
		||||
 | 
			
		||||
    int const zone = get_zone_nr();
 | 
			
		||||
    if (zone == -1) {
 | 
			
		||||
 | 
			
		||||
    // DEBUG
 | 
			
		||||
    qCritical() << "init_tariff:";
 | 
			
		||||
    qCritical() << "      ... zone = " << zone;
 | 
			
		||||
 | 
			
		||||
    if (zone <= 0) {
 | 
			
		||||
        return false;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -36,7 +44,7 @@ bool CALCULATE_LIBRARY_API init_tariff(parking_tariff_t **tariff, char const *co
 | 
			
		||||
        confFile += "/";
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    char buffer[16];
 | 
			
		||||
    char buffer[32];
 | 
			
		||||
    memset(buffer, 0x00, sizeof(buffer));
 | 
			
		||||
    snprintf(buffer, sizeof(buffer)-1, "tariff%02d.json", zone);
 | 
			
		||||
    confFile += buffer;
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user