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

Repeat retriggering #38

Draft
wants to merge 7 commits into
base: master
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: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ set(pulseview_SOURCES
pv/dialogs/storeprogress.cpp
pv/popups/deviceoptions.cpp
pv/popups/channels.cpp
pv/popups/triggermode.cpp
pv/prop/bool.cpp
pv/prop/double.cpp
pv/prop/enum.cpp
Expand Down Expand Up @@ -342,6 +343,7 @@ set(pulseview_HEADERS
pv/dialogs/storeprogress.hpp
pv/popups/channels.hpp
pv/popups/deviceoptions.hpp
pv/popups/triggermode.hpp
pv/prop/bool.hpp
pv/prop/double.hpp
pv/prop/enum.hpp
Expand Down
24 changes: 24 additions & 0 deletions icons/status-yellow.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
118 changes: 118 additions & 0 deletions icons/trigger-repeat-rearm.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions pulseview.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
<file>icons/status-green.svg</file>
<file>icons/status-grey.svg</file>
<file>icons/status-red.svg</file>
<file>icons/status-yellow.svg</file>
<file>icons/show-cursors.svg</file>
<file>icons/trigger-change.svg</file>
<file>icons/trigger-falling.svg</file>
Expand All @@ -36,6 +37,7 @@
<file>icons/trigger-marker-high.svg</file>
<file>icons/trigger-marker-low.svg</file>
<file>icons/trigger-marker-rising.svg</file>
<file>icons/trigger-repeat-rearm.svg</file>
<file>icons/trigger-none.svg</file>
<file>icons/trigger-rising.svg</file>
<file>icons/view-displaymode-last_complete_segment.svg</file>
Expand Down
7 changes: 6 additions & 1 deletion pv/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ MainWindow::MainWindow(DeviceManager &device_manager, QWidget *parent) :
device_manager_(device_manager),
session_selector_(this),
icon_red_(":/icons/status-red.svg"),
icon_yellow_(":/icons/status-yellow.svg"),
icon_green_(":/icons/status-green.svg"),
icon_grey_(":/icons/status-grey.svg")
{
Expand Down Expand Up @@ -583,7 +584,8 @@ void MainWindow::update_acq_button(Session *session)
run_caption = tr("Run");
}

const QIcon *icons[] = {&icon_grey_, &icon_red_, &icon_green_};
// Maps to pv::Session::capture_state enum elements
const QIcon *icons[] = {&icon_grey_, &icon_grey_, &icon_red_, &icon_green_, &icon_yellow_};
run_stop_button_->setIcon(*icons[state]);
run_stop_button_->setText((state == pv::Session::Stopped) ?
run_caption : tr("Stop"));
Expand Down Expand Up @@ -681,6 +683,7 @@ void MainWindow::on_run_stop_clicked()
bool any_running = any_of(hw_sessions.begin(), hw_sessions.end(),
[](const shared_ptr<Session> &s)
{ return (s->get_capture_state() == Session::AwaitingTrigger) ||
(s->get_capture_state() == Session::AwaitingRearm) ||
(s->get_capture_state() == Session::Running); });

for (shared_ptr<Session> s : hw_sessions)
Expand All @@ -701,6 +704,8 @@ void MainWindow::on_run_stop_clicked()
session->start_capture([&](QString message) {
show_session_error("Capture failed", message); });
break;
case Session::Starting:
case Session::AwaitingRearm:
case Session::AwaitingTrigger:
case Session::Running:
session->stop_capture();
Expand Down
1 change: 1 addition & 0 deletions pv/mainwindow.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ private Q_SLOTS:
QTabWidget session_selector_;

QIcon icon_red_;
QIcon icon_yellow_;
QIcon icon_green_;
QIcon icon_grey_;

Expand Down
86 changes: 86 additions & 0 deletions pv/popups/triggermode.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
/*
* This file is part of the PulseView project.
*
* Copyright (C) 2012-2013 Joel Holdsworth <[email protected]>
*
* 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 2 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 <http://www.gnu.org/licenses/>.
*/

#include "triggermode.hpp"

#include <pv/session.hpp>

namespace pv {
namespace popups {

TriggerMode::TriggerMode(Session &session, QWidget *parent) :
Popup(parent),
session_(session),
layout_(this),
form_(this),
form_layout_(&form_)
{
setWindowTitle(tr("Trigger Mode"));

form_.setLayout(&form_layout_);

// mode

QCheckBox *chkbox_repetitive_ = new QCheckBox(tr("&Repetitive"), this);

QVBoxLayout *vbox_mode_ = new QVBoxLayout;
vbox_mode_->addWidget(chkbox_repetitive_);

QGroupBox *groupbox_mode_ = new QGroupBox(tr("Select the trigger mode"));
groupbox_mode_->setLayout(vbox_mode_);
form_layout_.addRow(groupbox_mode_);

// delay

rearm_delay_ = new QSpinBox;
rearm_delay_->setRange(100, 2000000000);
rearm_delay_->setValue(5000);

QVBoxLayout *vbox_rearm_delay_ = new QVBoxLayout;
vbox_rearm_delay_->addWidget(rearm_delay_);

QGroupBox *groupbox_rearm_delay_ = new QGroupBox(tr("Set the trigger rearm delay in mSec"));
groupbox_rearm_delay_->setLayout(vbox_rearm_delay_);
form_layout_.addRow(groupbox_rearm_delay_);

// connections

connect(chkbox_repetitive_, SIGNAL(toggled(bool)), this, SLOT(chkbox_toggled(bool)));
connect(rearm_delay_, SIGNAL(valueChanged(int)), this, SLOT(rearm_time_changed(int)));

layout_.addWidget(&form_);

// sync with session

chkbox_repetitive_->setChecked(session_.get_capture_mode() == pv::Repetitive);
rearm_delay_->setValue(session_.get_repetitive_rearm_time());
}

void TriggerMode::chkbox_toggled(bool checked)
{
session_.set_capture_mode(checked ? pv::Repetitive : pv::Single);
}

void TriggerMode::rearm_time_changed(int value)
{
session_.set_repetitive_rearm_time(value);
}

} // namespace dialogs
} // namespace pv
79 changes: 79 additions & 0 deletions pv/popups/triggermode.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
/*
* This file is part of the PulseView project.
*
* Copyright (C) 2012-2013 Joel Holdsworth <[email protected]>
*
* 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 2 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 <http://www.gnu.org/licenses/>.
*/

#ifndef PULSEVIEW_PV_POPUPS_TRIGGERMODE_HPP
#define PULSEVIEW_PV_POPUPS_TRIGGERMODE_HPP

#include <memory>

#include <QDialog>
#include <QWidget>
#include <QDialogButtonBox>
#include <QFormLayout>
#include <QCheckBox>
#include <QSpinBox>
#include <QVBoxLayout>
#include <QGroupBox>

#include <pv/widgets/popup.hpp>

using std::shared_ptr;

namespace pv {
class Session;
namespace popups {

class TriggerMode : public pv::widgets::Popup
{
Q_OBJECT

public:
TriggerMode(Session &session, QWidget *parent);

private:
Session &session_;

private Q_SLOTS:
void chkbox_toggled(bool checked);
void rearm_time_changed(int value);

private:
QVBoxLayout layout_;
QWidget form_;
QFormLayout form_layout_;

// mode

QCheckBox *chkbox_repetitive_;

QVBoxLayout *vbox_mode_;
QGroupBox *groupbox_mode_;

// delay

QSpinBox *rearm_delay_;

QVBoxLayout *vbox_rearm_delay_;
QGroupBox *groupbox_rearm_delay_;
};

} // namespace dialogs
} // namespace pv

#endif // PULSEVIEW_PV_POPUPS_TRIGGERMODE_HPP
Loading