Changeset - 3b97826f2f6b
[Not reviewed]
Merge default
0 4 13
Hasan Yavuz ÖZDERYA - 10 years ago 2015-10-18 05:28:08
hy@ozderya.net
Merge with command-panel
17 files changed with 777 insertions and 6 deletions:
0 comments (0 inline, 0 general)
CMakeLists.txt
Show inline comments
 
@@ -57,8 +57,15 @@ qt5_wrap_ui(UI_FILES
 
  portcontrol.ui
 
  about_dialog.ui
 
  snapshotview.ui
 
  commandpanel.ui
 
  commandwidget.ui
 
  )
 
qt5_add_resources(RES_FILES misc/icons.qrc)
 

	
 
if (WIN32)
 
  qt5_add_resources(RES_FILES misc/icons.qrc misc/winicons.qrc)
 
else (WIN32)
 
  qt5_add_resources(RES_FILES misc/icons.qrc)
 
endif (WIN32)
 

	
 
add_executable(${PROGRAM_NAME} WIN32
 
  main.cpp
 
@@ -75,6 +82,9 @@ add_executable(${PROGRAM_NAME} WIN32
 
  snapshotview.cpp
 
  snapshotmanager.cpp
 
  plotsnapshotoverlay.cpp
 
  commandpanel.cpp
 
  commandwidget.cpp
 
  commandedit.cpp
 
  ${UI_FILES}
 
  ${RES_FILES}
 
  misc/windows_icon.rc
commandedit.cpp
Show inline comments
 
new file 100644
 
/*
 
  Copyright © 2015 Hasan Yavuz Özderya
 

	
 
  This file is part of serialplot.
 

	
 
  serialplot 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.
 

	
 
  serialplot 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 serialplot.  If not, see <http://www.gnu.org/licenses/>.
 
*/
 

	
 
#include <QKeyEvent>
 

	
 
#include <QtDebug>
 

	
 
#include "commandedit.h"
 

	
 
class HexCommandValidator : public QRegExpValidator
 
{
 
public:
 
    explicit HexCommandValidator(QObject* parent = 0);
 
    QValidator::State validate(QString & input, int & pos) const;
 
};
 

	
 
HexCommandValidator::HexCommandValidator(QObject* parent) :
 
    QRegExpValidator(parent)
 
{
 
    QRegExp regExp("^(?:(?:[0-9A-F]{2}[ ])+(?:[0-9A-F]{2}))|(?:[0-9A-F]{2})$");
 
    setRegExp(regExp);
 
}
 

	
 
QValidator::State HexCommandValidator::validate(QString & input, int & pos) const
 
{
 
    input = input.toUpper();
 

	
 
    // don't let pos to be altered at this stage
 
    int orgPos = pos;
 
    auto r = QRegExpValidator::validate(input, pos);
 
    pos = orgPos;
 

	
 
    // try fixing up spaces
 
    if (r != QValidator::Acceptable)
 
    {
 
        input = input.replace(" ", "");
 
        input.replace(QRegExp("([0-9A-F]{2}(?!$))"), "\\1 ");
 
        if (pos == input.size()-1) pos = input.size();
 
        r = QRegExpValidator::validate(input, pos);
 
    }
 

	
 
    return r;
 
}
 

	
 
CommandEdit::CommandEdit(QWidget *parent) :
 
    QLineEdit(parent)
 
{
 
    hexValidator = new HexCommandValidator(this);
 
    asciiValidator = new QRegExpValidator(QRegExp("[\\x0000-\\x007F]+"));
 
    ascii_mode = true;
 
    setValidator(asciiValidator);
 
}
 

	
 
CommandEdit::~CommandEdit()
 
{
 
    delete hexValidator;
 
}
 

	
 
QString unEscape(QString str);
 
QString escape(QString str);
 

	
 
void CommandEdit::setMode(bool ascii)
 
{
 
    ascii_mode = ascii;
 
    if (ascii)
 
    {
 
        setValidator(asciiValidator);
 

	
 
        auto hexText = text().remove(" ");
 
        // try patching HEX string in case of missing nibble so that
 
        // input doesn't turn into gibberish
 
        if (hexText.size() % 2 == 1)
 
        {
 
            hexText.replace(hexText.size()-1, 1, "3F"); // 0x3F = '?'
 
            qWarning() << "Broken byte in hex command is replaced. Check your command!";
 
        }
 

	
 
        setText(escape(QByteArray::fromHex(hexText.toLatin1())));
 
    }
 
    else
 
    {
 
        setValidator(hexValidator);
 
        setText(unEscape(text()).toLatin1().toHex());
 
    }
 
}
 

	
 
void CommandEdit::keyPressEvent(QKeyEvent * event)
 
{
 
    if (ascii_mode)
 
    {
 
        QLineEdit::keyPressEvent(event);
 
        return;
 
    }
 

	
 
    if (event->key() == Qt::Key_Backspace && !hasSelectedText())
 
    {
 
        int cursor = cursorPosition();
 
        if (cursor != 0 && text()[cursor-1] == ' ')
 
        {
 
            setCursorPosition(cursor-1);
 
        }
 
    }
 

	
 
    QLineEdit::keyPressEvent(event);
 
}
 

	
 
QString CommandEdit::unEscapedText()
 
{
 
    return unEscape(text());
 
}
 

	
 
QString unEscape(QString str)
 
{
 
    str.replace("\\n", "\n");
 
    str.replace("\\r", "\r");
 
    str.replace("\\t", "\t");
 
    return str;
 
}
 

	
 
QString escape(QString str)
 
{
 
    str.replace("\n", "\\n");
 
    str.replace("\r", "\\r");
 
    str.replace("\t", "\\t");
 
    return str;
 
}
commandedit.h
Show inline comments
 
new file 100644
 
/*
 
  Copyright © 2015 Hasan Yavuz Özderya
 

	
 
  This file is part of serialplot.
 

	
 
  serialplot 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.
 

	
 
  serialplot 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 serialplot.  If not, see <http://www.gnu.org/licenses/>.
 
*/
 

	
 
#ifndef COMMANDEDIT_H
 
#define COMMANDEDIT_H
 

	
 
#include <QLineEdit>
 
#include <QValidator>
 
#include <QString>
 

	
 
class CommandEdit : public QLineEdit
 
{
 
    Q_OBJECT
 

	
 
public:
 
    explicit CommandEdit(QWidget *parent = 0);
 
    ~CommandEdit();
 
    void setMode(bool ascii); // true = ascii, false = hex
 
    QString unEscapedText(); // return unescaped text(), used in ascii_mode only
 

	
 
private:
 
    bool ascii_mode;
 
    QValidator* hexValidator;
 
    QValidator* asciiValidator;
 

	
 
protected:
 
    void keyPressEvent(QKeyEvent * event) Q_DECL_OVERRIDE;
 
};
 

	
 
#endif // COMMANDEDIT_H
commandpanel.cpp
Show inline comments
 
new file 100644
 
/*
 
  Copyright © 2015 Hasan Yavuz Özderya
 

	
 
  This file is part of serialplot.
 

	
 
  serialplot 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.
 

	
 
  serialplot 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 serialplot.  If not, see <http://www.gnu.org/licenses/>.
 
*/
 

	
 
#include "commandpanel.h"
 
#include "ui_commandpanel.h"
 

	
 
#include <QByteArray>
 
#include <QtDebug>
 

	
 
CommandPanel::CommandPanel(QSerialPort* port, QWidget *parent) :
 
    QWidget(parent),
 
    ui(new Ui::CommandPanel)
 
{
 
    serialPort = port;
 

	
 
    ui->setupUi(this);
 
    ui->scrollAreaWidgetContents->setLayout(new QVBoxLayout);
 

	
 
#ifdef Q_OS_WIN
 
    ui->pbNew->setIcon(QIcon(":/icons/list-add"));
 
#endif // Q_OS_WIN
 

	
 
    connect(ui->pbNew, &QPushButton::clicked, this, &CommandPanel::newCommand);
 

	
 
    newCommand(); // add an empty slot by default
 
}
 

	
 
CommandPanel::~CommandPanel()
 
{
 
    delete ui;
 
}
 

	
 
void CommandPanel::newCommand()
 
{
 
    auto command = new CommandWidget();
 
    ui->scrollAreaWidgetContents->layout()->addWidget(command);
 
    connect(command, &CommandWidget::sendCommand, this, &CommandPanel::sendCommand);
 
}
 

	
 
void CommandPanel::sendCommand(QByteArray command)
 
{
 
    if (!serialPort->isOpen())
 
    {
 
        qCritical() << "Port is not open!";
 
        return;
 
    }
 

	
 
    if (serialPort->write(command) < 0)
 
    {
 
        qCritical() << "Send command failed!";
 
    }
 
}
commandpanel.h
Show inline comments
 
new file 100644
 
/*
 
  Copyright © 2015 Hasan Yavuz Özderya
 

	
 
  This file is part of serialplot.
 

	
 
  serialplot 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.
 

	
 
  serialplot 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 serialplot.  If not, see <http://www.gnu.org/licenses/>.
 
*/
 

	
 
#ifndef COMMANDPANEL_H
 
#define COMMANDPANEL_H
 

	
 
#include <QWidget>
 
#include <QSerialPort>
 
#include <QByteArray>
 

	
 
#include "commandwidget.h"
 

	
 
namespace Ui {
 
class CommandPanel;
 
}
 

	
 
class CommandPanel : public QWidget
 
{
 
    Q_OBJECT
 

	
 
public:
 
    explicit CommandPanel(QSerialPort* port, QWidget *parent = 0);
 
    ~CommandPanel();
 

	
 
private:
 
    Ui::CommandPanel *ui;
 
    QSerialPort* serialPort;
 

	
 
private slots:
 
    void newCommand();
 
    void sendCommand(QByteArray command);
 
};
 

	
 
#endif // COMMANDPANEL_H
commandpanel.ui
Show inline comments
 
new file 100644
 
<?xml version="1.0" encoding="UTF-8"?>
 
<ui version="4.0">
 
 <class>CommandPanel</class>
 
 <widget class="QWidget" name="CommandPanel">
 
  <property name="geometry">
 
   <rect>
 
    <x>0</x>
 
    <y>0</y>
 
    <width>583</width>
 
    <height>109</height>
 
   </rect>
 
  </property>
 
  <property name="windowTitle">
 
   <string>Form</string>
 
  </property>
 
  <property name="autoFillBackground">
 
   <bool>false</bool>
 
  </property>
 
  <layout class="QVBoxLayout" name="verticalLayout">
 
   <item>
 
    <widget class="QScrollArea" name="scrollArea">
 
     <property name="frameShape">
 
      <enum>QFrame::StyledPanel</enum>
 
     </property>
 
     <property name="widgetResizable">
 
      <bool>true</bool>
 
     </property>
 
     <property name="alignment">
 
      <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
 
     </property>
 
     <widget class="QWidget" name="scrollAreaWidgetContents">
 
      <property name="geometry">
 
       <rect>
 
        <x>0</x>
 
        <y>0</y>
 
        <width>563</width>
 
        <height>16</height>
 
       </rect>
 
      </property>
 
      <property name="sizePolicy">
 
       <sizepolicy hsizetype="Preferred" vsizetype="Maximum">
 
        <horstretch>0</horstretch>
 
        <verstretch>0</verstretch>
 
       </sizepolicy>
 
      </property>
 
     </widget>
 
    </widget>
 
   </item>
 
   <item>
 
    <widget class="QPushButton" name="pbNew">
 
     <property name="text">
 
      <string>New Command</string>
 
     </property>
 
     <property name="icon">
 
      <iconset theme="list-add"/>
 
     </property>
 
    </widget>
 
   </item>
 
  </layout>
 
 </widget>
 
 <resources/>
 
 <connections/>
 
</ui>
commandwidget.cpp
Show inline comments
 
new file 100644
 
/*
 
  Copyright © 2015 Hasan Yavuz Özderya
 

	
 
  This file is part of serialplot.
 

	
 
  serialplot 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.
 

	
 
  serialplot 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 serialplot.  If not, see <http://www.gnu.org/licenses/>.
 
*/
 

	
 
#include "commandwidget.h"
 
#include "ui_commandwidget.h"
 

	
 
#include <QRegExp>
 
#include <QRegExpValidator>
 
#include <QtDebug>
 
#include <QIcon>
 

	
 
CommandWidget::CommandWidget(QWidget *parent) :
 
    QWidget(parent),
 
    ui(new Ui::CommandWidget)
 
{
 
    ui->setupUi(this);
 

	
 
#ifdef Q_OS_WIN
 
    ui->pbDelete->setIcon(QIcon(":/icons/list-remove"));
 
#endif // Q_OS_WIN
 

	
 
    connect(ui->pbDelete, &QPushButton::clicked, this, &CommandWidget::onDeleteClicked);
 
    connect(ui->pbSend, &QPushButton::clicked, this, &CommandWidget::onSendClicked);
 
    connect(ui->pbASCII, &QPushButton::toggled, this, &CommandWidget::onASCIIToggled);
 
}
 

	
 
CommandWidget::~CommandWidget()
 
{
 
    delete ui;
 
}
 

	
 
void CommandWidget::onDeleteClicked()
 
{
 
    this->deleteLater();
 
}
 

	
 
void CommandWidget::onSendClicked()
 
{
 
    auto command = ui->leCommand->text();
 

	
 
    if (command.isEmpty())
 
    {
 
        qWarning() << "Enter a command to send!";
 
        ui->leCommand->setFocus(Qt::OtherFocusReason);
 
        return;
 
    }
 

	
 
    if (isASCIIMode())
 
    {
 
        qDebug() << "Sending:" << command;
 
        emit sendCommand(ui->leCommand->unEscapedText().toLatin1());
 
    }
 
    else // hex mode
 
    {
 
        command = command.remove(' ');
 
        // check if nibbles are missing
 
        if (command.size() % 2 == 1)
 
        {
 
            qWarning() << "HEX command is missing a nibble at the end!";
 
            ui->leCommand->setFocus(Qt::OtherFocusReason);
 
            // highlight the byte that is missing a nibble (last byte obviously)
 
            int textSize = ui->leCommand->text().size();
 
            ui->leCommand->setSelection(textSize-1, textSize);
 
            return;
 
        }
 
        qDebug() << "Sending HEX:" << command;
 
        emit sendCommand(QByteArray::fromHex(command.toLatin1()));
 
    }
 
}
 

	
 
void CommandWidget::onASCIIToggled(bool checked)
 
{
 
    ui->leCommand->setMode(checked);
 
}
 

	
 
bool CommandWidget::isASCIIMode()
 
{
 
    return ui->pbASCII->isChecked();
 
}
commandwidget.h
Show inline comments
 
new file 100644
 
/*
 
  Copyright © 2015 Hasan Yavuz Özderya
 

	
 
  This file is part of serialplot.
 

	
 
  serialplot 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.
 

	
 
  serialplot 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 serialplot.  If not, see <http://www.gnu.org/licenses/>.
 
*/
 

	
 
#ifndef COMMANDWIDGET_H
 
#define COMMANDWIDGET_H
 

	
 
#include <QWidget>
 
#include <QByteArray>
 

	
 
namespace Ui {
 
class CommandWidget;
 
}
 

	
 
class CommandWidget : public QWidget
 
{
 
    Q_OBJECT
 

	
 
public:
 
    explicit CommandWidget(QWidget *parent = 0);
 
    ~CommandWidget();
 

	
 
signals:
 
    void deleteRequested(CommandWidget* thisWidget); // emitted when delete button is clicked
 

	
 
    // emitted when send button is clicked
 
    //
 
    // in case of hex mode, command text should be a hexadecimal
 
    // string containing hexadecimal characters only (not even spaces)
 
    void sendCommand(QByteArray command);
 

	
 
private:
 
    Ui::CommandWidget *ui;
 

	
 
    bool isASCIIMode(); // true: ascii mode, false hex mode
 

	
 
private slots:
 
    void onDeleteClicked();
 
    void onSendClicked();
 
    void onASCIIToggled(bool checked);
 
};
 

	
 
#endif // COMMANDWIDGET_H
commandwidget.ui
Show inline comments
 
new file 100644
 
<?xml version="1.0" encoding="UTF-8"?>
 
<ui version="4.0">
 
 <class>CommandWidget</class>
 
 <widget class="QWidget" name="CommandWidget">
 
  <property name="geometry">
 
   <rect>
 
    <x>0</x>
 
    <y>0</y>
 
    <width>433</width>
 
    <height>34</height>
 
   </rect>
 
  </property>
 
  <property name="windowTitle">
 
   <string>Form</string>
 
  </property>
 
  <layout class="QHBoxLayout" name="horizontalLayout_2">
 
   <property name="leftMargin">
 
    <number>0</number>
 
   </property>
 
   <property name="topMargin">
 
    <number>0</number>
 
   </property>
 
   <property name="rightMargin">
 
    <number>0</number>
 
   </property>
 
   <property name="bottomMargin">
 
    <number>0</number>
 
   </property>
 
   <item>
 
    <widget class="QToolButton" name="pbDelete">
 
     <property name="minimumSize">
 
      <size>
 
       <width>30</width>
 
       <height>0</height>
 
      </size>
 
     </property>
 
     <property name="text">
 
      <string/>
 
     </property>
 
     <property name="icon">
 
      <iconset theme="list-remove">
 
       <normaloff/>
 
      </iconset>
 
     </property>
 
     <property name="autoRaise">
 
      <bool>true</bool>
 
     </property>
 
    </widget>
 
   </item>
 
   <item>
 
    <widget class="CommandEdit" name="leCommand">
 
     <property name="sizePolicy">
 
      <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
 
       <horstretch>0</horstretch>
 
       <verstretch>0</verstretch>
 
      </sizepolicy>
 
     </property>
 
     <property name="toolTip">
 
      <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Enter your command here.&lt;/p&gt;&lt;p&gt;In ASCII mode you can use backslash '\' to send some special characters. These are:&lt;br/&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;\n&lt;/span&gt; : Line Feed (new line)&lt;br/&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;\r&lt;/span&gt; : Carriage Return&lt;br/&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;\t&lt;/span&gt; : Tab&lt;/p&gt;&lt;p&gt;Be careful though, you cannot escape the backslash character itself!&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
 
     </property>
 
     <property name="clearButtonEnabled">
 
      <bool>true</bool>
 
     </property>
 
    </widget>
 
   </item>
 
   <item>
 
    <widget class="QFrame" name="frame">
 
     <property name="sizePolicy">
 
      <sizepolicy hsizetype="Maximum" vsizetype="Preferred">
 
       <horstretch>0</horstretch>
 
       <verstretch>0</verstretch>
 
      </sizepolicy>
 
     </property>
 
     <property name="frameShape">
 
      <enum>QFrame::StyledPanel</enum>
 
     </property>
 
     <property name="frameShadow">
 
      <enum>QFrame::Raised</enum>
 
     </property>
 
     <layout class="QHBoxLayout" name="horizontalLayout">
 
      <property name="spacing">
 
       <number>0</number>
 
      </property>
 
      <property name="leftMargin">
 
       <number>0</number>
 
      </property>
 
      <property name="topMargin">
 
       <number>0</number>
 
      </property>
 
      <property name="bottomMargin">
 
       <number>0</number>
 
      </property>
 
      <item>
 
       <widget class="QPushButton" name="pbASCII">
 
        <property name="sizePolicy">
 
         <sizepolicy hsizetype="Ignored" vsizetype="Fixed">
 
          <horstretch>0</horstretch>
 
          <verstretch>0</verstretch>
 
         </sizepolicy>
 
        </property>
 
        <property name="minimumSize">
 
         <size>
 
          <width>40</width>
 
          <height>0</height>
 
         </size>
 
        </property>
 
        <property name="text">
 
         <string>ASCII</string>
 
        </property>
 
        <property name="checkable">
 
         <bool>true</bool>
 
        </property>
 
        <property name="checked">
 
         <bool>true</bool>
 
        </property>
 
        <property name="autoExclusive">
 
         <bool>true</bool>
 
        </property>
 
       </widget>
 
      </item>
 
      <item>
 
       <widget class="QPushButton" name="pbHEX">
 
        <property name="sizePolicy">
 
         <sizepolicy hsizetype="Ignored" vsizetype="Fixed">
 
          <horstretch>0</horstretch>
 
          <verstretch>0</verstretch>
 
         </sizepolicy>
 
        </property>
 
        <property name="minimumSize">
 
         <size>
 
          <width>40</width>
 
          <height>0</height>
 
         </size>
 
        </property>
 
        <property name="text">
 
         <string>HEX</string>
 
        </property>
 
        <property name="checkable">
 
         <bool>true</bool>
 
        </property>
 
        <property name="autoExclusive">
 
         <bool>true</bool>
 
        </property>
 
       </widget>
 
      </item>
 
     </layout>
 
    </widget>
 
   </item>
 
   <item>
 
    <widget class="QPushButton" name="pbSend">
 
     <property name="sizePolicy">
 
      <sizepolicy hsizetype="Maximum" vsizetype="Fixed">
 
       <horstretch>0</horstretch>
 
       <verstretch>0</verstretch>
 
      </sizepolicy>
 
     </property>
 
     <property name="text">
 
      <string>Send</string>
 
     </property>
 
    </widget>
 
   </item>
 
  </layout>
 
 </widget>
 
 <customwidgets>
 
  <customwidget>
 
   <class>CommandEdit</class>
 
   <extends>QLineEdit</extends>
 
   <header>commandedit.h</header>
 
  </customwidget>
 
 </customwidgets>
 
 <resources/>
 
 <connections/>
 
</ui>
mainwindow.cpp
Show inline comments
 
@@ -54,10 +54,12 @@ MainWindow::MainWindow(QWidget *parent) 
 
    QMainWindow(parent),
 
    ui(new Ui::MainWindow),
 
    portControl(&serialPort),
 
    commandPanel(&serialPort),
 
    snapshotMan(this, &channelBuffers)
 
{
 
    ui->setupUi(this);
 
    ui->tabWidget->insertTab(0, &portControl, "Port");
 
    ui->tabWidget->insertTab(3, &commandPanel, "Commands");
 
    ui->tabWidget->setCurrentIndex(0);
 
    addToolBar(portControl.toolBar());
 

	
mainwindow.h
Show inline comments
 
@@ -35,6 +35,7 @@
 
#include <qwt_plot_textlabel.h>
 

	
 
#include "portcontrol.h"
 
#include "commandpanel.h"
 
#include "ui_about_dialog.h"
 
#include "framebuffer.h"
 
#include "snapshotmanager.h"
 
@@ -100,6 +101,8 @@ private:
 
    unsigned int sampleCount;
 
    QTimer spsTimer;
 

	
 
    CommandPanel commandPanel;
 

	
 
    SnapshotManager snapshotMan;
 

	
 
    // demo
misc/pseudo_device_2.py
Show inline comments
 
new file 100755
 
#!/usr/bin/python3
 
#
 
# Copyright © 2015 Hasan Yavuz Özderya
 
#
 
# This file is part of serialplot.
 
#
 
# serialplot 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.
 
#
 
# serialplot 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 serialplot.  If not, see <http://www.gnu.org/licenses/>.
 
#
 

	
 
import os, pty, time
 

	
 
def run():
 
    # create the pseudo terminal
 
    master, slave = pty.openpty()
 

	
 
    slave_name = os.ttyname(slave)
 
    print("Slave terminal: {}".format(slave_name))
 

	
 
    masterw = os.fdopen(master, 'w')
 
    masterr = os.fdopen(master, 'r')
 

	
 
    while True:
 
        line = masterr.read(4)
 
        print(">" + line)
 
        if (line.strip() == "data"):
 
            masterw.write("1,1\r\n")
 
        time.sleep(0.01)
 

	
 
if __name__ == "__main__":
 
    run()
misc/tango/license_notice
Show inline comments
 
new file 100644
 
Icon files in this directory are taken from Tango project
 
(http://tango.freedesktop.org/). Please see referenced web page for
 
more information.
 
\ No newline at end of file
misc/tango/list-add.png
Show inline comments
 
new file 100644
 
binary diff not shown
Show images
misc/tango/list-remove.png
Show inline comments
 
new file 100644
 
binary diff not shown
Show images
misc/winicons.qrc
Show inline comments
 
new file 100644
 
<RCC>
 
    <qresource prefix="/icons">
 
        <file alias="list-add">tango/list-add.png</file>
 
        <file alias="list-remove">tango/list-remove.png</file>
 
    </qresource>
 
</RCC>
serialplot.pro
Show inline comments
 
@@ -46,7 +46,10 @@ SOURCES += main.cpp\
 
    snapshotview.cpp \
 
    snapshotmanager.cpp \
 
    snapshot.cpp \
 
    plotsnapshotoverlay.cpp
 
    plotsnapshotoverlay.cpp \
 
    commandpanel.cpp \
 
    commandwidget.cpp \
 
    commandedit.cpp
 

	
 
HEADERS  += mainwindow.h \
 
    utils.h \
 
@@ -62,16 +65,24 @@ HEADERS  += mainwindow.h \
 
    snapshotview.h \
 
    snapshotmanager.h \
 
    snapshot.h \
 
    plotsnapshotoverlay.h
 
    plotsnapshotoverlay.h \
 
    commandpanel.h \
 
    commandwidget.h \
 
    commandedit.h
 

	
 
FORMS    += mainwindow.ui \
 
    about_dialog.ui \
 
    portcontrol.ui \
 
    snapshotview.ui
 
    snapshotview.ui \
 
    commandpanel.ui \
 
    commandwidget.ui
 

	
 
INCLUDEPATH += qmake/
 

	
 
CONFIG += c++11
 

	
 
RESOURCES += \
 
    misc/icons.qrc
 
RESOURCES += misc/icons.qrc
 

	
 
win32 {
 
    RESOURCES += misc/winicons.qrc
 
}
0 comments (0 inline, 0 general)