提交 7d689397 编写于 作者: 代码海贼团船长's avatar 代码海贼团船长

功能完善

上级 e9721c5e
...@@ -88,3 +88,23 @@ void ZSettings::setHexFormalSend(bool checked) { ...@@ -88,3 +88,23 @@ void ZSettings::setHexFormalSend(bool checked) {
this->setValue("SEND_HEX",checked); this->setValue("SEND_HEX",checked);
this->endGroup(); this->endGroup();
} }
int ZSettings::getCycleValue() const {
return this->value("SINGLE/CYCLE").toInt();
}
void ZSettings::setCycleValue(int value) {
this->beginGroup("SINGLE");
this->setValue("CYCLE",value);
this->endGroup();
}
bool ZSettings::getIsSendEnter() const {
return this->value("SINGLE/ENTER").toBool();
}
void ZSettings::setSendEnter(bool icChecked) {
this->beginGroup("SINGLE");
this->setValue("ENTER",icChecked);
this->endGroup();
}
...@@ -43,6 +43,14 @@ public: ...@@ -43,6 +43,14 @@ public:
bool getHexFormalSend()const; bool getHexFormalSend()const;
//! 设置发送HEX //! 设置发送HEX
void setHexFormalSend(bool checked); void setHexFormalSend(bool checked);
//! 获取周期时间
int getCycleValue() const;
//! 设置周期时间
void setCycleValue(int value);
//! 获取是否发送新行
bool getIsSendEnter() const;
//! 设置是否发送新行
void setSendEnter(bool icChecked);
virtual ~ZSettings(); virtual ~ZSettings();
}; };
......
...@@ -5,8 +5,10 @@ ...@@ -5,8 +5,10 @@
// You may need to build the project (run Qt uic code generator) to get "ui_Home.h" resolved // You may need to build the project (run Qt uic code generator) to get "ui_Home.h" resolved
#include <QTime> #include <QTime>
#include <QMessageBox> #include <QMessageBox>
#include <QFileDialog>
#include <QComboBox> #include <QComboBox>
#include <QMetaEnum> #include <QMetaEnum>
#include <QtConcurrent/QtConcurrent>
#include "home.h" #include "home.h"
#include "ui_Home.h" #include "ui_Home.h"
...@@ -19,6 +21,10 @@ Home::Home(QWidget *parent) : QWidget(parent), ui(new Ui::Home),mpZControl(ZCont ...@@ -19,6 +21,10 @@ Home::Home(QWidget *parent) : QWidget(parent), ui(new Ui::Home),mpZControl(ZCont
mpSingleSend = new SingleSend(); mpSingleSend = new SingleSend();
ui->tabWidget->addTab(mpSingleSend, tr("单条发送")); ui->tabWidget->addTab(mpSingleSend, tr("单条发送"));
connect(mpSingleSend,SIGNAL(signalSerialWrite(QByteArray)),this,SLOT(slotSerialWrite(QByteArray))); connect(mpSingleSend,SIGNAL(signalSerialWrite(QByteArray)),this,SLOT(slotSerialWrite(QByteArray)));
connect(mpSingleSend,&SingleSend::signalClearSendInfo,[=](){
this->m_SendNumber = 0;
ui->label_SendNumber->setText(tr("发送:%0").arg(m_SendNumber));
});
mpMultipleSend = new MultipleSend(); mpMultipleSend = new MultipleSend();
ui->tabWidget->addTab(mpMultipleSend, tr("多条发送")); ui->tabWidget->addTab(mpMultipleSend, tr("多条发送"));
...@@ -54,6 +60,27 @@ Home::Home(QWidget *parent) : QWidget(parent), ui(new Ui::Home),mpZControl(ZCont ...@@ -54,6 +60,27 @@ Home::Home(QWidget *parent) : QWidget(parent), ui(new Ui::Home),mpZControl(ZCont
connect(mpZControl->getMpSerialPort(), SIGNAL(error(QSerialPort::SerialPortError)),this,SLOT(slotSerialError(QSerialPort::SerialPortError))); connect(mpZControl->getMpSerialPort(), SIGNAL(error(QSerialPort::SerialPortError)),this,SLOT(slotSerialError(QSerialPort::SerialPortError)));
connect(mpZControl->getMpSerialPort(), SIGNAL(signalSerialPortListChange(const QStringList &, QString)),this,SLOT(slotSerialPortListChange(const QStringList &,QString))); connect(mpZControl->getMpSerialPort(), SIGNAL(signalSerialPortListChange(const QStringList &, QString)),this,SLOT(slotSerialPortListChange(const QStringList &,QString)));
connect(ui->pBn_TtySet,SIGNAL(clicked()),this,SLOT(slotPBnTtySetClicked())); connect(ui->pBn_TtySet,SIGNAL(clicked()),this,SLOT(slotPBnTtySetClicked()));
connect(ui->pBn_Clear,&QPushButton::clicked,[=](){
m_RecNumber = 0;
ui->label_RecNumber->setText(tr("接收:%0").arg(m_RecNumber));
});
connect(ui->pBn_Save,&QPushButton::clicked,[=](){
QString fileName = QFileDialog::getSaveFileName(this,tr("选择文件夹"),"./","文本(*.txt);;所有文件(*)");
if(fileName.isEmpty())
{
return ;
}
QtConcurrent::run([=](){
QFile file(fileName);
if(!file.open(QIODevice::WriteOnly))
{
QMessageBox::warning(this, tr("提示"),tr("文件保存失败。"));
return;
}
file.write(ui->tEdit_Rec->toPlainText().toLocal8Bit());
file.close();
});
});
} }
Home::~Home() { Home::~Home() {
...@@ -67,13 +94,6 @@ void Home::timerEvent(QTimerEvent *event) { ...@@ -67,13 +94,6 @@ void Home::timerEvent(QTimerEvent *event) {
QObject::timerEvent(event); QObject::timerEvent(event);
QString currentTimeStr = QTime::currentTime().toString("hh:mm:ss"); QString currentTimeStr = QTime::currentTime().toString("hh:mm:ss");
ui->label_CurrentTime->setText(tr("当前时间 %0").arg(currentTimeStr)); ui->label_CurrentTime->setText(tr("当前时间 %0").arg(currentTimeStr));
// static int updateHz = 0;
// if(!mpZControl->getMpSerialPort()->isOpen()&&updateHz%2==0) {
// ui->cbBox_Tty->clear();
// ui->cbBox_Tty->addItems(mpZControl->getMpSerialPort()->getTtyList());
// }
// updateHz++;
} }
void Home::slotPBnTtySetClicked() { void Home::slotPBnTtySetClicked() {
......
...@@ -41,13 +41,6 @@ ...@@ -41,13 +41,6 @@
<item row="3" column="9" colspan="2"> <item row="3" column="9" colspan="2">
<widget class="QComboBox" name="cbBox_Stop"/> <widget class="QComboBox" name="cbBox_Stop"/>
</item> </item>
<item row="9" column="8">
<widget class="QCheckBox" name="ckBox_Rts">
<property name="text">
<string>RTS</string>
</property>
</widget>
</item>
<item row="5" column="9" colspan="2"> <item row="5" column="9" colspan="2">
<widget class="QComboBox" name="cbBox_Parity"/> <widget class="QComboBox" name="cbBox_Parity"/>
</item> </item>
...@@ -65,9 +58,6 @@ ...@@ -65,9 +58,6 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="10" column="9">
<widget class="QSpinBox" name="spin_TimeLine"/>
</item>
<item row="13" column="5"> <item row="13" column="5">
<widget class="Line" name="line_2"> <widget class="Line" name="line_2">
<property name="orientation"> <property name="orientation">
...@@ -105,13 +95,6 @@ ...@@ -105,13 +95,6 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="9" column="9" colspan="2">
<widget class="QCheckBox" name="ckBox_AutoSave">
<property name="text">
<string>自动保存</string>
</property>
</widget>
</item>
<item row="13" column="7"> <item row="13" column="7">
<widget class="Line" name="line_3"> <widget class="Line" name="line_3">
<property name="orientation"> <property name="orientation">
...@@ -133,13 +116,6 @@ ...@@ -133,13 +116,6 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="10" column="10">
<widget class="QLabel" name="label_TimeLine">
<property name="text">
<string>ms</string>
</property>
</widget>
</item>
<item row="13" column="1"> <item row="13" column="1">
<widget class="Line" name="line_4"> <widget class="Line" name="line_4">
<property name="orientation"> <property name="orientation">
...@@ -255,6 +231,13 @@ p, li { white-space: pre-wrap; } ...@@ -255,6 +231,13 @@ p, li { white-space: pre-wrap; }
</property> </property>
</widget> </widget>
</item> </item>
<item row="10" column="9">
<widget class="QCheckBox" name="ckBox_Rts">
<property name="text">
<string>RTS</string>
</property>
</widget>
</item>
</layout> </layout>
</widget> </widget>
<resources/> <resources/>
......
...@@ -12,6 +12,14 @@ ...@@ -12,6 +12,14 @@
SingleSend::SingleSend(QWidget *parent) : SingleSend::SingleSend(QWidget *parent) :
QWidget(parent), ui(new Ui::SingleSend),mpControl(ZControl::instance()) { QWidget(parent), ui(new Ui::SingleSend),mpControl(ZControl::instance()) {
ui->setupUi(this); ui->setupUi(this);
connect(ui->pBn_Clear,&QPushButton::clicked,[=](){
ui->tEdit_Send->clear();
emit signalClearSendInfo();
});
ui->spin_Cycle->setValue(mpControl->getMpSettings()->getCycleValue());
ui->ckBox_SendEnter->setChecked(mpControl->getMpSettings()->getIsSendEnter());
ui->ckBox_HexSend->setChecked(mpControl->getMpSettings()->getHexFormalSend()); ui->ckBox_HexSend->setChecked(mpControl->getMpSettings()->getHexFormalSend());
m_CurrentArray = mpControl->getMpSettings()->getTextSend(); m_CurrentArray = mpControl->getMpSettings()->getTextSend();
switch(ui->ckBox_HexSend->checkState()){ switch(ui->ckBox_HexSend->checkState()){
...@@ -19,7 +27,7 @@ SingleSend::SingleSend(QWidget *parent) : ...@@ -19,7 +27,7 @@ SingleSend::SingleSend(QWidget *parent) :
ui->tEdit_Send->setText(QString::fromLocal8Bit(m_CurrentArray)); ui->tEdit_Send->setText(QString::fromLocal8Bit(m_CurrentArray));
break; break;
case Qt::Checked: case Qt::Checked:
ui->tEdit_Send->setText(m_CurrentArray.toHex('%c ')); ui->tEdit_Send->setText(m_CurrentArray.toHex(' '));
break; break;
} }
connect(ui->tEdit_Send, SIGNAL(textChanged()),this,SLOT(slotTextSendChanged())); connect(ui->tEdit_Send, SIGNAL(textChanged()),this,SLOT(slotTextSendChanged()));
...@@ -31,6 +39,8 @@ SingleSend::SingleSend(QWidget *parent) : ...@@ -31,6 +39,8 @@ SingleSend::SingleSend(QWidget *parent) :
SingleSend::~SingleSend() { SingleSend::~SingleSend() {
mpControl->getMpSettings()->setTextSend(m_CurrentArray); mpControl->getMpSettings()->setTextSend(m_CurrentArray);
mpControl->getMpSettings()->setHexFormalSend(ui->ckBox_HexSend->isChecked()); mpControl->getMpSettings()->setHexFormalSend(ui->ckBox_HexSend->isChecked());
mpControl->getMpSettings()->setSendEnter(ui->ckBox_SendEnter->isChecked());
mpControl->getMpSettings()->setCycleValue(ui->spin_Cycle->value());
delete ui; delete ui;
} }
...@@ -42,6 +52,7 @@ void SingleSend::slotpBnSendClicked() { ...@@ -42,6 +52,7 @@ void SingleSend::slotpBnSendClicked() {
{ {
return; return;
} }
ui->ckBox_SendEnter->isChecked()?m_CurrentArray.append('\n'):m_CurrentArray;
emit signalSerialWrite(m_CurrentArray); emit signalSerialWrite(m_CurrentArray);
} }
} }
...@@ -52,7 +63,7 @@ void SingleSend::slotHexSendStateChanged(int state) { ...@@ -52,7 +63,7 @@ void SingleSend::slotHexSendStateChanged(int state) {
ui->tEdit_Send->setText(QString::fromLocal8Bit(m_CurrentArray)); ui->tEdit_Send->setText(QString::fromLocal8Bit(m_CurrentArray));
break; break;
case Qt::Checked: case Qt::Checked:
ui->tEdit_Send->setText(m_CurrentArray.toHex('%c ')); ui->tEdit_Send->setText(m_CurrentArray.toHex(' '));
break; break;
} }
} }
......
...@@ -26,6 +26,7 @@ public: ...@@ -26,6 +26,7 @@ public:
virtual ~SingleSend() override; virtual ~SingleSend() override;
signals: signals:
void signalSerialWrite(QByteArray array); void signalSerialWrite(QByteArray array);
void signalClearSendInfo();
private slots: private slots:
//! 点击发送 //! 点击发送
void slotpBnSendClicked(); void slotpBnSendClicked();
...@@ -33,9 +34,9 @@ private slots: ...@@ -33,9 +34,9 @@ private slots:
void slotHexSendStateChanged(int state); void slotHexSendStateChanged(int state);
//! 发送端文本改变 //! 发送端文本改变
void slotTextSendChanged(); void slotTextSendChanged();
//! 循环发送 //! 循环发送
void slotTimerSendStateChanged(int state); void slotTimerSendStateChanged(int state);
private: private:
Ui::SingleSend *ui; Ui::SingleSend *ui;
ZControl *mpControl; ZControl *mpControl;
......
...@@ -110,22 +110,5 @@ ...@@ -110,22 +110,5 @@
</layout> </layout>
</widget> </widget>
<resources/> <resources/>
<connections> <connections/>
<connection>
<sender>pBn_Clear</sender>
<signal>clicked()</signal>
<receiver>tEdit_Send</receiver>
<slot>clear()</slot>
<hints>
<hint type="sourcelabel">
<x>911</x>
<y>75</y>
</hint>
<hint type="destinationlabel">
<x>752</x>
<y>72</y>
</hint>
</hints>
</connection>
</connections>
</ui> </ui>
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册