Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Video tutorial #1799

Draft
wants to merge 3 commits into
base: dev
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion gui/include/gui/printplotmanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class SCOPY_GUI_EXPORT PrintPlotManager : public QObject
public:
explicit PrintPlotManager(QObject *parent = nullptr);

void printPlots(QList<PlotWidget *> plotList, QString toolName);
void printPlots(QList<PlotWidget *> plotList, QString toolName, QString folderPath = "");
void setPrintWithSymbols(bool printWithSymbols);
signals:

Expand Down
1 change: 1 addition & 0 deletions gui/include/gui/tutorialbuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ public Q_SLOTS:
int y_offset;
HoverPosition anchor;
HoverPosition content;
QString api_call;
};

QMap<uint16_t, ChapterInstructions *> m_chapters;
Expand Down
6 changes: 5 additions & 1 deletion gui/include/gui/tutorialchapter.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class SCOPY_GUI_EXPORT TutorialChapter : public QObject

static TutorialChapter *build(const QList<QWidget *> &subjects, const QString &description,
QWidget *mainSubject, int x_offset, int y_offset, HoverPosition anchor,
HoverPosition content, QObject *parent = nullptr);
HoverPosition content, QString api_call, QObject *parent = nullptr);

void addSubject(QWidget *s);

Expand All @@ -48,6 +48,7 @@ class SCOPY_GUI_EXPORT TutorialChapter : public QObject
int y_offset;
HoverPosition anchor;
HoverPosition content;
QString api_call;

int getXOffset() const;
void setXOffset(int xOffset);
Expand All @@ -67,6 +68,9 @@ class SCOPY_GUI_EXPORT TutorialChapter : public QObject
QWidget *getMainSubject() const;
void setMainSubject(QWidget *mainSubject);

QString getApi() const;
void setApi(QString apiCall);

Q_SIGNALS:
void chapterStarted();
void chapterFinished();
Expand Down
2 changes: 1 addition & 1 deletion gui/include/gui/tutorialoverlay.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class SCOPY_GUI_EXPORT TutorialOverlay : public QWidget
TutorialChapter *addChapter(const QList<QWidget *> &subjects, const QString &description,
QWidget *mainWidget = nullptr, int x_offset = 0, int y_offset = 0,
HoverPosition anchor = HoverPosition::HP_CENTER,
HoverPosition content = HoverPosition::HP_CENTER);
HoverPosition content = HoverPosition::HP_CENTER, QString api_call = "");
TutorialChapter *addChapter(QWidget *subject, QString description);
void addChapter(TutorialChapter *ch);

Expand Down
11 changes: 7 additions & 4 deletions gui/src/printplotmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,15 @@ PrintPlotManager::PrintPlotManager(QObject *parent)
: QObject{parent}
{}

void PrintPlotManager::printPlots(QList<PlotWidget *> plotList, QString toolName)
void PrintPlotManager::printPlots(QList<PlotWidget *> plotList, QString toolName, QString folderPath)
{
// select folder where to save
QString folderPath = QFileDialog::getExistingDirectory(
nullptr, "Select Folder", "",
QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks | QFileDialog::DontUseNativeDialog);
if(folderPath.isEmpty()) {
folderPath =
QFileDialog::getExistingDirectory(nullptr, "Select Folder", "",
QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks |
QFileDialog::DontUseNativeDialog);
}

if(!folderPath.isEmpty()) {
// use current date and tool name to crete the file name
Expand Down
6 changes: 5 additions & 1 deletion gui/src/tutorialbuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,8 @@ uint16_t TutorialBuilder::collectChapters()
this->addChapter(chapter->widgets.values(), chapter->description,
(chapter->mainWidget.isNull()) ? chapter->widgets.first()
: chapter->widgets[chapter->mainWidget],
chapter->x_offset, chapter->y_offset, chapter->anchor, chapter->content);
chapter->x_offset, chapter->y_offset, chapter->anchor, chapter->content,
chapter->api_call);
}

return chaptersCollected;
Expand Down Expand Up @@ -171,6 +172,7 @@ void TutorialBuilder::readTutorialRequirements()
// "y_offset": int, optional
// "anchor": string, HoverPosition, optional
// "content": string, HoverPosition, optional
// "api_call": string, api function call, optional
// }
QJsonArray chapters_array = value.toArray();
for(QJsonValueRef item : chapters_array) {
Expand All @@ -189,6 +191,7 @@ void TutorialBuilder::readTutorialRequirements()
QString contentString = item_object.value("content").toString();
HoverPosition anchor = convertStringToHoverPosition(anchorString);
HoverPosition content = convertStringToHoverPosition(contentString);
QString api_call = item_object.value("api_call").toString();

auto *chapterInstructions = new ChapterInstructions;
for(const auto &name : qAsConst(names)) {
Expand All @@ -200,6 +203,7 @@ void TutorialBuilder::readTutorialRequirements()
chapterInstructions->y_offset = y_offset;
chapterInstructions->anchor = anchor;
chapterInstructions->content = content;
chapterInstructions->api_call = api_call;
if(m_chapters.contains(index)) {
qWarning(CAT_TUTORIALBUILDER) << "There is already a chapter with the key" << index;
} else {
Expand Down
7 changes: 6 additions & 1 deletion gui/src/tutorialchapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ TutorialChapter::~TutorialChapter() {}

TutorialChapter *TutorialChapter::build(const QList<QWidget *> &subjects, const QString &description,
QWidget *mainSubject, int x_offset, int y_offset, HoverPosition anchor,
HoverPosition content, QObject *parent)
HoverPosition content, QString api_call, QObject *parent)
{
TutorialChapter *ch = new TutorialChapter(parent);
for(QWidget *subject : subjects) {
Expand All @@ -46,6 +46,7 @@ TutorialChapter *TutorialChapter::build(const QList<QWidget *> &subjects, const
ch->setYOffset(y_offset);
ch->setAnchor(anchor);
ch->setContent(content);
ch->setApi(api_call);
return ch;
}

Expand Down Expand Up @@ -81,4 +82,8 @@ scopy::HoverPosition TutorialChapter::getContent() const { return content; }

void TutorialChapter::setContent(scopy::HoverPosition newContent) { content = newContent; }

QString TutorialChapter::getApi() const { return api_call; }

void TutorialChapter::setApi(QString apiCall) { api_call = apiCall; }

#include "moc_tutorialchapter.cpp"
7 changes: 3 additions & 4 deletions gui/src/tutorialoverlay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@ TutorialOverlay::~TutorialOverlay() { qDebug(CAT_TUTORIALOVERLAY) << "dtor"; }

TutorialChapter *TutorialOverlay::addChapter(const QList<QWidget *> &subjects, const QString &description,
QWidget *mainWidget, int x_offset, int y_offset, HoverPosition anchor,
HoverPosition content)
HoverPosition content, QString api_call)
{
// in case TutorialOverlay is used without TutorialBuilder
if(!mainWidget) {
mainWidget = subjects[0];
}
TutorialChapter *ch =
TutorialChapter::build(subjects, description, mainWidget, x_offset, y_offset, anchor, content, this);
TutorialChapter *ch = TutorialChapter::build(subjects, description, mainWidget, x_offset, y_offset, anchor,
content, api_call, this);
chapter.append(ch);
ch->setMainSubject(mainWidget);
return ch;
Expand Down Expand Up @@ -91,7 +91,6 @@ void TutorialOverlay::next()
Q_EMIT chapter[cnt - 1]->chapterFinished();

Q_EMIT chapter[cnt]->chapterStarted();

initPopupWidget();
m_popupWidget->setDescription(chapter[cnt]->description);
overlay->raise();
Expand Down
8 changes: 8 additions & 0 deletions plugins/datalogger/include/datalogger/datalogger_api.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
#include "scopy-datalogger_export.h"

#include <dataloggerplugin.h>
#include <sevensegmentdisplay.hpp>
#include <sevensegmentmonitorsettings.hpp>

namespace scopy::datamonitor {

Expand All @@ -22,6 +24,12 @@ class SCOPY_DATALOGGER_EXPORT DataLogger_API : public ApiObject
Q_INVOKABLE QString disableMonitor(QString monitor);
Q_INVOKABLE void setRunning(bool running);
Q_INVOKABLE void clearData();
Q_INVOKABLE void print(QString filePath);
Q_INVOKABLE void changeTool(QString name);
Q_INVOKABLE void setMinMax(bool enable);
Q_INVOKABLE void changePrecision(int decimals);
Q_INVOKABLE void setMinYAxis(double min);
Q_INVOKABLE void setMaxYAxis(double max);

// TOOL RELATED
Q_INVOKABLE QString createTool();
Expand Down
1 change: 1 addition & 0 deletions plugins/datalogger/include/datalogger/datamonitortool.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ class SCOPY_DATALOGGER_EXPORT DatamonitorTool : public QWidget

void initTutorialProperties();
void startTutorial();
void startVideoTutorial();
};
} // namespace scopy::datamonitor
#endif // DATAMONITORTOOL_H
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ namespace datamonitor {
class SCOPY_DATALOGGER_EXPORT SevenSegmentMonitorSettings : public QWidget
{
friend class DataMonitorStyleHelper;
friend class DataLogger_API;
Q_OBJECT
public:
explicit SevenSegmentMonitorSettings(QWidget *parent = nullptr);
Expand Down
95 changes: 95 additions & 0 deletions plugins/datalogger/js/dataLoggerAutomatedTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,101 @@
evaluateFile("../js/scopycommon.js")
evaluateFile("../plugins/datalogger/js/dataLoggerFunctions.js")

//Plot
function readDataTest() {
connect()
scopy.switchTool("DataLogger 0")
datalogger.enableMonitorOfTool("DataLogger 0","xadc:temp0")
datalogger.setRunning(true)
msleep(5000)
datalogger.setRunning(false)
disconnect()
}

function readClearDataTest() {
connect()
scopy.switchTool("DataLogger 0")
datalogger.enableMonitorOfTool("DataLogger 0","xadc:temp0")
datalogger.setRunning(true)
msleep(3000)
datalogger.setRunning(false)
datalogger.clearData()
disconnect()
}

function readPrintDataTest() {
connect()
scopy.switchTool("DataLogger 0")
datalogger.enableMonitorOfTool("DataLogger 0","xadc:temp0")
datalogger.setRunning(true)
msleep(3000)
datalogger.setRunning(false)
datalogger.print("../plugins/datalogger/js")
disconnect()
}

//7 Segment
function readDataSegmentTest() {
connect()
scopy.switchTool("DataLogger 0")
datalogger.enableMonitorOfTool("DataLogger 0","xadc:temp0")
datalogger.changeTool("7 Segment")
datalogger.setRunning(true)
msleep(2000)
datalogger.setRunning(false)
disconnect()
}

function minMaxSegementText() {
connect()
scopy.switchTool("DataLogger 0")
datalogger.enableMonitorOfTool("DataLogger 0","xadc:temp0")
datalogger.changeTool("7 Segment")
datalogger.setMinMax(false)
datalogger.setRunning(true)
msleep(2000)
datalogger.setRunning(false)
disconnect()
}

function changeSegmentPrecisionTest() {
connect()
scopy.switchTool("DataLogger 0")
datalogger.enableMonitorOfTool("DataLogger 0","xadc:temp0")
datalogger.changeTool("7 Segment")
datalogger.changePrecision(2)
datalogger.setRunning(true)
msleep(2000)
datalogger.setRunning(false)
disconnect()
}

//Text
function readDataTextTest() {
connect()
scopy.switchTool("DataLogger 0")
datalogger.enableMonitorOfTool("DataLogger 0","xadc:temp0")
datalogger.changeTool("Text")
datalogger.setRunning(true)
msleep(2000)
datalogger.setRunning(false)
disconnect()
}

function readMultipleTextTest() {
connect()
scopy.switchTool("DataLogger 0")
datalogger.enableMonitorOfTool("DataLogger 0", "xadc:temp0")
datalogger.enableMonitorOfTool("DataLogger 0", "xadc:voltage0")
datalogger.changeTool("Text")
datalogger.setRunning(true)
msleep(2000)
datalogger.disableMonitorOfTool("DataLogger 0", "xadc:voltage0")
msleep(2000)
datalogger.setRunning(false)
disconnect()
}

function dataLogAndLoadTest(){
const filePath = "../plugins/datalogger/js/test.csv"

Expand Down
1 change: 1 addition & 0 deletions plugins/datalogger/resources/resources.qrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<RCC>
<qresource prefix="/datamonitor">
<file>tutorial_chapters.json</file>
<file>video_tutorial_chapters.json</file>
</qresource>
</RCC>
29 changes: 29 additions & 0 deletions plugins/datalogger/resources/video_tutorial_chapters.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"datamonitor": [
{
"index": 1,
"names": ["MONITOR_MENU"],
"description": "Select the signals you want to log",
"anchor": "HP_RIGHT",
"content": "HP_RIGHT",
"x_offset": 10
},
{
"index": 2,
"names": ["RUN_BUTTON"],
"description": "Starts data collection",
"anchor": "HP_BOTTOM",
"content": "HP_BOTTOM",
"y_offset": 10,
"api_call": "datalogger.setRunning(true)"
},
{
"index": 3,
"names": ["MONITOR_PLOT"],
"description": "Display values on plot ",
"anchor": "HP_RIGHT",
"content": "HP_RIGHT",
"x_offset": 10
}
]
}
Loading
Loading