Move value flags to bcvalue class definition.
This commit is contained in:
18
bc.h
18
bc.h
@@ -119,24 +119,6 @@ struct BC
|
||||
|
||||
public:
|
||||
|
||||
enum class OpID : uint8_t
|
||||
{
|
||||
ReadValue,
|
||||
WriteValue,
|
||||
};
|
||||
Q_ENUM(OpID)
|
||||
|
||||
// __fix! flags draus machen ?
|
||||
enum class State : uint8_t
|
||||
{
|
||||
Invalid,
|
||||
Locked,
|
||||
Failed,
|
||||
InSync,
|
||||
OK
|
||||
};
|
||||
Q_ENUM(State)
|
||||
|
||||
enum class ID : uint8_t
|
||||
{
|
||||
//{%Region Console}
|
||||
|
||||
@@ -77,7 +77,7 @@ void BCDeviceView::onValueListReady( BCDevice::ID deviceID, BCValueList valueLis
|
||||
_valueModel.takeValueList( valueList );
|
||||
}
|
||||
|
||||
void BCDeviceView::onValueUpdated(int index, BC::State state, const QString& newVisibleValue )
|
||||
void BCDeviceView::onValueUpdated(int index, BCValue::State state, const QString& newVisibleValue )
|
||||
{
|
||||
_valueModel.onValueUpdated( index,state,newVisibleValue);
|
||||
_itemDelegate->onHighlightRow( index );
|
||||
|
||||
@@ -58,7 +58,7 @@ public:
|
||||
public slots:
|
||||
|
||||
void onValueListReady( BCDevice::ID deviceID, BCValueList valueList );
|
||||
void onValueUpdated( int index, BC::State state, const QString& newVisibleValue="" );
|
||||
void onValueUpdated( int index, BCValue::State state, const QString& newVisibleValue="" );
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
@@ -153,7 +153,7 @@ void BCMainWindow::initMainWindow()
|
||||
|
||||
_transmitter.moveToThread(&_worker);
|
||||
|
||||
connect(this, &BCMainWindow::sendValueCommand, &_transmitter, &BCTransmitter::enqueueValueOp);
|
||||
connect(this, &BCMainWindow::requestValueUpdate, &_transmitter, &BCTransmitter::enqueueValueOp);
|
||||
|
||||
// B) Ergebnisse empfangen (Runner -> Manager)
|
||||
//connect(&_transmitter, &BCTransmitter::valueStateChanged, this, &BCDataManager::onvalueStateChanged);
|
||||
@@ -221,9 +221,9 @@ void BCMainWindow::onConnectButtonToggled(bool checked )
|
||||
//_dataManager.setDriverConnectionState( checked );
|
||||
}
|
||||
|
||||
void BCMainWindow::onValueUpdated(BCDevice::ID deviceID, int index, BC::State state, const QString& newValue )
|
||||
void BCMainWindow::onValueUpdated(BCDevice::ID deviceID, int index, BCValue::State state, const QString& newValue )
|
||||
{
|
||||
qDebug() << "Reply: from: " << deviceID << " at: " << index << "finished. Success:" << state << " on:" << newValue;
|
||||
qDebug() << "Reply: from: " << deviceID << " at: " << index << "finished. Success:" << (uint8_t)state << " on:" << newValue;
|
||||
if( _devicePanels.contains( deviceID ) )
|
||||
{
|
||||
BCDeviceView& panel = *_devicePanels[deviceID];
|
||||
@@ -249,15 +249,8 @@ void BCMainWindow::onSyncFromDevice()
|
||||
qDebug() << " --- value: " << value.label;
|
||||
|
||||
// statt '_transmitter.enqueueValueCommand( value )' entkoppeln
|
||||
// wir das eleganter über emit sendValueCommand()
|
||||
|
||||
//_transmitter.enqueueValueCommand( value );
|
||||
emit sendValueCommand( BC::OpID::ReadValue, &value);
|
||||
//emit valueTouched( value.indexRow );
|
||||
|
||||
bc::processEventsFor(50);
|
||||
|
||||
|
||||
// wir das eleganter über emit requestValueUpdate()
|
||||
emit requestValueUpdate( BCValue::OpID::ReadValue, &value);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -60,13 +60,13 @@ public slots:
|
||||
void onConnectButtonToggled(bool active );
|
||||
|
||||
// Slots für Rückmeldungen vom Runner
|
||||
void onValueUpdated( BCDevice::ID deviceID, int index, BC::State state, const QString& newValue="" );
|
||||
void onValueUpdated( BCDevice::ID deviceID, int index, BCValue::State state, const QString& newValue="" );
|
||||
void onSyncFromDevice();
|
||||
|
||||
signals:
|
||||
|
||||
// Internes Signal, um Daten an den Worker Thread zu senden
|
||||
void sendValueCommand( BC::OpID, const BCValue* cmd);
|
||||
void requestValueUpdate( BCValue::OpID, const BCValue* cmd);
|
||||
//void valuedTouched(const BCValue& cmd);
|
||||
void valueTouched(int indexRow );
|
||||
|
||||
|
||||
@@ -84,7 +84,7 @@ void BCTransmitter::onToggleConnectionState( bool connect )
|
||||
}
|
||||
|
||||
|
||||
void BCTransmitter::enqueueValueOp(BC::OpID opID, const BCValue* value)
|
||||
void BCTransmitter::enqueueValueOp(BCValue::OpID opID, const BCValue* value)
|
||||
{
|
||||
QMutexLocker locker(&_mutex);
|
||||
_valueQueue.enqueue( value );
|
||||
@@ -100,11 +100,11 @@ void BCTransmitter::enqueueValueOp(BC::OpID opID, const BCValue* value)
|
||||
//QMetaObject::invokeMethod(this, "processValueOp", Qt::QueuedConnection);
|
||||
QMetaObject::invokeMethod(this, [this, opID]()
|
||||
{
|
||||
this->processValueOp(opID);
|
||||
processValueOp(opID);
|
||||
}, Qt::QueuedConnection );
|
||||
}
|
||||
|
||||
void BCTransmitter::processValueOp( BC::OpID opID )
|
||||
void BCTransmitter::processValueOp( BCValue::OpID opID )
|
||||
{
|
||||
|
||||
if (_isBusy)
|
||||
@@ -131,14 +131,14 @@ void BCTransmitter::processValueOp( BC::OpID opID )
|
||||
// Abkürzung
|
||||
const BCValue& val = *currentValue;
|
||||
// Value ist 'under construction'
|
||||
//emit valueUpdated( val.deviceID, val.indexRow, BC::State::Locked );
|
||||
if( opID == BC::OpID::ReadValue )
|
||||
//emit valueUpdated( val.deviceID, val.indexRow, BCValue::State::Locked );
|
||||
if( opID == BCValue::OpID::ReadValue )
|
||||
{
|
||||
QString result = currentValue->readRawValueX( *this );
|
||||
emit valueUpdated( val.deviceID, val.indexRow, BC::State::InSync, result );
|
||||
emit valueUpdated( val.deviceID, val.indexRow, BCValue::State::InSync, result );
|
||||
}
|
||||
|
||||
else if( opID == BC::OpID::WriteValue )
|
||||
else if( opID == BCValue::OpID::WriteValue )
|
||||
{
|
||||
currentValue->writeRawValueX( *this );
|
||||
}
|
||||
@@ -149,6 +149,9 @@ void BCTransmitter::processValueOp( BC::OpID opID )
|
||||
qDebug() << " --- OUCH!";
|
||||
}
|
||||
|
||||
// __fix
|
||||
bc::processEventsFor(50);
|
||||
|
||||
//emit valueStateChanged(cmd.id, true);
|
||||
//emit valueStateChanged(0, true);
|
||||
}
|
||||
|
||||
@@ -56,12 +56,12 @@ public:
|
||||
public slots:
|
||||
|
||||
void onToggleConnectionState( bool connect );
|
||||
void enqueueValueOp(BC::OpID opID, const BCValue* value );
|
||||
void processValueOp(BC::OpID opID);
|
||||
void enqueueValueOp(BCValue::OpID opID, const BCValue* value );
|
||||
void processValueOp(BCValue::OpID opID);
|
||||
|
||||
signals:
|
||||
|
||||
void valueUpdated(BCDevice::ID deviceID, int index, BC::State state, const QString& newValue="" );
|
||||
void valueUpdated(BCDevice::ID deviceID, int index, BCValue::State state, const QString& newValue="" );
|
||||
void messageLogged(const QString& msg);
|
||||
|
||||
private:
|
||||
|
||||
20
bcvalue.h
20
bcvalue.h
@@ -78,6 +78,24 @@ class BCValue
|
||||
|
||||
public:
|
||||
|
||||
enum class OpID : uint8_t
|
||||
{
|
||||
ReadValue,
|
||||
WriteValue,
|
||||
};
|
||||
//Q_ENUM(OpID)
|
||||
|
||||
// __fix! flags draus machen ?
|
||||
enum class State : uint8_t
|
||||
{
|
||||
Invalid,
|
||||
Locked,
|
||||
Failed,
|
||||
InSync,
|
||||
OK
|
||||
};
|
||||
//Q_ENUM(State)
|
||||
|
||||
BCValue( const BCValueType* valueType_, BCDevice::ID deviceID_, BC::ID registerID_ );
|
||||
|
||||
QString readRawValueX( const BCAbstractTransmitter& transmitter ) const;
|
||||
@@ -87,7 +105,7 @@ public:
|
||||
// später
|
||||
//protected:
|
||||
|
||||
mutable BC::State state{BC::State::Invalid};
|
||||
mutable State state{BCValue::State::Invalid};
|
||||
//const BCValueType& valueType;
|
||||
//BCValueTypeCRef valueType;
|
||||
const BCValueType* valueType{};
|
||||
|
||||
@@ -93,7 +93,7 @@ void BCValueModel::takeValueList(BCValueList& newValueList)
|
||||
* @param newValue Der neue sichtbare Zahlenwert, formatiert als QString, optionall
|
||||
*/
|
||||
|
||||
void BCValueModel::onValueUpdated( int row, BC::State state, const QString& newVisisbleValue )
|
||||
void BCValueModel::onValueUpdated( int row, BCValue::State state, const QString& newVisisbleValue )
|
||||
{
|
||||
qDebug() << " BCValueModel::onValueUpdated update: " << newVisisbleValue;
|
||||
if( row > -1 && row < _valueList.size() )
|
||||
|
||||
@@ -69,7 +69,7 @@ public:
|
||||
|
||||
public slots:
|
||||
|
||||
void onValueUpdated(int index, BC::State state, const QString& newVisisbleValue="" );
|
||||
void onValueUpdated(int index, BCValue::State state, const QString& newVisisbleValue="" );
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user