stared implementation

This commit is contained in:
Gerhard Hoffmann 2024-03-01 13:38:12 +01:00
parent bfa49cf226
commit ce0f355f88
8 changed files with 12923 additions and 0 deletions

View File

@ -0,0 +1,83 @@
QT += core
QT += serialport network
TARGET = ATBDownloadDCFirmware
VERSION="0.1.0"
win32 {
BUILD_DATE=$$system("date /t")
BUILD_TIME=$$system("time /t")
} else {
BUILD_DATE=$$system("date +%d-%m-%y")
BUILD_TIME=$$system("date +%H:%M:%S")
}
GIT_COMMIT=$$system("git log -1 --format=oneline | cut -d' ' -f1")
EXTENDED_VERSION="$${VERSION}-$${GIT_COMMIT}"
CONFIG += c++17
DEFINES+=APP_VERSION=\\\"$$VERSION\\\"
DEFINES+=APP_BUILD_DATE=\\\"$$BUILD_DATE\\\"
DEFINES+=APP_BUILD_TIME=\\\"$$BUILD_TIME\\\"
DEFINES+=APP_EXTENDED_VERSION=\\\"$$EXTENDED_VERSION\\\"
# keep comments, as /* fall through */
QMAKE_CXXFLAGS += -C
QMAKE_CXXFLAGS += -g
QMAKE_CXXFLAGS += -Wno-deprecated-copy -O
contains( CONFIG, PTU5 ) {
greaterThan(QT_MAJOR_VERSION, 4): QT += serialport
CONFIG += link_pkgconfig
lessThan(QT_MAJOR_VERSION, 5): PKGCONFIG += qextserialport
QMAKE_CXXFLAGS += -O2 -std=c++17 # for GCC >= 4.7
# QMAKE_CXXFLAGS += -Wno-deprecated-copy
ARCH = PTU5
DEFINES+=PTU5
}
contains( CONFIG, PTU5_YOCTO ) {
greaterThan(QT_MAJOR_VERSION, 4): QT += serialport
QMAKE_CXXFLAGS += -std=c++17 # for GCC >= 4.7
# QMAKE_CXXFLAGS += -Wno-deprecated-copy
PTU5BASEPATH = /opt/devel/ptu5
ARCH = PTU5
DEFINES+=PTU5
# add qmqtt lib
#LIBS += -lQt5Qmqtt
}
contains( CONFIG, DesktopLinux ) {
greaterThan(QT_MAJOR_VERSION, 4): QT += serialport
lessThan(QT_MAJOR_VERSION, 5): CONFIG += extserialport
# QMAKE_CC = ccache $$QMAKE_CC
# QMAKE_CXX = ccache $$QMAKE_CXX
QMAKE_CXXFLAGS += -std=c++17
# QMAKE_CXXFLAGS += -Wno-deprecated-copy
linux-clang { QMAKE_CXXFLAGS += -Qunused-arguments }
ARCH = DesktopLinux
DEFINES+=DesktopLinux
}
SOURCES += \
main.cpp \
tariff_json_template.cpp \
tariff_json_parser.cpp
HEADERS += \
tariff_json_template.h \
tariff_json_parser.h
OTHER_FILES += \
tariff.json \
tariff.template.json
##########################################################################################
# for running program on target through QtCreator
contains( CONFIG, PTU5 ) {
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/app/tools/atbupdate/
!isEmpty(target.path): INSTALLS += target
}

9
Utilities/main.cpp Normal file
View File

@ -0,0 +1,9 @@
#include <QtGlobal>
int main(int argc, char **argv) {
Q_UNUSED(argc);
Q_UNUSED(argv);
return 0;
}

5770
Utilities/tariff.json Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

View File

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,277 @@
#ifndef TARIFF_JSON_TEMPLATE_H_INCLUDED
#define TARIFF_JSON_TEMPLATE_H_INCLUDED
#include <QJsonArray>
#include <QJsonDocument>
#include <QJsonObject>
#include <QJsonParseError>
#include <QJsonValue>
struct Tariff : public QJsonObject {
QJsonValue m_project;
QJsonValue m_version;
QJsonValue m_date;
QJsonValue m_committer;
QJsonValue m_info;
struct TariffProduct : public QJsonObject {
QJsonValue m_tariff_product_id;
QJsonValue m_tariff_product_price_id;
QJsonValue m_tariff_product_name;
QJsonArray m_tariff_product_time_ranges;
} m_tariff_product;
QJsonArray m_tariff_product_setting;
struct TariffProduct : public QJsonObject {
QJsonValue m_tariff_accuracy_id;
QJsonValue m_tariff_accuracy_label;
QJsonValue m_tariff_accuracy_value;
QJsonArray m_comment;
} m_tariff_accuracy;
QJsonArray m_tariff_accuracy_setting;
struct TariffType : public QJsonObject {
QJsonValue m_tariff_type_id;
QJsonValue m_tariff_type_label;
QJsonValue m_comment;
} m_tariff_type;
QJsonArray m_tariff_type_setting;
struct TariffTimeBase : public QJsonObject {
QJsonValue m_tariff_timebase_id;
QJsonValue m_tariff_timebase_label;
QJsonValue m_comment;
} m_tariff_timebase;
QJsonArray m_tariff_timebase_setting;
struct TariffPriceCustomer : public QJsonObject {
QJsonValue m_tariff_price_customer_id;
QJsonValue m_tariff_price_customer_label;
QJsonValue m_editable;
QJsonValue m_comment;
};
struct TariffConfig : public QJsonObject {
QJsonValue m_tariff_config_id;
QJsonValue m_tariff_config_label;
QJsonValue m_tariff_config_accuracy;
QJsonValue m_tariff_config_type;
struct TariffMinimalTime : public QJsonObject {
QJsonValue m_value;
QJsonValue m_editable;
QJsonValue m_comment;
} m_tariff_minimal_time;
struct TariffMaximalTime : public QJsonObject {
QJsonValue m_value;
QJsonValue m_editable;
QJsonValue m_comment;
} m_tariff_maximal_time;
struct TariffMinimalPrice : public QJsonObject {
QJsonValue m_value;
QJsonValue m_editable;
QJsonValue m_comment;
} m_minimal_price;
struct TariffMaximalPrice : public QJsonObject {
QJsonValue m_value;
QJsonValue m_editable;
QJsonValue m_comment;
} m_maximal_price;
QJsonValue m_tariff_config_time_base;
QJsonValue m_tariff_config_carry_over;
QJsonValue m_tariff_config_prepaid;
};
struct TariffTimeRange : public QJsonObject {
QJsonValue m_time_range_id;
QJsonValue m_time_range_start;
QJsonValue m_time_range_end;
QJsonValue m_time_range_start_minute;
QJsonValue m_time_range_end_minute;
QJsonValue m_time_range_price_id;
QJsonValue m_comment;
} m_tariff_time_range;
QJsonArray m_tariff_time_range_setting;
struct TariffDateRange : public QJsonObject {
QJsonValue m_date_range_id;
QJsonValue m_date_range_label;
QJsonValue m_date_range_from;
};
QJsonArray m_tariff_time_range_setting;
struct TariffDayConfiguration : public QJsonObject {
QJsonValue m_day_config_id;
QJsonValue m_day_config_date_range;
QJsonValue m_day_consfig_comment_date_range;
QJsonArray m_day_config_product_ids;
QJsonValue m_day_config_comment_product_ids;
struct : QJsonArray {
struct : public QJsonObject {
QJsonArray m_data;
} m_day_time_ranges_short_time_parking;
struct : public QJsonObject {
QJsonArray m_data;
} m_day_time_ranges_day_ticket;
} m_day_config_day_time_ranges;
};
struct TariffWeekDay : public QJsonObject {
QJsonValue m_day_id;
QJsonValue m_day_label;
QJsonValue m_day_config_id;
};
struct TariffHolidayDay : public QJsonObject {
QJsonValue m_day_id;
QJsonValue m_day_label;
QJsonValue m_day_config_id;
QJsonValue m_day_moveable;
};
QJsonArray m_tariff_days_setting;
};
#if 0
namespace ISMAS {
struct TransferData : public QJsonObject {
struct : public QJsonObject {
QJsonValue tariffId;
QJsonValue group;
QJsonValue zone;
} device;
struct : public QJsonObject {
QJsonValue state;
QJsonValue uid;
QJsonValue seq_tick_number;
QJsonValue timestamp;
QJsonValue userText;
QJsonValue userTextType;
} transaction;
struct : public QJsonObject {
// TODO: check what is really used at the moment
QJsonValue id; // unique article id
QJsonValue name; // name
QJsonValue price; // price in cent
QJsonValue currency; //
QJsonValue startTime; // start time
QJsonValue endTime; // end time
QJsonValue userText; // additional info
QJsonValue parkingTime;
QJsonValue printText;
// QJsonValue discount;
} item;
struct : public QJsonObject {
struct : public QJsonObject {
QJsonValue coins; // total amount of coins value
// QJsonValue notes; // total amount of notes value
QJsonValue overpaid; // in cent
QJsonValue currency;
QJsonValue change;
} cash;
struct : public QJsonObject {
QJsonValue cardNumber;
QJsonValue value; // buchungsbetrag
QJsonValue cardType;
QJsonValue currency;
QJsonValue tid;
QJsonValue tresult;
} card;
struct : public QJsonObject {
QJsonValue cardNumber;
QJsonValue cardType;
QJsonValue value;
QJsonValue valueOld;
QJsonValue valueNew;
QJsonValue time;
QJsonValue timeOld;
QJsonValue timeNew;
} prePaidCard;
} payment;
struct : public QJsonObject {
QJsonValue delivery; // PRINT, OnlineTicket
QJsonValue result; // SUCCESS, ERROR
QJsonValue errorCode; // 0=OK, 1=...
QJsonValue errorMsg;
} result;
};
struct AccountData : public QJsonObject {
struct : public QJsonObject {
QJsonValue UID;
QJsonValue ChangeNumber;
QJsonValue Process; // Vorgang
QJsonValue startDateTime;
QJsonValue endDateTime;
QJsonValue startHash;
QJsonValue endHash;
struct : public QJsonObject {
QJsonValue value; // coin value
QJsonValue numberOfCoins; // number of coins
QJsonValue currency;
} coin;
} coinBox; // Münzkasse
};
struct EventData : public QJsonObject {
struct : public QJsonObject {
QJsonValue eventID;
QJsonValue deviceName;
QJsonValue reason;
QJsonValue event;
QJsonValue eventState;
QJsonValue timeStamp;
QJsonValue parameter;
QJsonValue secondLevelInfo;
} machineEvent; //
};
struct StateData : public QJsonObject {
QJsonValue Timestamp;
QJsonArray HW_States;
struct : public QJsonObject {
QJsonValue name;
QJsonValue value;
QJsonValue unit;
} machineState; //
};
enum class REQUEST : quint8 {
NO_REQUEST,
START,
STOP,
PING,
SELF,
PARAMETER
};
}
#endif
#endif // TARIFF_JSON_TEMPLATE_H_INCLUDED