Compare commits

..

2 Commits

Author SHA1 Message Date
9cac6a6461 Added comment for std::atomic<bool>::exchange() 2024-02-21 10:46:34 +01:00
aa10d3b275 Add atomic<bool> variable m_coinAttached to check for state change:
send signal runProc_coinAttached only if state changes from false true.
2024-02-21 10:39:03 +01:00
2 changed files with 14 additions and 2 deletions

View File

@ -15,6 +15,7 @@
#include <QDebug>
#include "datIf.h"
#include <QSharedMemory>
#include <atomic>
#include "sendWRcmd.h"
#include "controlBus.h"
#include "storeINdata.h"
@ -35,6 +36,10 @@ class T_runProc : public QObject
void restoreDeviceParameter(struct T_devices *deviceSettings);
#ifndef THIS_IS_CA_MASTER
std::atomic_bool m_coinAttached{false};
#endif
private slots:
void runProc_slotProcess(void);
bool bl_performComplStart(void);

View File

@ -48,8 +48,15 @@ T_runProc::T_runProc()
void T_runProc::runProc_slotProcess(void)
{
#ifndef THIS_IS_CA_MASTER
if (epi_getDI_CoinAttach()) {
emit runProc_coinAttached();
bool const coinAttached = epi_getDI_CoinAttach();
// exchange: (atomically) replaces the underlying value of m_coinAttached
// with the value of coinAttached, returns the value of m_coinAttached
// before the call
if (m_coinAttached.exchange(coinAttached) == false) {
if (coinAttached) {
// old value was false, and new value is true
emit runProc_coinAttached();
}
}
cash_paymentProcessing();
doors_supervise();