Create and rework data handling, part I

This commit is contained in:
2025-12-21 10:30:39 +01:00
parent f83f351d99
commit c382ba472d
12 changed files with 1540 additions and 25 deletions

View File

@@ -50,10 +50,10 @@ void BCTransmitter::onToggleConnectionState( bool connect )
}
void BCTransmitter::enqueueValueCommand(BC::OpID opID, const BCValue& value)
void BCTransmitter::enqueueValueOp(BC::OpID opID, const BCValue* value)
{
QMutexLocker locker(&_mutex);
_valueQueue.enqueue( std::ref(value) );
_valueQueue.enqueue( value );
// Logging (Thread-safe via Signal)
//emit messageLogged(QString("Command %1 queued.").arg(cmd.label));
@@ -64,16 +64,16 @@ void BCTransmitter::enqueueValueCommand(BC::OpID opID, const BCValue& value)
// Trigger processing im Event-Loop des Worker Threads
// invokeMethod mit QueuedConnection entkoppelt den Aufruf,
// damit enqueueValueCommand sofort zurückkehrt (non-blocking für den Aufrufer).
// damit enqueueValueOp sofort zurückkehrt (non-blocking für den Aufrufer).
//QMetaObject::invokeMethod(this, "processValueCommand", Qt::QueuedConnection);
//QMetaObject::invokeMethod(this, "processValueOp", Qt::QueuedConnection);
QMetaObject::invokeMethod(this, [this, opID]()
{
this->processValueCommand(opID);
this->processValueOp(opID);
}, Qt::QueuedConnection );
}
void BCTransmitter::processValueCommand( BC::OpID opID )
void BCTransmitter::processValueOp( BC::OpID opID )
{
if (_isBusy)
@@ -83,7 +83,7 @@ void BCTransmitter::processValueCommand( BC::OpID opID )
while (true)
{
BCValue currentValue;
const BCValue* currentValue{};
{
QMutexLocker locker(&_mutex);
if (_valueQueue.isEmpty())
@@ -95,12 +95,13 @@ void BCTransmitter::processValueCommand( BC::OpID opID )
} // Mutex wird hier freigegeben! WICHTIG: Execute ohne Lock!
std::optional<uint32_t> result;
// 3. Ausführung (Dauert potentiell lange)
/*
if( opID == BC::OpID::ReadValue )
result = executeRead(currentValue);
else if( opID == BC::OpID::WriteValue )
result = executeRead(currentValue);
*/
//emit commandFinished(cmd.id, true);
//emit commandFinished(0, true);
}