Compare commits
7 Commits
palanga-sw
...
1.99.11-2
Author | SHA1 | Date | |
---|---|---|---|
1897e8237a
|
|||
d5693cb2b1
|
|||
d3b1046a9f | |||
a98ddbdb85 | |||
dd29fb0762
|
|||
c9e5834e29
|
|||
8fa6d40a0c
|
@@ -117,7 +117,9 @@ private:
|
|||||||
ReportingThread *m_reportingThread;
|
ReportingThread *m_reportingThread;
|
||||||
DownloadThread *m_downloadThread;
|
DownloadThread *m_downloadThread;
|
||||||
QScopedPointer<QFileSystemWatcher> m_fileSystemWatcher;
|
QScopedPointer<QFileSystemWatcher> m_fileSystemWatcher;
|
||||||
QString m_watchedFile;
|
|
||||||
|
QString m_powerctrl_cc;
|
||||||
|
QString m_powerctrl_modem;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void onCCWakeGpioChanged(QString const &file);
|
void onCCWakeGpioChanged(QString const &file);
|
||||||
|
@@ -1205,7 +1205,7 @@ char T_datif::loadRecDataFromFrame()
|
|||||||
uit2=0;
|
uit2=0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (uit2==3 || uit2==5 || uit2==10 || uit2==20 || uit2==50 || uit2==100 || uit2==200 || uit2==500)
|
if (uit2==3 || uit2==5 || uit2==10 || uit2==20 || uit2==40 || uit2==50 || uit2==100 || uit2==200 || uit2==500)
|
||||||
{
|
{
|
||||||
// valid coin
|
// valid coin
|
||||||
if ((newInsertedAmount != lastInsertedAmount) || uit2>0 )
|
if ((newInsertedAmount != lastInsertedAmount) || uit2>0 )
|
||||||
|
@@ -60,16 +60,21 @@ hwapi::hwapi(QObject *parent) : QObject(parent)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
QSettings settings("/opt/app/ATBAPP/ATBQT.ini", QSettings::IniFormat);
|
QSettings settings("/opt/app/ATBAPP/ATBQT.ini", QSettings::IniFormat);
|
||||||
m_watchedFile = settings.value("AsyncPOS_CCPlugin/terminal_watch_file",
|
m_powerctrl_cc = settings.value("AsyncPOS_CCPlugin/terminal_watch_file",
|
||||||
"/opt/app/ATBAPP/watch.txt").toString();
|
"/run/powerctrl_cc").toString();
|
||||||
|
|
||||||
m_fileSystemWatcher.reset(new QFileSystemWatcher());
|
m_fileSystemWatcher.reset(new QFileSystemWatcher());
|
||||||
if (!m_fileSystemWatcher->addPath(m_watchedFile)) {
|
|
||||||
qCritical() << "cannot add path for" << m_watchedFile;
|
m_powerctrl_modem = "/run/powerctrl_modem";
|
||||||
|
m_fileSystemWatcher->addPath(m_powerctrl_modem);
|
||||||
|
|
||||||
|
|
||||||
|
if (!m_fileSystemWatcher->addPath(m_powerctrl_cc)) {
|
||||||
|
qCritical() << "cannot add path for" << m_powerctrl_cc;
|
||||||
} else {
|
} else {
|
||||||
if (connect(m_fileSystemWatcher.get(), SIGNAL(fileChanged(QString const&)),
|
if (connect(m_fileSystemWatcher.get(), SIGNAL(fileChanged(QString const&)),
|
||||||
this, SLOT(onCCWakeGpioChanged(QString const&)))) {
|
this, SLOT(onCCWakeGpioChanged(QString const&)))) {
|
||||||
qCritical() << "connected file watcher with" << m_watchedFile;
|
qCritical() << "connected file watcher with" << m_powerctrl_cc;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -137,40 +142,58 @@ hwapi::hwapi(QObject *parent) : QObject(parent)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void hwapi::onCCWakeGpioChanged(QString const &fileName) {
|
void hwapi::onCCWakeGpioChanged(QString const &fileName) {
|
||||||
if (fileName == m_watchedFile) {
|
|
||||||
QFile f(m_watchedFile);
|
qCritical() << __func__ << ":" << __LINE__ << fileName;
|
||||||
if (f.open(QFile::ReadOnly | QFile::Text)) {
|
|
||||||
|
if (fileName == m_powerctrl_cc) {
|
||||||
|
|
||||||
|
QFile f(m_powerctrl_cc);
|
||||||
|
if (f.exists() && f.open(QFile::ReadOnly | QFile::Text)) {
|
||||||
QTextStream stream(&f);
|
QTextStream stream(&f);
|
||||||
QString const &content = stream.readAll();
|
QString const &content = stream.readAll();
|
||||||
if (content.startsWith("0")) {
|
if (content.startsWith("0")) {
|
||||||
qCritical() << __func__ << ":" << __LINE__ << "switching terminal off...";
|
qCritical() << __func__ << ":" << __LINE__ << "switching cc-terminal off...";
|
||||||
mod_switchWake(false);
|
credit_switchWake(false);
|
||||||
mod_switchPower(false);
|
credit_switchPower(false);
|
||||||
f.close();
|
|
||||||
f.setFileName(m_watchedFile);
|
|
||||||
// to turn off cc-terminal, the content must be "0"
|
|
||||||
if (f.open(QFile::WriteOnly | QIODevice::Truncate | QIODevice::Text)) {
|
|
||||||
QTextStream s(&f);
|
|
||||||
s << "switching terminal off";
|
|
||||||
}
|
|
||||||
} else
|
} else
|
||||||
if (content.startsWith("1")) {
|
if (content.startsWith("1")) {
|
||||||
qCritical() << __func__ << ":" << __LINE__ << "switching terminal on...";
|
qCritical() << __func__ << ":" << __LINE__ << "switching cc-terminal on...";
|
||||||
mod_switchPower(true);
|
credit_switchPower(true);
|
||||||
|
credit_switchWake(true);
|
||||||
|
} else
|
||||||
|
if (content.startsWith("2")) {
|
||||||
|
qCritical() << __func__ << ":" << __LINE__ << "switching cc-terminal off and on...";
|
||||||
|
credit_switchWake(false);
|
||||||
|
credit_switchPower(false);
|
||||||
|
QThread::sleep(1);
|
||||||
|
credit_switchPower(true);
|
||||||
|
credit_switchWake(true);
|
||||||
|
} else {
|
||||||
|
qCritical() << "switching cc-terminal watched file contained" << content;
|
||||||
|
QFile::resize(m_powerctrl_cc, 0); // empty file
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (fileName == m_powerctrl_modem) {
|
||||||
|
|
||||||
|
QFile f(m_powerctrl_modem);
|
||||||
|
if (f.exists() && f.open(QFile::ReadOnly | QFile::Text)) {
|
||||||
|
QTextStream stream(&f);
|
||||||
|
QString const &content = stream.readAll();
|
||||||
|
if (content.startsWith("0")) {
|
||||||
|
qCritical() << __func__ << ":" << __LINE__ << "switching modem off...";
|
||||||
|
mod_switchWake(false);
|
||||||
|
mod_switchPower(false);
|
||||||
|
} else
|
||||||
|
if (content.startsWith("1")) {
|
||||||
|
qCritical() << __func__ << ":" << __LINE__ << "switching modem on...";
|
||||||
mod_switchWake(true);
|
mod_switchWake(true);
|
||||||
f.close();
|
mod_switchPower(true);
|
||||||
f.setFileName(m_watchedFile);
|
|
||||||
// to turn on cc-terminal, the content must be "1"
|
|
||||||
if (f.open(QFile::WriteOnly | QIODevice::Truncate | QIODevice::Text)) {
|
|
||||||
QTextStream s(&f);
|
|
||||||
s << "switching terminal on";
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
qCritical() << "watched file contained" << content;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
qCritical() << "ERROR watching the wrong file" << fileName;
|
else {
|
||||||
|
qCritical() << "ERROR watching the wrong file" << fileName << m_powerctrl_cc;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user