Changeset - 3b329010cce9
CMakeLists.txt
Show inline comments
 
@@ -112,12 +112,13 @@ add_executable(${PROGRAM_NAME} WIN32
 
  src/asciireader.cpp
 
  src/asciireadersettings.cpp
 
  src/demoreader.cpp
 
  src/framedreader.cpp
 
  src/framedreadersettings.cpp
 
  src/plotmanager.cpp
 
  src/numberformat.cpp
 
  misc/windows_icon.rc
 
  ${UI_FILES}
 
  ${RES_FILES}
 
  )
 

	
 
# Use the Widgets module from Qt 5.
serialplot.pro
Show inline comments
 
@@ -63,13 +63,14 @@ SOURCES += \
 
    src/binarystreamreader.cpp \
 
    src/binarystreamreadersettings.cpp \
 
    src/asciireadersettings.cpp \
 
    src/asciireader.cpp \
 
    src/demoreader.cpp \
 
    src/framedreader.cpp \
 
    src/plotmanager.cpp
 
    src/plotmanager.cpp \
 
    src/numberformat.cpp
 

	
 
HEADERS += \
 
    src/mainwindow.h \
 
    src/utils.h \
 
    src/portcontrol.h \
 
    src/floatswap.h \
 
@@ -100,13 +101,15 @@ HEADERS += \
 
    src/binarystreamreader.h \
 
    src/binarystreamreadersettings.h \
 
    src/asciireadersettings.h \
 
    src/asciireader.h \
 
    src/demoreader.h \
 
    src/framedreader.h \
 
    src/plotmanager.h
 
    src/plotmanager.h \
 
    src/setting_defines.h \
 
    src/numberformat.h
 

	
 
FORMS += \
 
    src/mainwindow.ui \
 
    src/about_dialog.ui \
 
    src/portcontrol.ui \
 
    src/snapshotview.ui \
src/asciireader.cpp
Show inline comments
 
@@ -156,6 +156,16 @@ void AsciiReader::onDataReady()
 
                qWarning() << "Data parsing error for channel: " << ci;
 
            }
 
        }
 
        emit dataAdded();
 
    }
 
}
 

	
 
void AsciiReader::saveSettings(QSettings* settings)
 
{
 
    _settingsWidget.saveSettings(settings);
 
}
 

	
 
void AsciiReader::loadSettings(QSettings* settings)
 
{
 
    _settingsWidget.loadSettings(settings);
 
}
src/asciireader.h
Show inline comments
 
@@ -17,24 +17,30 @@
 
  along with serialplot.  If not, see <http://www.gnu.org/licenses/>.
 
*/
 

	
 
#ifndef ASCIIREADER_H
 
#define ASCIIREADER_H
 

	
 
#include <QSettings>
 

	
 
#include "abstractreader.h"
 
#include "asciireadersettings.h"
 

	
 
class AsciiReader : public AbstractReader
 
{
 
    Q_OBJECT
 

	
 
public:
 
    explicit AsciiReader(QIODevice* device, ChannelManager* channelMan, QObject *parent = 0);
 
    QWidget* settingsWidget();
 
    unsigned numOfChannels();
 
    void enable(bool enabled = true);
 
    /// Stores settings into a `QSettings`
 
    void saveSettings(QSettings* settings);
 
    /// Loads settings from a `QSettings`.
 
    void loadSettings(QSettings* settings);
 

	
 
public slots:
 
    void pause(bool);
 

	
 
private:
 
    AsciiReaderSettings _settingsWidget;
src/asciireadersettings.cpp
Show inline comments
 
@@ -15,16 +15,19 @@
 

	
 
  You should have received a copy of the GNU General Public License
 
  along with serialplot.  If not, see <http://www.gnu.org/licenses/>.
 
*/
 

	
 
#include "utils.h"
 
#include "setting_defines.h"
 

	
 
#include "asciireadersettings.h"
 
#include "ui_asciireadersettings.h"
 

	
 
#include <QtDebug>
 

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

	
 
@@ -42,6 +45,43 @@ AsciiReaderSettings::~AsciiReaderSetting
 
}
 

	
 
unsigned AsciiReaderSettings::numOfChannels()
 
{
 
    return ui->spNumOfChannels->value();
 
}
 

	
 
void AsciiReaderSettings::saveSettings(QSettings* settings)
 
{
 
    settings->beginGroup(SettingGroup_ASCII);
 

	
 
    // save number of channels setting
 
    QString numOfChannelsSetting = QString::number(numOfChannels());
 
    if (numOfChannelsSetting == "0") numOfChannelsSetting = "auto";
 
    settings->setValue(SG_ASCII_NumOfChannels, numOfChannelsSetting);
 

	
 
    settings->endGroup();
 
}
 

	
 
void AsciiReaderSettings::loadSettings(QSettings* settings)
 
{
 
    settings->beginGroup(SettingGroup_ASCII);
 

	
 
    // load number of channels
 
    QString numOfChannelsSetting =
 
        settings->value(SG_ASCII_NumOfChannels, numOfChannels()).toString();
 

	
 
    if (numOfChannelsSetting == "auto")
 
    {
 
        ui->spNumOfChannels->setValue(0);
 
    }
 
    else
 
    {
 
        bool ok;
 
        int nc = numOfChannelsSetting.toInt(&ok);
 
        if (ok)
 
        {
 
            ui->spNumOfChannels->setValue(nc);
 
        }
 
    }
 

	
 
    settings->endGroup();
 
}
src/asciireadersettings.h
Show inline comments
 
@@ -18,12 +18,13 @@
 
*/
 

	
 
#ifndef ASCIIREADERSETTINGS_H
 
#define ASCIIREADERSETTINGS_H
 

	
 
#include <QWidget>
 
#include <QSettings>
 

	
 
namespace Ui {
 
class AsciiReaderSettings;
 
}
 

	
 
class AsciiReaderSettings : public QWidget
 
@@ -32,12 +33,16 @@ class AsciiReaderSettings : public QWidg
 

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

	
 
    unsigned numOfChannels();
 
    /// Stores settings into a `QSettings`
 
    void saveSettings(QSettings* settings);
 
    /// Loads settings from a `QSettings`.
 
    void loadSettings(QSettings* settings);
 

	
 
signals:
 
    void numOfChannelsChanged(unsigned);
 

	
 
private:
 
    Ui::AsciiReaderSettings *ui;
src/binarystreamreader.cpp
Show inline comments
 
@@ -112,12 +112,15 @@ void BinaryStreamReader::onNumberFormatC
 
            readSample = &BinaryStreamReader::readSampleAs<qint32>;
 
            break;
 
        case NumberFormat_float:
 
            sampleSize = 4;
 
            readSample = &BinaryStreamReader::readSampleAs<float>;
 
            break;
 
        case NumberFormat_INVALID:
 
            Q_ASSERT(1); // never
 
            break;
 
    }
 
}
 

	
 
void BinaryStreamReader::onNumOfChannelsChanged(unsigned value)
 
{
 
    _numOfChannels = value;
 
@@ -176,13 +179,12 @@ void BinaryStreamReader::onDataReady()
 
    }
 
    emit dataAdded();
 

	
 
    delete channelSamples;
 
}
 

	
 

	
 
template<typename T> double BinaryStreamReader::readSampleAs()
 
{
 
    T data;
 

	
 
    _device->read((char*) &data, sizeof(data));
 

	
 
@@ -201,6 +203,16 @@ template<typename T> double BinaryStream
 
void BinaryStreamReader::addChannelData(unsigned int channel,
 
                                        double* data, unsigned size)
 
{
 
    _channelMan->addChannelData(channel, data, size);
 
    sampleCount += size;
 
}
 

	
 
void BinaryStreamReader::saveSettings(QSettings* settings)
 
{
 
    _settingsWidget.saveSettings(settings);
 
}
 

	
 
void BinaryStreamReader::loadSettings(QSettings* settings)
 
{
 
    _settingsWidget.loadSettings(settings);
 
}
src/binarystreamreader.h
Show inline comments
 
@@ -17,12 +17,14 @@
 
  along with serialplot.  If not, see <http://www.gnu.org/licenses/>.
 
*/
 

	
 
#ifndef BINARYSTREAMREADER_H
 
#define BINARYSTREAMREADER_H
 

	
 
#include <QSettings>
 

	
 
#include "abstractreader.h"
 
#include "binarystreamreadersettings.h"
 

	
 
/**
 
 * Reads a simple stream of samples in binary form from the
 
 * device. There is no means of synchronization other than a button
 
@@ -33,12 +35,16 @@ class BinaryStreamReader : public Abstra
 
    Q_OBJECT
 
public:
 
    explicit BinaryStreamReader(QIODevice* device, ChannelManager* channelMan, QObject *parent = 0);
 
    QWidget* settingsWidget();
 
    unsigned numOfChannels();
 
    void enable(bool enabled = true);
 
    /// Stores settings into a `QSettings`
 
    void saveSettings(QSettings* settings);
 
    /// Loads settings from a `QSettings`.
 
    void loadSettings(QSettings* settings);
 

	
 
public slots:
 
    void pause(bool);
 

	
 
private:
 
    BinaryStreamReaderSettings _settingsWidget;
src/binarystreamreadersettings.cpp
Show inline comments
 
@@ -18,12 +18,13 @@
 
*/
 

	
 
#include "binarystreamreadersettings.h"
 
#include "ui_binarystreamreadersettings.h"
 

	
 
#include "utils.h"
 
#include "setting_defines.h"
 

	
 
BinaryStreamReaderSettings::BinaryStreamReaderSettings(QWidget *parent) :
 
    QWidget(parent),
 
    ui(new Ui::BinaryStreamReaderSettings)
 
{
 
    ui->setupUi(this);
 
@@ -58,6 +59,46 @@ NumberFormat BinaryStreamReaderSettings:
 
}
 

	
 
Endianness BinaryStreamReaderSettings::endianness()
 
{
 
    return ui->endiBox->currentSelection();
 
}
 

	
 
void BinaryStreamReaderSettings::saveSettings(QSettings* settings)
 
{
 
    settings->beginGroup(SettingGroup_Binary);
 
    settings->setValue(SG_Binary_NumOfChannels, numOfChannels());
 
    settings->setValue(SG_Binary_NumberFormat, numberFormatToStr(numberFormat()));
 
    settings->setValue(SG_Binary_Endianness,
 
                       endianness() == LittleEndian ? "little" : "big");
 
    settings->endGroup();
 
}
 

	
 
void BinaryStreamReaderSettings::loadSettings(QSettings* settings)
 
{
 
    settings->beginGroup(SettingGroup_Binary);
 

	
 
    // load number of channels
 
    ui->spNumOfChannels->setValue(
 
        settings->value(SG_Binary_NumOfChannels, numOfChannels()).toInt());
 

	
 
    // load number format
 
    NumberFormat nfSetting =
 
        strToNumberFormat(settings->value(SG_Binary_NumberFormat,
 
                                          QString()).toString());
 
    if (nfSetting == NumberFormat_INVALID) nfSetting = numberFormat();
 
    ui->nfBox->setSelection(nfSetting);
 

	
 
    // load endianness
 
    QString endiannessSetting =
 
        settings->value(SG_Binary_Endianness, QString()).toString();
 
    if (endiannessSetting == "little")
 
    {
 
        ui->endiBox->setSelection(LittleEndian);
 
    }
 
    else if (endiannessSetting == "big")
 
    {
 
        ui->endiBox->setSelection(BigEndian);
 
    } // else don't change
 

	
 
    settings->endGroup();
 
}
src/binarystreamreadersettings.h
Show inline comments
 
@@ -18,12 +18,14 @@
 
*/
 

	
 
#ifndef BINARYSTREAMREADERSETTINGS_H
 
#define BINARYSTREAMREADERSETTINGS_H
 

	
 
#include <QWidget>
 
#include <QSettings>
 

	
 
#include "numberformatbox.h"
 
#include "endiannessbox.h"
 

	
 
namespace Ui {
 
class BinaryStreamReaderSettings;
 
}
 
@@ -37,12 +39,17 @@ public:
 
    ~BinaryStreamReaderSettings();
 

	
 
    unsigned numOfChannels();
 
    NumberFormat numberFormat();
 
    Endianness endianness();
 

	
 
    /// Stores settings into a `QSettings`
 
    void saveSettings(QSettings* settings);
 
    /// Loads settings from a `QSettings`.
 
    void loadSettings(QSettings* settings);
 

	
 
signals:
 
    void numOfChannelsChanged(unsigned);
 
    void numberFormatChanged(NumberFormat);
 
    void skipByteRequested();
 
    void skipSampleRequested();
 

	
src/channelmanager.cpp
Show inline comments
 
@@ -14,17 +14,18 @@
 
  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 "channelmanager.h"
 

	
 
#include <QStringList>
 
#include <QModelIndex>
 

	
 
#include "channelmanager.h"
 
#include "setting_defines.h"
 

	
 
ChannelManager::ChannelManager(unsigned numberOfChannels, unsigned numberOfSamples, QObject *parent) :
 
    QObject(parent)
 
{
 
    _numOfChannels = numberOfChannels;
 
    _numOfSamples = numberOfSamples;
 

	
 
@@ -140,6 +141,32 @@ void ChannelManager::onChannelNameDataCh
 
}
 

	
 
void ChannelManager::addChannelData(unsigned channel, double* data, unsigned size)
 
{
 
    channelBuffer(channel)->addSamples(data, size);
 
}
 

	
 
void ChannelManager::saveSettings(QSettings* settings)
 
{
 
    settings->beginGroup(SettingGroup_Channels);
 
    settings->beginWriteArray(SG_Channels_Channel);
 
    for (unsigned i = 0; i < numOfChannels(); i++)
 
    {
 
        settings->setArrayIndex(i);
 
        settings->setValue(SG_Channels_Name, channelName(i));
 
    }
 
    settings->endArray();
 
    settings->endGroup();
 
}
 

	
 
void ChannelManager::loadSettings(QSettings* settings)
 
{
 
    settings->beginGroup(SettingGroup_Channels);
 
    settings->beginReadArray(SG_Channels_Channel);
 
    for (unsigned i = 0; i < numOfChannels(); i++)
 
    {
 
        settings->setArrayIndex(i);
 
        setChannelName(i, settings->value(SG_Channels_Name, channelName(i)).toString());
 
    }
 
    settings->endArray();
 
    settings->endGroup();
 
}
src/channelmanager.h
Show inline comments
 
@@ -21,12 +21,13 @@
 
#define CHANNELMANAGER_H
 

	
 
#include <QObject>
 
#include <QStringListModel>
 
#include <QModelIndex>
 
#include <QVector>
 
#include <QSettings>
 

	
 
#include "framebuffer.h"
 

	
 
class ChannelManager : public QObject
 
{
 
    Q_OBJECT
 
@@ -36,12 +37,16 @@ public:
 

	
 
    unsigned numOfChannels();
 
    unsigned numOfSamples();
 
    FrameBuffer* channelBuffer(unsigned channel);
 
    QStringListModel* channelNames();
 
    QString channelName(unsigned channel);
 
    /// Stores channel names into a `QSettings`
 
    void saveSettings(QSettings* settings);
 
    /// Loads channel names from a `QSettings`.
 
    void loadSettings(QSettings* settings);
 

	
 
signals:
 
    void numOfChannelsChanged(unsigned value);
 
    void numOfSamplesChanged(unsigned value);
 
    void channelNameChanged(unsigned channel, QString name);
 

	
src/commandpanel.cpp
Show inline comments
 
/*
 
  Copyright © 2015 Hasan Yavuz Özderya
 
  Copyright © 2016 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
 
@@ -14,17 +14,18 @@
 
  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 <QByteArray>
 
#include <QtDebug>
 

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

	
 
#include <QByteArray>
 
#include <QtDebug>
 
#include "setting_defines.h"
 

	
 
CommandPanel::CommandPanel(QSerialPort* port, QWidget *parent) :
 
    QWidget(parent),
 
    ui(new Ui::CommandPanel),
 
    _menu(trUtf8("Commands")), _newCommandAction(trUtf8("New Command"), this)
 
{
 
@@ -43,30 +44,38 @@ CommandPanel::CommandPanel(QSerialPort* 
 
    connect(&_newCommandAction, &QAction::triggered, this, &CommandPanel::newCommand);
 

	
 
    _menu.addAction(&_newCommandAction);
 
    _menu.addSeparator();
 

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

	
 
CommandPanel::~CommandPanel()
 
{
 
    commands.clear(); // UI will 'delete' actual objects
 
    delete ui;
 
}
 

	
 
void CommandPanel::newCommand()
 
CommandWidget* CommandPanel::newCommand()
 
{
 
    auto command = new CommandWidget();
 
    command_name_counter++;
 
    command->setName(trUtf8("Command ") + QString::number(command_name_counter));
 
    ui->scrollAreaWidgetContents->layout()->addWidget(command);
 
    command->setFocusToEdit();
 
    connect(command, &CommandWidget::sendCommand, this, &CommandPanel::sendCommand);
 
    connect(command, &CommandWidget::focusRequested, this, &CommandPanel::focusRequested);
 
    _menu.addAction(command->sendAction());
 

	
 
    // add to command list and remove on destroy
 
    commands << command;
 
    connect(command, &QObject::destroyed, [this](QObject* obj)
 
            {
 
                commands.removeOne(static_cast<CommandWidget*>(obj));
 
            });
 
    return command;
 
}
 

	
 
void CommandPanel::sendCommand(QByteArray command)
 
{
 
    if (!serialPort->isOpen())
 
    {
 
@@ -86,6 +95,69 @@ QMenu* CommandPanel::menu()
 
}
 

	
 
QAction* CommandPanel::newCommandAction()
 
{
 
    return &_newCommandAction;
 
}
 

	
 
unsigned CommandPanel::numOfCommands()
 
{
 
    return commands.size();
 
}
 

	
 
void CommandPanel::saveSettings(QSettings* settings)
 
{
 
    settings->beginGroup(SettingGroup_Commands);
 
    settings->beginWriteArray(SG_Commands_Command);
 
    for (int i = 0; i < commands.size(); i ++)
 
    {
 
        settings->setArrayIndex(i);
 
        auto command = commands[i];
 
        settings->setValue(SG_Commands_Name, command->name());
 
        settings->setValue(SG_Commands_Type, command->isASCIIMode() ? "ascii" : "hex");
 
        settings->setValue(SG_Commands_Data, command->commandText());
 
    }
 
    settings->endArray();
 
    settings->endGroup();
 
}
 

	
 
void CommandPanel::loadSettings(QSettings* settings)
 
{
 
    // clear all commands
 
    while (commands.size())
 
    {
 
        auto command = commands.takeLast();
 
        command->disconnect();
 
        delete command;
 
    }
 

	
 
    // load commands
 
    settings->beginGroup(SettingGroup_Commands);
 
    unsigned size = settings->beginReadArray(SG_Commands_Command);
 

	
 
    for (unsigned i = 0; i < size; i ++)
 
    {
 
        settings->setArrayIndex(i);
 
        auto command = newCommand();
 

	
 
        // load command name
 
        QString name = settings->value(SG_Commands_Name, "").toString();
 
        if (!name.isEmpty()) command->setName(name);
 

	
 
        // Important: type should be set before command data for correct validation
 
        QString type = settings->value(SG_Commands_Type, "").toString();
 
        if (type == "ascii")
 
        {
 
            command->setASCIIMode(true);
 
        }
 
        else if (type == "hex")
 
        {
 
            command->setASCIIMode(false);
 
        } // else unchanged
 

	
 
        // load command data
 
        command->setCommandText(settings->value(SG_Commands_Data, "").toString());
 
    }
 

	
 
    settings->endArray();
 
    settings->endGroup();
 
}
src/commandpanel.h
Show inline comments
 
/*
 
  Copyright © 2015 Hasan Yavuz Özderya
 
  Copyright © 2016 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
 
@@ -20,14 +20,16 @@
 
#ifndef COMMANDPANEL_H
 
#define COMMANDPANEL_H
 

	
 
#include <QWidget>
 
#include <QSerialPort>
 
#include <QByteArray>
 
#include <QList>
 
#include <QMenu>
 
#include <QAction>
 
#include <QSettings>
 

	
 
#include "commandwidget.h"
 

	
 
namespace Ui {
 
class CommandPanel;
 
}
 
@@ -38,26 +40,34 @@ class CommandPanel : public QWidget
 

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

	
 
    QMenu* menu();
 
    /// Action for creating a new command.
 
    QAction* newCommandAction();
 
    /// Stores commands into a `QSettings`
 
    void saveSettings(QSettings* settings);
 
    /// Loads commands from a `QSettings`.
 
    void loadSettings(QSettings* settings);
 
    /// Number of commands
 
    unsigned numOfCommands();
 

	
 
signals:
 
    // emitted when user tries to send an empty command
 
    void focusRequested();
 

	
 
private:
 
    Ui::CommandPanel *ui;
 
    QSerialPort* serialPort;
 
    QMenu _menu;
 
    QAction _newCommandAction;
 
    QList<CommandWidget*> commands;
 

	
 
    unsigned command_name_counter;
 

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

	
 
#endif // COMMANDPANEL_H
src/commandwidget.cpp
Show inline comments
 
/*
 
  Copyright © 2015 Hasan Yavuz Özderya
 
  Copyright © 2016 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
 
@@ -98,12 +98,17 @@ void CommandWidget::onASCIIToggled(bool 
 

	
 
bool CommandWidget::isASCIIMode()
 
{
 
    return ui->pbASCII->isChecked();
 
}
 

	
 
void CommandWidget::setASCIIMode(bool enabled)
 
{
 
    ui->pbASCII->setChecked(enabled);
 
}
 

	
 
void CommandWidget::setName(QString name)
 
{
 
    ui->leName->setText(name);
 
}
 

	
 
QString CommandWidget::name()
 
@@ -117,6 +122,17 @@ void CommandWidget::setFocusToEdit()
 
}
 

	
 
QAction* CommandWidget::sendAction()
 
{
 
    return &_sendAction;
 
}
 

	
 
QString CommandWidget::commandText()
 
{
 
    return ui->leCommand->text();
 
}
 

	
 
void CommandWidget::setCommandText(QString str)
 
{
 
    ui->leCommand->selectAll();
 
    ui->leCommand->insert(str);
 
}
src/commandwidget.h
Show inline comments
 
/*
 
  Copyright © 2015 Hasan Yavuz Özderya
 
  Copyright © 2016 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
 
@@ -36,32 +36,42 @@ public:
 
    explicit CommandWidget(QWidget *parent = 0);
 
    ~CommandWidget();
 

	
 
    void setName(QString name);
 
    QString name();
 
    void setFocusToEdit();
 
    /// An action that triggers sending of command.
 
    QAction* sendAction();
 
    /// true: ascii mode, false hex mode
 
    bool isASCIIMode();
 
    /// true: ascii mode, false hex mode
 
    void setASCIIMode(bool ascii);
 
        /// Returns the command data as text
 
    QString commandText();
 
    /// Set command data as text. Text is validated according to current mode.
 
    void setCommandText(QString str);
 

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

	
 
    // 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)
 
    /**
 
     * 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);
 

	
 
    // emitted when user tries to send an empty command
 
    /// emitted when user tries to send an empty command
 
    void focusRequested();
 

	
 
private:
 
    Ui::CommandWidget *ui;
 
    QAction _sendAction;
 

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

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

	
src/dataformatpanel.cpp
Show inline comments
 
@@ -19,15 +19,17 @@
 

	
 
#include "dataformatpanel.h"
 
#include "ui_dataformatpanel.h"
 

	
 
#include <QRadioButton>
 
#include <QtEndian>
 
#include <QMap>
 
#include <QtDebug>
 

	
 
#include "utils.h"
 
#include "setting_defines.h"
 
#include "floatswap.h"
 

	
 
DataFormatPanel::DataFormatPanel(QSerialPort* port,
 
                                 ChannelManager* channelMan,
 
                                 QWidget *parent) :
 
    QWidget(parent),
 
@@ -142,6 +144,66 @@ void DataFormatPanel::selectReader(Abstr
 

	
 
    // pause
 
    reader->pause(paused);
 

	
 
    currentReader = reader;
 
}
 

	
 
void DataFormatPanel::saveSettings(QSettings* settings)
 
{
 
    settings->beginGroup(SettingGroup_DataFormat);
 

	
 
    // save selected format
 
    QString format;
 
    if (currentReader == &bsReader)
 
    {
 
        format = "binary";
 
    }
 
    else if (currentReader == &asciiReader)
 
    {
 
        format = "ascii";
 
    }
 
    else // framed reader
 
    {
 
        format = "custom";
 
    }
 
    settings->setValue(SG_DataFormat_Format, format);
 

	
 
    settings->endGroup();
 

	
 
    // save reader settings
 
    bsReader.saveSettings(settings);
 
    asciiReader.saveSettings(settings);
 
    framedReader.saveSettings(settings);
 
}
 

	
 
void DataFormatPanel::loadSettings(QSettings* settings)
 
{
 
    settings->beginGroup(SettingGroup_DataFormat);
 

	
 
    // load selected format
 
    QString format = settings->value(
 
        SG_DataFormat_Format, QString()).toString();
 

	
 
    if (format == "binary")
 
    {
 
        selectReader(&bsReader);
 
        ui->rbBinary->setChecked(true);
 
    }
 
    else if (format == "ascii")
 
    {
 
        selectReader(&asciiReader);
 
        ui->rbAscii->setChecked(true);
 
    }
 
    else if (format == "custom")
 
    {
 
        selectReader(&framedReader);
 
        ui->rbFramed->setChecked(true);
 
    } // else current selection stays
 

	
 
    settings->endGroup();
 

	
 
    // load reader settings
 
    bsReader.loadSettings(settings);
 
    asciiReader.loadSettings(settings);
 
    framedReader.loadSettings(settings);
 
}
src/dataformatpanel.h
Show inline comments
 
@@ -22,12 +22,13 @@
 

	
 
#include <QWidget>
 
#include <QButtonGroup>
 
#include <QTimer>
 
#include <QSerialPort>
 
#include <QList>
 
#include <QSettings>
 
#include <QtGlobal>
 

	
 
#include "framebuffer.h"
 
#include "channelmanager.h"
 
#include "binarystreamreader.h"
 
#include "asciireader.h"
 
@@ -45,13 +46,18 @@ class DataFormatPanel : public QWidget
 
public:
 
    explicit DataFormatPanel(QSerialPort* port,
 
                             ChannelManager* channelMan,
 
                             QWidget *parent = 0);
 
    ~DataFormatPanel();
 

	
 
    /// Returns currently selected number of channels
 
    unsigned numOfChannels();
 
    /// Stores data format panel settings into a `QSettings`
 
    void saveSettings(QSettings* settings);
 
    /// Loads data format panel settings from a `QSettings`.
 
    void loadSettings(QSettings* settings);
 

	
 
public slots:
 
    void pause(bool);
 
    void enableDemo(bool); // demo shouldn't be enabled when port is open
 

	
 
signals:
src/endiannessbox.cpp
Show inline comments
 
@@ -45,6 +45,18 @@ Endianness EndiannessBox::currentSelecti
 
    }
 
    else
 
    {
 
        return BigEndian;
 
    }
 
}
 

	
 
void EndiannessBox::setSelection(Endianness endianness)
 
{
 
    if (endianness == LittleEndian)
 
    {
 
        ui->rbLittleE->setChecked(true);
 
    }
 
    else // big endian
 
    {
 
        ui->rbBigE->setChecked(true);
 
    }
 
}
src/endiannessbox.h
Show inline comments
 
@@ -37,13 +37,16 @@ class EndiannessBox : public QWidget
 
    Q_OBJECT
 

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

	
 
    Endianness currentSelection(); ///< currently selected endianness
 
    /// currently selected endianness
 
    Endianness currentSelection();
 
    /// change the currently selected endianness
 
    void setSelection(Endianness endianness);
 

	
 
signals:
 
    /// Signaled when endianness selection is changed
 
    void selectionChanged(Endianness endianness);
 

	
 
private:
src/framedreader.cpp
Show inline comments
 
@@ -119,12 +119,15 @@ void FramedReader::onNumberFormatChanged
 
            readSample = &FramedReader::readSampleAs<qint32>;
 
            break;
 
        case NumberFormat_float:
 
            sampleSize = 4;
 
            readSample = &FramedReader::readSampleAs<float>;
 
            break;
 
        case NumberFormat_INVALID:
 
            Q_ASSERT(1); // never
 
            break;
 
    }
 

	
 
    checkSettings();
 
    reset();
 
}
 

	
 
@@ -347,6 +350,16 @@ template<typename T> double FramedReader
 
    {
 
        data = qFromBigEndian(data);
 
    }
 

	
 
    return double(data);
 
}
 

	
 
void FramedReader::saveSettings(QSettings* settings)
 
{
 
    _settingsWidget.saveSettings(settings);
 
}
 

	
 
void FramedReader::loadSettings(QSettings* settings)
 
{
 
    _settingsWidget.loadSettings(settings);
 
}
src/framedreader.h
Show inline comments
 
@@ -17,12 +17,14 @@
 
  along with serialplot.  If not, see <http://www.gnu.org/licenses/>.
 
*/
 

	
 
#ifndef FRAMEDREADER_H
 
#define FRAMEDREADER_H
 

	
 
#include <QSettings>
 

	
 
#include "abstractreader.h"
 
#include "framedreadersettings.h"
 

	
 
/**
 
 * Reads data in a customizable framed format.
 
 */
 
@@ -32,12 +34,16 @@ class FramedReader : public AbstractRead
 

	
 
public:
 
    explicit FramedReader(QIODevice* device, ChannelManager* channelMan, QObject *parent = 0);
 
    QWidget* settingsWidget();
 
    unsigned numOfChannels();
 
    void enable(bool enabled = true);
 
    /// Stores settings into a `QSettings`
 
    void saveSettings(QSettings* settings);
 
    /// Loads settings from a `QSettings`.
 
    void loadSettings(QSettings* settings);
 

	
 
public slots:
 
    void pause(bool);
 

	
 
private:
 
    /// bit wise fields for `settingsValid` member
src/framedreadersettings.cpp
Show inline comments
 
@@ -17,12 +17,13 @@
 
  along with serialplot.  If not, see <http://www.gnu.org/licenses/>.
 
*/
 

	
 
#include <QButtonGroup>
 

	
 
#include "utils.h"
 
#include "setting_defines.h"
 
#include "framedreadersettings.h"
 
#include "ui_framedreadersettings.h"
 

	
 
FramedReaderSettings::FramedReaderSettings(QWidget *parent) :
 
    QWidget(parent),
 
    ui(new Ui::FramedReaderSettings)
 
@@ -147,6 +148,76 @@ bool FramedReaderSettings::isChecksumEna
 
}
 

	
 
bool FramedReaderSettings::isDebugModeEnabled()
 
{
 
    return ui->cbDebugMode->isChecked();
 
}
 

	
 
void FramedReaderSettings::saveSettings(QSettings* settings)
 
{
 
    settings->beginGroup(SettingGroup_CustomFrame);
 
    settings->setValue(SG_CustomFrame_NumOfChannels, numOfChannels());
 
    settings->setValue(SG_CustomFrame_NumberFormat, numberFormatToStr(numberFormat()));
 
    settings->setValue(SG_CustomFrame_Endianness,
 
                       endianness() == LittleEndian ? "little" : "big");
 
    settings->setValue(SG_CustomFrame_FrameStart, ui->leSyncWord->text());
 
    settings->setValue(SG_CustomFrame_FixedSize, ui->rbFixedSize->isChecked());
 
    settings->setValue(SG_CustomFrame_FrameSize, ui->spSize->value());
 
    settings->setValue(SG_CustomFrame_Checksum, ui->cbChecksum->isChecked());
 
    settings->setValue(SG_CustomFrame_DebugMode, ui->cbDebugMode->isChecked());
 
    settings->endGroup();
 
}
 

	
 
void FramedReaderSettings::loadSettings(QSettings* settings)
 
{
 
    settings->beginGroup(SettingGroup_CustomFrame);
 

	
 
    // load number of channels
 
    ui->spNumOfChannels->setValue(
 
        settings->value(SG_CustomFrame_NumOfChannels, numOfChannels()).toInt());
 

	
 
    // load number format
 
    NumberFormat nfSetting =
 
        strToNumberFormat(settings->value(SG_CustomFrame_NumberFormat,
 
                                          QString()).toString());
 
    if (nfSetting == NumberFormat_INVALID) nfSetting = numberFormat();
 
    ui->nfBox->setSelection(nfSetting);
 

	
 
    // load endianness
 
    QString endiannessSetting =
 
        settings->value(SG_CustomFrame_Endianness, QString()).toString();
 
    if (endiannessSetting == "little")
 
    {
 
        ui->endiBox->setSelection(LittleEndian);
 
    }
 
    else if (endiannessSetting == "big")
 
    {
 
        ui->endiBox->setSelection(BigEndian);
 
    } // else don't change
 

	
 
    // load frame start
 
    QString frameStartSetting =
 
        settings->value(SG_CustomFrame_FrameStart, ui->leSyncWord->text()).toString();
 
    auto validator = ui->leSyncWord->validator();
 
    validator->fixup(frameStartSetting);
 
    int pos = 0;
 
    if (validator->validate(frameStartSetting, pos) != QValidator::Invalid)
 
    {
 
        ui->leSyncWord->setText(frameStartSetting);
 
    }
 

	
 
    // load frame size
 
    ui->spSize->setValue(
 
        settings->value(SG_CustomFrame_FrameSize, ui->spSize->value()).toInt());
 
    ui->rbFixedSize->setChecked(
 
        settings->value(SG_CustomFrame_FixedSize, ui->rbFixedSize->isChecked()).toBool());
 

	
 
    // load checksum
 
    ui->cbChecksum->setChecked(
 
        settings->value(SG_CustomFrame_Checksum, ui->cbChecksum->isChecked()).toBool());
 

	
 
    // load debug mode
 
    ui->cbDebugMode->setChecked(
 
        settings->value(SG_CustomFrame_DebugMode, ui->cbDebugMode->isChecked()).toBool());
 

	
 
    settings->endGroup();
 
}
src/framedreadersettings.h
Show inline comments
 
@@ -19,12 +19,13 @@
 

	
 
#ifndef FRAMEDREADERSETTINGS_H
 
#define FRAMEDREADERSETTINGS_H
 

	
 
#include <QWidget>
 
#include <QByteArray>
 
#include <QSettings>
 

	
 
#include "numberformatbox.h"
 
#include "endiannessbox.h"
 

	
 
namespace Ui {
 
class FramedReaderSettings;
 
@@ -44,12 +45,16 @@ public:
 
    NumberFormat numberFormat();
 
    Endianness endianness();
 
    QByteArray syncWord();
 
    unsigned frameSize(); /// If frame bye is enabled `0` is returned
 
    bool isChecksumEnabled();
 
    bool isDebugModeEnabled();
 
    /// Save settings into a `QSettings`
 
    void saveSettings(QSettings* settings);
 
    /// Loads settings from a `QSettings`.
 
    void loadSettings(QSettings* settings);
 

	
 
signals:
 
    /// If sync word is invalid (empty or 1 nibble missing at the end)
 
    /// signaled with an empty array
 
    void syncWordChanged(QByteArray);
 
    /// `0` indicates frame size byte is enabled
src/mainwindow.cpp
Show inline comments
 
@@ -23,30 +23,39 @@
 
#include <QApplication>
 
#include <QFileDialog>
 
#include <QFile>
 
#include <QTextStream>
 
#include <QMenu>
 
#include <QDesktopServices>
 
#include <QMap>
 
#include <QtDebug>
 
#include <qwt_plot.h>
 
#include <limits.h>
 
#include <cmath>
 
#include <iostream>
 

	
 
#include <plot.h>
 

	
 
#include "framebufferseries.h"
 
#include "utils.h"
 
#include "defines.h"
 
#include "version.h"
 
#include "setting_defines.h"
 

	
 
#if defined(Q_OS_WIN) && defined(QT_STATIC)
 
#include <QtPlugin>
 
Q_IMPORT_PLUGIN(QWindowsIntegrationPlugin)
 
#endif
 

	
 
const QMap<int, QString> panelSettingMap({
 
        {0, "Port"},
 
        {1, "DataFormat"},
 
        {2, "Plot"},
 
        {3, "Commands"}
 
    });
 

	
 
MainWindow::MainWindow(QWidget *parent) :
 
    QMainWindow(parent),
 
    ui(new Ui::MainWindow),
 
    aboutDialog(this),
 
    portControl(&serialPort),
 
    channelMan(1, 1, this),
 
@@ -60,13 +69,14 @@ MainWindow::MainWindow(QWidget *parent) 
 

	
 
    ui->tabWidget->insertTab(0, &portControl, "Port");
 
    ui->tabWidget->insertTab(1, &dataFormatPanel, "Data Format");
 
    ui->tabWidget->insertTab(2, &plotControlPanel, "Plot");
 
    ui->tabWidget->insertTab(3, &commandPanel, "Commands");
 
    ui->tabWidget->setCurrentIndex(0);
 
    addToolBar(portControl.toolBar());
 
    auto tbPortControl = portControl.toolBar();
 
    addToolBar(tbPortControl);
 

	
 
    ui->plotToolBar->addAction(snapshotMan.takeSnapshotAction());
 
    ui->menuBar->insertMenu(ui->menuHelp->menuAction(), snapshotMan.menu());
 
    ui->menuBar->insertMenu(ui->menuHelp->menuAction(), commandPanel.menu());
 
    connect(commandPanel.newCommandAction(), &QAction::triggered, [this]()
 
            {
 
@@ -75,12 +85,15 @@ MainWindow::MainWindow(QWidget *parent) 
 

	
 
    connect(&commandPanel, &CommandPanel::focusRequested, [this]()
 
            {
 
                this->ui->tabWidget->setCurrentWidget(&commandPanel);
 
            });
 

	
 
    tbPortControl->setObjectName("tbPortControl");
 
    ui->plotToolBar->setObjectName("tbPlot");
 

	
 
    setupAboutDialog();
 

	
 
    // init view menu
 
    for (auto a : plotMan->menuActions())
 
    {
 
        ui->menuView->addAction(a);
 
@@ -91,22 +104,29 @@ MainWindow::MainWindow(QWidget *parent) 
 
    QMenu* tbMenu = ui->menuView->addMenu("Toolbars");
 
    tbMenu->addAction(ui->plotToolBar->toggleViewAction());
 
    tbMenu->addAction(portControl.toolBar()->toggleViewAction());
 

	
 
    // init UI signals
 

	
 
    // menu signals
 
    // Help menu signals
 
    QObject::connect(ui->actionHelpAbout, &QAction::triggered,
 
              &aboutDialog, &QWidget::show);
 

	
 
    QObject::connect(ui->actionReportBug, &QAction::triggered,
 
                     [](){QDesktopServices::openUrl(QUrl(BUG_REPORT_URL));});
 

	
 
    // File menu signals
 
    QObject::connect(ui->actionExportCsv, &QAction::triggered,
 
                     this, &MainWindow::onExportCsv);
 

	
 
    QObject::connect(ui->actionSaveSettings, &QAction::triggered,
 
                     this, &MainWindow::onSaveSettings);
 

	
 
    QObject::connect(ui->actionLoadSettings, &QAction::triggered,
 
                     this, &MainWindow::onLoadSettings);
 

	
 
    ui->actionQuit->setShortcutContext(Qt::ApplicationShortcut);
 

	
 
    QObject::connect(ui->actionQuit, &QAction::triggered,
 
                     this, &MainWindow::close);
 

	
 
    // port control signals
 
@@ -178,16 +198,30 @@ MainWindow::MainWindow(QWidget *parent) 
 
    // init demo
 
    QObject::connect(ui->actionDemoMode, &QAction::toggled,
 
                     this, &MainWindow::enableDemo);
 

	
 
    QObject::connect(ui->actionDemoMode, &QAction::toggled,
 
                     plotMan, &PlotManager::showDemoIndicator);
 

	
 
    // load default settings
 
    QSettings settings("serialplot", "serialplot");
 
    loadAllSettings(&settings);
 

	
 
    // ensure command panel has 1 command if none loaded
 
    if (!commandPanel.numOfCommands())
 
    {
 
        commandPanel.newCommandAction()->trigger();
 
    }
 
}
 

	
 
MainWindow::~MainWindow()
 
{
 
    // save settings
 
    QSettings settings("serialplot", "serialplot");
 
    saveAllSettings(&settings);
 

	
 
    if (serialPort.isOpen())
 
    {
 
        serialPort.close();
 
    }
 

	
 
    delete plotMan;
 
@@ -399,6 +433,103 @@ void MainWindow::messageHandler(QtMsgTyp
 

	
 
    if (type != QtDebugMsg && ui != NULL)
 
    {
 
        ui->statusBar->showMessage(msg, 5000);
 
    }
 
}
 

	
 
void MainWindow::saveAllSettings(QSettings* settings)
 
{
 
    saveMWSettings(settings);
 
    portControl.saveSettings(settings);
 
    dataFormatPanel.saveSettings(settings);
 
    channelMan.saveSettings(settings);
 
    plotControlPanel.saveSettings(settings);
 
    plotMan->saveSettings(settings);
 
    commandPanel.saveSettings(settings);
 
}
 

	
 
void MainWindow::loadAllSettings(QSettings* settings)
 
{
 
    loadMWSettings(settings);
 
    portControl.loadSettings(settings);
 
    dataFormatPanel.loadSettings(settings);
 
    channelMan.loadSettings(settings);
 
    plotControlPanel.loadSettings(settings);
 
    plotMan->loadSettings(settings);
 
    commandPanel.loadSettings(settings);
 
}
 

	
 
void MainWindow::saveMWSettings(QSettings* settings)
 
{
 
    // save window geometry
 
    settings->beginGroup(SettingGroup_MainWindow);
 
    settings->setValue(SG_MainWindow_Size, size());
 
    settings->setValue(SG_MainWindow_Pos, pos());
 
    // save active panel
 
    settings->setValue(SG_MainWindow_ActivePanel,
 
                       panelSettingMap.value(ui->tabWidget->currentIndex()));
 
    // save panel minimization
 
    settings->setValue(SG_MainWindow_HidePanels,
 
                       ui->tabWidget->hideAction.isChecked());
 
    // save window maximized state
 
    settings->setValue(SG_MainWindow_Maximized,
 
                       bool(windowState() & Qt::WindowMaximized));
 
    // save toolbar/dockwidgets state
 
    settings->setValue(SG_MainWindow_State, saveState());
 
    settings->endGroup();
 
}
 

	
 
void MainWindow::loadMWSettings(QSettings* settings)
 
{
 
    settings->beginGroup(SettingGroup_MainWindow);
 
    // load window geometry
 
    resize(settings->value(SG_MainWindow_Size, size()).toSize());
 
    move(settings->value(SG_MainWindow_Pos, pos()).toPoint());
 

	
 
    // set active panel
 
    QString tabSetting =
 
        settings->value(SG_MainWindow_ActivePanel, QString()).toString();
 
    ui->tabWidget->setCurrentIndex(
 
        panelSettingMap.key(tabSetting, ui->tabWidget->currentIndex()));
 

	
 
    // hide panels
 
    ui->tabWidget->hideAction.setChecked(
 
        settings->value(SG_MainWindow_HidePanels,
 
                        ui->tabWidget->hideAction.isChecked()).toBool());
 

	
 
    // maximize window
 
    if (settings->value(SG_MainWindow_Maximized).toBool())
 
    {
 
        showMaximized();
 
    }
 

	
 
    // load toolbar/dockwidgets state
 
    restoreState(settings->value(SG_MainWindow_State).toByteArray());
 
    settings->setValue(SG_MainWindow_State, saveState());
 

	
 
    settings->endGroup();
 
}
 

	
 
void MainWindow::onSaveSettings()
 
{
 
    QString fileName = QFileDialog::getSaveFileName(
 
        this, tr("Save Settings"), QString(), "INI (*.ini)");
 

	
 
    if (!fileName.isNull()) // user canceled
 
    {
 
        QSettings settings(fileName, QSettings::IniFormat);
 
        saveAllSettings(&settings);
 
    }
 
}
 

	
 
void MainWindow::onLoadSettings()
 
{
 
    QString fileName = QFileDialog::getOpenFileName(
 
        this, tr("Load Settings"), QString(), "INI (*.ini)");
 

	
 
    if (!fileName.isNull()) // user canceled
 
    {
 
        QSettings settings(fileName, QSettings::IniFormat);
 
        loadAllSettings(&settings);
 
    }
 
}
src/mainwindow.h
Show inline comments
 
@@ -28,12 +28,13 @@
 
#include <QList>
 
#include <QSerialPort>
 
#include <QSignalMapper>
 
#include <QTimer>
 
#include <QColor>
 
#include <QtGlobal>
 
#include <QSettings>
 
#include <qwt_plot_curve.h>
 

	
 
#include "portcontrol.h"
 
#include "commandpanel.h"
 
#include "dataformatpanel.h"
 
#include "plotcontrolpanel.h"
 
@@ -77,25 +78,32 @@ private:
 
    QLabel spsLabel;
 
    CommandPanel commandPanel;
 
    DataFormatPanel dataFormatPanel;
 
    PlotControlPanel plotControlPanel;
 

	
 
    bool isDemoRunning();
 
    /// Stores settings for all modules
 
    void saveAllSettings(QSettings* settings);
 
    /// Load settings for all modules
 
    void loadAllSettings(QSettings* settings);
 
    /// Stores main window settings into a `QSettings`
 
    void saveMWSettings(QSettings* settings);
 
    /// Loads main window settings from a `QSettings`
 
    void loadMWSettings(QSettings* settings);
 

	
 
private slots:
 
    void onPortToggled(bool open);
 
    void onPortError(QSerialPort::SerialPortError error);
 

	
 
    void onNumOfSamplesChanged(int value);
 
    void onNumOfChannelsChanged(unsigned value);
 
    void onChannelNameChanged(unsigned channel, QString name);
 

	
 
    void clearPlot();
 

	
 
    void onSpsChanged(unsigned sps);
 

	
 
    void enableDemo(bool enabled);
 

	
 
    void onExportCsv();
 
    void onSaveSettings();
 
    void onLoadSettings();
 
};
 

	
 
#endif // MAINWINDOW_H
src/mainwindow.ui
Show inline comments
 
@@ -102,12 +102,14 @@
 
    <addaction name="actionHelpAbout"/>
 
   </widget>
 
   <widget class="QMenu" name="menuFile">
 
    <property name="title">
 
     <string>File</string>
 
    </property>
 
    <addaction name="actionSaveSettings"/>
 
    <addaction name="actionLoadSettings"/>
 
    <addaction name="actionExportCsv"/>
 
    <addaction name="separator"/>
 
    <addaction name="actionQuit"/>
 
   </widget>
 
   <widget class="QMenu" name="menuView">
 
    <property name="title">
 
@@ -194,12 +196,28 @@
 
    <string>Report a Bug</string>
 
   </property>
 
   <property name="toolTip">
 
    <string>Report a Bug on SerialPlot Website</string>
 
   </property>
 
  </action>
 
  <action name="actionSaveSettings">
 
   <property name="text">
 
    <string>Save Settings</string>
 
   </property>
 
   <property name="toolTip">
 
    <string>Save Settings to a File</string>
 
   </property>
 
  </action>
 
  <action name="actionLoadSettings">
 
   <property name="text">
 
    <string>Load Settings</string>
 
   </property>
 
   <property name="toolTip">
 
    <string>Load Settings from a File</string>
 
   </property>
 
  </action>
 
 </widget>
 
 <layoutdefault spacing="6" margin="11"/>
 
 <customwidgets>
 
  <customwidget>
 
   <class>HidableTabWidget</class>
 
   <extends>QTabWidget</extends>
src/numberformat.cpp
Show inline comments
 
new file 100644
 
/*
 
  Copyright © 2016 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 <QMap>
 

	
 
#include "numberformat.h"
 

	
 
QMap<NumberFormat, QString> mapping({
 
        {NumberFormat_uint8, "uint8"},
 
        {NumberFormat_uint16, "uint16"},
 
        {NumberFormat_uint32, "uint32"},
 
        {NumberFormat_int8, "int8"},
 
        {NumberFormat_int16, "int16"},
 
        {NumberFormat_int32, "int32"},
 
        {NumberFormat_float, "float"}
 
    });
 

	
 
QString numberFormatToStr(NumberFormat nf)
 
{
 
    return mapping.value(nf);
 
}
 

	
 
NumberFormat strToNumberFormat(QString str)
 
{
 
    return mapping.key(str, NumberFormat_INVALID);
 
}
src/numberformat.h
Show inline comments
 
new file 100644
 
/*
 
  Copyright © 2016 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 NUMBERFORMAT_H
 
#define NUMBERFORMAT_H
 

	
 
#include <QString>
 

	
 
enum NumberFormat
 
{
 
    NumberFormat_uint8,
 
    NumberFormat_uint16,
 
    NumberFormat_uint32,
 
    NumberFormat_int8,
 
    NumberFormat_int16,
 
    NumberFormat_int32,
 
    NumberFormat_float,
 
    NumberFormat_INVALID ///< used for error cases
 
};
 

	
 
/// Convert `NumberFormat` to string for representation
 
QString numberFormatToStr(NumberFormat nf);
 

	
 
/// Convert string to `NumberFormat`
 
NumberFormat strToNumberFormat(QString str);
 

	
 
#endif // NUMBERFORMAT_H
src/numberformatbox.cpp
Show inline comments
 
@@ -51,6 +51,11 @@ void NumberFormatBox::onButtonToggled(in
 
}
 

	
 
NumberFormat NumberFormatBox::currentSelection()
 
{
 
    return (NumberFormat) buttonGroup.checkedId();
 
}
 

	
 
void NumberFormatBox::setSelection(NumberFormat nf)
 
{
 
    buttonGroup.button(nf)->setChecked(true);
 
}
src/numberformatbox.h
Show inline comments
 
@@ -20,36 +20,30 @@
 
#ifndef NUMBERFORMATBOX_H
 
#define NUMBERFORMATBOX_H
 

	
 
#include <QWidget>
 
#include <QButtonGroup>
 

	
 
#include "numberformat.h"
 

	
 
namespace Ui {
 
class NumberFormatBox;
 
}
 

	
 
enum NumberFormat
 
{
 
    NumberFormat_uint8,
 
    NumberFormat_uint16,
 
    NumberFormat_uint32,
 
    NumberFormat_int8,
 
    NumberFormat_int16,
 
    NumberFormat_int32,
 
    NumberFormat_float,
 
};
 

	
 
class NumberFormatBox : public QWidget
 
{
 
    Q_OBJECT
 

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

	
 
    NumberFormat currentSelection(); ///< returns the currently selected number format
 
    /// returns the currently selected number format
 
    NumberFormat currentSelection();
 
    /// change the currently selected number format
 
    void setSelection(NumberFormat nf);
 

	
 
signals:
 
    /// Signaled when number format selection is changed
 
    void selectionChanged(NumberFormat numberFormat);
 

	
 
private:
src/plotcontrolpanel.cpp
Show inline comments
 
@@ -20,13 +20,13 @@
 
#include <QVariant>
 

	
 
#include <math.h>
 

	
 
#include "plotcontrolpanel.h"
 
#include "ui_plotcontrolpanel.h"
 

	
 
#include "setting_defines.h"
 

	
 
/// Used for scale range selection combobox
 
struct Range
 
{
 
    double rmin;
 
    double rmax;
 
@@ -147,6 +147,28 @@ void PlotControlPanel::onRangeSelected()
 
}
 

	
 
void PlotControlPanel::setChannelNamesModel(QAbstractItemModel * model)
 
{
 
    ui->lvChannelNames->setModel(model);
 
}
 

	
 
void PlotControlPanel::saveSettings(QSettings* settings)
 
{
 
    settings->beginGroup(SettingGroup_Plot);
 
    settings->setValue(SG_Plot_NumOfSamples, numOfSamples());
 
    settings->setValue(SG_Plot_AutoScale, autoScale());
 
    settings->setValue(SG_Plot_YMax, yMax());
 
    settings->setValue(SG_Plot_YMin, yMin());
 
    settings->endGroup();
 
}
 

	
 
void PlotControlPanel::loadSettings(QSettings* settings)
 
{
 
    settings->beginGroup(SettingGroup_Plot);
 
    ui->spNumOfSamples->setValue(
 
        settings->value(SG_Plot_NumOfSamples, numOfSamples()).toInt());
 
    ui->cbAutoScale->setChecked(
 
        settings->value(SG_Plot_AutoScale, autoScale()).toBool());
 
    ui->spYmax->setValue(settings->value(SG_Plot_YMax, yMax()).toDouble());
 
    ui->spYmin->setValue(settings->value(SG_Plot_YMin, yMin()).toDouble());
 
    settings->endGroup();
 
}
src/plotcontrolpanel.h
Show inline comments
 
@@ -19,12 +19,13 @@
 

	
 
#ifndef PLOTCONTROLPANEL_H
 
#define PLOTCONTROLPANEL_H
 

	
 
#include <QWidget>
 
#include <QAbstractItemModel>
 
#include <QSettings>
 

	
 
namespace Ui {
 
class PlotControlPanel;
 
}
 

	
 
class PlotControlPanel : public QWidget
 
@@ -39,12 +40,17 @@ public:
 
    bool autoScale();
 
    double yMax();
 
    double yMin();
 

	
 
    void setChannelNamesModel(QAbstractItemModel * model);
 

	
 
    /// Stores plot settings into a `QSettings`
 
    void saveSettings(QSettings* settings);
 
    /// Loads plot settings from a `QSettings`.
 
    void loadSettings(QSettings* settings);
 

	
 
signals:
 
    void numOfSamplesChanged(int value);
 
    void scaleChanged(bool autoScaled, double yMin = 0, double yMax = 1);
 

	
 
private:
 
    Ui::PlotControlPanel *ui;
src/plotmanager.cpp
Show inline comments
 
@@ -19,13 +19,13 @@
 

	
 
#include <QtDebug>
 

	
 
#include "plot.h"
 
#include "plotmanager.h"
 
#include "utils.h"
 

	
 
#include "setting_defines.h"
 

	
 
PlotManager::PlotManager(QWidget* plotArea, QObject *parent) :
 
    QObject(parent),
 
    _plotArea(plotArea),
 
    showGridAction("Grid", this),
 
    showMinorGridAction("Minor Grid", this),
 
@@ -369,6 +369,39 @@ void PlotManager::onNumOfSamplesChanged(
 
{
 
    for (auto plot : plotWidgets)
 
    {
 
        plot->onNumOfSamplesChanged(value);
 
    }
 
}
 

	
 
void PlotManager::saveSettings(QSettings* settings)
 
{
 
    settings->beginGroup(SettingGroup_Plot);
 
    settings->setValue(SG_Plot_DarkBackground, darkBackgroundAction.isChecked());
 
    settings->setValue(SG_Plot_Grid, showGridAction.isChecked());
 
    settings->setValue(SG_Plot_MinorGrid, showMinorGridAction.isChecked());
 
    settings->setValue(SG_Plot_Legend, showLegendAction.isChecked());
 
    settings->setValue(SG_Plot_MultiPlot, showMultiAction.isChecked());
 
    settings->endGroup();
 
}
 

	
 
void PlotManager::loadSettings(QSettings* settings)
 
{
 
    settings->beginGroup(SettingGroup_Plot);
 
    darkBackgroundAction.setChecked(
 
        settings->value(SG_Plot_DarkBackground, darkBackgroundAction.isChecked()).toBool());
 
    darkBackground(darkBackgroundAction.isChecked());
 
    showGridAction.setChecked(
 
        settings->value(SG_Plot_Grid, showGridAction.isChecked()).toBool());
 
    showGrid(showGridAction.isChecked());
 
    showMinorGridAction.setChecked(
 
        settings->value(SG_Plot_MinorGrid, showMinorGridAction.isChecked()).toBool());
 
    showMinorGridAction.setEnabled(showGridAction.isChecked());
 
    showMinorGrid(showMinorGridAction.isChecked());
 
    showLegendAction.setChecked(
 
        settings->value(SG_Plot_Legend, showLegendAction.isChecked()).toBool());
 
    showLegend(showLegendAction.isChecked());
 
    showMultiAction.setChecked(
 
        settings->value(SG_Plot_MultiPlot, showMultiAction.isChecked()).toBool());
 
    setMulti(showMultiAction.isChecked());
 
    settings->endGroup();
 
}
src/plotmanager.h
Show inline comments
 
@@ -22,12 +22,13 @@
 

	
 
#include <QObject>
 
#include <QWidget>
 
#include <QScrollArea>
 
#include <QVBoxLayout>
 
#include <QList>
 
#include <QSettings>
 

	
 
#include <qwt_plot_curve.h>
 
#include "plot.h"
 
#include "framebufferseries.h"
 

	
 
class PlotManager : public QObject
 
@@ -47,12 +48,16 @@ public:
 
    /// Removes curves from the end
 
    void removeCurves(unsigned number);
 
    /// Returns current number of curves known by plot manager
 
    unsigned numOfCurves();
 
    /// Returns the list of actions to be inserted into the `View` menu
 
    QList<QAction*> menuActions();
 
    /// Stores plot settings into a `QSettings`.
 
    void saveSettings(QSettings* settings);
 
    /// Loads plot settings from a `QSettings`.
 
    void loadSettings(QSettings* settings);
 

	
 
public slots:
 
    /// Enable/Disable multiple plot display
 
    void setMulti(bool enabled);
 
    /// Update all plot widgets
 
    void replot();
src/portcontrol.cpp
Show inline comments
 
/*
 
  Copyright © 2015 Hasan Yavuz Özderya
 
  Copyright © 2016 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
 
@@ -20,17 +20,27 @@
 
#include "portcontrol.h"
 
#include "ui_portcontrol.h"
 

	
 
#include <QSerialPortInfo>
 
#include <QKeySequence>
 
#include <QLabel>
 
#include <QMap>
 
#include <QtDebug>
 

	
 
#include "setting_defines.h"
 
#include "utils.h"
 

	
 
#define TBPORTLIST_MINWIDTH (200)
 

	
 
// setting mappings
 
const QMap<QSerialPort::Parity, QString> paritySettingMap({
 
        {QSerialPort::NoParity, "none"},
 
        {QSerialPort::OddParity, "odd"},
 
        {QSerialPort::EvenParity, "even"},
 
    });
 

	
 
PortControl::PortControl(QSerialPort* port, QWidget* parent) :
 
    QWidget(parent),
 
    ui(new Ui::PortControl),
 
    portToolBar("Port Toolbar"),
 
    openAction("Open", this),
 
    loadPortListAction("↺", this)
 
@@ -270,12 +280,28 @@ void PortControl::selectPort(QString por
 
            // open new selection by toggling
 
            togglePort();
 
        }
 
    }
 
}
 

	
 
QString PortControl::selectedPortName()
 
{
 
    QString portText = ui->cbPortList->currentText();
 
    int portIndex = portList.indexOf(portText);
 
    if (portIndex < 0) // not in the list yet
 
    {
 
        // return the displayed name as port name
 
        return portText;
 
    }
 
    else
 
    {
 
        // get the port name from the 'port list'
 
        return static_cast<PortListItem*>(portList.item(portIndex))->portName();
 
    }
 
}
 

	
 
QToolBar* PortControl::toolBar()
 
{
 
    return &portToolBar;
 
}
 

	
 
void PortControl::openActionTriggered(bool checked)
 
@@ -289,6 +315,105 @@ void PortControl::onCbPortListActivated(
 
}
 

	
 
void PortControl::onTbPortListActivated(int index)
 
{
 
    ui->cbPortList->setCurrentIndex(index);
 
}
 

	
 
QString PortControl::currentParityText()
 
{
 
    return paritySettingMap.value(
 
        (QSerialPort::Parity) parityButtons.checkedId());
 
}
 

	
 
QString PortControl::currentFlowControlText()
 
{
 
    if (flowControlButtons.checkedId() == QSerialPort::HardwareControl)
 
    {
 
        return "hardware";
 
    }
 
    else if (flowControlButtons.checkedId() == QSerialPort::SoftwareControl)
 
    {
 
        return "software";
 
    }
 
    else // no parity
 
    {
 
        return "none";
 
    }
 
}
 

	
 
void PortControl::saveSettings(QSettings* settings)
 
{
 
    settings->beginGroup(SettingGroup_Port);
 
    settings->setValue(SG_Port_SelectedPort, selectedPortName());
 
    settings->setValue(SG_Port_BaudRate, ui->cbBaudRate->currentText());
 
    settings->setValue(SG_Port_Parity, currentParityText());
 
    settings->setValue(SG_Port_DataBits, dataBitsButtons.checkedId());
 
    settings->setValue(SG_Port_StopBits, stopBitsButtons.checkedId());
 
    settings->setValue(SG_Port_FlowControl, currentFlowControlText());
 
    settings->endGroup();
 
}
 

	
 
void PortControl::loadSettings(QSettings* settings)
 
{
 
    // make sure the port is closed
 
    if (serialPort->isOpen()) togglePort();
 

	
 
    settings->beginGroup(SettingGroup_Port);
 

	
 
    // set port name if it exists in the current list otherwise ignore
 
    QString portName = settings->value(SG_Port_SelectedPort, QString()).toString();
 
    if (!portName.isEmpty())
 
    {
 
        int index = portList.indexOfName(portName);
 
        if (index > -1) ui->cbPortList->setCurrentIndex(index);
 
    }
 

	
 
    // load baud rate setting if it exists in baud rate list
 
    QString baudSetting = settings->value(
 
        SG_Port_BaudRate, ui->cbBaudRate->currentText()).toString();
 
    int baudIndex = ui->cbBaudRate->findText(baudSetting);
 
    if (baudIndex > -1) ui->cbBaudRate->setCurrentIndex(baudIndex);
 

	
 
    // load parity setting
 
    QString parityText =
 
        settings->value(SG_Port_Parity, currentParityText()).toString();
 
    QSerialPort::Parity paritySetting = paritySettingMap.key(
 
        parityText, (QSerialPort::Parity) parityButtons.checkedId());
 
    parityButtons.button(paritySetting)->setChecked(true);
 

	
 
    // load number of bits
 
    int dataBits = settings->value(SG_Port_Parity, dataBitsButtons.checkedId()).toInt();
 
    if (dataBits >=5 && dataBits <= 8)
 
    {
 
        dataBitsButtons.button((QSerialPort::DataBits) dataBits)->setChecked(true);
 
    }
 

	
 
    // load stop bits
 
    int stopBits = settings->value(SG_Port_StopBits, stopBitsButtons.checkedId()).toInt();
 
    if (stopBits == QSerialPort::OneStop)
 
    {
 
        ui->rb1StopBit->setChecked(true);
 
    }
 
    else if (stopBits == QSerialPort::TwoStop)
 
    {
 
        ui->rb2StopBit->setChecked(true);
 
    }
 

	
 
    // load flow control
 
    QString flowControlSetting =
 
        settings->value(SG_Port_FlowControl, currentFlowControlText()).toString();
 
    if (flowControlSetting == "hardware")
 
    {
 
        ui->rbHardwareControl->setChecked(true);
 
    }
 
    else if (flowControlSetting == "software")
 
    {
 
        ui->rbSoftwareControl->setChecked(true);
 
    }
 
    else
 
    {
 
        ui->rbNoFlowControl->setChecked(true);
 
    }
 

	
 
    settings->endGroup();
 
}
src/portcontrol.h
Show inline comments
 
/*
 
  Copyright © 2015 Hasan Yavuz Özderya
 
  Copyright © 2016 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
 
@@ -24,12 +24,13 @@
 
#include <QButtonGroup>
 
#include <QSerialPort>
 
#include <QStringList>
 
#include <QToolBar>
 
#include <QAction>
 
#include <QComboBox>
 
#include <QSettings>
 

	
 
#include "portlist.h"
 

	
 
namespace Ui {
 
class PortControl;
 
}
 
@@ -40,14 +41,18 @@ class PortControl : public QWidget
 

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

	
 
    QSerialPort* serialPort;
 
    QToolBar* toolBar();
 

	
 
    QToolBar* toolBar();
 
    /// Stores port settings into a `QSettings`
 
    void saveSettings(QSettings* settings);
 
    /// Loads port settings from a `QSettings`. If open serial port is closed.
 
    void loadSettings(QSettings* settings);
 

	
 
private:
 
    Ui::PortControl *ui;
 

	
 
    QButtonGroup parityButtons;
 
    QButtonGroup dataBitsButtons;
 
@@ -57,12 +62,19 @@ private:
 
    QToolBar portToolBar;
 
    QAction openAction;
 
    QAction loadPortListAction;
 
    QComboBox tbPortList;
 
    PortList portList;
 

	
 
    /// Returns the currently selected (entered) "portName" in the UI
 
    QString selectedPortName();
 
    /// Returns currently selected parity as text to be saved in settings
 
    QString currentParityText();
 
    /// Returns currently selected flow control as text to be saved in settings
 
    QString currentFlowControlText();
 

	
 
public slots:
 
    void loadPortList();
 
    void loadBaudRateList();
 
    void togglePort();
 
    void selectPort(QString portName);
 

	
src/portlist.cpp
Show inline comments
 
/*
 
  Copyright © 2015 Hasan Yavuz Özderya
 
  Copyright © 2016 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
 
@@ -109,12 +109,24 @@ int PortList::indexOf(QString portText)
 
            return i;
 
        }
 
    }
 
    return -1; // not found
 
}
 

	
 
int PortList::indexOfName(QString portName)
 
{
 
    for (int i = 0; i < rowCount(); i++)
 
    {
 
        if (item(i)->data(PortNameRole) == portName)
 
        {
 
            return i;
 
        }
 
    }
 
    return -1; // not found
 
}
 

	
 
void PortList::onRowsInserted(QModelIndex parent, int start, int end)
 
{
 
    PortListItem* newItem = static_cast<PortListItem*>(item(start));
 
    QString portName = newItem->text();
 
    newItem->setData(portName, PortNameRole);
 
    userEnteredPorts << portName;
src/portlist.h
Show inline comments
 
/*
 
  Copyright © 2015 Hasan Yavuz Özderya
 
  Copyright © 2016 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
 
@@ -47,13 +47,16 @@ class PortList : public QStandardItemMod
 
{
 
    Q_OBJECT
 
public:
 
    PortList(QObject* parent=0);
 

	
 
    void loadPortList();
 
    /// Search for displayed text of the port
 
    int indexOf(QString portText); // return -1 if not found
 
    /// Search for the actual port name
 
    int indexOfName(QString portName); // return -1 if not found
 

	
 
private:
 
    QStringList userEnteredPorts;
 

	
 
private slots:
 
    void onRowsInserted(QModelIndex parent, int start, int end);
src/setting_defines.h
Show inline comments
 
new file 100644
 
/*
 
  Copyright © 2016 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 SETTING_DEFINES_H
 
#define SETTING_DEFINES_H
 

	
 
const char SettingGroup_MainWindow[] = "MainWindow";
 
const char SettingGroup_Port[] = "Port";
 
const char SettingGroup_DataFormat[] = "DataFormat";
 
const char SettingGroup_Binary[] = "DataFormat_Binary";
 
const char SettingGroup_ASCII[] = "DataFormat_ASCII";
 
const char SettingGroup_CustomFrame[] = "DataFormat_CustomFrame";
 
const char SettingGroup_Channels[] = "Channels";
 
const char SettingGroup_Plot[] = "Plot";
 
const char SettingGroup_Commands[] = "Commands";
 

	
 
// mainwindow setting keys
 
const char SG_MainWindow_Size[] = "size";
 
const char SG_MainWindow_Pos[] = "pos";
 
const char SG_MainWindow_ActivePanel[] = "activePanel";
 
const char SG_MainWindow_HidePanels[] = "hidePanels";
 
const char SG_MainWindow_Maximized[] = "maximized";
 
const char SG_MainWindow_State[] = "state";
 

	
 
// port setting keys
 
const char SG_Port_SelectedPort[] = "selectedPort";
 
const char SG_Port_BaudRate[] = "baudRate";
 
const char SG_Port_Parity[] = "parity";
 
const char SG_Port_DataBits[] = "dataBits";
 
const char SG_Port_StopBits[] = "stopBits";
 
const char SG_Port_FlowControl[] = "flowControl";
 

	
 
// data format panel keys
 
const char SG_DataFormat_Format[] = "format";
 

	
 
// binary stream reader keys
 
const char SG_Binary_NumOfChannels[] = "numOfChannels";
 
const char SG_Binary_NumberFormat[] = "numberFormat";
 
const char SG_Binary_Endianness[] = "endianness";
 

	
 
// ascii reader keys
 
const char SG_ASCII_NumOfChannels[] = "numOfChannels";
 

	
 
// framed reader keys
 
const char SG_CustomFrame_NumOfChannels[] = "numOfChannels";
 
const char SG_CustomFrame_FrameStart[] = "frameStart";
 
const char SG_CustomFrame_FixedSize[] = "fixedSize";
 
const char SG_CustomFrame_FrameSize[] = "frameSize";
 
const char SG_CustomFrame_NumberFormat[] = "numberFormat";
 
const char SG_CustomFrame_Endianness[] = "endianness";
 
const char SG_CustomFrame_Checksum[] = "checksum";
 
const char SG_CustomFrame_DebugMode[] = "debugMode";
 

	
 
// channel manager keys
 
const char SG_Channels_Channel[] = "channel";
 
const char SG_Channels_Name[] = "name";
 

	
 
// plot settings keys
 
const char SG_Plot_NumOfSamples[] = "numOfSamples";
 
const char SG_Plot_AutoScale[] = "autoScale";
 
const char SG_Plot_YMax[] = "yMax";
 
const char SG_Plot_YMin[] = "yMin";
 
const char SG_Plot_DarkBackground[] = "darkBackground";
 
const char SG_Plot_Grid[] = "grid";
 
const char SG_Plot_MinorGrid[] = "minorGrid";
 
const char SG_Plot_Legend[] = "legend";
 
const char SG_Plot_MultiPlot[] = "multiPlot";
 

	
 
// command setting keys
 
const char SG_Commands_Command[] = "command";
 
const char SG_Commands_Name[] = "name";
 
const char SG_Commands_Type[] = "type";
 
const char SG_Commands_Data[] = "data";
 

	
 
#endif // SETTING_DEFINES_H
0 comments (0 inline, 0 general)