-
Notifications
You must be signed in to change notification settings - Fork 168
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
plugins/swiotrefactor: Added faults instrument.
I removed the ToolView bindings and I used ToolTemplate instead. Removed .ui files. Cleaned the code. Signed-off-by: andrei.danila <[email protected]>
- Loading branch information
1 parent
e0ce8e6
commit f8d7af9
Showing
21 changed files
with
1,418 additions
and
675 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
74 changes: 74 additions & 0 deletions
74
plugins/swiotrefactor/include/swiotrefactor/faults/faults.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
/* | ||
* Copyright (c) 2023 Analog Devices Inc. | ||
* | ||
* This file is part of Scopy | ||
* (see https://www.github.com/analogdevicesinc/scopy). | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#ifndef FAULTS_H | ||
#define FAULTS_H | ||
|
||
#include "scopy-swiotrefactor_export.h" | ||
#include "faultspage.h" | ||
#include <pluginbase/toolmenuentry.h> | ||
|
||
#include <iio.h> | ||
#include <gui/widgets/toolbuttons.h> | ||
|
||
#include <gui/channel_manager.hpp> | ||
#include <gui/generic_menu.hpp> | ||
#include <gui/tool_view.hpp> | ||
#include <gui/tooltemplate.h> | ||
|
||
namespace scopy::swiotrefactor { | ||
class SCOPY_SWIOTREFACTOR_EXPORT Faults : public QWidget | ||
{ | ||
Q_OBJECT | ||
public: | ||
explicit Faults(QString uri, ToolMenuEntry *tme, QWidget *parent = nullptr); | ||
~Faults(); | ||
|
||
void pollFaults(); | ||
|
||
Q_SIGNALS: | ||
void backBtnPressed(); | ||
|
||
public Q_SLOTS: | ||
void runButtonClicked(bool toggled); | ||
void singleButtonClicked(); | ||
|
||
private Q_SLOTS: | ||
void onBackBtnPressed(); | ||
|
||
private: | ||
void connectSignalsAndSlots(); | ||
void initTutorialProperties(); | ||
QPushButton *createConfigBtn(QWidget *parent); | ||
|
||
ToolTemplate *m_tool; | ||
RunBtn *m_runBtn; | ||
SingleShotBtn *m_singleBtn; | ||
QPushButton *m_configBtn; | ||
|
||
QTimer *m_timer; | ||
QThread *m_thread; | ||
|
||
FaultsPage *m_faultsPage; | ||
|
||
ToolMenuEntry *m_tme; | ||
}; | ||
} // namespace scopy::swiotrefactor | ||
#endif // FAULTS_H |
99 changes: 99 additions & 0 deletions
99
plugins/swiotrefactor/include/swiotrefactor/faults/faultsdevice.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
/* | ||
* Copyright (c) 2023 Analog Devices Inc. | ||
* | ||
* This file is part of Scopy | ||
* (see https://www.github.com/analogdevicesinc/scopy). | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#ifndef FAULTSDEVICE_H | ||
#define FAULTSDEVICE_H | ||
|
||
#include "scopy-swiotrefactor_export.h" | ||
#include "faultsgroup.h" | ||
#include <QLineEdit> | ||
#include <QPushButton> | ||
#include <QTextEdit> | ||
#include <QWidget> | ||
|
||
#include <iio.h> | ||
#include <iioutil/commandqueue.h> | ||
|
||
namespace scopy::swiotrefactor { | ||
class FaultsGroup; | ||
|
||
class SCOPY_SWIOTREFACTOR_EXPORT FaultsDevice : public QWidget | ||
{ | ||
Q_OBJECT | ||
public: | ||
explicit FaultsDevice(const QString &name, QString path, QString uri, QVector<uint32_t> ®isters, | ||
QWidget *parent = nullptr); | ||
~FaultsDevice(); | ||
|
||
void update(); | ||
|
||
void readRegister(); | ||
public Q_SLOTS: | ||
void resetStored(); | ||
void updateExplanations(); | ||
void updateExplanation(int index); | ||
void onFaultNumericUpdated(); | ||
void onFaultRegisterRead(int iReg, uint32_t value); | ||
|
||
Q_SIGNALS: | ||
void specialFaultsUpdated(int index, QString channelFunction); | ||
void faultNumericUpdated(); | ||
void faultRegisterRead(int iReg, uint32_t value); | ||
|
||
private Q_SLOTS: | ||
void updateMinimumHeight(); | ||
void deviceConfigCmdFinished(scopy::Command *cmd); | ||
void functionConfigCmdFinished(scopy::Command *cmd); | ||
|
||
private: | ||
void establishConnection(QString name); | ||
void initSpecialFaults(); | ||
void initTutorialProperties(); | ||
void connectSignalsAndSlots(); | ||
QWidget *createTopWidget(QWidget *parent); | ||
QWidget *createExplanationSection(QWidget *parent); | ||
|
||
QLineEdit *m_registerNoLineEdit; | ||
QPushButton *m_resetBtn; | ||
QPushButton *m_clearBtn; | ||
QWidget *m_faultsExplanation; | ||
|
||
QString m_uri; | ||
CommandQueue *m_cmdQueue; | ||
|
||
FaultsGroup *m_faultsGroup; | ||
QVector<QWidget *> m_faultExplanationWidgets; | ||
|
||
QString m_name; | ||
|
||
struct iio_device *m_device; | ||
struct iio_device *m_swiot; | ||
struct iio_context *m_context; | ||
|
||
uint32_t m_faultNumeric = 0; | ||
QVector<uint32_t> m_registers; | ||
QVector<uint32_t> m_registerValues; | ||
QVector<Command *> m_deviceConfigCmds; | ||
QVector<Command *> m_functionConfigCmds; | ||
}; | ||
|
||
} // namespace scopy::swiotrefactor | ||
|
||
#endif // FAULTSDEVICE_H |
77 changes: 77 additions & 0 deletions
77
plugins/swiotrefactor/include/swiotrefactor/faults/faultsgroup.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
/* | ||
* Copyright (c) 2023 Analog Devices Inc. | ||
* | ||
* This file is part of Scopy | ||
* (see https://www.github.com/analogdevicesinc/scopy). | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#ifndef FAULTSGROUP_H | ||
#define FAULTSGROUP_H | ||
|
||
#include "scopy-swiotrefactor_export.h" | ||
#include "faultwidget.h" | ||
#include <set> | ||
#include <QVector> | ||
#include <gui/flexgridlayout.hpp> | ||
|
||
namespace scopy::swiotrefactor { | ||
class SCOPY_SWIOTREFACTOR_EXPORT FaultsGroup : public QWidget | ||
{ | ||
Q_OBJECT | ||
public: | ||
explicit FaultsGroup(QString name, const QString &path, QWidget *parent = nullptr); | ||
~FaultsGroup() override; | ||
|
||
const QVector<FaultWidget *> &getFaults() const; | ||
|
||
const QString &getName() const; | ||
void setName(const QString &name); | ||
|
||
void clearSelection(); | ||
void update(uint32_t faults_numeric); | ||
QStringList getExplanations(); | ||
QString getExplanation(unsigned int id); | ||
std::set<unsigned int> getSelectedIndexes(); | ||
std::set<unsigned int> getActiveIndexes(); | ||
|
||
Q_SIGNALS: | ||
void selectionUpdated(); | ||
void minimumSizeChanged(); | ||
void specialFaultsUpdated(unsigned int index, QString channelFunction); | ||
void specialFaultExplanationChanged(unsigned int, QString); | ||
|
||
private Q_SLOTS: | ||
void layoutUpdate(); | ||
void onFaultSelected(unsigned int id); | ||
|
||
protected: | ||
QWidget *buildActiveStoredWidget(); | ||
QJsonArray *getJsonArray(const QString &path); | ||
|
||
private: | ||
void createFaultWidgets(const QString &path); | ||
|
||
int m_maxFaults; | ||
QString m_name; | ||
QVector<FaultWidget *> m_faults; | ||
std::set<unsigned int> m_currentlySelected; | ||
std::set<unsigned int> m_actives; | ||
FlexGridLayout *m_customColGrid; | ||
QWidget *m_activeStoredWidget; | ||
}; | ||
} // namespace scopy::swiotrefactor | ||
|
||
#endif // FAULTSGROUP_H |
Oops, something went wrong.