Skip to content

Commit

Permalink
Revert "core/DeviceManager: Changed restartDevice method (WIP)."
Browse files Browse the repository at this point in the history
This was needed for swiot but the entire mechanism changed.
So we revert it instead of force pushing the master branch.
This reverts commit 799f45f.
  • Loading branch information
AlexandraTrifan committed Jul 4, 2023
1 parent b79d8f4 commit 3ef90e7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 15 deletions.
3 changes: 0 additions & 3 deletions core/include/core/devicemanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ private Q_SLOTS:
void connectDevice();
void disconnectDevice();
void restartDevice();
void onRestart(QString id, Device *d);

Q_SIGNALS:
void deviceChangedToolList(QString, QList<ToolMenuEntry*>);
Expand All @@ -57,8 +56,6 @@ private Q_SLOTS:
void disconnectDeviceFromManager(DeviceImpl *d);
private:
bool exclusive = false;
QString m_restartedDevNewId;

QStringList scannedDev;
QStringList connectedDev;
QMap<QString,Device*> map;
Expand Down
17 changes: 5 additions & 12 deletions core/src/devicemanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ void DeviceManager::connectDeviceToManager(DeviceImpl *d) {
connect(d,SIGNAL(requestedRestart()), this,SLOT(restartDevice()));
connect(d,SIGNAL(toolListChanged()),this,SLOT(changeToolListDevice()));
connect(d,SIGNAL(requestTool(QString)),this,SIGNAL(requestTool(QString)));

}
void DeviceManager::disconnectDeviceFromManager(DeviceImpl *d) {
disconnect(d,SIGNAL(connected()));
Expand Down Expand Up @@ -188,22 +189,14 @@ void DeviceManager::setExclusive(bool val) {
bool DeviceManager::getExclusive() const {
return exclusive;
}
//WIP: We need it at SWIOT until a better method is found

void DeviceManager::restartDevice() {
QString id = dynamic_cast<Device*>(QObject::sender())->id();
qDebug(CAT_DEVICEMANAGER)<<"restarting "<< id << "...";
m_restartedDevNewId = restartDevice(id);
connect(this, &DeviceManager::deviceAdded, this, &DeviceManager::onRestart, Qt::QueuedConnection);
QString newId = restartDevice(id);
// connect(this,SIGNAL(deviceAdded(QString,Device*)),this,SIGNAL(requestDevice(QString)));
// Q_EMIT requestDevice(newId);
}

void DeviceManager::onRestart(QString id, Device *d)
{
if (m_restartedDevNewId.compare(id) == 0) {
DeviceImpl* di = dynamic_cast<DeviceImpl*>(d);
di->connectDev();
disconnect(this, &DeviceManager::deviceAdded, this, &DeviceManager::onRestart);
}
}
//------------------------

#include "moc_devicemanager.cpp"

0 comments on commit 3ef90e7

Please sign in to comment.