Recreated device sync, part I.

This commit is contained in:
2025-12-28 14:42:12 +01:00
parent a0bedf254d
commit 94323e7409
5 changed files with 35 additions and 34 deletions

View File

@@ -83,11 +83,16 @@ QTableView* BCDevicePanel::getValueView()
}
const BCValueList& BCDevicePanel::getValueList()
{
return _valueModel.getValueList();
}
void BCDevicePanel::onValueListReady( BCDevice::ID deviceID, BCValueList valueList )
{
qDebug() << " --- onValueListReady: " << getHeaderText() <<" : " << deviceID << ": " << valueList.size();
if(_devideID == deviceID)
_valueModel.setValueList( valueList );
_valueModel.takeValueList( valueList );
}
/*

View File

@@ -50,10 +50,8 @@ public:
void setDeviceID( BCDevice::ID deviceID );
BCDevice::ID getDeviceID() const;
BCValueList& exposeValueList();
QTableView* getValueView();
const BCValueList& getValueList();
public slots:

View File

@@ -162,9 +162,10 @@ void BCMainWindow::initMainWindow()
// C) Aufräumen: Wenn Thread endet, lösche den Runner
connect(&_worker, &QThread::finished, &_transmitter, &QObject::deleteLater);
// 5. Thread starten
_worker.start();
_consoleAction->trigger();
}
@@ -179,7 +180,7 @@ void BCMainWindow::onValueListReady( BCDevice::ID deviceID )
BCValueList& newValueList = _dataManager.getCurrentValueList();
qDebug() << " --- Before: " << victim.size() << " orig:" << newValueList.size();
victim = std::exchange(newValueList, BCValueList());
//_devicePanels[deviceID]->setValueList( newValueList );
//_devicePanels[deviceID]->exchangeValueList( newValueList );
qDebug() << " ---After: " << victim.size() << " orig:" << newValueList.size();
}
}
@@ -230,19 +231,16 @@ void BCMainWindow::onRunnerMessage(const QString &msg)
void BCMainWindow::onSyncFromDevice()
{
qDebug() << " ---Syncing";
/*
if( _currentDeviceID != BCDevice::ID::Invalid )
{
if( _valueModels.contains(_currentDeviceID) )
{
BCValueModel* model = _valueModels[_currentDeviceID];
BCValueList& currentList = model->getValueList();
Q_ASSERT(_currentPanel && "currentpanel ist null!");
//BCDataValue& value = currentList[4];
const BCValueList& currentList =_currentPanel->getValueList();
// alle einzeln? echt jetzt?
for( const BCDataValue& value : currentList )
{
@@ -263,7 +261,5 @@ void BCMainWindow::onSyncFromDevice()
//QThread::msleep(500);
}
} // if contains
}
*/
}

View File

@@ -55,10 +55,11 @@ const BCValueList& BCValueModel::getValueList()
}
void BCValueModel::setValueList(const BCValueList& valueList)
void BCValueModel::takeValueList(BCValueList& newValueList)
{
beginResetModel();
_valueList = valueList;
// hier nehmen wir die valueList in Besitz.
_valueList = std::exchange(newValueList, {} );
endResetModel();
}

View File

@@ -53,7 +53,8 @@ public:
explicit BCValueModel(QObject *parent = nullptr);
void addValue(const BCDataValue& val);
void setValueList(const BCValueList& valueList);
void takeValueList(BCValueList& valueList);
const BCValueList& getValueList();
// Pure Virtual Functions von QAbstractTableModel