Skip to content

Commit

Permalink
V1.2.2
Browse files Browse the repository at this point in the history
  • Loading branch information
gztss committed Mar 29, 2018
1 parent 245b394 commit 94e8f1e
Show file tree
Hide file tree
Showing 48 changed files with 1,509 additions and 1,334 deletions.
12 changes: 6 additions & 6 deletions SerialTool/SerialTool.pro
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ SOURCES += \
source/main.cpp \
source/optionsbox.cpp \
source/portsetbox.cpp \
source/serialtool.cpp\
source/textedit.cpp \
source/wavedecode.cpp \
source/oscilloscope.cpp \
Expand All @@ -48,14 +47,14 @@ SOURCES += \
source/terminalview.cpp \
source/serialport.cpp \
source/pointdatabuffer.cpp \
source/valuedisplay.cpp
source/valuedisplay.cpp \
source/mainwindow.cpp

HEADERS += \
include/aboutbox.h \
include/channelitem.h \
include/optionsbox.h \
include/portsetbox.h \
include/serialtool.h \
include/textedit.h \
include/version.h \
include/wavedecode.h \
Expand All @@ -71,7 +70,8 @@ HEADERS += \
include/terminalview.h \
include/serialport.h \
include/pointdatabuffer.h \
include/valuedisplay.h
include/valuedisplay.h \
include/mainwindow.h

DISTFILES += \
resource/images/clear.png \
Expand All @@ -92,13 +92,13 @@ FORMS += \
ui/aboutbox.ui \
ui/optionsbox.ui \
ui/portsetbox.ui \
ui/serialtool.ui \
ui/oscilloscope.ui \
ui/filetransferview.ui \
ui/vediobox.ui \
ui/tcpudpport.ui \
ui/terminalview.ui \
ui/valuedisplay.ui \
ui/serialport.ui \
ui/valuedisplay.ui
ui/mainwindow.ui

LIBS += -lqscintilla2_qt5
8 changes: 6 additions & 2 deletions SerialTool/include/aboutbox.h
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
#ifndef __ABOUTBOX_H
#define __ABOUTBOX_H

#include "ui_aboutbox.h"
#include <QtWidgets/QDialog>

namespace Ui {
class AboutBox;
}

class AboutBox : public QDialog {
public:
AboutBox(QWidget *parent);
~AboutBox();
private:
Ui_AboutBox ui;
Ui::AboutBox *ui;
};

#endif
35 changes: 31 additions & 4 deletions SerialTool/include/filethread.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
#include <QColor>
#include <QFile>
#include <QMutex>
#include <QSemaphore>
#include <QWaitCondition>
#include <QTimer>

class FileThread : public QThread
{
Expand All @@ -29,8 +31,8 @@ public :
void setFileName(const QString &fileName);
void setProtocol(Protocol mode);
void setTransMode(TransMode mode);
bool startTransfer();
bool cancelTransfer();
void startTransmit();
void cancelTransmit();
qint64 fileSize();
qint64 filePos();
char progress();
Expand All @@ -44,17 +46,42 @@ public slots:
signals:
void sendData(const QByteArray &);
void transFinsh(void);
void fileError();
void timeout();

protected:
void run();

private slots:
void onTimerUpdate();

private:
enum Status {
None = 0,
StartTrans,
CancelTrans,
ReadData
};

void setStatus(Status status);
void startTransmit_p();
void receivePack_p(const QByteArray &array);
void cancelTransmit_p();
void closeFile();

private:
Protocol protocol;
TransMode transMode;
qint64 fSize, fPos;
QByteArray receiveArray; // ½ÓÊÕ»º³åÇø
QMutex m_mutex;
QSemaphore m_sem;
QByteArray receiveArray; // 接收缓冲区
QString fileName;
QFile *file;
QFile *m_file;
Status m_status = None;
QByteArray m_rxbuffer;
QTimer m_timer;
int m_timeoutCount;
};

#endif
12 changes: 9 additions & 3 deletions SerialTool/include/filetransferview.h
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
#ifndef __FILETRANSFERVIEW_H
#define __FILETRANSFERVIEW_H

#include "ui_filetransferview.h"
#include <QSettings>
#include <QWidget>
#include "filethread.h"

namespace Ui {
class FileTransferView;
}
class QSettings;

class FileTransferView : public QWidget
{
Q_OBJECT

public:
FileTransferView(QWidget *parent = Q_NULLPTR);
~FileTransferView();
void retranslate();
void loadConfig(QSettings *config);
void saveConfig(QSettings *config);
Expand All @@ -28,12 +33,13 @@ private slots:
void portSendData(const QByteArray &array);
void sendFile();
void onTransFinsh();
void onTimeoutError();

signals:
void sendData(const QByteArray &);

private:
Ui_FileTransferView ui;
Ui::FileTransferView *ui;
FileThread thread;
QByteArray receiveArray; // 接收缓冲区
};
Expand Down
52 changes: 27 additions & 25 deletions SerialTool/include/serialtool.h → SerialTool/include/mainwindow.h
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
#ifndef __SERIALTOOL_H
#define __SERIALTOOL_H
#ifndef __MAINWINDOW_H
#define __MAINWINDOW_H

#include <QtWidgets/QMainWindow>
#include "ui_serialtool.h"
#include <QtSerialPort/QSerialPort>
#include <QtSerialPort/QSerialPortInfo>
#include <QMessageBox>
#include "channelitem.h"
#include "vediobox.h"
#include <QTimer>

namespace Ui {
class MainWindow;
}
class QSettings;
class TcpUdpPort;
class WaveDecode;
class SerialPort;
class VedioBox;
class ValueDisplay;
class QTranslator;
class QActionGroup;

class SerialTool : public QMainWindow
class MainWindow : public QMainWindow
{
Q_OBJECT

Expand All @@ -24,12 +27,12 @@ class SerialTool : public QMainWindow
};

public:
SerialTool(QWidget *parent = Q_NULLPTR);
~SerialTool();
MainWindow(QWidget *parent = Q_NULLPTR);
~MainWindow();

void loadSettings();
void saveConfig();
QSettings *getConfig() { return config; }
QSettings *getConfig() { return m_config; }
void setLanguage(const QString &string);
void setStyleSheet(const QString &string);

Expand Down Expand Up @@ -68,21 +71,20 @@ private slots:
void setWindowStaysOnTop(bool enabled);

private:
Ui_SerialTool ui;
QString docPath;
QTimer secTimer; // 秒定时器
TcpUdpPort *tcpUdpPort; // TCP/UDP端口
QSettings *config;
bool runFlag = true;
QActionGroup *tabActionGroup;
int rxCount, txCount;
QLabel *rxCntLabel, *txCntLabel, *portInfoLabel;
QVector<QTranslator*> translator;
Ui::MainWindow *ui;
QString m_docPath;
QTimer m_timer; // 秒定时器
TcpUdpPort *m_tcpUdpPort; // TCP/UDP端口
QSettings *m_config;
bool m_runFlag = true;
QActionGroup *m_tabActionGroup;
int m_rxCount, m_txCount;
QLabel *m_rxCntLabel, *m_txCntLabel, *m_portInfoLabel;
QVector<QTranslator*> m_translator;
VedioBox *m_vedioBox = NULL;
ValueDisplay *m_valueDisplay = NULL;
PortType portType;
WaveDecode* waveDecode;
SerialPort *serialPort;
PortType m_portType;
SerialPort *m_serialPort;
};

#endif // SERIALTOOL_H
#endif // __MAINWINDOW_H
13 changes: 8 additions & 5 deletions SerialTool/include/optionsbox.h
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
#ifndef __OPTIONSBOX_H
#define __OPTIONSBOX_H

#include "ui_optionsbox.h"
#include <QtWidgets/QDialog>

class SerialTool;
namespace Ui {
class OptionsBox;
}
class MainWindow;
class QAbstractButton;

class OptionsBox : public QDialog {
Q_OBJECT

public:
OptionsBox(SerialTool *parent = Q_NULLPTR);
OptionsBox(MainWindow *parent = Q_NULLPTR);
~OptionsBox();

private:
Expand All @@ -36,8 +39,8 @@ private slots:
void setLanguage(int index);

private:
Ui_OptionsBox ui;
SerialTool *serialTool;
Ui::OptionsBox *ui;
MainWindow *m_parent;
QString fontFamily, fontStyle;
int fontSize;
QString rxColor, txColor, bgColor, axColor;
Expand Down
22 changes: 11 additions & 11 deletions SerialTool/include/oscilloscope.h
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
#ifndef __OSCILLOSCOPE_H
#define __OSCILLOSCOPE_H

#include "ui_oscilloscope.h"

#include <QTimer>
#include <QWidget>

#ifndef CH_NUM
#define CH_NUM 16
#endif

struct WaveDataType;
namespace Ui {
class Oscilloscope;
}
class OscopeTimeStamp;
class PointDataBuffer;
class ChannelItem;
class WaveDecode;
class QSettings;
namespace QtCharts {
class QLineSeries;
Expand All @@ -39,7 +40,7 @@ class Oscilloscope : public QWidget {
void setBackground(QColor color);
void setGridColor(QColor color);
void setUpdateInterval(int msec);
void addData(const WaveDataType& data);
void append(const QByteArray &array);
void clear();

void savePng(const QString &fileName);
Expand All @@ -54,9 +55,7 @@ class Oscilloscope : public QWidget {
QStringList csvSplitLine(const QString &line) {
return line.split(", ");
}
ChannelItem* channelWidget(int channel) {
return (ChannelItem *)(ui.channelList->itemWidget(ui.channelList->item(channel)));
}
ChannelItem* channelWidget(int channel);

private slots:
void yOffsetChanged(double offset);
Expand All @@ -67,14 +66,15 @@ private slots:
void timeUpdata();

private:
Ui_Oscilloscope ui;
Ui::Oscilloscope *ui;
bool replotFlag = 1;
QVector<QtCharts::QLineSeries*> m_series;
QtCharts::QChart *m_chart;
int m_count, m_xRange;
QTimer updataTimer;
OscopeTimeStamp* timeStamp;
QTimer *m_timer;
OscopeTimeStamp *m_timeStamp;
PointDataBuffer *m_buffer;
WaveDecode *m_decode;
};

#endif
12 changes: 5 additions & 7 deletions SerialTool/include/oscopetimestamp.h
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
#ifndef __OSCOPE_TIME_STAMP_H
#define __OSCOPE_TIME_STAMP_H


#include <QVector>
#include <QTextStream>

struct WaveDataType;
#include "wavedecode.h"

class OscopeTimeStamp {
public:
OscopeTimeStamp() { timeStamp.clear(); }
OscopeTimeStamp() { m_timeStampVector.clear(); }
void printTextStream(QTextStream &stream, uint64_t count);
void append(const WaveDataType &data, uint64_t count);
void append(const WaveDecode::DataType &data, uint64_t count);
void append(const QString &string, uint64_t count);
void clear() { timeStamp.clear(); }
void clear() { m_timeStampVector.clear(); }

private:
struct TimeStamp_p {
Expand All @@ -28,7 +26,7 @@ class OscopeTimeStamp {
uint32_t sampleRate;
};

QVector<TimeStamp_p> timeStamp;
QVector<TimeStamp_p> m_timeStampVector;
};

#endif
Loading

0 comments on commit 94e8f1e

Please sign in to comment.