Compare commits
10 Commits
4a3d313deb
...
0.0.1
Author | SHA1 | Date | |
---|---|---|---|
b422f82dea
|
|||
30af400779
|
|||
db1b64649b | |||
adce2983ce | |||
568d7d8680 | |||
f650612a63 | |||
129c474691 | |||
a8fa4c2613 | |||
194ecd2771 | |||
a7d7e61d9b |
@@ -3,3 +3,7 @@ CONFIG += ordered
|
||||
SUBDIRS = library main
|
||||
|
||||
main.depends = library
|
||||
|
||||
contains( CONFIG, PTU5_YOCTO ) {
|
||||
SUBDIRS = library
|
||||
}
|
@@ -22,7 +22,7 @@ typedef Configuration parking_tariff_t;
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct price_t {
|
||||
struct CALCULATE_LIBRARY_API price_t {
|
||||
uint32_t units;
|
||||
double netto;
|
||||
double brutto;
|
||||
|
@@ -1,5 +1,5 @@
|
||||
TEMPLATE = lib
|
||||
TARGET = mobility_calc
|
||||
TARGET = mobilisis_calc
|
||||
# CONFIG += staticlib
|
||||
|
||||
QMAKE_CXXFLAGS += -std=c++17 -g -O0
|
||||
@@ -8,8 +8,16 @@ INCLUDEPATH += $$_PRO_FILE_PWD_/include
|
||||
INCLUDEPATH += $$_PRO_FILE_PWD_/include/mobilisis
|
||||
INCLUDEPATH += $$_PRO_FILE_PWD_/include/rapidjson
|
||||
|
||||
win32 {
|
||||
CONFIG+=-DCALCULATE_LIBRARY_EXPORTS
|
||||
CONFIG(debug, debug|release) {
|
||||
win32 {
|
||||
QMAKE_CXXFLAGS += -DCALCULATE_LIBRARY_EXPORTS
|
||||
QMAKE_LFLAGS += -Wl,--out-implib,debug\libmobilisis_calc.a
|
||||
}
|
||||
} else {
|
||||
win32 {
|
||||
QMAKE_CXXFLAGS += -DCALCULATE_LIBRARY_EXPORTS
|
||||
QMAKE_LFLAGS += -Wl,--out-implib,release\libmobilisis_calc.a
|
||||
}
|
||||
}
|
||||
|
||||
SOURCES += \
|
||||
|
@@ -10,24 +10,32 @@
|
||||
|
||||
static Calculator calculator;
|
||||
|
||||
int get_zone_nr() {
|
||||
int CALCULATE_LIBRARY_API get_zone_nr() {
|
||||
QFile zone("/etc/zone_nr");
|
||||
if (zone.exists()) {
|
||||
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();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
bool init_tariff(parking_tariff_t **tariff, char const *config_file) {
|
||||
bool CALCULATE_LIBRARY_API init_tariff(parking_tariff_t **tariff, char const *config_file) {
|
||||
*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,27 +44,41 @@ bool init_tariff(parking_tariff_t **tariff, char const *config_file) {
|
||||
confFile += "/";
|
||||
}
|
||||
|
||||
char buffer[16];
|
||||
char buffer[32];
|
||||
memset(buffer, 0x00, sizeof(buffer));
|
||||
snprintf(buffer, sizeof(buffer)-1, "tariff%02d.json", zone);
|
||||
confFile += buffer;
|
||||
|
||||
// DEBUG
|
||||
qCritical() << " ... confFile = " << confFile;
|
||||
|
||||
QFile fname(confFile);
|
||||
if (fname.exists()) {
|
||||
|
||||
// DEBUG
|
||||
qCritical() << " ... confFile exists";
|
||||
|
||||
if (fname.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||
|
||||
// DEBUG
|
||||
qCritical() << " ... confFile is open";
|
||||
|
||||
QString json = fname.readAll();
|
||||
return (*tariff)->ParseJson(*tariff, json.toStdString().c_str());
|
||||
}
|
||||
}
|
||||
|
||||
qCritical() << "init_tariff: Parsing tariff config (" << confFile << ") failed!";
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void free_tariff(parking_tariff_t *tariff) {
|
||||
void CALCULATE_LIBRARY_API free_tariff(parking_tariff_t *tariff) {
|
||||
delete tariff;
|
||||
}
|
||||
|
||||
bool compute_price_for_parking_ticket(parking_tariff_t *tariff,
|
||||
bool CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
|
||||
parking_tariff_t *tariff,
|
||||
time_t start_parking_time, // in minutes
|
||||
time_t end_parking_time, // in minutes
|
||||
struct price_t *price) {
|
||||
|
@@ -10,16 +10,16 @@ INCLUDEPATH += $$_PRO_FILE_PWD_/../../MOBILISIS-Calculator/library/include/mobil
|
||||
INCLUDEPATH += .
|
||||
|
||||
unix {
|
||||
LIBS += -L$$OUT_PWD/../library/ -lmobility_calc
|
||||
LIBS += -L$$OUT_PWD/../library/ -lmobilisis_calc
|
||||
}
|
||||
|
||||
CONFIG(debug, debug|release) {
|
||||
win32 {
|
||||
LIBS += -L$$OUT_PWD/../library/debug/ -lmobility_calc
|
||||
LIBS += -L$$OUT_PWD/../library/debug/ -lmobilisis_calc
|
||||
}
|
||||
} else {
|
||||
win32 {
|
||||
LIBS += -L$$OUT_PWD/../library/release/ -lmobility_calc
|
||||
LIBS += -L$$OUT_PWD/../library/release/ -lmobilisis_calc
|
||||
}
|
||||
}
|
||||
|
||||
|
1
tariffs/tariff04.json
Normal file
1
tariffs/tariff04.json
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user