Squashed 'DCPlugin/' changes from 60c4858..e5a8cfd
e5a8cfd copy of include/interfaces.h 5e6e601 Minor change f3d9c69 Added dc_printTemplate. Fixed implementation of dc_updatePrinterTemplate 3f10469 Added dc_printTemplate. Changed interface for updating printer templates. d92bdbf Added dc_printTemplate. Changed interface for updating printer templates. git-subtree-dir: DCPlugin git-subtree-split: e5a8cfd1cd6a0ece3db295669c801b8e2ea9332b
This commit is contained in:
parent
84729f90fc
commit
a9e69cd0c4
@ -145,9 +145,15 @@ public:
|
|||||||
QString comPort) const override;
|
QString comPort) const override;
|
||||||
|
|
||||||
bool dc_updatePrinterTemplate(enum FileTypeJson type,
|
bool dc_updatePrinterTemplate(enum FileTypeJson type,
|
||||||
int templateNr,
|
QVector<int> templateIdx,
|
||||||
QString const &fname) const override;
|
QVector<QString> fnames,
|
||||||
|
QString br,
|
||||||
|
QString serial) const override;
|
||||||
|
|
||||||
|
bool dc_printTemplate(enum FileTypeJson type,
|
||||||
|
QVector<int> templateIdx,
|
||||||
|
QString br,
|
||||||
|
QString serial) const override;
|
||||||
// ------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------
|
||||||
// Level 1, control device-controller (functions of µC)
|
// Level 1, control device-controller (functions of µC)
|
||||||
// check serial connection to deviceController
|
// check serial connection to deviceController
|
||||||
|
@ -307,8 +307,15 @@ public:
|
|||||||
// download binary file down into device controller
|
// download binary file down into device controller
|
||||||
|
|
||||||
virtual bool dc_updatePrinterTemplate(enum FileTypeJson type,
|
virtual bool dc_updatePrinterTemplate(enum FileTypeJson type,
|
||||||
int templateNr,
|
QVector<int> templateIdx,
|
||||||
QString const &fname) const = 0;
|
QVector<QString> fnames,
|
||||||
|
QString br,
|
||||||
|
QString serial) const = 0;
|
||||||
|
|
||||||
|
virtual bool dc_printTemplate(enum FileTypeJson type,
|
||||||
|
QVector<int> templateIdx,
|
||||||
|
QString br,
|
||||||
|
QString serial) const = 0;
|
||||||
|
|
||||||
virtual void dc_autoRequest(bool on) const =0;
|
virtual void dc_autoRequest(bool on) const =0;
|
||||||
// on = true: select that all READ-Requests are sent automatically
|
// on = true: select that all READ-Requests are sent automatically
|
||||||
|
@ -122,17 +122,17 @@ struct T_vaultRecord
|
|||||||
//16
|
//16
|
||||||
char label3buffer[4]; // mw >
|
char label3buffer[4]; // mw >
|
||||||
|
|
||||||
// Verkauf, Tür zu:
|
// Verkauf, Tür zu:
|
||||||
uint32_t VKcoinsInserted[16]; // nur für Wechsler, soviel wurde eingeworfen
|
uint32_t VKcoinsInserted[16]; // nur für Wechsler, soviel wurde eingeworfen
|
||||||
uint32_t VKcoinsReturned[6]; // nur für Wechsler, Anzahl Münzen pro Typ, soviel wurde zurückgegeben
|
uint32_t VKcoinsReturned[6]; // nur für Wechsler, Anzahl Münzen pro Typ, soviel wurde zurückgegeben
|
||||||
//88
|
//88
|
||||||
|
|
||||||
// Service, Tür offen:
|
// Service, Tür offen:
|
||||||
uint16_t ServCoinsInserted[16]; // nur für Wechsler, soviel wurde eingeworfen
|
uint16_t ServCoinsInserted[16]; // nur für Wechsler, soviel wurde eingeworfen
|
||||||
uint16_t ServCoinsReturned[6]; // nur für Wechsler, Anzahl Münzen pro Typ, soviel wurde zurückgegeben
|
uint16_t ServCoinsReturned[6]; // nur für Wechsler, Anzahl Münzen pro Typ, soviel wurde zurückgegeben
|
||||||
uint16_t resint3;
|
uint16_t resint3;
|
||||||
uint16_t resint4;
|
uint16_t resint4;
|
||||||
uint16_t currentTubeContent[6]; // nur für Wechsler, aktueller Füllstand
|
uint16_t currentTubeContent[6]; // nur für Wechsler, aktueller Füllstand
|
||||||
uint16_t resint5;
|
uint16_t resint5;
|
||||||
uint16_t resint6;
|
uint16_t resint6;
|
||||||
// 56
|
// 56
|
||||||
@ -265,6 +265,7 @@ class hwinf
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
enum class DownloadResult {OK, ERROR, TIMEOUT, NOP};
|
enum class DownloadResult {OK, ERROR, TIMEOUT, NOP};
|
||||||
|
enum class FileTypeJson {CONFIG=1, DEVICE, CASH, SERIAL, TIME, PRINTER};
|
||||||
|
|
||||||
virtual ~hwinf() {}
|
virtual ~hwinf() {}
|
||||||
|
|
||||||
@ -305,6 +306,17 @@ public:
|
|||||||
QString comPort) const = 0;
|
QString comPort) const = 0;
|
||||||
// download binary file down into device controller
|
// download binary file down into device controller
|
||||||
|
|
||||||
|
virtual bool dc_updatePrinterTemplate(enum FileTypeJson type,
|
||||||
|
QVector<int> templateIdx,
|
||||||
|
QVector<QString> fnames,
|
||||||
|
QString br,
|
||||||
|
QString serial) const = 0;
|
||||||
|
|
||||||
|
virtual bool dc_printTemplate(enum FileTypeJson type,
|
||||||
|
QVector<int> templateIdx,
|
||||||
|
QString br,
|
||||||
|
QString serial) const = 0;
|
||||||
|
|
||||||
virtual void dc_autoRequest(bool on) const =0;
|
virtual void dc_autoRequest(bool on) const =0;
|
||||||
// on = true: select that all READ-Requests are sent automatically
|
// on = true: select that all READ-Requests are sent automatically
|
||||||
// on = false: select that all READ-Requests are sent manually one by one
|
// on = false: select that all READ-Requests are sent manually one by one
|
||||||
@ -320,7 +332,7 @@ public:
|
|||||||
// get data back in "payLoad", max 64 byte, can be used for diagnosis
|
// get data back in "payLoad", max 64 byte, can be used for diagnosis
|
||||||
// retval = nr of bytes received. If host buffer too small then
|
// retval = nr of bytes received. If host buffer too small then
|
||||||
// only plBufSiz bytes are copied to "payLoad"
|
// only plBufSiz bytes are copied to "payLoad"
|
||||||
// plBufSizz=size of host buffer
|
// plBufSizz=size of host buffer
|
||||||
|
|
||||||
virtual void dc_requTestResponse() const =0;
|
virtual void dc_requTestResponse() const =0;
|
||||||
// tell DC2 to send a test-string, useful to see if cable and baudrate is OK
|
// tell DC2 to send a test-string, useful to see if cable and baudrate is OK
|
||||||
@ -441,10 +453,10 @@ public:
|
|||||||
|
|
||||||
// Analog values:
|
// Analog values:
|
||||||
virtual uint32_t dc_getTemperature(void) const =0;
|
virtual uint32_t dc_getTemperature(void) const =0;
|
||||||
// in Sax-Format 0...400 (0=-50,0°C 100=0,0°C 141=20,5°C 400=150,0°C)
|
// in Sax-Format 0...400 (0=-50,0°C 100=0,0°C 141=20,5°C 400=150,0°C)
|
||||||
|
|
||||||
virtual QString dc_getTemperaturStr(void) const =0;
|
virtual QString dc_getTemperaturStr(void) const =0;
|
||||||
// as string like "-12,5°C"
|
// as string like "-12,5°C"
|
||||||
|
|
||||||
virtual uint32_t dc_getVoltage(void) const =0;
|
virtual uint32_t dc_getVoltage(void) const =0;
|
||||||
// as value in mV, 0...65,535V
|
// as value in mV, 0...65,535V
|
||||||
@ -599,7 +611,7 @@ public:
|
|||||||
uint8_t kindOfModem, uint8_t kindOfCredit ) const =0;
|
uint8_t kindOfModem, uint8_t kindOfCredit ) const =0;
|
||||||
// enable hardware in device controller:
|
// enable hardware in device controller:
|
||||||
// kindOfPrinter: 0:off 1: GPT4672 (only this one implemented)
|
// kindOfPrinter: 0:off 1: GPT4672 (only this one implemented)
|
||||||
// kindOfCoinChecker: 0:off 1:EMP820 2:EMP900 3: C²_changer
|
// kindOfCoinChecker: 0:off 1:EMP820 2:EMP900 3: C²_changer
|
||||||
// kindOfMifareReader: 0:off 1: SL025 (only this one implemented)
|
// kindOfMifareReader: 0:off 1: SL025 (only this one implemented)
|
||||||
// suppressSleep: 0:sleep allowed 1: sleep surpressed for special reason
|
// suppressSleep: 0:sleep allowed 1: sleep surpressed for special reason
|
||||||
// kindOfModem: 0:off 1: ATB_Sunlink_LTE (not yet implemented)
|
// kindOfModem: 0:off 1: ATB_Sunlink_LTE (not yet implemented)
|
||||||
@ -705,7 +717,7 @@ public:
|
|||||||
// send 5 byte: byte 0,1: speed 5...250 mm/s
|
// send 5 byte: byte 0,1: speed 5...250 mm/s
|
||||||
// byte2: density 0....(25)....50
|
// byte2: density 0....(25)....50
|
||||||
// byte3: alignment 'l', 'c', 'r' = left, center, right
|
// byte3: alignment 'l', 'c', 'r' = left, center, right
|
||||||
// byte4: orientation 0, 90, 180 = 0°, 90°, 180° rotation (by now not supported!)
|
// byte4: orientation 0, 90, 180 = 0°, 90°, 180° rotation (by now not supported!)
|
||||||
// not batched! don't use twice within 100ms
|
// not batched! don't use twice within 100ms
|
||||||
|
|
||||||
virtual void prn_movePaper(uint8_t wayInMm, uint8_t direction) const =0;
|
virtual void prn_movePaper(uint8_t wayInMm, uint8_t direction) const =0;
|
||||||
@ -1273,7 +1285,7 @@ public:
|
|||||||
|
|
||||||
|
|
||||||
// Komplett-schreib Funktion, noch nicht getestet
|
// Komplett-schreib Funktion, noch nicht getestet
|
||||||
// Nachteil: keine Rückmeldung wie lang's noch dauert
|
// Nachteil: keine Rückmeldung wie lang's noch dauert
|
||||||
//virtual void bl_startSending(void) const=0;
|
//virtual void bl_startSending(void) const=0;
|
||||||
// call once after BL is working and file is loaded
|
// call once after BL is working and file is loaded
|
||||||
//virtual void bl_sendFile(void) const=0;
|
//virtual void bl_sendFile(void) const=0;
|
||||||
@ -1299,7 +1311,7 @@ public:
|
|||||||
buf[4]=GlobTime.Month;
|
buf[4]=GlobTime.Month;
|
||||||
buf[5]=GlobTime.Day;
|
buf[5]=GlobTime.Day;
|
||||||
buf[6]=GlobTime.DOW;
|
buf[6]=GlobTime.DOW;
|
||||||
buf[7]=' '; // immer auf 32bit auffüllen sonst Speicherproblem beim Master!
|
buf[7]=' '; // immer auf 32bit auffüllen sonst Speicherproblem beim Master!
|
||||||
uitmp=GlobTime.MinOfDay;
|
uitmp=GlobTime.MinOfDay;
|
||||||
buf[8]=swl_getOneByteFromUint(uitmp, 0);
|
buf[8]=swl_getOneByteFromUint(uitmp, 0);
|
||||||
buf[9]=swl_getOneByteFromUint(uitmp, 1);
|
buf[9]=swl_getOneByteFromUint(uitmp, 1);
|
||||||
|
103
src/hwapi.cpp
103
src/hwapi.cpp
@ -10,6 +10,7 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
|
|
||||||
@ -412,33 +413,116 @@ bool hwapi::dc_updateDC(QString bFile, QString br, QString serial) const {
|
|||||||
//
|
//
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
bool hwapi::dc_updatePrinterTemplate(enum FileTypeJson type,
|
bool hwapi::dc_updatePrinterTemplate(enum FileTypeJson type,
|
||||||
int nrOfTemplate,
|
QVector<int> templatesIdx,
|
||||||
QString const &fname) const {
|
QVector<QString> fnames,
|
||||||
if ((type == FileTypeJson::PRINTER) &&
|
QString br,
|
||||||
(nrOfTemplate >= 1 && nrOfTemplate <= 32)) {
|
QString serial) const {
|
||||||
|
// sanity checks
|
||||||
|
if (!baudrateMap.contains(br)) {
|
||||||
|
qCritical() << "passed wrong baudrate" << br;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (templatesIdx.size() != fnames.size()) {
|
||||||
|
qCritical() << "list sizes must be equal" << br;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!std::all_of(templatesIdx.cbegin(), templatesIdx.cend(),
|
||||||
|
[](int i) { return i >= 1 && i <= 32; })) {
|
||||||
|
qCritical() << "wrong template indices";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (type != FileTypeJson::PRINTER) {
|
||||||
|
qCritical() << "wrong file type" << (uint8_t)type;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
qDebug() << "updating: " << fnames << br << serial << "...";
|
||||||
|
|
||||||
|
if (!openSerial(baudrateMap.value(br), br, serial)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
int nTry = 50;
|
int nTry = 50;
|
||||||
while (!sys_ready4sending()) { // wait max. 5 seconds
|
while (!sys_ready4sending()) { // wait max. 5 seconds
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(100));
|
std::this_thread::sleep_for(std::chrono::milliseconds(100));
|
||||||
if (--nTry <= 0) {
|
if (--nTry <= 0) {
|
||||||
|
qCritical() << "sys not ready for sending";
|
||||||
|
closeSerial(serial);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
QFile file(fname);
|
|
||||||
|
bool ret = true;
|
||||||
|
for (int i = 0; i < fnames.size(); ++i) {
|
||||||
|
QFile file(fnames[i]);
|
||||||
if (file.exists() && file.open(QIODevice::ReadOnly)) {
|
if (file.exists() && file.open(QIODevice::ReadOnly)) {
|
||||||
QByteArray ba = file.readAll();
|
QByteArray ba = file.readAll();
|
||||||
if (ba.size() <= 800) { // max. size is 800 bytes
|
if (ba.size() <= 800) { // max. size is 800 bytes
|
||||||
if (sys_sendJsonFileToDc((uint8_t)(type),
|
if (sys_sendJsonFileToDc((uint8_t)(type),
|
||||||
nrOfTemplate,
|
templatesIdx[i],
|
||||||
(uint8_t *)ba.data())) {
|
(uint8_t *)ba.data())) {
|
||||||
std::this_thread::sleep_for(std::chrono::seconds(1));
|
std::this_thread::sleep_for(std::chrono::seconds(1));
|
||||||
return true;
|
qInfo() << "sent file" << fnames[i] << "to dc";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
qCritical() << fnames[i] << "!!! does not exist!!!";
|
||||||
|
ret = false;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
closeSerial(serial);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool hwapi::dc_printTemplate(enum FileTypeJson type,
|
||||||
|
QVector<int> templateIdx,
|
||||||
|
QString br,
|
||||||
|
QString serial) const {
|
||||||
|
// sanity checks
|
||||||
|
if (!baudrateMap.contains(br)) {
|
||||||
|
qCritical() << "passed wrong baudrate" << br;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!std::all_of(templateIdx.cbegin(), templateIdx.cend(),
|
||||||
|
[](int i) { return i >= 1 && i <= 32; })) {
|
||||||
|
qCritical() << "wrong template indices";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (type != FileTypeJson::PRINTER) {
|
||||||
|
qCritical() << "wrong file type" << (uint8_t)type;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
qDebug() << "printing: " << templateIdx << br << serial << "...";
|
||||||
|
|
||||||
|
if (!openSerial(baudrateMap.value(br), br, serial)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
int nTry = 50;
|
||||||
|
while (!sys_ready4sending()) { // wait max. 5 seconds
|
||||||
|
std::this_thread::sleep_for(std::chrono::milliseconds(100));
|
||||||
|
if (--nTry <= 0) {
|
||||||
|
qCritical() << "sys not ready for sending";
|
||||||
|
closeSerial(serial);
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
bool ret = true;
|
||||||
|
for (int i = 0; i < templateIdx.size(); ++i) {
|
||||||
|
if (prn_printTemplate(templateIdx[i])) {
|
||||||
|
qDebug() << "printing template" << templateIdx[i];
|
||||||
|
std::this_thread::sleep_for(std::chrono::seconds(3));
|
||||||
|
} else {
|
||||||
|
ret = false;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
closeSerial(serial);
|
||||||
|
return ret;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------
|
||||||
@ -3284,7 +3368,8 @@ bool hwapi::sys_sendJsonFileToDc(uint8_t kindOfFile, uint8_t nrOfTemplate, uint8
|
|||||||
{
|
{
|
||||||
biox_CopyBlock(inhaltOfJson, uitmp, temp, 0, 64);
|
biox_CopyBlock(inhaltOfJson, uitmp, temp, 0, 64);
|
||||||
longFDcmd_set(31,0, bn++, 64, temp);
|
longFDcmd_set(31,0, bn++, 64, temp);
|
||||||
uitmp<<=6;
|
uitmp += 64;
|
||||||
|
// uitmp<<=6;
|
||||||
} while(uitmp < dateiLang);
|
} while(uitmp < dateiLang);
|
||||||
|
|
||||||
longFDcmd_set(32, 0,0, 0,temp); // Abschluss
|
longFDcmd_set(32, 0,0, 0,temp); // Abschluss
|
||||||
|
@ -602,7 +602,7 @@ bool longFDcmd_set(uint8_t nextWrCmd, uint8_t nextRdCmd, uint8_t blockNum, uint8
|
|||||||
uint8_t nn;
|
uint8_t nn;
|
||||||
if (p_longFDcmdsInQueue>=FDLONG_STACKDEPTH)
|
if (p_longFDcmdsInQueue>=FDLONG_STACKDEPTH)
|
||||||
{
|
{
|
||||||
qDebug() << "cannot save cmd because stack is full";
|
qCritical() << "cannot save cmd because stack is full";
|
||||||
return false; // not possible
|
return false; // not possible
|
||||||
}
|
}
|
||||||
longFDwrCmd[p_longFDcmdsInQueue]=nextWrCmd;
|
longFDwrCmd[p_longFDcmdsInQueue]=nextWrCmd;
|
||||||
@ -613,6 +613,7 @@ bool longFDcmd_set(uint8_t nextWrCmd, uint8_t nextRdCmd, uint8_t blockNum, uint8
|
|||||||
longFDpara[p_longFDcmdsInQueue][nn]=data[nn];
|
longFDpara[p_longFDcmdsInQueue][nn]=data[nn];
|
||||||
|
|
||||||
p_longFDcmdsInQueue++;
|
p_longFDcmdsInQueue++;
|
||||||
|
|
||||||
return true; // ok, will be sent
|
return true; // ok, will be sent
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user