forked from GerhardHoffmann/DCLibraries
Start repository
This commit is contained in:
58
dCArun/dCArun.pro
Normal file
58
dCArun/dCArun.pro
Normal file
@@ -0,0 +1,58 @@
|
||||
QT += core gui
|
||||
QT +=widgets serialport
|
||||
QT +=network
|
||||
# for TCP-IP
|
||||
|
||||
TARGET = dCArun
|
||||
DESTDIR=$${_PRO_FILE_PWD_}/../build
|
||||
|
||||
|
||||
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
|
||||
|
||||
CONFIG += c++11
|
||||
CONFIG += PTU5
|
||||
|
||||
# _FORTIFY_SOURCE requires compiling with optimization (-O) [-Wcpp]
|
||||
QMAKE_CXXFLAGS += -O
|
||||
|
||||
INCLUDEPATH += ../include
|
||||
|
||||
|
||||
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}"
|
||||
|
||||
DEFINES+=APP_VERSION=\\\"$$VERSION\\\"
|
||||
DEFINES+=APP_BUILD_DATE=\\\"$$BUILD_DATE\\\"
|
||||
DEFINES+=APP_BUILD_TIME=\\\"$$BUILD_TIME\\\"
|
||||
DEFINES+=APP_EXTENDED_VERSION=\\\"$$EXTENDED_VERSION\\\"
|
||||
|
||||
SOURCES += \
|
||||
main.cpp \
|
||||
mainwindow.cpp \
|
||||
tslib.cpp \
|
||||
win01_com.cpp \
|
||||
datei.cpp
|
||||
|
||||
HEADERS += \
|
||||
guidefs.h \
|
||||
mainwindow.h \
|
||||
stepList.h \
|
||||
tslib.h \
|
||||
versionHistory.txt \
|
||||
win01_com.h \
|
||||
datei.h \
|
||||
plugin.h
|
||||
|
||||
# Default rules for deployment.
|
||||
qnx: target.path = /tmp/$${TARGET}/bin
|
||||
else: unix:!android: target.path = /opt/$${TARGET}/bin
|
||||
!isEmpty(target.path): INSTALLS += target
|
944
dCArun/datei.cpp
Executable file
944
dCArun/datei.cpp
Executable file
@@ -0,0 +1,944 @@
|
||||
// written by Thomas Sax, Jan.2022
|
||||
#include "datei.h"
|
||||
|
||||
|
||||
// -------------------------------------------------------------------------------------------------
|
||||
// ------------------------------------------------------ create csv file -------------------------------
|
||||
// -------------------------------------------------------------------------------------------------
|
||||
|
||||
QByteArray datei_writeArray, datei_tempArray;
|
||||
|
||||
void csv_startCreatingFile(void)
|
||||
{
|
||||
datei_writeArray.clear();
|
||||
datei_tempArray.clear();
|
||||
}
|
||||
|
||||
void csv_addTextToFile(QString myText)
|
||||
{
|
||||
datei_writeArray.append(myText.toLatin1());
|
||||
datei_writeArray.append(FILESEPERATOR);
|
||||
}
|
||||
|
||||
void csv_addIntToFile(int myValue)
|
||||
{
|
||||
//qulonglong ullt=12345678901234567890; // max 1,844 x10^19
|
||||
datei_tempArray.setNum(myValue,10); // accepted types: short, ushort, int, uint,
|
||||
// qlonglong, qulonglong, float, double
|
||||
// numerbase can be 2...36(!),10=dec
|
||||
|
||||
datei_writeArray.append(datei_tempArray);
|
||||
datei_writeArray.append(FILESEPERATOR);
|
||||
}
|
||||
|
||||
void csv_addUintToFile(uint myValue)
|
||||
{
|
||||
datei_tempArray.setNum(myValue,10);
|
||||
datei_writeArray.append(datei_tempArray);
|
||||
datei_writeArray.append(FILESEPERATOR);
|
||||
}
|
||||
|
||||
|
||||
void csv_addLongvalToFile(qlonglong myValue)
|
||||
{
|
||||
datei_tempArray.setNum(myValue,10);
|
||||
datei_writeArray.append(datei_tempArray);
|
||||
datei_writeArray.append(FILESEPERATOR);
|
||||
}
|
||||
|
||||
void csv_addUlongvalToFile(qulonglong myValue)
|
||||
{
|
||||
datei_tempArray.setNum(myValue,10);
|
||||
datei_writeArray.append(datei_tempArray);
|
||||
datei_writeArray.append(FILESEPERATOR);
|
||||
}
|
||||
|
||||
/*
|
||||
void csv_addCurrentTimeToFile(void)
|
||||
{
|
||||
uint8_t hour, minute, sec, ui8buf[20];
|
||||
char buf[20];
|
||||
|
||||
config_getSysTime(&hour, &minute, &sec);
|
||||
GetTimeString(hour, minute, sec, 0, 1, ui8buf);
|
||||
for (uint8_t nn=0; nn<20; nn++)
|
||||
buf[nn]=char(ui8buf[nn]);
|
||||
datei_writeArray.append(buf,8); // time string
|
||||
datei_writeArray.append(FILESEPERATOR);
|
||||
|
||||
}
|
||||
|
||||
void csv_addCurrentDateToFile(void)
|
||||
{
|
||||
uint16_t year;
|
||||
uint8_t month, day, ui8buf[20];
|
||||
char buf[20];
|
||||
|
||||
config_getSystemDate(&year, &month, &day);
|
||||
//qDebug()<<"date year: "<<year;
|
||||
GetDateString(day, month, 0x20, uint8_t(year%100), 0, 0, ui8buf);
|
||||
for (uint8_t nn=0; nn<20; nn++)
|
||||
buf[nn]=char(ui8buf[nn]);
|
||||
datei_writeArray.append(buf, 10); // date string
|
||||
datei_writeArray.append(NEWLINEINFILE);
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
void csv_addNewlineToFile(void)
|
||||
{
|
||||
datei_writeArray.chop(1); // Komma weg
|
||||
datei_writeArray.append(NEWLINEINFILE);
|
||||
}
|
||||
|
||||
QByteArray csv_readbackArray(void)
|
||||
{
|
||||
return datei_writeArray;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
QByteArray csv_writeContent_testValues(void)
|
||||
{
|
||||
QByteArray myBA, tmpBA;
|
||||
uint8_t modCount=5, modAddr=23;
|
||||
uint8_t hour, minute, sec, month, day, ui8buf[20];
|
||||
uint16_t year, modType=45678;
|
||||
char buf[20];
|
||||
uint32_t modNrDIs=1234567890;
|
||||
uint8_t modNrAIs=4, modNrCtr=2, modNrDOs=8;
|
||||
int modNrAOs=-2;
|
||||
|
||||
myBA.clear();
|
||||
tmpBA.clear();
|
||||
myBA.append("scan time");
|
||||
myBA.append(FILESEPERATOR);
|
||||
|
||||
datei_getSysTime(&hour, &minute, &sec);
|
||||
GetTimeString(hour, minute, sec, 0, 1, ui8buf);
|
||||
for (uint8_t nn=0; nn<20; nn++)
|
||||
buf[nn]=char(ui8buf[nn]);
|
||||
myBA.append(buf,8); // time string
|
||||
myBA.append(FILESEPERATOR);
|
||||
|
||||
datei_getSystemDate(&year, &month, &day);
|
||||
//qDebug()<<"date year: "<<year;
|
||||
GetDateString(day, month, 0x20, uint8_t(year%100), 0, 0, ui8buf);
|
||||
for (uint8_t nn=0; nn<20; nn++)
|
||||
buf[nn]=char(ui8buf[nn]);
|
||||
myBA.append(buf, 10); // date string
|
||||
myBA.append(NEWLINEINFILE);
|
||||
|
||||
myBA.append("number of modules");
|
||||
myBA.append(FILESEPERATOR);
|
||||
tmpBA.setNum(modCount,10); //2nd para = number base 2, 8, 10 or 16 (bin, oct, dec, hex)
|
||||
myBA.append(tmpBA);
|
||||
myBA.append(NEWLINEINFILE);
|
||||
|
||||
myBA.append("busaddr");
|
||||
myBA.append(FILESEPERATOR);
|
||||
myBA.append("type");
|
||||
myBA.append(FILESEPERATOR);
|
||||
myBA.append("NrOfDI");
|
||||
myBA.append(FILESEPERATOR);
|
||||
myBA.append("NrOfAI");
|
||||
myBA.append(FILESEPERATOR);
|
||||
myBA.append("NrOfCtrIn");
|
||||
myBA.append(FILESEPERATOR);
|
||||
myBA.append("NrOfDO");
|
||||
myBA.append(FILESEPERATOR);
|
||||
myBA.append("NrOfAO");
|
||||
myBA.append(NEWLINEINFILE);
|
||||
|
||||
tmpBA.setNum(modAddr,10);
|
||||
myBA.append(tmpBA);
|
||||
myBA.append(FILESEPERATOR);
|
||||
tmpBA.setNum(modType,10);
|
||||
myBA.append(tmpBA);
|
||||
myBA.append(FILESEPERATOR);
|
||||
tmpBA.setNum(modNrDIs,10);
|
||||
myBA.append(tmpBA);
|
||||
myBA.append(FILESEPERATOR);
|
||||
tmpBA.setNum(modNrAIs,10);
|
||||
myBA.append(tmpBA);
|
||||
myBA.append(FILESEPERATOR);
|
||||
tmpBA.setNum(modNrCtr,10);
|
||||
myBA.append(tmpBA);
|
||||
myBA.append(FILESEPERATOR);
|
||||
tmpBA.setNum(modNrDOs,10);
|
||||
myBA.append(tmpBA);
|
||||
myBA.append(FILESEPERATOR);
|
||||
tmpBA.setNum(modNrAOs,10);
|
||||
myBA.append(tmpBA);
|
||||
myBA.append(NEWLINEINFILE);
|
||||
return myBA;
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
// -------------------------------------------------------------------------------------------------
|
||||
// ------------------------------------------------------ parse csv file -------------------------------
|
||||
// -------------------------------------------------------------------------------------------------
|
||||
|
||||
// first: QByteArray datei_readFromFile(QString filename);
|
||||
|
||||
|
||||
uint32_t csv_nrOfEntriesInFile(QByteArray readFromFile)
|
||||
{
|
||||
// count sequences between FILESEPERATOR and NEWLINEINFILE
|
||||
uint32_t filSize=0, pp=0;
|
||||
char oneByt=0;
|
||||
|
||||
int filLen=readFromFile.size();
|
||||
if(filLen>1)
|
||||
filSize=uint32_t(filLen);
|
||||
else
|
||||
return 0;
|
||||
|
||||
// 1) find position of seperators
|
||||
for (uint32_t ii=0; ii<filSize; ii++)
|
||||
{
|
||||
oneByt=readFromFile[ii];
|
||||
if (oneByt==FILESEP1 || oneByt==FILESEP2 || oneByt==NEWLINEINFILE)
|
||||
pp++;
|
||||
}
|
||||
// now: pp = number of seperators
|
||||
// oneByt = last byte in file. If it's not a seperator then
|
||||
// there's one more entry (last entry without termination)
|
||||
if (oneByt !=FILESEP1 && oneByt !=FILESEP2 && oneByt !=NEWLINEINFILE)
|
||||
pp++;
|
||||
//qDebug()<<"csv: nr of sequences="<< pp;
|
||||
return pp;
|
||||
}
|
||||
|
||||
QByteArray csv_getOneFileSequence(QByteArray sourceFile, uint32_t sequNr)
|
||||
{
|
||||
// seperate file content in single sequences between FILESEPERATOR and NEWLINEINFILE
|
||||
// and return "entryNr" - entry
|
||||
// for this first step leave data type QByteArray
|
||||
// 2nd step can change in numbers and strings
|
||||
QByteArray sequence;
|
||||
uint32_t sepPos[MAXNUMBEROFSEQUENCES];
|
||||
uint32_t filSize=0, pp=0, ii, start=0, ende=0;
|
||||
char oneByt;
|
||||
int filLen, mm;
|
||||
|
||||
filLen=sourceFile.size();
|
||||
//qDebug()<<"fillen="<< filLen;
|
||||
if(filLen<10)
|
||||
return "";
|
||||
filSize=uint32_t(filLen);
|
||||
|
||||
if (sequNr>MAXNUMBEROFSEQUENCES)
|
||||
return "";
|
||||
|
||||
// 1) find position of seperators
|
||||
for (ii=0; ii<filSize; ii++)
|
||||
{
|
||||
oneByt=sourceFile[ii];
|
||||
if (oneByt==FILESEP1 || oneByt==FILESEP2 || oneByt==NEWLINEINFILE)
|
||||
{
|
||||
sepPos[pp++]=ii;
|
||||
}
|
||||
}
|
||||
// now: pp = number of entries
|
||||
//qDebug()<<"nr of seperators="<< pp;
|
||||
|
||||
if (sequNr>=pp)
|
||||
return "";
|
||||
|
||||
// 2) get sequence
|
||||
if (sequNr==0)
|
||||
{
|
||||
start=0;
|
||||
ende=sepPos[sequNr];
|
||||
} else
|
||||
if (sequNr>0)
|
||||
{
|
||||
start=sepPos[sequNr-1]+1;
|
||||
ende=sepPos[sequNr];
|
||||
}
|
||||
|
||||
//qDebug()<<"datei getOneFileSequence start/ende: "<<start << " " << ende;
|
||||
if (start>=ende)
|
||||
return "";
|
||||
//return "-err3-";
|
||||
sequence.clear();
|
||||
//batmp.clear();
|
||||
pp=0;
|
||||
for (ii=start; ii<ende; ii++)
|
||||
{
|
||||
mm=int(ii);
|
||||
if (mm>=int(filSize))
|
||||
mm=0;
|
||||
oneByt=sourceFile.at(mm);
|
||||
sequence.append(oneByt);
|
||||
}
|
||||
return sequence;
|
||||
}
|
||||
|
||||
int csv_getEntryAsInt(QByteArray sourceFile, uint32_t sequNr)
|
||||
{
|
||||
QByteArray myBA, myVA;
|
||||
int entry=0;
|
||||
bool ok;
|
||||
|
||||
myVA.clear();
|
||||
myBA = csv_getOneFileSequence(sourceFile, sequNr);
|
||||
//qDebug()<<"datei getEntryAsInt, sequence: " << myBA;
|
||||
|
||||
entry=myBA.toInt(&ok,16);
|
||||
if (ok)
|
||||
{
|
||||
//qDebug()<<"datei getEntryAsInt, number: " << entry;
|
||||
return entry;
|
||||
}
|
||||
//qDebug()<<"datei getEntryAsInt, error " << myBA;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t csv_getEntryAsLong(QByteArray sourceFile, uint32_t sequNr)
|
||||
{
|
||||
QByteArray myBA = csv_getOneFileSequence(sourceFile, sequNr);
|
||||
long entry=0;
|
||||
bool ok;
|
||||
|
||||
entry=myBA.toLong(&ok,10);
|
||||
if (ok)
|
||||
return entry;
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint8_t csv_getEntryAsUshort(QByteArray sourceFile, uint32_t sequNr)
|
||||
{
|
||||
QByteArray myBA = csv_getOneFileSequence(sourceFile, sequNr);
|
||||
uint8_t entry=0;
|
||||
bool ok;
|
||||
|
||||
entry=uint8_t(myBA.toUShort(&ok,10));
|
||||
if (ok)
|
||||
return entry;
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint16_t csv_getEntryAsUint(QByteArray sourceFile, uint32_t sequNr)
|
||||
{
|
||||
QByteArray myBA = csv_getOneFileSequence(sourceFile, sequNr);
|
||||
uint16_t entry=0;
|
||||
bool ok;
|
||||
|
||||
entry=uint16_t(myBA.toUInt(&ok,10));
|
||||
if (ok)
|
||||
return entry;
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32_t csv_getEntryAsUlong(QByteArray sourceFile, uint32_t sequNr)
|
||||
{
|
||||
QByteArray myBA = csv_getOneFileSequence(sourceFile, sequNr);
|
||||
uint32_t entry=0;
|
||||
bool ok;
|
||||
|
||||
entry=myBA.toULong(&ok,10);
|
||||
if (ok)
|
||||
return entry;
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint64_t csv_getEntryAs2Ulong(QByteArray sourceFile, uint32_t sequNr)
|
||||
{
|
||||
QByteArray myBA = csv_getOneFileSequence(sourceFile, sequNr);
|
||||
uint64_t entry=0;
|
||||
bool ok;
|
||||
|
||||
entry=myBA.toULongLong(&ok,10);
|
||||
if (ok)
|
||||
return entry;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
QString csv_getEntryAsString(QByteArray sourceFile, uint32_t sequNr)
|
||||
{
|
||||
QByteArray myBA = csv_getOneFileSequence(sourceFile, sequNr);
|
||||
QString entry;
|
||||
|
||||
//qDebug()<<"datei getEntryAsString, sequence: " << myBA;
|
||||
entry=myBA.toStdString().c_str();
|
||||
return entry;
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------------------------------
|
||||
// ------------------------------------------------------ create Json file -------------------------------
|
||||
// -------------------------------------------------------------------------------------------------
|
||||
|
||||
/*
|
||||
example
|
||||
QString str = "{"
|
||||
" \"Herausgeber\": \"Xema\","
|
||||
" \"Nummer\": \"1234-5678-9012-3456\","
|
||||
" \"Deckung\": 2e+6,"
|
||||
" \"Währung\": \"EURO\","
|
||||
" \"Inhaber\": {"
|
||||
" \"Name\": \"Mustermann\","
|
||||
" \"Vorname\": \"Max\","
|
||||
" \"männlich\": true,"
|
||||
" \"Hobbys\": [ \"Reiten\", \"Golfen\", \"Lesen\" ],"
|
||||
" \"Alter\": 42,"
|
||||
" \"Kinder\": [],"
|
||||
" \"Partner\": null"
|
||||
" }"
|
||||
"}";
|
||||
|
||||
*/
|
||||
|
||||
QString myJsonCon;
|
||||
QString tmpStr;
|
||||
|
||||
void json_startRecord(void)
|
||||
{
|
||||
myJsonCon.clear();
|
||||
tmpStr.clear();
|
||||
myJsonCon.append('{');
|
||||
}
|
||||
|
||||
void json_enterIntToRecord(QString attribute, ulong i_value)
|
||||
{
|
||||
tmpStr.clear();
|
||||
myJsonCon.append('"');
|
||||
myJsonCon.append(attribute);
|
||||
myJsonCon.append('"');
|
||||
myJsonCon.append(':');
|
||||
tmpStr.setNum(i_value);
|
||||
myJsonCon.append(tmpStr);
|
||||
myJsonCon.append(',');
|
||||
myJsonCon.append(NEWLINEINFILE);
|
||||
}
|
||||
|
||||
void json_enterTextToRecord(QString attribute, QString txt_value)
|
||||
{
|
||||
myJsonCon.append('"');
|
||||
myJsonCon.append(attribute);
|
||||
myJsonCon.append('"');
|
||||
myJsonCon.append(':');
|
||||
myJsonCon.append('"');
|
||||
myJsonCon.append(txt_value);
|
||||
myJsonCon.append('"');
|
||||
myJsonCon.append(',');
|
||||
myJsonCon.append(NEWLINEINFILE);
|
||||
}
|
||||
/*
|
||||
void json_addCurrentTimeToRecord(QString attribute)
|
||||
{
|
||||
uint8_t hour, minute, sec, ui8buf[20];
|
||||
//char buf[20];
|
||||
|
||||
myJsonCon.append('"');
|
||||
myJsonCon.append(attribute);
|
||||
myJsonCon.append('"');
|
||||
myJsonCon.append(':');
|
||||
myJsonCon.append('"');
|
||||
|
||||
datei_getSysTime(&hour, &minute, &sec);
|
||||
GetTimeString(hour, minute, sec, 0, 1, ui8buf);
|
||||
for (uint8_t nn=0; nn<8; nn++)
|
||||
myJsonCon.append(ui8buf[nn]);
|
||||
|
||||
myJsonCon.append('"');
|
||||
myJsonCon.append(',');
|
||||
myJsonCon.append(NEWLINEINFILE);
|
||||
|
||||
}
|
||||
|
||||
void json_addCurrentDateToRecord(QString attribute)
|
||||
{
|
||||
uint16_t year;
|
||||
uint8_t month, day, ui8buf[20];
|
||||
//char buf[20];
|
||||
|
||||
myJsonCon.append('"');
|
||||
myJsonCon.append(attribute);
|
||||
myJsonCon.append('"');
|
||||
myJsonCon.append(':');
|
||||
myJsonCon.append('"');
|
||||
|
||||
datei_getSystemDate(&year, &month, &day);
|
||||
GetDateString(day, month, 0x20, uint8_t(year%100), 0, 0, ui8buf);
|
||||
for (uint8_t nn=0; nn<10; nn++)
|
||||
myJsonCon.append(ui8buf[nn]);
|
||||
|
||||
myJsonCon.append('"');
|
||||
myJsonCon.append(',');
|
||||
myJsonCon.append(NEWLINEINFILE);
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
void json_enterArrayToRecord(QString attribute, uint8_t *buf, ulong nrofVals)
|
||||
{
|
||||
// add array of numbers with "nrofVals" elements
|
||||
|
||||
myJsonCon.append('"');
|
||||
myJsonCon.append(attribute);
|
||||
myJsonCon.append('"');
|
||||
myJsonCon.append(':');
|
||||
myJsonCon.append('['); // eckig!!!
|
||||
for (ulong ul=0; ul<nrofVals; ul++)
|
||||
{
|
||||
tmpStr.setNum(buf[ul]);
|
||||
myJsonCon.append(tmpStr);
|
||||
myJsonCon.append(',');
|
||||
}
|
||||
myJsonCon.chop(1); // Komma weg
|
||||
myJsonCon.append(']'); // eckig!!!
|
||||
myJsonCon.append(',');
|
||||
myJsonCon.append(NEWLINEINFILE);
|
||||
}
|
||||
|
||||
void json_enterStructToRecord(QString attribute)
|
||||
{
|
||||
// every call must be concluded with "json_finishFile()"
|
||||
myJsonCon.append('"');
|
||||
myJsonCon.append(attribute);
|
||||
myJsonCon.append('"');
|
||||
myJsonCon.append(':');
|
||||
myJsonCon.append('{'); // geschweift!!
|
||||
myJsonCon.append(NEWLINEINFILE);
|
||||
}
|
||||
|
||||
void json_finishStruct(void)
|
||||
{
|
||||
myJsonCon.chop(2); // remove , and \r from the end
|
||||
myJsonCon.append('}');
|
||||
myJsonCon.append(',');
|
||||
myJsonCon.append(NEWLINEINFILE);
|
||||
|
||||
}
|
||||
|
||||
void json_finishRecord(void)
|
||||
{
|
||||
myJsonCon.chop(2); // remove , and \r from the end
|
||||
myJsonCon.append(NEWLINEINFILE);
|
||||
myJsonCon.append('}');
|
||||
myJsonCon.append(NEWLINEINFILE);
|
||||
|
||||
}
|
||||
|
||||
|
||||
QString json_readbackRecordStr(void)
|
||||
{
|
||||
return myJsonCon;
|
||||
}
|
||||
|
||||
QByteArray json_readbackRecordBa(void)
|
||||
{
|
||||
return myJsonCon.toLatin1();
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------------------------------
|
||||
// ------------------------------------------------------ parse Json file -------------------------------
|
||||
// -------------------------------------------------------------------------------------------------
|
||||
|
||||
/*
|
||||
example Json File:
|
||||
{"temperature":28,
|
||||
"snow":"no",
|
||||
"Zeit":"16_21_45",
|
||||
"sunny":"12h",
|
||||
"humidity":75,
|
||||
"wann ":"24.01.2022",
|
||||
"unterstruktur":{
|
||||
"day of week":"tuesday",
|
||||
"year":22,
|
||||
"month":1,
|
||||
"day":24},
|
||||
"fast am":"Ende",
|
||||
"Puffer":[8,3,9,2,10]
|
||||
}
|
||||
*/
|
||||
// first: QByteArray datei_readFromFile(QString filename);
|
||||
|
||||
|
||||
int json_nrOfPairsInFile(QByteArray filename)
|
||||
{
|
||||
QJsonDocument jdoc = QJsonDocument::fromJson(filename);
|
||||
QJsonObject jobj = jdoc.object();
|
||||
|
||||
// key value pair consisting of key (unique string) and value (QJsonValue)
|
||||
int nrOfPairs=jobj.size();
|
||||
|
||||
qDebug() << "my Json file has got: " << nrOfPairs<< "pairs";
|
||||
return nrOfPairs;
|
||||
}
|
||||
|
||||
bool json_exists(QByteArray filename, QString searchForKey)
|
||||
{
|
||||
// look for "searchForKey" =name of the pair (left of : )
|
||||
QJsonDocument jdoc = QJsonDocument::fromJson(filename);
|
||||
QJsonObject jobj = jdoc.object();
|
||||
|
||||
if (jobj.contains(searchForKey))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool json_remove(QByteArray filename, QString searchFor)
|
||||
{
|
||||
// look for "searchFor" =name of the pair (left of : ) and remove the record from file
|
||||
QJsonDocument jdoc = QJsonDocument::fromJson(filename);
|
||||
QJsonObject jobj = jdoc.object();
|
||||
|
||||
if (jobj.contains(searchFor))
|
||||
{
|
||||
jobj.remove(searchFor);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
QString json_searchForStringInFile(QByteArray filename, QString searchFor)
|
||||
{
|
||||
// look for "searchFor" =name of the pair (left of : ) and return value of this pair (right of : ) as String
|
||||
QJsonDocument jdoc = QJsonDocument::fromJson(filename);
|
||||
QJsonObject jobj = jdoc.object();
|
||||
|
||||
if (jobj.contains(searchFor))
|
||||
{
|
||||
return jobj[searchFor].toString(); // toObject(); toArray();
|
||||
} else
|
||||
{
|
||||
//qDebug() << "pairname not found in Json file";
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
int json_searchForIntInFile(QByteArray filename, QString searchFor)
|
||||
{
|
||||
// look for "searchFor" =name of the pair (left of : ) and return value of this pair (right of : ) as String
|
||||
QJsonDocument jdoc = QJsonDocument::fromJson(filename);
|
||||
QJsonObject jobj = jdoc.object();
|
||||
|
||||
if (jobj.contains(searchFor))
|
||||
{
|
||||
return jobj[searchFor].toInt(); // toObject(); toArray();
|
||||
} else
|
||||
{
|
||||
//qDebug() << "number not found in Json file";
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
bool json_searchForObjectInFile(QByteArray filename, QString searchFor, QJsonObject *oneObject)
|
||||
{
|
||||
// return an object from the json file
|
||||
QJsonDocument jdoc = QJsonDocument::fromJson(filename);
|
||||
QJsonObject jobj = jdoc.object();
|
||||
|
||||
if (jobj.contains(searchFor))
|
||||
{
|
||||
*oneObject = jobj[searchFor].toObject();
|
||||
return true;
|
||||
} else
|
||||
{
|
||||
//qDebug() << "Object not found in Json file";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
int json_nrOfPairsInObject(QJsonObject objname)
|
||||
{
|
||||
int nrOfPairs=objname.size();
|
||||
qDebug() << "my Json Object has got: " << nrOfPairs<< "pairs";
|
||||
return nrOfPairs;
|
||||
}
|
||||
|
||||
QString json_searchForStringInObject(QJsonObject objname, QString searchFor)
|
||||
{
|
||||
// look for "searchFor" =name of the pair (left of : ) and return value of this pair (right of : ) as String
|
||||
|
||||
if (objname.contains(searchFor))
|
||||
{
|
||||
return objname[searchFor].toString();
|
||||
} else
|
||||
{
|
||||
//qDebug() << "string not found in Json object";
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
int json_searchForIntInObject(QJsonObject objname, QString searchFor)
|
||||
{
|
||||
// look for "searchFor" =name of the pair (left of : ) and return value of this pair (right of : ) as String
|
||||
|
||||
if (objname.contains(searchFor))
|
||||
{
|
||||
return objname[searchFor].toInt();
|
||||
} else
|
||||
{
|
||||
//qDebug() << "number not found in Json file";
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
bool json_searchForArrayInFile(QByteArray filename, QString searchFor, QJsonArray *oneArray)
|
||||
{
|
||||
// look for "searchFor" =name of the pair (left of : ) and return value of this pair (right of : ) as String
|
||||
QJsonDocument jdoc = QJsonDocument::fromJson(filename);
|
||||
QJsonObject jobj = jdoc.object();
|
||||
|
||||
if (jobj.contains(searchFor))
|
||||
{
|
||||
*oneArray = jobj[searchFor].toArray();
|
||||
return true;
|
||||
} else
|
||||
{
|
||||
//qDebug() << "Array not found in Json file";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
int json_nrOfValuesInArray(QJsonArray arrayname)
|
||||
{
|
||||
int nrOfPairs=arrayname.size();
|
||||
qDebug() << "my Json Array has got: " << nrOfPairs<< "values";
|
||||
return nrOfPairs;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool json_getValuesOfArray(QJsonArray arrayname, int *buf, int MaxBufferSize)
|
||||
{
|
||||
// assuming that the array consists of integers
|
||||
|
||||
/* copy to local buffer:
|
||||
#define MAXNROFARRAYVALUES 100
|
||||
int buf[MAXNROFARRAYVALUES], ii;
|
||||
int nrOfPairs=arrayname.size();
|
||||
|
||||
if (nrOfPairs>MAXNROFARRAYVALUES)
|
||||
nrOfPairs=MAXNROFARRAYVALUES;
|
||||
|
||||
for (ii=0; ii<nrOfPairs; ii++)
|
||||
buf[ii]=arrayname[ii].toInt();
|
||||
*/
|
||||
// copy to host buffer:
|
||||
bool ok=true;
|
||||
int nrOfPairs=arrayname.size();
|
||||
|
||||
if (nrOfPairs>MaxBufferSize)
|
||||
{
|
||||
ok=false; // got not all
|
||||
nrOfPairs=MaxBufferSize;
|
||||
}
|
||||
for (int ii=0; ii<nrOfPairs; ii++)
|
||||
buf[ii]=arrayname[ii].toInt();
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
/*
|
||||
void datei_json_readTestFile(QString filename)
|
||||
{
|
||||
QByteArray my2Ba;
|
||||
QString my2Str;
|
||||
|
||||
my2Str.clear();
|
||||
my2Ba=datei_readFromFile(filename);
|
||||
|
||||
QJsonDocument jdoc = QJsonDocument::fromJson(my2Ba);
|
||||
QJsonObject jobj = jdoc.object();
|
||||
//QJsonParseError jerror;
|
||||
QJsonObject myObj;
|
||||
QJsonArray myArray;
|
||||
|
||||
// key value pair consisting of key (unique string) and value (QJsonValue)
|
||||
int nrOfPairs=jobj.size();
|
||||
qDebug() << "my Json file has got: " << nrOfPairs<< "pairs";
|
||||
|
||||
if (jobj.contains("Zeit"))
|
||||
qDebug() << "my Json file: " << jobj["Zeit"].toString(); // toObject(); toArray();
|
||||
else
|
||||
qDebug() << "my Json file contains no Zeit";
|
||||
|
||||
if (jobj.contains("Humidity"))
|
||||
qDebug() << "my Json file: " << jobj["humidity"].toInt();
|
||||
else
|
||||
qDebug() << "my Json file contains no Humidity";
|
||||
|
||||
if (jobj.contains("month"))
|
||||
qDebug() << "my Json file: " << jobj["month"].toObject(); // anzeige QJsonObject()
|
||||
else
|
||||
qDebug() << "my Json file contains no month";
|
||||
|
||||
|
||||
myObj=jobj["unterstruktur"].toObject();
|
||||
qDebug() << "my unterstruktur: " << myObj["month"].toInt();
|
||||
qDebug() << "my unterstruktur: " << myObj["day of week"].toString();
|
||||
//if (jerror.error == QJsonParseError::NoError)
|
||||
// qDebug() << "no error";
|
||||
|
||||
qDebug() << "my Month: " << myObj["Month"].toInt();
|
||||
//if (myObj["Month"] == QJsonValue::Undefined)
|
||||
// qDebug() << "no found"; geht nicht
|
||||
|
||||
//if (jerror.error != QJsonParseError::NoError)
|
||||
// qDebug() << "no found";
|
||||
|
||||
myArray=jobj["Puffer"].toArray();
|
||||
qDebug() << "my array " <<myArray[2].toInt();
|
||||
//if (jerror.error != QJsonParseError::NoError)
|
||||
// qDebug() << "no found";
|
||||
|
||||
if ( !jobj.contains("Puffer"))
|
||||
qDebug() << "no Puffer found";
|
||||
|
||||
if ( !myArray.contains(20))
|
||||
qDebug() << "no entry found";
|
||||
} */
|
||||
|
||||
|
||||
|
||||
// -------------------------------------------------------------------------------------------------
|
||||
// ------------------------------------------------------ read, write, copy files -------------------
|
||||
// -------------------------------------------------------------------------------------------------
|
||||
|
||||
void datei_closeFile(QString filename)
|
||||
{
|
||||
QFile file(filename);
|
||||
file.close();
|
||||
}
|
||||
|
||||
QByteArray datei_readFromFile(QString filename)
|
||||
{
|
||||
//QFile file("/own/H2B/dc2.hex");
|
||||
//QFile file(FILENAME_STRUCTURE);
|
||||
QFile file;
|
||||
|
||||
file.setFileName(filename);
|
||||
QByteArray myBA;
|
||||
|
||||
myBA.clear();
|
||||
if (!file.exists())
|
||||
{
|
||||
qDebug()<<"file not exists";
|
||||
return myBA;
|
||||
} else
|
||||
{
|
||||
if (!file.open(QIODevice::ReadOnly) )
|
||||
{
|
||||
qDebug()<<"cannot open";
|
||||
|
||||
} else
|
||||
{
|
||||
//qDebug()<<"loading file with " << file.size() <<"byte";
|
||||
myBA = file.readAll();
|
||||
//qDebug()<<"datei read: " << myBA;
|
||||
file.close();
|
||||
}
|
||||
}
|
||||
return myBA;
|
||||
}
|
||||
|
||||
bool datei_ifFileExists(QString filename)
|
||||
{
|
||||
|
||||
QFile file;
|
||||
file.setFileName(filename);
|
||||
|
||||
if (file.exists())
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
char datei_writeToFile(QString filename, QByteArray content)
|
||||
{
|
||||
// retval=0 if successful 1: no write access allowed 2:cannot open to append 3:cannot create new file
|
||||
QFile file(filename);
|
||||
QFileInfo myFI(filename);
|
||||
|
||||
//if (!myFI.isWritable()) //geht nur bei NTFS, weg.
|
||||
//{
|
||||
//file.setPermissions(filename, QFile::WriteOther); geht nicht :(
|
||||
// qDebug()<<"datei_writeToFile: writing not allowed. set attributes first!";
|
||||
// return 1;
|
||||
//}
|
||||
|
||||
if (file.exists())
|
||||
{
|
||||
if (!file.open(QIODevice::Append))
|
||||
{
|
||||
qDebug()<<"datei_writeToFile cannot open to append";
|
||||
return 2;
|
||||
} else
|
||||
{
|
||||
// add new object to the end of the file
|
||||
file.write(content);
|
||||
file.close();
|
||||
return 0; // OK
|
||||
}
|
||||
} else
|
||||
{
|
||||
if (!file.open(QIODevice::WriteOnly))
|
||||
{
|
||||
qDebug()<<"datei_writeToFile cannot open new";
|
||||
return 3;
|
||||
} else
|
||||
{
|
||||
qDebug()<<"create new file";
|
||||
// write first lines into file
|
||||
file.write(content);
|
||||
file.close();
|
||||
return 0; // OK
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool datei_copyFile(QString currentFileName, QString newFileName)
|
||||
{
|
||||
// retval=true if successful
|
||||
QFile file;
|
||||
file.setFileName(currentFileName);
|
||||
return file.copy(newFileName);
|
||||
}
|
||||
|
||||
bool datei_clearFile(QString filename)
|
||||
{
|
||||
// retval=true if successful
|
||||
QFile file;
|
||||
file.setFileName(filename);
|
||||
|
||||
file.remove(); // 3.2.22 erst ganz löschen wegen Schreibrechten
|
||||
if (!file.open(QIODevice::WriteOnly))
|
||||
{
|
||||
qDebug()<<"datei_clearFile cannot open file to delete";
|
||||
return false;
|
||||
} else
|
||||
{
|
||||
file.write(0);
|
||||
file.close();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
209
dCArun/datei.h
Executable file
209
dCArun/datei.h
Executable file
@@ -0,0 +1,209 @@
|
||||
#ifndef DATEI_H
|
||||
#define DATEI_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <QFile>
|
||||
#include <QFileInfo>
|
||||
#include <QDebug>
|
||||
#include "tslib.h"
|
||||
#include <QString>
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonObject>
|
||||
#include <QJsonArray>
|
||||
#include <QJsonParseError>
|
||||
|
||||
// create csv file with:
|
||||
#define FILESEPERATOR ','
|
||||
|
||||
// pasre csv with:
|
||||
#define FILESEP1 ','
|
||||
#define FILESEP2 ';'
|
||||
|
||||
#define NEWLINEINFILE '\n'
|
||||
#define MAXNUMBEROFSEQUENCES 200
|
||||
// only for csv files
|
||||
|
||||
|
||||
// all seting-files located in sudirectory "static machine data - smd"
|
||||
// all generated files located in sudirectory "dynamic machine data - dmd"
|
||||
|
||||
#define FILENAME_COMPORT "../comport.csv"
|
||||
#define FILENAME_CONFIG "/own/work2023/PSA1256ptu5/smd/DC2C_conf.json"
|
||||
#define FILENAME_DEVICE "/own/work2023/PSA1256ptu5/smd/DC2C_device.json"
|
||||
#define FILENAME_CASH "/own/work2023/PSA1256ptu5/smd/DC2C_cash.json"
|
||||
#define FILENAME_PRINT "/own/work2023/PSA1256ptu5/smd/DC2C_print32.json"
|
||||
#define FILENAME_APSERVCONF "../APserviceConfig.csv"
|
||||
|
||||
|
||||
|
||||
// -------------------------------------------------------------------------------------------------
|
||||
// ------------------------------------------------------ create csv file -------------------------------
|
||||
// -------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
// create array with strings and values (to be written to file)
|
||||
void csv_startCreatingFile(void);
|
||||
void csv_addTextToFile(QString myText);
|
||||
void csv_addIntToFile(int myValue);
|
||||
void csv_addUintToFile(uint myValue);
|
||||
void csv_addLongvalToFile(qlonglong myValue);
|
||||
void csv_addUlongvalToFile(qulonglong myValue);
|
||||
//void csv_addCurrentTimeToFile(void);
|
||||
//void csv_addCurrentDateToFile(void);
|
||||
void csv_addNewlineToFile(void);
|
||||
QByteArray csv_readbackArray(void);
|
||||
|
||||
|
||||
// -------------------------------------------------------------------------------------------------
|
||||
// ------------------------------------------------------ parse csv file -------------------------------
|
||||
// -------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
// return number of entries in the just read file (entries are seperated by
|
||||
// comma or line-feed)
|
||||
uint32_t csv_nrOfEntriesInFile(QByteArray readFromFile);
|
||||
|
||||
// before: QByteArray sourceFile=datei_readFromFile(filename);
|
||||
|
||||
QByteArray csv_getOneFileSequence(QByteArray sourceFile, uint32_t sequNr);
|
||||
// not needed, just for test // sequNr: 0....(size-1)
|
||||
|
||||
// get single entries of of the just read fie:
|
||||
int csv_getEntryAsInt(QByteArray sourceFile, uint32_t sequNr);
|
||||
// sequNr: 0....(size-1)
|
||||
|
||||
int32_t csv_getEntryAsLong(QByteArray sourceFile, uint32_t sequNr);
|
||||
// sequNr: 0....(size-1)
|
||||
|
||||
uint8_t csv_getEntryAsUshort(QByteArray sourceFile, uint32_t sequNr);
|
||||
// sequNr: 0....(size-1)
|
||||
|
||||
uint16_t csv_getEntryAsUint(QByteArray sourceFile, uint32_t sequNr);
|
||||
// sequNr: 0....(size-1)
|
||||
|
||||
uint32_t csv_getEntryAsUlong(QByteArray sourceFile, uint32_t sequNr);
|
||||
// sequNr: 0....(size-1)
|
||||
|
||||
uint64_t csv_getEntryAs2Ulong(QByteArray sourceFile, uint32_t sequNr);
|
||||
// sequNr: 0....(size-1)
|
||||
|
||||
QString csv_getEntryAsString(QByteArray sourceFile, uint32_t sequNr);
|
||||
// sequNr: 0....(size-1)
|
||||
|
||||
|
||||
// -------------------------------------------------------------------------------------------------
|
||||
// ------------------------------------------------------ create Json Record -------------------------------
|
||||
// -------------------------------------------------------------------------------------------------
|
||||
|
||||
void json_startRecord(void);
|
||||
// clear buffer and write opening curly bracket {
|
||||
|
||||
void json_enterIntToRecord(QString attribute, ulong i_value);
|
||||
// example: "parameter":1234567890
|
||||
|
||||
void json_enterTextToRecord(QString attribute, QString txt_value);
|
||||
// example: "parameter":"slow"
|
||||
|
||||
//void json_addCurrentTimeToRecord(QString attribute);
|
||||
// example: if attribute=myTime: "myTime":"hh_mm_ss"
|
||||
|
||||
//void json_addCurrentDateToRecord(QString attribute);
|
||||
// example: if attribute=myDate: "myDate":"dd.mm.yyyy"
|
||||
// also / possible as seperator
|
||||
// further possible forms:
|
||||
// format= 0: dd.mm.yyyy (deutsch)
|
||||
// 1: mm.dd.yyyy (amerika)
|
||||
// 2: yyyy.mm.dd (Iran, Dubai)
|
||||
// 3: dd.yyyy.mm
|
||||
// 4: mm.yyyy.dd
|
||||
// 5: yyyy.dd.mm
|
||||
|
||||
void json_enterArrayToRecord(QString attribute, uint8_t *buf, ulong nrofVals);
|
||||
// add array of numbers with "nrofVals" elements
|
||||
|
||||
void json_enterStructToRecord(QString attribute);
|
||||
// every call must be concluded with an extra "json_finishFile()"
|
||||
// example: "sname":{
|
||||
|
||||
void json_finishStruct(void);
|
||||
|
||||
void json_finishRecord(void);
|
||||
// close curly bracket
|
||||
|
||||
|
||||
QString json_readbackRecordStr(void);
|
||||
|
||||
QByteArray json_readbackRecordBa(void);
|
||||
|
||||
|
||||
// -------------------------------------------------------------------------------------------------
|
||||
// ------------------------------------------------------ parse Json file -------------------------------
|
||||
// -------------------------------------------------------------------------------------------------
|
||||
|
||||
// first: QByteArray datei_readFromFile(QString filename);
|
||||
|
||||
//void datei_json_readTestFile(QString filename);
|
||||
|
||||
int json_nrOfPairsInFile(QByteArray filename);
|
||||
|
||||
bool json_exists(QByteArray filename, QString searchForKey);
|
||||
// look for "searchForKey" =name of the pair (left of : )
|
||||
// retval true if exists
|
||||
|
||||
bool json_remove(QByteArray filename, QString searchFor);
|
||||
// look for "searchFor" =name of the pair (left of : ) and remove the record from file
|
||||
// retval true if removed
|
||||
|
||||
QString json_searchForStringInFile(QByteArray filename, QString searchFor);
|
||||
// look for "searchFor" =name of the pair (left of : ) and return value of this pair (right of : ) as String
|
||||
|
||||
int json_searchForIntInFile(QByteArray filename, QString searchFor);
|
||||
// look for "searchFor" =name of the pair (left of : ) and return value of this pair (right of : ) as String
|
||||
|
||||
//.......................
|
||||
|
||||
QJsonObject json_searchForObjectInFile(QByteArray filename, QString searchFor);
|
||||
// return an object from the json file
|
||||
|
||||
int json_nrOfPairsInObject(QJsonObject objname);
|
||||
|
||||
QString json_searchForStringInObject(QJsonObject objname, QString searchFor);
|
||||
// look for "searchFor" =name of the pair (left of : ) and return value of this pair (right of : ) as String
|
||||
|
||||
int json_searchForIntInObject(QJsonObject objname, QString searchFor);
|
||||
// look for "searchFor" =name of the pair (left of : ) and return value of this pair (right of : ) as String
|
||||
|
||||
//.......................
|
||||
|
||||
QJsonArray json_searchForArrayInFile(QByteArray filename, QString searchFor);
|
||||
// look for "searchFor" =name of the pair (left of : ) and return value of this pair (right of : ) as String
|
||||
|
||||
int json_nrOfValuesInArray(QJsonArray arrayname);
|
||||
|
||||
bool json_getValuesOfArray(QJsonArray arrayname, int *buf, int MaxBufferSize);
|
||||
// assuming that the array consists of integers
|
||||
|
||||
|
||||
|
||||
// -------------------------------------------------------------------------------------------------
|
||||
// ------------------------------------------------------ read, write, copy files -------------------
|
||||
// -------------------------------------------------------------------------------------------------
|
||||
|
||||
void datei_closeFile(QString filename);
|
||||
|
||||
// read content of an exiting file:
|
||||
QByteArray datei_readFromFile(QString filename);
|
||||
|
||||
bool datei_ifFileExists(QString filename);
|
||||
|
||||
char datei_writeToFile(QString filename, QByteArray content);
|
||||
// retval=0 if successful 1: no write access allowed
|
||||
// 2:cannot open to append 3:cannot create new file
|
||||
|
||||
bool datei_copyFile(QString currentFileName, QString newFileName);
|
||||
// retval=true if successful
|
||||
|
||||
bool datei_clearFile(QString filename);
|
||||
// retval=true if successful
|
||||
|
||||
#endif // DATEI_H
|
24
dCArun/guidefs.h
Executable file
24
dCArun/guidefs.h
Executable file
@@ -0,0 +1,24 @@
|
||||
#ifndef GUIDEFS_H
|
||||
#define GUIDEFS_H
|
||||
|
||||
#define PIXELSIZE_BUTTONS 18
|
||||
#define PIXELSIZE_LABEL 18
|
||||
#define PIXELSIZE_DATA 16
|
||||
|
||||
#define PIXELSIZE_BIGFONT 22
|
||||
#define PIXELSIZE_SMALLFONT 14
|
||||
|
||||
#define BUTTONCOLOR "background-color: rgb(150,250,150)"
|
||||
|
||||
#define COLORGREEN "background-color: rgb(160,250,190)"
|
||||
#define COLOR_RED "background-color: rgb(150,0,0)"
|
||||
#define COLOR_LIGHTRED "background-color: rgb(250,150,150)"
|
||||
//#define COLORGREY "background-color: rgb(160,250,190)"
|
||||
#define COLORGREY "background-color: grey"
|
||||
#define COLORYELLOW "background-color: yellow"
|
||||
#define COLORWHITE "background-color: white"
|
||||
|
||||
// "background-color: lightgrey"
|
||||
|
||||
|
||||
#endif
|
43
dCArun/main.cpp
Executable file
43
dCArun/main.cpp
Executable file
@@ -0,0 +1,43 @@
|
||||
#include "mainwindow.h"
|
||||
//#include "message_handler.h"
|
||||
#include <QApplication>
|
||||
|
||||
int thisisglobal;
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int ret;
|
||||
QApplication myapp(argc, argv);
|
||||
QApplication::setApplicationName("CArunGui");
|
||||
QApplication::setApplicationVersion(APP_VERSION);
|
||||
|
||||
/*
|
||||
if (!messageHandlerInstalled()) { // change internal qt-QDebug-handling
|
||||
atbInstallMessageHandler(atbDebugOutput);
|
||||
setDebugLevel(QtMsgType::QtDebugMsg);
|
||||
//setDebugLevel(QtMsgType::QtDebugMsg);
|
||||
}
|
||||
*/
|
||||
MainWindow myMainWin;
|
||||
QSize myMainSize={800, 480}; // breite, höhe, PTU: 800x440
|
||||
myMainWin.setMinimumSize(myMainSize);
|
||||
myMainWin.setMaximumSize(myMainSize);
|
||||
myMainWin.setWindowTitle("CArun_V4.2 run cash agent master lib");
|
||||
//myMainWin.show();
|
||||
|
||||
ret=myapp.exec();
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//QApplication a(argc, argv);
|
||||
//MainWindow CatMW;
|
||||
//QSize myMainSize={800, 480}; // breite, höhe
|
||||
//CatMW.setMinimumSize(myMainSize);
|
||||
//CatMW.setMaximumSize(myMainSize);
|
||||
//CatMW.setWindowTitle("ATB CashAgent V2.0");
|
||||
// QPalette mainPal;
|
||||
// mainPal.setColor(QPalette::Window, Qt::red );
|
||||
// CatMW.setPalette(mainPal); sieht man nicht mehr
|
438
dCArun/mainwindow.cpp
Executable file
438
dCArun/mainwindow.cpp
Executable file
@@ -0,0 +1,438 @@
|
||||
#include "mainwindow.h"
|
||||
|
||||
char MainWindow::loadPlugIn(char lade1_entlade2)
|
||||
{
|
||||
plugInDir.cd("plugins");
|
||||
QPluginLoader *pluginLoader = new QPluginLoader();
|
||||
|
||||
// select system:
|
||||
//pluginLoader->setFileName("../MasterPlug/libCAmaster.so"); // for suse
|
||||
//pluginLoader->setFileName("../SlavePlug/libCAslave.so"); // for ptu5
|
||||
//pluginLoader->setFileName("../../MasterPlug/CAmaster.dll"); // for windows
|
||||
pluginLoader->setFileName("CAmaster.dll"); // for windows
|
||||
|
||||
if (lade1_entlade2==2)
|
||||
{
|
||||
pluginLoader->unload();
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!pluginLoader->load())
|
||||
{
|
||||
qDebug()<<"cannot load plugin";
|
||||
} else
|
||||
qDebug() <<"loaded plugin: " << pluginLoader->fileName();
|
||||
|
||||
if (!pluginLoader->isLoaded())
|
||||
{
|
||||
qDebug()<<pluginLoader->errorString();
|
||||
return 0;
|
||||
}
|
||||
|
||||
QObject *plugin = pluginLoader->instance();
|
||||
if ( plugin == nullptr)
|
||||
{
|
||||
// make instance of the root component (which can hold more then one clases)
|
||||
// also loads the lib if not yet done
|
||||
qDebug()<<"cannot start instance";
|
||||
return 0;
|
||||
}
|
||||
|
||||
//int rr=hwapi->giveVal(2); funktioniert :))
|
||||
//qDebug()<<"got value from plugin"<<rr; funktioniert :))
|
||||
// aber besser globaler pointer:
|
||||
// im h-file
|
||||
// hwinf *hwapi=nullptr; // pointer to plugin-class
|
||||
|
||||
HWaccess= qobject_cast<hwinf *>(plugin);
|
||||
// make instance to class "hwinf" in dll_HWapi.h over "interfaces.h"
|
||||
|
||||
qDebug()<<"loadPlugIn, HWAccess: " << HWaccess;
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#define WINCTRMIN 0
|
||||
// 0 is always the home screen
|
||||
|
||||
#define WINCTRMAX 30
|
||||
// number of needed application screens, up to 255
|
||||
// All screens must be defined below in mainwindow-class first before increasing the nr
|
||||
// numbers must be consecutively from 0 always, 0 is the home screen always
|
||||
|
||||
#define FORMWIDTH 725
|
||||
//#define FORMWIDTH 690
|
||||
// this width is the same for ALL windows
|
||||
|
||||
#define FORMHEIGHT 440
|
||||
// this height is the same for ALL windows
|
||||
|
||||
#define NAVIBUTTONHEIGHT 70
|
||||
#define NAVIBUTTONWIDHT 50
|
||||
|
||||
#define HOMEPAGE_BACKGROUND_COLOR "background-color: lightgrey"
|
||||
|
||||
#define BUTTON_COLOR "background-color: rgb(160,250,190)"
|
||||
|
||||
#define ACTIVE_NAVI_COLOR "background-color: rgb(160,250,190)"
|
||||
#define DISABL_NAVI_COLOR "background-color: grey"
|
||||
|
||||
#define APPPAGE_BACKGROUND_COLOR "background-color: lightgrey"
|
||||
|
||||
#define UPDATE_PERIOD_MS 100
|
||||
// period to call chain steps
|
||||
|
||||
#define VENDINGTIMEOUT_MS 30000
|
||||
// after this time without any operation the program returns to idle state
|
||||
// time in ms, that means 30.000 gives 30seconds
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent)
|
||||
{
|
||||
loadPlugIn(1);
|
||||
|
||||
// define all working moduls (besides gui) here, call ini and working in chainControl() (~Line 1000)
|
||||
//mifCard = new T_Mifare(HWaccess); // ganz wichtig: HWaccess an sub-Konstruktor übergeben
|
||||
// sonst crash bei HW-Zugriff!!!!
|
||||
//diary = new T_lib_diary(); absturz!!!!!!
|
||||
//conf = new T_lib_config(HWaccess);
|
||||
|
||||
timerChainCtrl = new QTimer(this);
|
||||
connect(timerChainCtrl, SIGNAL(timeout()), this, SLOT(chainControl()));
|
||||
timerChainCtrl->setSingleShot(0);
|
||||
timerChainCtrl->start(UPDATE_PERIOD_MS); // 1000: call every 1000ms
|
||||
|
||||
timerVendingTimeout = new QTimer(this);
|
||||
connect(timerVendingTimeout, SIGNAL(timeout()), this, SLOT(vendingTimeout()));
|
||||
timerVendingTimeout->setSingleShot(true);
|
||||
timerVendingTimeout->start(VENDINGTIMEOUT_MS); // in ms
|
||||
|
||||
// ##########################################################################################
|
||||
// für jedes anzuzeigende Fenster eine eigene Groupbox mit eigenem Grid anlegen:
|
||||
|
||||
frame01 = new QGroupBox;
|
||||
frame01->setStyleSheet(APPPAGE_BACKGROUND_COLOR);
|
||||
frame01->setMinimumSize(FORMWIDTH,FORMHEIGHT);
|
||||
QVBoxLayout *smallLay01 = new QVBoxLayout;
|
||||
frame01->setLayout(smallLay01);
|
||||
// Fensterinhalt aus externer Klasse einfügen:
|
||||
myFenster01 = new T_winComPort(HWaccess); // HWaccess damit auf das HW-Plugin zugegriffen werden kann, sonst crash
|
||||
smallLay01->addWidget(myFenster01);
|
||||
|
||||
// ##########################################################################################
|
||||
// draw Mainwindow:
|
||||
bigGroupbox = new QGroupBox;
|
||||
bigGroupbox->setStyleSheet("background-color: grey");
|
||||
bigGroupbox->setMinimumSize(800,480);
|
||||
// bigLayout = new QVBoxLayout; // navi buttons on bottom side
|
||||
bigLayout = new QHBoxLayout; // navi buttons right hand
|
||||
|
||||
// ##########################################################################################
|
||||
// add all windows (but display only one)
|
||||
// display only one: then all windows are shown at the same place
|
||||
// display more then one: the windows are listed in vertical order
|
||||
|
||||
bigLayout->addWidget(frame01);
|
||||
|
||||
bigGroupbox->setLayout(bigLayout);
|
||||
switchScreen(1);
|
||||
//HideAllWindows();
|
||||
|
||||
// ##########################################################################################
|
||||
// Steuer Leiste
|
||||
|
||||
//QHBoxLayout *ButtonLayout = new QHBoxLayout();
|
||||
QVBoxLayout *ButtonLayout = new QVBoxLayout();
|
||||
QFont myTabFont;
|
||||
myTabFont.setPixelSize(26);
|
||||
|
||||
pBback = new QPushButton("<"); //b\na\nc\nk");
|
||||
pBback->setFont(myTabFont);
|
||||
pBback->setStyleSheet(ACTIVE_NAVI_COLOR);
|
||||
pBback->setMinimumHeight(NAVIBUTTONHEIGHT);
|
||||
pBback->setMaximumWidth(NAVIBUTTONWIDHT);
|
||||
connect(pBback, SIGNAL( clicked() ), myFenster01, SLOT( Nav_back()));
|
||||
|
||||
myTabFont.setPixelSize(22);
|
||||
pBhome = new QPushButton("<<"); //h\no\nm\ne");
|
||||
pBhome->setFont(myTabFont);
|
||||
pBhome->setStyleSheet(ACTIVE_NAVI_COLOR);
|
||||
pBhome->setMinimumHeight(NAVIBUTTONHEIGHT);
|
||||
pBhome->setMaximumWidth(NAVIBUTTONWIDHT);
|
||||
connect(pBhome, SIGNAL( clicked() ), myFenster01, SLOT( Nav_home()));
|
||||
|
||||
myTabFont.setPixelSize(26);
|
||||
pBforward = new QPushButton(">"); //n\ne\nx\nt");
|
||||
pBforward->setFont(myTabFont);
|
||||
pBforward->setStyleSheet(ACTIVE_NAVI_COLOR);
|
||||
pBforward->setMinimumHeight(NAVIBUTTONHEIGHT);
|
||||
pBforward->setMaximumWidth(NAVIBUTTONWIDHT);
|
||||
connect(pBforward, SIGNAL( clicked() ), myFenster01, SLOT( Nav_next()));
|
||||
|
||||
QLabel *buttonSpace = new QLabel(" ");
|
||||
ButtonLayout->addWidget(pBback);
|
||||
ButtonLayout->addWidget(buttonSpace);
|
||||
//ButtonLayout->addWidget(buttonSpace);
|
||||
ButtonLayout->addWidget(pBhome);
|
||||
ButtonLayout->addWidget(buttonSpace);
|
||||
//ButtonLayout->addWidget(buttonSpace);
|
||||
ButtonLayout->addWidget(pBforward);
|
||||
QLabel *bottomSpace = new QLabel(" ");
|
||||
ButtonLayout->addWidget(bottomSpace);
|
||||
|
||||
bigLayout->addLayout(ButtonLayout);
|
||||
|
||||
setCentralWidget(bigGroupbox);
|
||||
|
||||
// AUTOSTART serial transmission
|
||||
//HWaccess->dc_openSerial(5,"115200","ttyS0",1); // my suse computer
|
||||
//HWaccess->dc_openSerial(1,"9600","COM5",1); // my suse computer
|
||||
//HWaccess->dc_openSerial(5,"115200","ttymxc2",1); // ptu5
|
||||
//HWaccess->dc_autoRequest(true);
|
||||
//myFenster01->setButtons4autoStart();
|
||||
//HWaccess->alarm_switchSiren(0); // test
|
||||
|
||||
enableNaviButtons(BACKBUTTON,true);
|
||||
enableNaviButtons(HOMEBUTTON,true);
|
||||
enableNaviButtons(FORWBUTTON,true);
|
||||
this->chainIni();
|
||||
|
||||
//connect(myFenster02, SIGNAL(quitMyApp()), this, SLOT(close()));
|
||||
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
{
|
||||
loadPlugIn(2);
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::HideAllWindows()
|
||||
{
|
||||
// vorsicht: Fenster muss oben definiert sein sonst Programmabsturz ohne Kommentar
|
||||
|
||||
frame01->setEnabled(false);
|
||||
frame01->setVisible(false);
|
||||
}
|
||||
|
||||
|
||||
// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
// Call Windows
|
||||
// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
void MainWindow::switchScreen(uint16_t winNr) // 0...30
|
||||
{
|
||||
|
||||
HideAllWindows();
|
||||
//qDebug()<<"switch screen to " << winNr;
|
||||
|
||||
switch (winNr)
|
||||
{
|
||||
case 1:
|
||||
frame01->setEnabled(true);
|
||||
frame01->setVisible(true);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
// Navigation buttons
|
||||
// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
void MainWindow::enableNaviButtons(uint8_t switchBitwise)
|
||||
{
|
||||
// switchBitwise=0: no change
|
||||
// bit0,1: enable/disable button "next"
|
||||
// bit2,3: enable/disable button "home"
|
||||
// bit4,5: enable/disable button "back"
|
||||
|
||||
if (switchBitwise &1)
|
||||
{
|
||||
pBforward->setStyleSheet(ACTIVE_NAVI_COLOR);
|
||||
//pBforward->setText("next");
|
||||
pBforward->setEnabled(true);
|
||||
} else
|
||||
if (switchBitwise &2)
|
||||
{
|
||||
pBforward->setStyleSheet(DISABL_NAVI_COLOR);
|
||||
//pBforward->setText(" ");
|
||||
pBforward->setEnabled(false);
|
||||
}
|
||||
|
||||
if (switchBitwise &4)
|
||||
{
|
||||
pBhome->setStyleSheet(ACTIVE_NAVI_COLOR);
|
||||
//pBhome->setText("home");
|
||||
pBhome->setEnabled(true);
|
||||
} else
|
||||
if (switchBitwise &8)
|
||||
{
|
||||
pBhome->setStyleSheet(DISABL_NAVI_COLOR);
|
||||
//pBhome->setText(" ");
|
||||
pBhome->setEnabled(false);
|
||||
}
|
||||
|
||||
if (switchBitwise &16)
|
||||
{
|
||||
pBback->setStyleSheet(ACTIVE_NAVI_COLOR);
|
||||
//pBback->setText("back");
|
||||
pBback->setEnabled(true);
|
||||
} else
|
||||
if (switchBitwise &32)
|
||||
{
|
||||
pBback->setStyleSheet(DISABL_NAVI_COLOR);
|
||||
//pBback->setText(" ");
|
||||
pBback->setEnabled(false);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
void MainWindow::enableNaviButtons(uint8_t buttonNr, bool enabled)
|
||||
{
|
||||
if (buttonNr==1)
|
||||
{
|
||||
if (enabled)
|
||||
{
|
||||
pBback->setStyleSheet(ACTIVE_NAVI_COLOR);
|
||||
//pBback->setText("back");
|
||||
pBback->setEnabled(true);
|
||||
} else
|
||||
{
|
||||
pBback->setStyleSheet(DISABL_NAVI_COLOR);
|
||||
//pBback->setText(" ");
|
||||
pBback->setEnabled(false);
|
||||
}
|
||||
} else
|
||||
if (buttonNr==2)
|
||||
{
|
||||
if (enabled)
|
||||
{
|
||||
pBhome->setStyleSheet(ACTIVE_NAVI_COLOR);
|
||||
//pBhome->setText("home");
|
||||
pBhome->setEnabled(true);
|
||||
} else
|
||||
{
|
||||
pBhome->setStyleSheet(DISABL_NAVI_COLOR);
|
||||
//pBhome->setText(" ");
|
||||
pBhome->setEnabled(false);
|
||||
}
|
||||
} else
|
||||
if (buttonNr==3)
|
||||
{
|
||||
if (enabled)
|
||||
{
|
||||
pBforward->setStyleSheet(ACTIVE_NAVI_COLOR);
|
||||
//pBforward->setText("next");
|
||||
pBforward->setEnabled(true);
|
||||
} else
|
||||
{
|
||||
pBforward->setStyleSheet(DISABL_NAVI_COLOR);
|
||||
//pBforward->setText(" ");
|
||||
pBforward->setEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
// control work flow by Finite state machine
|
||||
// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
static uint16_t chainCurrentStep, chainNextStep;
|
||||
static bool chain_stepIni;
|
||||
|
||||
void MainWindow::chainIni(void)
|
||||
{
|
||||
// called once after power-up by constructor
|
||||
chainCurrentStep=WCS_STARTSCREEN; // start screen
|
||||
chainNextStep=chainCurrentStep;
|
||||
switchScreen(chainCurrentStep);
|
||||
chain_stepIni=true;
|
||||
//qDebug()<<"chain ini, call step "<<WCS_STARTUP << " " << chainCurrentStep;
|
||||
}
|
||||
|
||||
void MainWindow::chainControl(void)
|
||||
{
|
||||
|
||||
uint16_t nextScreen=0;
|
||||
uint8_t useNavi=0;
|
||||
bool busy=false;
|
||||
// working step chain:
|
||||
if (chainCurrentStep != chainNextStep)
|
||||
{
|
||||
if (chainNextStep!=WCS_STARTSCREEN)
|
||||
{
|
||||
timerVendingTimeout->stop();
|
||||
timerVendingTimeout->start(VENDINGTIMEOUT_MS);
|
||||
}
|
||||
//qDebug()<<"found new sreen";
|
||||
chainCurrentStep=chainNextStep;
|
||||
switchScreen(chainCurrentStep);
|
||||
chain_stepIni=true;
|
||||
|
||||
}
|
||||
|
||||
if (chainCurrentStep==1)
|
||||
{
|
||||
if (chain_stepIni)
|
||||
busy=myFenster01->work_ini(&nextScreen, &useNavi);
|
||||
else
|
||||
busy=myFenster01->working(&nextScreen, &useNavi);
|
||||
} else
|
||||
|
||||
{
|
||||
// error undefined step
|
||||
qDebug()<<"error main chain control, wrong step ("<<chainCurrentStep<<") selected";
|
||||
|
||||
}
|
||||
|
||||
if (chain_stepIni)
|
||||
{
|
||||
chain_stepIni=false;
|
||||
switchScreen(chainCurrentStep); // the mainWindow frame has always the same number as the working step
|
||||
}
|
||||
|
||||
if (nextScreen>0)
|
||||
{
|
||||
// call next chain step
|
||||
//qDebug()<<"chain control: new step selected: "<< nextScreen;
|
||||
|
||||
chainNextStep=nextScreen;
|
||||
}
|
||||
if (useNavi>0)
|
||||
{
|
||||
//qDebug()<<"chain control: navi buttons "<< useNavi;
|
||||
enableNaviButtons(useNavi);
|
||||
}
|
||||
|
||||
if (busy>0)
|
||||
{
|
||||
// reset time-out
|
||||
timerVendingTimeout->start();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
void MainWindow::vendingTimeout(void)
|
||||
{
|
||||
// there was no user operation for 30s so return to start screen
|
||||
// uint16_t nextScreen=WCS_STARTSCREEN;
|
||||
// chainNextStep=nextScreen; erstmal stilllegen, stört bei IBN
|
||||
//qDebug()<<"chain control: vending TO";
|
||||
timerVendingTimeout->stop();
|
||||
}
|
||||
|
||||
|
||||
|
72
dCArun/mainwindow.h
Executable file
72
dCArun/mainwindow.h
Executable file
@@ -0,0 +1,72 @@
|
||||
#ifndef MAINWINDOW_H
|
||||
#define MAINWINDOW_H
|
||||
|
||||
#include <QMainWindow>
|
||||
#include <QTimer>
|
||||
#include <QGroupBox>
|
||||
#include <QStyle>
|
||||
#include <QVBoxLayout>
|
||||
#include <QHBoxLayout>
|
||||
#include <QGridLayout>
|
||||
#include <QLabel>
|
||||
#include <QDebug>
|
||||
#include <QPushButton>
|
||||
#include <QDialog>
|
||||
#include <QWidget>
|
||||
#include <QApplication>
|
||||
#include <QObject>
|
||||
#include <QDateTime>
|
||||
#include <QDate>
|
||||
#include <QTime>
|
||||
|
||||
#include <QPluginLoader>
|
||||
#include <QDir>
|
||||
#include "plugin.h"
|
||||
#include "stepList.h"
|
||||
//#include "stepList.h" // define all working chain steps here
|
||||
#include "win01_com.h"
|
||||
|
||||
|
||||
class MainWindow : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
QPushButton *pBback;
|
||||
QPushButton *pBhome;
|
||||
QPushButton *pBforward;
|
||||
QGroupBox *bigGroupbox;
|
||||
QHBoxLayout *bigLayout;
|
||||
QTimer *timerChainCtrl;
|
||||
QTimer *timerVendingTimeout;
|
||||
|
||||
QGroupBox *frame01;
|
||||
T_winComPort *myFenster01;
|
||||
|
||||
void HideAllWindows();
|
||||
void switchScreen(uint16_t winNr);
|
||||
char loadPlugIn(char lade1_entlade2);
|
||||
QDir plugInDir;
|
||||
void chainIni(void);
|
||||
|
||||
public:
|
||||
hwinf *HWaccess=nullptr; // global pointer to plugin-class
|
||||
|
||||
MainWindow(QWidget *parent = nullptr);
|
||||
~MainWindow();
|
||||
|
||||
#define BACKBUTTON 1
|
||||
#define HOMEBUTTON 2
|
||||
#define FORWBUTTON 3
|
||||
void enableNaviButtons(uint8_t buttonNr, bool enabled);
|
||||
void enableNaviButtons(uint8_t switchBitwise);
|
||||
|
||||
private slots:
|
||||
void chainControl();
|
||||
void vendingTimeout();
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // MAINWINDOW_H
|
5
dCArun/plugin.h
Executable file
5
dCArun/plugin.h
Executable file
@@ -0,0 +1,5 @@
|
||||
#ifndef PLUGIN_H
|
||||
#define PLUGIN_H
|
||||
#include "interfaces.h"
|
||||
|
||||
#endif
|
210
dCArun/stepList.h
Executable file
210
dCArun/stepList.h
Executable file
@@ -0,0 +1,210 @@
|
||||
#ifndef STEPLIST_H
|
||||
#define STEPLIST_H
|
||||
|
||||
|
||||
// define all working chain steps
|
||||
// every FSM-Step get's a frame in MainWindow with the same number and a self-designed GUI
|
||||
// labels are used for switchScreen( label=nr );
|
||||
// numbers are important: e.g. number 3 calls frame3 and frame3 includes subClass "T_fenster03"
|
||||
// so best solution: label = same name like class (in example: Fenster03). Label is fixed bound to number, never change!
|
||||
|
||||
// numbers are fixed assosiated with the function (e.g. ComPort), can't be changed.
|
||||
// but screen order can be called in step chain randomly
|
||||
|
||||
|
||||
// Windownumbers for certain function, never change
|
||||
#define PAGE_COMPORT 1
|
||||
#define PAGE_SERVICEMAIN 2
|
||||
#define PAGE_TIMEDATEVERSION 3
|
||||
#define PAGE_MACHINESTATUS 4
|
||||
#define PAGE_CHECKDOORS 5
|
||||
#define PAGE_PRINTER 6
|
||||
#define PAGE_COINMECHANIC 7
|
||||
#define PAGE_MIFARE 8
|
||||
#define PAGE_MODEM 9
|
||||
#define PAGE_COINPAYMENT 10
|
||||
#define PAGE_VAULTRECORD 11
|
||||
#define PAGE_BOOTLOADER 12
|
||||
#define PAGE_PROG_JSON 13
|
||||
#define PAGE_COINCHANGER 14
|
||||
#define PAGE_BILLREADER 15
|
||||
#define PAGE_NEXT16 16
|
||||
#define PAGE_NEXT17 17
|
||||
#define PAGE_NEXT18 18
|
||||
#define PAGE_NEXT19 19
|
||||
#define PAGE_NEXT20 20
|
||||
|
||||
// fix: customize:
|
||||
#define WCS_STARTSCREEN PAGE_COMPORT
|
||||
|
||||
// PAGE_COMPORT:
|
||||
#define WCS_WIN01BAK PAGE_COMPORT
|
||||
#define WCS_WIN01MID PAGE_SERVICEMAIN
|
||||
#define WCS_WIN01FWD PAGE_SERVICEMAIN
|
||||
|
||||
// PAGE_SERVICEMAIN:
|
||||
#define WCS_WIN02BAK PAGE_COMPORT
|
||||
#define WCS_WIN02MID PAGE_SERVICEMAIN
|
||||
#define WCS_WIN02FWD PAGE_TIMEDATEVERSION
|
||||
|
||||
// PAGE_TIMEDATEVERSION:
|
||||
#define WCS_WIN03BAK PAGE_SERVICEMAIN
|
||||
#define WCS_WIN03MID PAGE_SERVICEMAIN
|
||||
#define WCS_WIN03FWD PAGE_MACHINESTATUS
|
||||
|
||||
// PAGE_MACHINESTATUS:
|
||||
#define WCS_WIN04BAK PAGE_TIMEDATEVERSION
|
||||
#define WCS_WIN04MID PAGE_SERVICEMAIN
|
||||
#define WCS_WIN04FWD PAGE_CHECKDOORS
|
||||
|
||||
|
||||
// PAGE_CHECKDOORS:
|
||||
#define WCS_WIN05BAK PAGE_MACHINESTATUS
|
||||
#define WCS_WIN05MID PAGE_SERVICEMAIN
|
||||
#define WCS_WIN05FWD PAGE_COINMECHANIC
|
||||
|
||||
// PAGE_COINMECHANIC:
|
||||
#define WCS_WIN07BAK PAGE_CHECKDOORS
|
||||
#define WCS_WIN07MID PAGE_SERVICEMAIN
|
||||
#define WCS_WIN07FWD PAGE_COINPAYMENT
|
||||
|
||||
// PAGE_COINPAYMENT:
|
||||
#define WCS_WIN10BAK PAGE_COINMECHANIC
|
||||
#define WCS_WIN10MID PAGE_SERVICEMAIN
|
||||
#define WCS_WIN10FWD PAGE_COINCHANGER
|
||||
|
||||
// PAGE_COINCHANGER:
|
||||
#define WCS_WIN14BAK PAGE_COINPAYMENT
|
||||
#define WCS_WIN14MID PAGE_SERVICEMAIN
|
||||
#define WCS_WIN14FWD PAGE_BILLREADER
|
||||
|
||||
|
||||
// PAGE_BILLREADER:
|
||||
#define WCS_WIN15BAK PAGE_COINCHANGER
|
||||
#define WCS_WIN15MID PAGE_SERVICEMAIN
|
||||
#define WCS_WIN15FWD PAGE_PRINTER
|
||||
|
||||
// PAGE_PRINTER:
|
||||
#define WCS_WIN06BAK PAGE_BILLREADER
|
||||
#define WCS_WIN06MID PAGE_SERVICEMAIN
|
||||
#define WCS_WIN06FWD PAGE_MIFARE
|
||||
|
||||
// PAGE_MIFARE:
|
||||
#define WCS_WIN08BAK PAGE_PRINTER
|
||||
#define WCS_WIN08MID PAGE_SERVICEMAIN
|
||||
#define WCS_WIN08FWD PAGE_MODEM
|
||||
|
||||
// PAGE_MODEM:
|
||||
#define WCS_WIN09BAK PAGE_MIFARE
|
||||
#define WCS_WIN09MID PAGE_SERVICEMAIN
|
||||
#define WCS_WIN09FWD PAGE_VAULTRECORD
|
||||
|
||||
|
||||
// PAGE_VAULTRECORD:
|
||||
#define WCS_WIN11BAK PAGE_MODEM
|
||||
#define WCS_WIN11MID PAGE_SERVICEMAIN
|
||||
#define WCS_WIN11FWD PAGE_PROG_JSON
|
||||
|
||||
// PAGE_PROG_JSON:
|
||||
#define WCS_WIN13BAK PAGE_VAULTRECORD
|
||||
#define WCS_WIN13MID PAGE_SERVICEMAIN
|
||||
#define WCS_WIN13FWD PAGE_BOOTLOADER
|
||||
|
||||
// PAGE_BOOTLOADER:
|
||||
#define WCS_WIN12BAK PAGE_PROG_JSON
|
||||
#define WCS_WIN12MID PAGE_SERVICEMAIN
|
||||
#define WCS_WIN12FWD PAGE_NEXT16
|
||||
|
||||
|
||||
// PAGE_NEXT16
|
||||
#define WCS_WIN16BAK PAGE_BOOTLOADER
|
||||
#define WCS_WIN16MID PAGE_SERVICEMAIN
|
||||
#define WCS_WIN16FWD PAGE_NEXT17
|
||||
|
||||
// PAGE_NEXT17
|
||||
#define WCS_WIN17BAK PAGE_NEXT16
|
||||
#define WCS_WIN17MID PAGE_SERVICEMAIN
|
||||
#define WCS_WIN17FWD PAGE_NEXT18
|
||||
|
||||
// PAGE_NEXT18
|
||||
#define WCS_WIN18BAK PAGE_NEXT17
|
||||
#define WCS_WIN18MID PAGE_SERVICEMAIN
|
||||
#define WCS_WIN18FWD PAGE_NEXT19
|
||||
|
||||
// PAGE_NEXT19
|
||||
#define WCS_WIN19BAK PAGE_NEXT18
|
||||
#define WCS_WIN19MID PAGE_SERVICEMAIN
|
||||
#define WCS_WIN19FWD PAGE_NEXT20
|
||||
|
||||
// PAGE_NEXT20
|
||||
#define WCS_WIN20BAK PAGE_NEXT19
|
||||
#define WCS_WIN20MID PAGE_SERVICEMAIN
|
||||
#define WCS_WIN20FWD PAGE_SERVICEMAIN
|
||||
|
||||
// just for Template
|
||||
#define WCS_WIN99BAK PAGE_SERVICEMAIN
|
||||
#define WCS_WIN99MID PAGE_SERVICEMAIN
|
||||
#define WCS_WIN99FWD PAGE_SERVICEMAIN
|
||||
|
||||
|
||||
|
||||
#define WIN02_LABEL_SHORT01 " Status"
|
||||
#define WCS_WIN02SHORT01 PAGE_MACHINESTATUS
|
||||
#define WIN02_LABEL_SHORT02 " Doors "
|
||||
#define WCS_WIN02SHORT02 PAGE_CHECKDOORS
|
||||
#define WIN02_LABEL_SHORT03 "Coin mech"
|
||||
#define WCS_WIN02SHORT03 PAGE_COINMECHANIC
|
||||
#define WIN02_LABEL_SHORT04 "Payment"
|
||||
#define WCS_WIN02SHORT04 PAGE_COINPAYMENT
|
||||
|
||||
#define WIN02_LABEL_SHORT05 "Changer"
|
||||
#define WCS_WIN02SHORT05 PAGE_COINCHANGER
|
||||
#define WIN02_LABEL_SHORT06 " Bill "
|
||||
#define WCS_WIN02SHORT06 PAGE_BILLREADER
|
||||
#define WIN02_LABEL_SHORT07 "Printer"
|
||||
#define WCS_WIN02SHORT07 PAGE_PRINTER
|
||||
|
||||
#define WIN02_LABEL_SHORT08 "Program"
|
||||
#define WCS_WIN02SHORT08 PAGE_VAULTRECORD
|
||||
#define WIN02_LABEL_SHORT09 " "
|
||||
#define WCS_WIN02SHORT09 PAGE_SERVICEMAIN
|
||||
#define WIN02_LABEL_SHORT10 " "
|
||||
#define WCS_WIN02SHORT10 PAGE_SERVICEMAIN
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// set needed navigation buttons, use | to combine more then one:
|
||||
#define SWITCH_NEXT_ON 1
|
||||
#define SWITCH_NEXT_OFF 2
|
||||
#define SWITCH_HOME_ON 4
|
||||
#define SWITCH_HOME_OFF 8
|
||||
#define SWITCH_BACK_ON 16
|
||||
#define SWITCH_BACK_OFF 32
|
||||
// example: *useNavi=SWITCH_BACK_ON; // change only this one, or set all:
|
||||
// *useNavi=SWITCH_BACK_OFF | SWITCH_HOME_OFF | SWITCH_NEXT_ON;
|
||||
|
||||
|
||||
|
||||
// some defines for Widget design:
|
||||
|
||||
#define TS_VALUEBOX_FRAMESTYLE 0x0032
|
||||
#define TS_VALUEBOX_LINEWIDTH 3
|
||||
|
||||
//genDatPort->setFrameStyle(QFrame::Panel | QFrame::Sunken ); funktioniert aber gibt unverständliche Warnung
|
||||
// QFrame::Panel = 0x0002 QFrame::Sunken=0x0030
|
||||
//genDatPort->setFrameStyle(0x0032); // funktioniert und gibt keine Warnung
|
||||
//genDatPort->setFrameStyle(TS_VALUEBOX_FRAMESTYLE); // funktioniert und gibt keine Warnung
|
||||
|
||||
#define TS_LED_FRAMESTYLE 0x0031
|
||||
// QFrame::Box | QFrame::Sunken
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // STEPLIST_H
|
267
dCArun/subwindows.cpp
Executable file
267
dCArun/subwindows.cpp
Executable file
@@ -0,0 +1,267 @@
|
||||
#include "subwindows.h"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
|
||||
// %%%%%%%%%%%%%%%%%%%% TabChanger
|
||||
|
||||
T_fenster12::T_fenster12(hwinf *HWaccess, QWidget *parent) : QWidget(parent)
|
||||
{
|
||||
QGridLayout *myLayout = new QGridLayout();
|
||||
QLabel *Lab1 = new QLabel("Coin Changer");
|
||||
myLayout->addWidget(Lab1,1,1);
|
||||
setLayout(myLayout);
|
||||
}
|
||||
|
||||
void T_fenster12::updateGui(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
// %%%%%%%%%%%%%%%%%%%% TabBill
|
||||
T_fenster13::T_fenster13(hwinf *HWaccess, QWidget *parent) : QWidget(parent)
|
||||
{
|
||||
QGridLayout *myLayout = new QGridLayout();
|
||||
QLabel *Lab1 = new QLabel("Bank note acceptor");
|
||||
myLayout->addWidget(Lab1,1,1);
|
||||
setLayout(myLayout);
|
||||
}
|
||||
|
||||
void T_fenster13::updateGui(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
T_fenster14::T_fenster14(hwinf *HWaccess, QWidget *parent) : QWidget(parent)
|
||||
{
|
||||
QGridLayout *myLayout = new QGridLayout();
|
||||
QLabel *Lab1 = new QLabel("Dialog 14");
|
||||
myLayout->addWidget(Lab1,1,1);
|
||||
setLayout(myLayout);
|
||||
}
|
||||
|
||||
void T_fenster14::updateGui(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
T_fenster15::T_fenster15(hwinf *HWaccess, QWidget *parent) : QWidget(parent)
|
||||
{
|
||||
QGridLayout *myLayout = new QGridLayout();
|
||||
QLabel *Lab1 = new QLabel("Dialog 15");
|
||||
myLayout->addWidget(Lab1,1,1);
|
||||
setLayout(myLayout);
|
||||
}
|
||||
|
||||
void T_fenster15::updateGui(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
T_fenster16::T_fenster16(hwinf *HWaccess, QWidget *parent) : QWidget(parent)
|
||||
{
|
||||
QGridLayout *myLayout = new QGridLayout();
|
||||
QLabel *Lab1 = new QLabel("Dialog 16");
|
||||
myLayout->addWidget(Lab1,1,1);
|
||||
setLayout(myLayout);
|
||||
}
|
||||
|
||||
void T_fenster16::updateGui(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
T_fenster17::T_fenster17(hwinf *HWaccess, QWidget *parent) : QWidget(parent)
|
||||
{
|
||||
QGridLayout *myLayout = new QGridLayout();
|
||||
QLabel *Lab1 = new QLabel("Dialog 17");
|
||||
myLayout->addWidget(Lab1,1,1);
|
||||
setLayout(myLayout);
|
||||
}
|
||||
|
||||
void T_fenster17::updateGui(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
T_fenster18::T_fenster18(hwinf *HWaccess, QWidget *parent) : QWidget(parent)
|
||||
{
|
||||
QGridLayout *myLayout = new QGridLayout();
|
||||
QLabel *Lab1 = new QLabel("Dialog 18");
|
||||
myLayout->addWidget(Lab1,1,1);
|
||||
setLayout(myLayout);
|
||||
}
|
||||
|
||||
void T_fenster18::updateGui(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
T_fenster19::T_fenster19(hwinf *HWaccess, QWidget *parent) : QWidget(parent)
|
||||
{
|
||||
QGridLayout *myLayout = new QGridLayout();
|
||||
QLabel *Lab1 = new QLabel("Dialog 19");
|
||||
myLayout->addWidget(Lab1,1,1);
|
||||
setLayout(myLayout);
|
||||
}
|
||||
|
||||
void T_fenster19::updateGui(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
T_fenster20::T_fenster20(hwinf *HWaccess, QWidget *parent) : QWidget(parent)
|
||||
{
|
||||
QGridLayout *myLayout = new QGridLayout();
|
||||
QLabel *Lab1 = new QLabel("Dialog 20");
|
||||
myLayout->addWidget(Lab1,1,1);
|
||||
setLayout(myLayout);
|
||||
}
|
||||
|
||||
void T_fenster20::updateGui(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
T_fenster21::T_fenster21(hwinf *HWaccess, QWidget *parent) : QWidget(parent)
|
||||
{
|
||||
QGridLayout *myLayout = new QGridLayout();
|
||||
QLabel *Lab1 = new QLabel("Dialog 21");
|
||||
myLayout->addWidget(Lab1,1,1);
|
||||
setLayout(myLayout);
|
||||
}
|
||||
|
||||
void T_fenster21::updateGui(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
T_fenster22::T_fenster22(hwinf *HWaccess, QWidget *parent) : QWidget(parent)
|
||||
{
|
||||
QGridLayout *myLayout = new QGridLayout();
|
||||
QLabel *Lab1 = new QLabel("Dialog 22");
|
||||
myLayout->addWidget(Lab1,1,1);
|
||||
setLayout(myLayout);
|
||||
}
|
||||
|
||||
void T_fenster22::updateGui(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
T_fenster23::T_fenster23(hwinf *HWaccess, QWidget *parent) : QWidget(parent)
|
||||
{
|
||||
QGridLayout *myLayout = new QGridLayout();
|
||||
QLabel *Lab1 = new QLabel("Dialog 23");
|
||||
myLayout->addWidget(Lab1,1,1);
|
||||
setLayout(myLayout);
|
||||
}
|
||||
|
||||
void T_fenster23::updateGui(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
T_fenster24::T_fenster24(hwinf *HWaccess, QWidget *parent) : QWidget(parent)
|
||||
{
|
||||
QGridLayout *myLayout = new QGridLayout();
|
||||
QLabel *Lab1 = new QLabel("Dialog 24");
|
||||
myLayout->addWidget(Lab1,1,1);
|
||||
setLayout(myLayout);
|
||||
}
|
||||
|
||||
void T_fenster24::updateGui(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
T_fenster25::T_fenster25(hwinf *HWaccess, QWidget *parent) : QWidget(parent)
|
||||
{
|
||||
QGridLayout *myLayout = new QGridLayout();
|
||||
QLabel *Lab1 = new QLabel("Dialog 25");
|
||||
myLayout->addWidget(Lab1,1,1);
|
||||
setLayout(myLayout);
|
||||
}
|
||||
|
||||
void T_fenster25::updateGui(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
T_fenster26::T_fenster26(hwinf *HWaccess, QWidget *parent) : QWidget(parent)
|
||||
{
|
||||
QGridLayout *myLayout = new QGridLayout();
|
||||
QLabel *Lab1 = new QLabel("Dialog 26");
|
||||
myLayout->addWidget(Lab1,1,1);
|
||||
setLayout(myLayout);
|
||||
}
|
||||
|
||||
void T_fenster26::updateGui(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
T_fenster27::T_fenster27(hwinf *HWaccess, QWidget *parent) : QWidget(parent)
|
||||
{
|
||||
QGridLayout *myLayout = new QGridLayout();
|
||||
QLabel *Lab1 = new QLabel("Dialog 27");
|
||||
myLayout->addWidget(Lab1,1,1);
|
||||
setLayout(myLayout);
|
||||
}
|
||||
|
||||
void T_fenster27::updateGui(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
T_fenster28::T_fenster28(hwinf *HWaccess, QWidget *parent) : QWidget(parent)
|
||||
{
|
||||
QGridLayout *myLayout = new QGridLayout();
|
||||
QLabel *Lab1 = new QLabel("Dialog 28");
|
||||
myLayout->addWidget(Lab1,1,1);
|
||||
setLayout(myLayout);
|
||||
}
|
||||
|
||||
void T_fenster28::updateGui(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
T_fenster29::T_fenster29(hwinf *HWaccess, QWidget *parent) : QWidget(parent)
|
||||
{
|
||||
QGridLayout *myLayout = new QGridLayout();
|
||||
QLabel *Lab1 = new QLabel("Dialog 29");
|
||||
myLayout->addWidget(Lab1,1,1);
|
||||
setLayout(myLayout);
|
||||
}
|
||||
|
||||
void T_fenster29::updateGui(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
T_fenster30::T_fenster30(hwinf *HWaccess, QWidget *parent) : QWidget(parent)
|
||||
{
|
||||
QGridLayout *myLayout = new QGridLayout();
|
||||
QLabel *Lab1 = new QLabel("Dialog 30");
|
||||
myLayout->addWidget(Lab1,1,1);
|
||||
setLayout(myLayout);
|
||||
}
|
||||
|
||||
void T_fenster30::updateGui(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
*/
|
||||
|
161
dCArun/subwindows.h
Executable file
161
dCArun/subwindows.h
Executable file
@@ -0,0 +1,161 @@
|
||||
#ifndef SUBWINDOWS_H
|
||||
#define SUBWINDOWS_H
|
||||
|
||||
#include <QVBoxLayout>
|
||||
#include <QHBoxLayout>
|
||||
#include <QGridLayout>
|
||||
#include <QObject>
|
||||
#include <QTimer>
|
||||
#include <QDebug>
|
||||
#include <QScrollBar>
|
||||
#include <QPlainTextEdit>
|
||||
#include <QComboBox>
|
||||
#include <QLabel>
|
||||
#include <QScrollArea>
|
||||
#include <QWidget>
|
||||
#include <QListWidget>
|
||||
#include <QGroupBox>
|
||||
#include <QPushButton>
|
||||
#include <QRadioButton>
|
||||
#include "tslib.h"
|
||||
#include "stepList.h" // define all working chain steps here
|
||||
#include "../plugins/interfaces.h"
|
||||
|
||||
|
||||
|
||||
class T_fenster12 : public QWidget // TabChanger
|
||||
{
|
||||
public:
|
||||
explicit T_fenster12(hwinf *HWaccess = nullptr, QWidget *parent = nullptr);
|
||||
void updateGui(void);
|
||||
|
||||
};
|
||||
class T_fenster13 : public QWidget // TabBill
|
||||
{
|
||||
public:
|
||||
explicit T_fenster13(hwinf *HWaccess = nullptr, QWidget *parent = nullptr);
|
||||
void updateGui(void);
|
||||
|
||||
};
|
||||
class T_fenster14 : public QWidget
|
||||
{
|
||||
public:
|
||||
explicit T_fenster14(hwinf *HWaccess = nullptr, QWidget *parent = nullptr);
|
||||
void updateGui(void);
|
||||
|
||||
};
|
||||
class T_fenster15 : public QWidget
|
||||
{
|
||||
public:
|
||||
explicit T_fenster15(hwinf *HWaccess = nullptr, QWidget *parent = nullptr);
|
||||
void updateGui(void);
|
||||
|
||||
};
|
||||
class T_fenster16 : public QWidget
|
||||
{
|
||||
public:
|
||||
explicit T_fenster16(hwinf *HWaccess = nullptr, QWidget *parent = nullptr);
|
||||
void updateGui(void);
|
||||
|
||||
};
|
||||
class T_fenster17 : public QWidget
|
||||
{
|
||||
public:
|
||||
explicit T_fenster17(hwinf *HWaccess = nullptr, QWidget *parent = nullptr);
|
||||
void updateGui(void);
|
||||
|
||||
};
|
||||
class T_fenster18 : public QWidget
|
||||
{
|
||||
public:
|
||||
explicit T_fenster18(hwinf *HWaccess = nullptr, QWidget *parent = nullptr);
|
||||
void updateGui(void);
|
||||
|
||||
};
|
||||
class T_fenster19 : public QWidget
|
||||
{
|
||||
public:
|
||||
explicit T_fenster19(hwinf *HWaccess = nullptr, QWidget *parent = nullptr);
|
||||
void updateGui(void);
|
||||
|
||||
};
|
||||
class T_fenster20 : public QWidget
|
||||
{
|
||||
public:
|
||||
explicit T_fenster20(hwinf *HWaccess = nullptr, QWidget *parent = nullptr);
|
||||
void updateGui(void);
|
||||
|
||||
};
|
||||
|
||||
class T_fenster21 : public QWidget
|
||||
{
|
||||
public:
|
||||
explicit T_fenster21(hwinf *HWaccess = nullptr, QWidget *parent = nullptr);
|
||||
void updateGui(void);
|
||||
|
||||
};
|
||||
class T_fenster22 : public QWidget
|
||||
{
|
||||
public:
|
||||
explicit T_fenster22(hwinf *HWaccess = nullptr, QWidget *parent = nullptr);
|
||||
void updateGui(void);
|
||||
|
||||
};
|
||||
class T_fenster23 : public QWidget
|
||||
{
|
||||
public:
|
||||
explicit T_fenster23(hwinf *HWaccess = nullptr, QWidget *parent = nullptr);
|
||||
void updateGui(void);
|
||||
|
||||
};
|
||||
class T_fenster24 : public QWidget
|
||||
{
|
||||
public:
|
||||
explicit T_fenster24(hwinf *HWaccess = nullptr, QWidget *parent = nullptr);
|
||||
void updateGui(void);
|
||||
|
||||
};
|
||||
class T_fenster25 : public QWidget
|
||||
{
|
||||
public:
|
||||
explicit T_fenster25(hwinf *HWaccess = nullptr, QWidget *parent = nullptr);
|
||||
void updateGui(void);
|
||||
|
||||
};
|
||||
class T_fenster26 : public QWidget
|
||||
{
|
||||
public:
|
||||
explicit T_fenster26(hwinf *HWaccess = nullptr, QWidget *parent = nullptr);
|
||||
void updateGui(void);
|
||||
|
||||
};
|
||||
class T_fenster27 : public QWidget
|
||||
{
|
||||
public:
|
||||
explicit T_fenster27(hwinf *HWaccess = nullptr, QWidget *parent = nullptr);
|
||||
void updateGui(void);
|
||||
|
||||
};
|
||||
class T_fenster28 : public QWidget
|
||||
{
|
||||
public:
|
||||
explicit T_fenster28(hwinf *HWaccess = nullptr, QWidget *parent = nullptr);
|
||||
void updateGui(void);
|
||||
|
||||
};
|
||||
class T_fenster29 : public QWidget
|
||||
{
|
||||
public:
|
||||
explicit T_fenster29(hwinf *HWaccess = nullptr, QWidget *parent = nullptr);
|
||||
void updateGui(void);
|
||||
|
||||
};
|
||||
class T_fenster30 : public QWidget
|
||||
{
|
||||
public:
|
||||
explicit T_fenster30(hwinf *HWaccess = nullptr, QWidget *parent = nullptr);
|
||||
void updateGui(void);
|
||||
|
||||
};
|
||||
|
||||
#endif
|
1016
dCArun/tslib.cpp
Executable file
1016
dCArun/tslib.cpp
Executable file
File diff suppressed because it is too large
Load Diff
168
dCArun/tslib.h
Executable file
168
dCArun/tslib.h
Executable file
@@ -0,0 +1,168 @@
|
||||
#ifndef TSLIB_H
|
||||
#define TSLIB_H
|
||||
#include <stdint.h>
|
||||
#include <QByteArray>
|
||||
|
||||
typedef uint8_t UCHAR;
|
||||
typedef uint16_t UINT;
|
||||
typedef uint32_t ULONG;
|
||||
|
||||
#define LOWBYTE false
|
||||
#define HIGHBYTE true
|
||||
|
||||
uint16_t uchar2uint(char Highbyte, char Lowbyte);
|
||||
uint16_t uchar2uint(uint8_t Highbyte, uint8_t Lowbyte);
|
||||
uint32_t uchar2ulong(uint8_t Highbyte, uint8_t MHbyte, uint8_t MLbyte, uint8_t Lowbyte);
|
||||
|
||||
uint8_t uint2uchar(uint16_t uival, bool getHighB);
|
||||
|
||||
|
||||
void delay(uint16_t MilliSec);
|
||||
|
||||
#define MITSEK 1
|
||||
#define OHNESEK 0
|
||||
#define HourSys12h 1
|
||||
#define HourSys24h 0
|
||||
|
||||
void GetTimeString(uint8_t hours, uint8_t minutes, uint8_t seconds, uint8_t System12h, uint8_t ShowSec, uint8_t *buf);
|
||||
// generate time as ascii string from integers hours/minutes/seconds
|
||||
// System12h=0: 24h system =1: 12h System
|
||||
// ShowSec=0: String has 5 digits (hh:mm) =1: String has 8 digits (hh:mm:ss)
|
||||
// return String in *buf // 12 byte für buf!
|
||||
|
||||
#define DateFormatDeutsch 0
|
||||
#define DateFormatAmerica 1
|
||||
#define UsePointSeperator 0
|
||||
#define UseSlashSeperator 1
|
||||
|
||||
|
||||
void GetDateString(uint8_t day, uint8_t month, uint8_t yearhigh, uint8_t yearlow, uint8_t format, uint8_t sep, uint8_t *buf);
|
||||
// generate date as ascii string from integers day/month/year
|
||||
// yearhigh in europe always 20 (not in arabia)
|
||||
// format= 0: dd.mm.yyyy (deutsch)
|
||||
// 1: mm.dd.yyyy (amerika)
|
||||
// 2: yyyy.mm.dd (Iran, Dubai)
|
||||
// 3: dd.yyyy.mm
|
||||
// 4: mm.yyyy.dd
|
||||
// 5: yyyy.dd.mm
|
||||
// sep: 0: use . as seperator 1: use / as seperator
|
||||
// return String in *buf // 11 byte für buf!
|
||||
|
||||
|
||||
void GetShortDateString(uint8_t day, uint8_t month, uint8_t yearlow, uint8_t format, uint8_t sep, uint8_t *buf);
|
||||
// generate date as ascii string from integers day/month/year
|
||||
// format= 0: dd.mm.yy (deutsch)
|
||||
// 1: mm.dd.yy (amerika)
|
||||
// 2: yy.mm.dd (Iran, Dubai)
|
||||
// 3: dd.yy.mm
|
||||
// 4: mm.yy.dd
|
||||
// 5: yy.dd.mm
|
||||
// sep: 0: use . as seperator 1: use / as seperator
|
||||
// return String in *buf // 11byte für buf!
|
||||
|
||||
|
||||
uint16_t tslib_strlen(char *buf);
|
||||
|
||||
void tslib_strclr(char *buf, char clrsign, uint16_t len);
|
||||
void tslib_strclr(uint8_t *buf, char clrsign, uint16_t len);
|
||||
|
||||
void tslib_strcpy(char *srcbuf, char *destbuf, uint16_t len);
|
||||
void tslib_strcpy(char *srcbuf, uint8_t *destbuf, uint16_t len);
|
||||
void tslib_strcpy(uint8_t *srcbuf, uint8_t *destbuf, uint16_t len);
|
||||
|
||||
|
||||
uint16_t tslib_calcCrcCcitt(uint16_t BufLength, uint8_t *buf);
|
||||
|
||||
bool tslib_isDecAsciiNumber(char sign);
|
||||
bool tslib_isHexAsciiNumber(char sign);
|
||||
|
||||
|
||||
int tslib_getMinimum(int val1, int val2);
|
||||
|
||||
void tslib_text2array(QByteArray text, char *aray, uint16_t maxArayLen);
|
||||
// usage: tslib_text2array("my text", ctmp, 50);
|
||||
|
||||
bool tslib_strComp(uint8_t *buf, char *compStr);
|
||||
|
||||
bool tslib_plausiChkTime(uint8_t hour, uint8_t min, uint8_t sec );
|
||||
// retval: true: time is OK
|
||||
|
||||
bool tslib_plausiChkDate(uint8_t year, uint8_t month, uint8_t dom );
|
||||
// retval: true: time is OK
|
||||
|
||||
UCHAR swl_LengthCurrentMonth(UCHAR month, UCHAR year);
|
||||
// return nr of days for this month, respecting leap years
|
||||
|
||||
UINT swl_GetDaysOfaCompleteYear(UCHAR year);
|
||||
// year: 0=2000 4=2004 99=2099
|
||||
// retval: 365 or 366 (leap year)
|
||||
|
||||
UINT swl_GetDaysOfYear(UCHAR year, UCHAR month, UCHAR day);
|
||||
// number of days of momentary year from 1. Jan until
|
||||
// (inclusive) given date with respect to leap years
|
||||
// year: 0..99 month=1..12 day=1..31
|
||||
|
||||
unsigned long swl_getNrOfDaysSince2000Jan1(UCHAR thisYear, UCHAR thisMonth, UCHAR thisDay);
|
||||
// till today
|
||||
|
||||
unsigned long swl_getNrOfHoursSince_Midnight2000Jan1(UCHAR thisYear, UCHAR thisMonth, UCHAR thisDay, UCHAR hoursNow);
|
||||
|
||||
unsigned long swl_getNrOfMinutesSince_Midnight2000Jan1(UCHAR thisYear, \
|
||||
UCHAR thisMonth, UCHAR thisDay, UCHAR hoursNow, UCHAR minuteNow);
|
||||
|
||||
unsigned long swl_getNrOfSecondsSince_Midnight2000Jan1(UCHAR thisYear, \
|
||||
UCHAR thisMonth, UCHAR thisDay, UCHAR hoursNow, UCHAR minuteNow, UCHAR secondNow);
|
||||
|
||||
char swl_isLeap(UCHAR year);
|
||||
|
||||
UCHAR swl_getNextLeapYear(UCHAR year);
|
||||
|
||||
UCHAR swl_getLastLeapYear(UCHAR year);
|
||||
|
||||
UCHAR swl_hoursOfThisWeek(UCHAR dow, UCHAR hoursNow);
|
||||
// always calculate from monday 0 o'clock
|
||||
// dow: 1=monday 7=sunday
|
||||
|
||||
UINT swl_minutesOfThisWeek(UCHAR dow, UCHAR hoursNow, UCHAR minutesNow);
|
||||
// always calculate from monday 0 o'clock
|
||||
// dow: 1=monday 7=sunday
|
||||
|
||||
UINT swl_hoursOfThisMonth(UCHAR thisDay, UCHAR hoursNow);
|
||||
|
||||
UINT swl_minutesOfThisMonth(UCHAR thisDay, UCHAR hoursNow, UCHAR minutesNow);
|
||||
|
||||
UINT swl_GetHoursOfYear(UCHAR year, UCHAR month, UCHAR day, UCHAR hourNow);
|
||||
|
||||
ULONG swl_GetMinutesOfYear(UCHAR year, UCHAR month, UCHAR day, UCHAR hourNow, UCHAR minutesNow);
|
||||
|
||||
UCHAR swl_weekday(UCHAR year, UCHAR month, UCHAR dayOfMonth);
|
||||
// return 1...7 = monday...sunday, starting from 1.1.2000
|
||||
|
||||
QString swl_int2str(int val);
|
||||
QString swl_hex2str(double val);
|
||||
|
||||
void swl_text2ui8buf(QString text, uint8_t *outbuf, uint16_t length);
|
||||
// copy text byte-by-byte to outbuf
|
||||
|
||||
QString swl_ulong2str(uint32_t val);
|
||||
|
||||
QString swl_long2str(long val);
|
||||
|
||||
uint16_t swl_str2uint(QString myIntStr);
|
||||
|
||||
uint32_t swl_str2ulong(QString myIntStr);
|
||||
|
||||
QString swl_labelAndValToStr(QString label, uint32_t val);
|
||||
|
||||
QString swl_8valInaRowToStr(QString label, uint8_t val[8]);
|
||||
|
||||
QString swl_8valInaRowToStr(QString label, uint16_t val[8]);
|
||||
|
||||
QString swl_8intsInaRowToStr(QString label, int val[8]);
|
||||
|
||||
QString swl_centToEuroString(uint32_t amount_in_cent);
|
||||
|
||||
#endif // TSLIB_H
|
||||
|
||||
// qDebug << QDateTime::currentDateTime().toString(Qt::ISODateWithMs) << QByteArray((const char*)dataSendBuf,dataBufLen).toHex(':');
|
||||
|
13
dCArun/versionHistory.txt
Executable file
13
dCArun/versionHistory.txt
Executable file
@@ -0,0 +1,13 @@
|
||||
#ifndef VERSIONHISTORY_H
|
||||
#define VERSIONHISTORY_H
|
||||
|
||||
APservice3.0 bis September2023 fuer DBM, Szeged
|
||||
|
||||
|
||||
APservice3.2 12.10.23
|
||||
screen Abfolge komplett mit defines aufgebaut, kann jetzt in "stepList.h" veraendert werden
|
||||
Neuen Screen Muenzwechsler und Banknote
|
||||
passend zu CashAgent-Plugin: "Atb.Psa1256ptu5.software.HWapi/5.0"
|
||||
Farben und Schriftgroessen vereinheitlichen (guidefs.h)
|
||||
|
||||
#endif
|
578
dCArun/win01_com.cpp
Executable file
578
dCArun/win01_com.cpp
Executable file
@@ -0,0 +1,578 @@
|
||||
#include "win01_com.h"
|
||||
#include "stepList.h" // define all working chain steps here
|
||||
#include "datei.h"
|
||||
//#include "globVars.h"
|
||||
|
||||
|
||||
|
||||
// %%%%%%%%%%%%%%%%%%%% TabComPort
|
||||
|
||||
Console::Console(QWidget *parent) : QPlainTextEdit(parent)
|
||||
{
|
||||
document()->setMaximumBlockCount(100);
|
||||
QPalette p = palette();
|
||||
p.setColor(QPalette::Base, Qt::black); //geht nicht weil untergrund schon farbig
|
||||
p.setColor(QPalette::Text, Qt::blue);
|
||||
setPalette(p);
|
||||
|
||||
}
|
||||
|
||||
void Console::putData(const QByteArray &data)
|
||||
{
|
||||
insertPlainText(data);
|
||||
insertPlainText("\n");
|
||||
QScrollBar *bar = verticalScrollBar();
|
||||
bar->setValue(bar->maximum());
|
||||
}
|
||||
|
||||
void Console::putText(QString text)
|
||||
{
|
||||
insertPlainText(text);
|
||||
insertPlainText("\n");
|
||||
QScrollBar *bar = verticalScrollBar();
|
||||
bar->setValue(bar->maximum());
|
||||
}
|
||||
|
||||
void T_winComPort::subPortInfo()
|
||||
{
|
||||
|
||||
// Port Info Anzeige Feld, 2. Zeile links
|
||||
QStringList myStringList;
|
||||
QStringList comboPortList;
|
||||
|
||||
const auto infos = QSerialPortInfo::availablePorts();
|
||||
for (const QSerialPortInfo &info : infos)
|
||||
{
|
||||
myStringList.append(QObject::tr(" \n Port: ") + info.portName() );
|
||||
myStringList.append(QObject::tr("Location: ") + info.systemLocation()); // + "\n");
|
||||
myStringList.append(QObject::tr("Description: ") + info.description() );
|
||||
myStringList.append(QObject::tr("Manufacturer: ") + info.manufacturer());
|
||||
myStringList.append(QObject::tr("Serial number: ") + info.serialNumber());
|
||||
myStringList.append (QObject::tr("Vendor Id: ") + QString::number(info.vendorIdentifier(), 16));
|
||||
myStringList.append(QObject::tr("Product Id: ") +QString::number(info.productIdentifier(), 16));
|
||||
//myStringList.append(QObject::tr("Busy: ") + (info.isBusy() ? QObject::tr("Yes") : QObject::tr("No")));
|
||||
comboPortList.append(info.portName()); // wenn Comport im System vorhanden dann in die Liste eintragen
|
||||
}
|
||||
QListWidget *myListWidget = new QListWidget;
|
||||
myListWidget->insertItems(0, myStringList);
|
||||
myListWidget->setMaximumWidth(250);
|
||||
myTabComLayout->addWidget(myListWidget,1,0);
|
||||
|
||||
|
||||
// ComboBox Comport Nr:
|
||||
CB_portSel = new QComboBox();
|
||||
CB_portSel->addItems(comboPortList); // string Liste mit addItems (s am Schluss) !
|
||||
CB_portSel->setMinimumHeight(30);
|
||||
CB_portSel->setMaximumWidth(150);
|
||||
QFont myCBfont;
|
||||
//myCBfont.setBold(true);
|
||||
myCBfont.setPixelSize(15);
|
||||
CB_portSel->setFont(myCBfont);
|
||||
CB_portSel->setCurrentIndex(2); // default 3. Comport in der Liste = ttymxc2 in PTU5
|
||||
myTabComLayout->addWidget(CB_portSel, 4,0);
|
||||
|
||||
}
|
||||
|
||||
void T_winComPort::callOpenSerial()
|
||||
{
|
||||
// Taste Connect wurde gedrückt, eine Klasse/einen Slot aus einer übergeordneten Klasse:
|
||||
// openSerialPort();
|
||||
// kann man nicht aufrufen. deshalb: speichere ComPort, Baudrate und Startbefehl global.
|
||||
// Von dort wird mit einem zyklischen Timer ausgelesen
|
||||
|
||||
int br, ci;
|
||||
QString bs, cn;
|
||||
//br=CB_baudSel->currentIndex();
|
||||
//bs=CB_baudSel->currentText();
|
||||
br=5;
|
||||
bs="115200";
|
||||
cn=CB_portSel->currentText();
|
||||
ci=CB_portSel->currentIndex();
|
||||
|
||||
// aktuell: br=5 bs=115200 cn=0 (=Com5)
|
||||
//epi_setSerial(5,"115200","COM5",1);
|
||||
// epi_setSerial(br, bs, cn, 1);
|
||||
|
||||
// new: save values for next time
|
||||
QByteArray myBA, tmpBA;
|
||||
myBA.clear(); tmpBA.clear();
|
||||
myBA.append('s'); // start sign, not used
|
||||
myBA.append(FILESEPERATOR);
|
||||
tmpBA.setNum(br,10);
|
||||
myBA.append(tmpBA);
|
||||
myBA.append(FILESEPERATOR);
|
||||
myBA.append(bs.toLatin1());
|
||||
myBA.append(FILESEPERATOR);
|
||||
myBA.append(cn.toLatin1());
|
||||
myBA.append(FILESEPERATOR);
|
||||
tmpBA.clear();
|
||||
tmpBA.setNum(ci,10);
|
||||
myBA.append(tmpBA);
|
||||
myBA.append(FILESEPERATOR);
|
||||
|
||||
datei_clearFile(FILENAME_COMPORT);
|
||||
datei_writeToFile(FILENAME_COMPORT, myBA);
|
||||
qDebug() << "winComPort opening serial with: " << br << " " << bs << " " << cn;
|
||||
HWaccess->dc_openSerial(br, bs, cn, 1);// same function with hwapi
|
||||
// void dc_openSerial(int BaudNr, QString BaudStr, QString ComName, uint8_t connect)
|
||||
// BaudNr: 0:1200 1:9600 2:19200 3:38400 4:57600 5:115200
|
||||
// BaudStr: for exapmle "19200"
|
||||
// ComName: for example "COM48"
|
||||
// connect: 0, 1
|
||||
|
||||
emit connectButtonPressed();
|
||||
}
|
||||
|
||||
void T_winComPort::callCloseSerial()
|
||||
{
|
||||
HWaccess->dc_closeSerial();
|
||||
// epi_closeSerial(); // same function without hwapi
|
||||
emit closeButtonPressed();
|
||||
}
|
||||
|
||||
void T_winComPort::callAutoSend()
|
||||
{
|
||||
if (AutSendButton->isChecked())
|
||||
{
|
||||
HWaccess->dc_autoRequest(1);
|
||||
emit autoSendButtonIsOn();
|
||||
} else
|
||||
{
|
||||
HWaccess->dc_autoRequest(0);
|
||||
|
||||
emit autoSendButtonIsOff();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void T_winComPort::callRefresh(void)
|
||||
{
|
||||
subPortInfo();
|
||||
}
|
||||
|
||||
void T_winComPort::callConnectToggle()
|
||||
{
|
||||
if (connectButton->isChecked())
|
||||
{
|
||||
//qDebug() << "down";
|
||||
|
||||
callOpenSerial();
|
||||
} else
|
||||
{
|
||||
//qDebug() << "released";
|
||||
callCloseSerial();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void T_winComPort::getDcTestRS232()
|
||||
{
|
||||
//qDebug() << "request test response...";
|
||||
HWaccess->dc_requTestResponse();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
void T_winComPort::newBaud(void)
|
||||
{
|
||||
|
||||
qDebug() << "new baud selected...";
|
||||
|
||||
}
|
||||
|
||||
void T_winComPort::setButtons4autoStart()
|
||||
{
|
||||
connectButton->setEnabled(true);
|
||||
connectButton->setDown(true);
|
||||
connectButton->setChecked(true);
|
||||
|
||||
AutSendButton->setEnabled(true);
|
||||
AutSendButton->setDown(true);
|
||||
AutSendButton->setChecked(true);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
T_winComPort::T_winComPort(hwinf *HWaccess, QWidget *parent) : QWidget(parent)
|
||||
{
|
||||
this->HWaccess = HWaccess;
|
||||
|
||||
myTabComLayout = new QGridLayout;
|
||||
//QGridLayout *myGridLayout = new QGridLayout();
|
||||
|
||||
// Überschrift linke Spalte
|
||||
QLabel *portListLabel2 = new QLabel(tr("in System available Ports:"));
|
||||
myTabComLayout->addWidget(portListLabel2, 0,0);
|
||||
|
||||
// Überschrift rechte Spalte
|
||||
QLabel *lab_headlineR = new QLabel(tr("Serial traffic:"));
|
||||
myTabComLayout->addWidget(lab_headlineR, 0, 1);
|
||||
|
||||
subPortInfo();
|
||||
// sende-empfangs-Rohdaten-Fenster, 2. Zeile rechts
|
||||
myDiagWindow = new Console();
|
||||
myDiagWindow->setReadOnly(true);
|
||||
myDiagWindow->setEnabled(true);
|
||||
//myDiagWindow->setLocalEchoEnabled(p.localEchoEnabled);
|
||||
//myDiagWindow->setMinimumWidth(300);
|
||||
//myDiagWindow->putData("ongoing serial traffic: ");
|
||||
myTabComLayout->addWidget(myDiagWindow, 1,1);
|
||||
|
||||
// links:
|
||||
// refresh button:
|
||||
refreshButton = new QPushButton(tr("&refresh"));
|
||||
refreshButton->setCheckable(false); // true = toggle button
|
||||
refreshButton->setAutoDefault(false); // beim start aus
|
||||
//refreshButton->setMaximumWidth(90);
|
||||
myTabComLayout->addWidget(refreshButton, 2,0);
|
||||
//connect(refreshButton, &QAbstractButton::clicked, this, &T_fenster01::callRefresh);
|
||||
connect(refreshButton, SIGNAL(clicked()), this, SLOT(callRefresh()));
|
||||
|
||||
|
||||
QLabel *Label3 = new QLabel(tr("Port:"));
|
||||
myTabComLayout->addWidget(Label3, 3,0);
|
||||
|
||||
|
||||
|
||||
QLabel *Label4 = new QLabel(tr("Baud:"));
|
||||
myTabComLayout->addWidget(Label4, 5,0);
|
||||
|
||||
// ComboBox Baudrate:
|
||||
QFont my2CBfont;
|
||||
//my2CBfont.setBold(true);
|
||||
my2CBfont.setPixelSize(15);
|
||||
/*
|
||||
CB_baudSel = new QComboBox();
|
||||
CB_baudSel->addItem(tr("1200"));
|
||||
CB_baudSel->addItem(tr("9600"));
|
||||
CB_baudSel->addItem(tr("19200"));
|
||||
CB_baudSel->addItem(tr("38400"));
|
||||
CB_baudSel->addItem(tr("57600"));
|
||||
CB_baudSel->addItem(tr("115200"));
|
||||
CB_baudSel->setMinimumHeight(30);
|
||||
CB_baudSel->setMaximumWidth(150);
|
||||
CB_baudSel->setFont(my2CBfont);
|
||||
CB_baudSel->setCurrentIndex(5); // default 115k baud
|
||||
//CB_baudSel->setCurrentIndex(1); // default 9600 baud
|
||||
myTabComLayout->addWidget(CB_baudSel, 6,0);
|
||||
//connect(CB_baudSel, SIGNAL(currentIndexChanged(int)), this, SLOT(newBaud()));
|
||||
connect(CB_baudSel, SIGNAL(currentIndexChanged(int)), this, SLOT(newBaud()));
|
||||
*/
|
||||
// Statuszeile COM Port (serial Port)
|
||||
LabelComState = new QLabel(tr("not connected"));
|
||||
myTabComLayout->addWidget(LabelComState, 7,0);
|
||||
|
||||
// Connect button:
|
||||
connectButton = new QPushButton(tr("&Connect"));
|
||||
connectButton->setCheckable(true); // true = toggle button
|
||||
connectButton->setAutoDefault(true); // beim start ein
|
||||
connectButton->setMaximumWidth(90);
|
||||
connectButton->setMinimumHeight(50);
|
||||
myTabComLayout->addWidget(connectButton, 8,0);
|
||||
//connect(connectButton, &QAbstractButton::clicked, this, &T_fenster01::callConnectToggle);
|
||||
connect(connectButton, SIGNAL(clicked()), this, SLOT(callConnectToggle()));
|
||||
|
||||
|
||||
// rechts:
|
||||
|
||||
// test serial line:
|
||||
TestButton = new QPushButton(tr("test Connection"));
|
||||
TestButton->setMaximumWidth(150);
|
||||
myTabComLayout->addWidget(TestButton,2,1);
|
||||
TestButton->setCheckable(false); // true = toggle button
|
||||
TestButton->setAutoDefault(false); // beim start aus
|
||||
// connect(TestButton, &QAbstractButton::clicked, this, &T_fenster01::getDcTestRS232);
|
||||
connect(TestButton, SIGNAL(clicked()), this, SLOT(getDcTestRS232()));
|
||||
|
||||
// I Statuszeile Handshakes (serial Control) flow.cpp
|
||||
// geht überhaupt was raus? kommt überhaupt was zurück?
|
||||
//LabelHandshakes = new QLabel(tr("control line"));
|
||||
LabelHandshakes = new QLabel("HS"); // not used
|
||||
myTabComLayout->addWidget(LabelHandshakes, 3,1);
|
||||
|
||||
// II Statuszeile Auswertung der SlaveResponse (serial Frame, CRC usw) (prot.cpp)
|
||||
LabelRecieveFrame = new QLabel(tr("slave receive"));
|
||||
myTabComLayout->addWidget(LabelRecieveFrame, 4,1);
|
||||
|
||||
// III Anzeige der Slave-Results (Datif)
|
||||
LabelResults = new QLabel(tr("results line"));
|
||||
myTabComLayout->addWidget(LabelResults, 5,1);
|
||||
|
||||
// IV Statuszeile Sende- und Empfangsdaten brauchbar? (Datif)
|
||||
LabelDataState = new QLabel(tr("datif line"));
|
||||
myTabComLayout->addWidget(LabelDataState, 6,1);
|
||||
|
||||
// V
|
||||
LabelDatif = new QLabel(tr("datif line"));
|
||||
myTabComLayout->addWidget(LabelDatif, 7,1);
|
||||
|
||||
// Autosend:
|
||||
AutSendButton = new QPushButton(tr("&Automatic reading")); // &A --> also keycode Alt-A possible
|
||||
//AutSendButton->setMaximumWidth(90);
|
||||
myTabComLayout->addWidget(AutSendButton,8,1);
|
||||
AutSendButton->setCheckable(true); // true = toggle button
|
||||
AutSendButton->setAutoDefault(true); // beim start aus
|
||||
AutSendButton->setMinimumHeight(50);
|
||||
// connect(AutSendButton, &QAbstractButton::clicked, this, &T_fenster01::callAutoSend);
|
||||
connect(AutSendButton, SIGNAL(clicked()), this, SLOT(callAutoSend()));
|
||||
|
||||
setLayout(myTabComLayout);
|
||||
myNextStep=0;
|
||||
myStep=0;
|
||||
callConnectToggle();
|
||||
callAutoSend();
|
||||
|
||||
myTO = new QTimer();
|
||||
myTO->setSingleShot(true);
|
||||
myTO->start(2000);
|
||||
|
||||
|
||||
}
|
||||
|
||||
// not needed:
|
||||
T_winComPort::~T_winComPort()
|
||||
{
|
||||
close();
|
||||
}
|
||||
|
||||
void T_winComPort::Nav_back(void)
|
||||
{
|
||||
myNextStep=WCS_WIN01BAK;
|
||||
}
|
||||
void T_winComPort::Nav_home(void)
|
||||
{
|
||||
myNextStep=WCS_WIN01MID;
|
||||
}
|
||||
void T_winComPort::Nav_next(void)
|
||||
{
|
||||
myNextStep=WCS_WIN01FWD;
|
||||
}
|
||||
|
||||
bool T_winComPort::work_ini(uint16_t *nextScreen, uint8_t *useNavi)
|
||||
{
|
||||
// one state of the vending/operating FSM
|
||||
// called ONE time after selecting this state (initialization)
|
||||
// useNavi=0: no change
|
||||
// bit0,1: enable/disable button "next"
|
||||
// bit2,3: enable/disable button "home"
|
||||
// bit4,5: enable/disable button "back"
|
||||
|
||||
*nextScreen=0; // needed 0=no change
|
||||
// *useNavi=SWITCH_BACK_OFF | SWITCH_HOME_OFF | SWITCH_NEXT_ON;
|
||||
*useNavi=SWITCH_BACK_OFF | SWITCH_HOME_OFF | SWITCH_NEXT_OFF; // bei CArun alle aus
|
||||
return false;
|
||||
}
|
||||
|
||||
bool T_winComPort::working(uint16_t *nextScreen, uint8_t *useNavi)
|
||||
{
|
||||
// one state of the vending/operating FSM
|
||||
// called cyclic until this state changes intentionally to another state
|
||||
// display informations for human operator, react on operators inputs or wait for payment media
|
||||
|
||||
// useNavi=0: no change
|
||||
// bit0,1: enable/disable button "next"
|
||||
// bit2,3: enable/disable button "home"
|
||||
// bit4,5: enable/disable button "back"
|
||||
|
||||
this->updateGui();
|
||||
*nextScreen=0; // 0=no change
|
||||
*useNavi=0;
|
||||
|
||||
if (myStep==0)
|
||||
{
|
||||
// load and use last settings: --------------------
|
||||
QByteArray myBA;
|
||||
myBA=datei_readFromFile(FILENAME_COMPORT);
|
||||
|
||||
//uint32_t len= datei_nrOfEntriesInFile(myBA);
|
||||
//uint64_t ulltmp=csv_getEntryAs2Ulong(myBA,0);
|
||||
//qDebug()<<"win_startup load long numer: "<<ulltmp;
|
||||
|
||||
QString bs=csv_getEntryAsString(myBA,0); // read the 's' war 2!??
|
||||
int br=csv_getEntryAsInt(myBA,1); // z.B. 5 (5.Eintrag in der Baud-Liste)
|
||||
bs=csv_getEntryAsString(myBA,2); // z.B 115200
|
||||
QString cn=csv_getEntryAsString(myBA,3); // z.B. COM9
|
||||
int ci=csv_getEntryAsInt(myBA,4); // Eintragsnummer in COM-Fenster
|
||||
//qDebug()<<"win_startup loaded com settings: "<<br<<" "<<bs<<" "<<cn;
|
||||
HWaccess->dc_openSerial(br,bs,cn,1);
|
||||
//CB_baudSel->setCurrentIndex(br); // im BR auswahlfenster diese Baud vorgeben
|
||||
CB_portSel->setCurrentIndex(ci); // den Port aus der Datei hier vorgeben
|
||||
connectButton->setChecked(true); // connect Taste "druecken"
|
||||
|
||||
myTO->start(100); // restart
|
||||
myStep++;
|
||||
} else
|
||||
|
||||
if (myStep==1)
|
||||
{
|
||||
if (!myTO->isActive())
|
||||
{
|
||||
if (HWaccess->dc_isPortOpen())
|
||||
myStep++;
|
||||
else
|
||||
myStep=99; // stop automatic connection and wait for manual start
|
||||
myTO->start(100);
|
||||
}
|
||||
} else
|
||||
|
||||
if (myStep==2)
|
||||
{
|
||||
if (!myTO->isActive())
|
||||
{
|
||||
HWaccess->dc_requTestResponse();
|
||||
myStep++;
|
||||
myTO->start(100);
|
||||
}
|
||||
} else
|
||||
|
||||
if (myStep==3)
|
||||
{
|
||||
if (!myTO->isActive())
|
||||
{
|
||||
if (HWaccess->dc_readAnswTestResponse())
|
||||
myStep++; // response was correct
|
||||
else
|
||||
myStep=99; // stop automatic connection and wait for manual start
|
||||
myTO->start(100);
|
||||
}
|
||||
|
||||
} else
|
||||
|
||||
if (myStep==4)
|
||||
{
|
||||
HWaccess->dc_autoRequest(1);
|
||||
AutSendButton->setChecked(true); // taste "druecken"
|
||||
myStep++;
|
||||
} else
|
||||
|
||||
if (myStep==5)
|
||||
{
|
||||
// got next screen:
|
||||
//myNextStep=2; // nicht bei CArun
|
||||
myStep++;
|
||||
|
||||
} else
|
||||
|
||||
if (myStep==6)
|
||||
{
|
||||
// stop here, everything done
|
||||
} else
|
||||
|
||||
if (myStep==7)
|
||||
{
|
||||
|
||||
} else
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
if (myNextStep)
|
||||
{
|
||||
//qDebug()<<"fenster1 working: "<< myNextStep;
|
||||
*nextScreen=myNextStep;
|
||||
myNextStep=0;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void T_winComPort::updateGui(void)
|
||||
{
|
||||
QByteArray myBA;
|
||||
QString ms;
|
||||
|
||||
ms=HWaccess->dc_getTxt4RsDiagWin();
|
||||
if (ms.length()>1) // sonst ständig scrolling
|
||||
{
|
||||
myDiagWindow->putText(ms);
|
||||
HWaccess->dc_clrTxt4RsDiagWin();
|
||||
}
|
||||
|
||||
ms=HWaccess->dc_get2ndTxt4RsDiagWin();
|
||||
if (ms.length()>1) // sonst ständig scrolling
|
||||
{
|
||||
myDiagWindow->putText(ms);
|
||||
HWaccess->dc_clr2ndTxt4RsDiagWin();
|
||||
}
|
||||
|
||||
// state of the COM Port (open, closed)
|
||||
ms=HWaccess->dc_getSerialState();
|
||||
if (ms.length()>1) // sonst ständig scrolling
|
||||
{
|
||||
LabelComState->setText(ms);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// I Statuszeile Handshakes (serial Control)
|
||||
|
||||
ms=HWaccess->dc_getTxt4HsStateLine();
|
||||
if (!connectButton->isChecked())
|
||||
ms="";
|
||||
if (ms.length()>1) // sonst ständig scrolling
|
||||
{
|
||||
LabelHandshakes->setText(ms);
|
||||
HWaccess->dc_clrTxt4HsStateLine();
|
||||
// clear to avoid multiple displaying
|
||||
}
|
||||
|
||||
|
||||
// II Master receive state (empfangenes Telgramm OK? crc? length? )
|
||||
// Statuszeile Auswertung der SlaveResponse (serial Frame, CRC usw) (prot.cpp)
|
||||
|
||||
ms=HWaccess->dc_getTxt4masterStateLine();
|
||||
if (!connectButton->isChecked())
|
||||
ms="---";
|
||||
if (ms.length()>1) // sonst ständig scrolling
|
||||
{
|
||||
LabelRecieveFrame->setText(ms);
|
||||
HWaccess->dc_clrTxt4masterStateLine();
|
||||
}
|
||||
|
||||
|
||||
|
||||
// III Slave receive (from Master) OK? if then show results, if not then show errors
|
||||
// entweder Empfangsfehler anzeigen (crc? length?) oder result OUT-OK, OUT_ERR, IN_OK, IN_ERR
|
||||
// Hintergrund: wenn der Slave Fehler im Master-Telegramm gefunden hat, dann kann er es auch
|
||||
// nicht verwenden und nichts ausgeben oder einlesen
|
||||
|
||||
ms=HWaccess->dc_getTxt4resultStateLine();
|
||||
if (!connectButton->isChecked())
|
||||
ms="---";
|
||||
if (ms.length()>1) // sonst ständig scrolling
|
||||
{
|
||||
LabelResults->setText(ms);
|
||||
HWaccess->dc_clrTxt4resultStateLine();
|
||||
}
|
||||
|
||||
|
||||
// IV Statuszeile Empfangsdaten
|
||||
|
||||
ms=HWaccess->dc_getdataStateLine();
|
||||
if (!connectButton->isChecked())
|
||||
ms="---";
|
||||
if (ms.length()>1) // sonst ständig scrolling
|
||||
{
|
||||
LabelDataState->setText(ms);
|
||||
HWaccess->dc_clrTxt4dataStateLine();
|
||||
// clear to avoid multiple displaying
|
||||
}
|
||||
|
||||
|
||||
// 5. Zeile: Datif Ergebnis, Daten brauchbar?
|
||||
|
||||
ms=HWaccess->dc_getdatifLine();
|
||||
if (!connectButton->isChecked())
|
||||
ms="---";
|
||||
if (ms.length()>1) // sonst ständig scrolling
|
||||
{
|
||||
LabelDatif->setText(ms);
|
||||
HWaccess->dc_clrTxt4datifLine();
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
}
|
||||
|
||||
|
107
dCArun/win01_com.h
Executable file
107
dCArun/win01_com.h
Executable file
@@ -0,0 +1,107 @@
|
||||
#ifndef WINCOMPORT_H
|
||||
#define WINCOMPORT_H
|
||||
|
||||
#include <QVBoxLayout>
|
||||
#include <QHBoxLayout>
|
||||
#include <QGridLayout>
|
||||
#include <QObject>
|
||||
#include <QTimer>
|
||||
#include <QDebug>
|
||||
#include <QTabWidget>
|
||||
#include <QScrollBar>
|
||||
#include <QPlainTextEdit>
|
||||
#include <QComboBox>
|
||||
#include <QLabel>
|
||||
#include <QScrollArea>
|
||||
#include <QSerialPortInfo>
|
||||
#include <QWidget>
|
||||
#include <QListWidget>
|
||||
#include <QGroupBox>
|
||||
#include <QPushButton>
|
||||
#include <QRadioButton>
|
||||
//#include "tslib.h"
|
||||
//#include "stepList.h" // define all working chain steps here
|
||||
//#include "datei.h"
|
||||
#include "plugin.h"
|
||||
//#include "globVars.h"
|
||||
|
||||
class Console : public QPlainTextEdit
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit Console(QWidget *parent = nullptr);
|
||||
|
||||
void putData(const QByteArray &data);
|
||||
void putText(QString text);
|
||||
};
|
||||
|
||||
class T_winComPort : public QWidget // former TabComport
|
||||
{
|
||||
Q_OBJECT
|
||||
Console *myDiagWindow; // Ausgabefenster
|
||||
QComboBox *CB_portSel;
|
||||
//QComboBox *CB_baudSel;
|
||||
QPushButton *connectButton;
|
||||
QPushButton *AutSendButton;
|
||||
QPushButton *TestButton;
|
||||
QPushButton *refreshButton;
|
||||
|
||||
QLabel *LabelComState; // Statusanzeige
|
||||
QLabel *LabelPort;
|
||||
QLabel *LabelHandshakes;
|
||||
QLabel *LabelRecieveFrame;
|
||||
QLabel *LabelResults;
|
||||
QLabel *LabelDataState;
|
||||
QLabel *LabelDatif;
|
||||
|
||||
QGridLayout *myTabComLayout;
|
||||
void subPortInfo();
|
||||
hwinf *HWaccess;
|
||||
void updateGui(void);
|
||||
uint16_t myNextStep;
|
||||
uint8_t myStep;
|
||||
QTimer *myTO;
|
||||
|
||||
private slots:
|
||||
void callOpenSerial();
|
||||
void callCloseSerial();
|
||||
void callAutoSend();
|
||||
//void tabComTime100ms();
|
||||
void callConnectToggle();
|
||||
void getDcTestRS232();
|
||||
void callRefresh(void);
|
||||
|
||||
public:
|
||||
explicit T_winComPort(hwinf *HWaccess = nullptr, QWidget *parent = nullptr);
|
||||
bool work_ini(uint16_t *nextScreen, uint8_t *useNavi);
|
||||
// useNavi=0: no change
|
||||
// bit0,1: enable/disable button "next"
|
||||
// bit2,3: enable/disable button "home"
|
||||
// bit4,5: enable/disable button "back"
|
||||
bool working (uint16_t *nextScreen, uint8_t *useNavi);
|
||||
~T_winComPort();
|
||||
|
||||
void writeRSdiagBytes(const QByteArray &bytarray);
|
||||
void writeRSdiagText(QString text);
|
||||
void writeComState(const QString text);
|
||||
void writeDataState(const QString text);
|
||||
void setButtons4autoStart();
|
||||
|
||||
signals:
|
||||
void connectButtonPressed();
|
||||
void closeButtonPressed();
|
||||
void autoSendButtonIsOn();
|
||||
void autoSendButtonIsOff();
|
||||
|
||||
private slots:
|
||||
void newBaud(void); // just for test
|
||||
|
||||
public slots:
|
||||
void Nav_back(void);
|
||||
void Nav_home(void);
|
||||
void Nav_next(void);
|
||||
|
||||
};
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user