Reworked transmitter.
This commit is contained in:
@@ -39,8 +39,10 @@
|
||||
BCTransmitter::BCTransmitter(QObject *parent)
|
||||
: QObject(parent), _isBusy(false)
|
||||
{
|
||||
_canDriver = new BCDriverTinyCan{this};
|
||||
//_canDriver = new BCDriverDummy{this};
|
||||
//_canDriver = new BCDriverTinyCan{this};
|
||||
_canDriver = new BCDriverDummy{this};
|
||||
// forward driver state
|
||||
connect( _canDriver, &BCDriver::driverStateChanged, this, &BCTransmitter::driverStateChanged );
|
||||
}
|
||||
|
||||
|
||||
@@ -82,11 +84,14 @@ void BCTransmitter::enqueueValue( BCValuePtrConst value)
|
||||
// invokeMethod mit QueuedConnection entkoppelt den Aufruf,
|
||||
// damit enqueueValue sofort zurückkehrt (non-blocking für den Aufrufer).
|
||||
|
||||
//QMetaObject::invokeMethod(this, "processValue", Qt::QueuedConnection);
|
||||
QMetaObject::invokeMethod(this, "processValue", Qt::QueuedConnection);
|
||||
|
||||
/*
|
||||
QMetaObject::invokeMethod(this, [this]()
|
||||
{
|
||||
processValue();
|
||||
}, Qt::QueuedConnection );
|
||||
*/
|
||||
}
|
||||
|
||||
void BCTransmitter::processValue()
|
||||
@@ -114,13 +119,15 @@ void BCTransmitter::processValue()
|
||||
const BCValue& value = *(valuePtr.get());
|
||||
|
||||
// Value ist 'under construction'
|
||||
//emit valueUpdated( val.deviceID, val.indexRow, BCValue::State::Locked );
|
||||
|
||||
//emit valueUpdated( value.deviceID, value.indexRow, BCValue::State::Locked );
|
||||
|
||||
const BCValueType& valueType = *value.valueType;
|
||||
uint32_t devID = static_cast<uint32_t>(value.deviceID);
|
||||
uint8_t regID = static_cast<uint8_t> (value.registerID);
|
||||
|
||||
QString newVisibleValue;
|
||||
BCValue::State newState = BCValue::State::NoState;
|
||||
|
||||
if(value.state.testFlag( BCValue::State::WriteMe ) )
|
||||
{
|
||||
|
||||
@@ -135,11 +142,18 @@ void BCTransmitter::processValue()
|
||||
// wir sind hier im anderen thread! nicht einfach so reinschreiben, nur lesen
|
||||
TransmitResult result = valueType.readValueFunc( *this, devID, regID );
|
||||
if( result.has_value() )
|
||||
{
|
||||
newVisibleValue = valueType.formatValue( result.value() );
|
||||
//emit valueUpdated( value.deviceID, value.indexRow, BCValue::State::InSync, result );
|
||||
newState = BCValue::State::InSync;
|
||||
}
|
||||
else
|
||||
{
|
||||
newState = BCValue::State::Failed;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// emit valueUpdated( value->deviceID, value->indexRow, BCValue::State::InSync, "fitze!");
|
||||
emit valueUpdated( value.deviceID, value.indexRow, newState, newVisibleValue );
|
||||
|
||||
// __fix
|
||||
bc::processEventsFor(50);
|
||||
|
||||
Reference in New Issue
Block a user