1722 lines
65 KiB
C++
1722 lines
65 KiB
C++
#include "mguangyingpinwidget.h"
|
||
#include "gutil/qgui.h"
|
||
#include "globaldefine.h"
|
||
#include <QDateTime>
|
||
#include <QMessageBox>
|
||
#include <QSerialPortInfo>
|
||
#include <QEvent>
|
||
|
||
mGuangYingPinWidget::mGuangYingPinWidget(QWidget *parent) : QWidget(parent) {
|
||
setAutoFillBackground(true);
|
||
QPalette pal;
|
||
pal.setBrush(QPalette::Window, QColor(0xeeeeee));
|
||
setPalette(pal);
|
||
|
||
auto vBox = new VBox(this);
|
||
auto hBox = new HBox(vBox);
|
||
|
||
auto line = new QFrame;
|
||
line->setFrameShape(QFrame::VLine);
|
||
line->setFrameShadow(QFrame::Sunken);
|
||
hBox->addWidget(line);
|
||
|
||
groupBox_com = new QGroupBox(this);
|
||
groupBox_com->setFlat(true);
|
||
groupBox_com->setCheckable(true);
|
||
horizontalLayout_29 = new QHBoxLayout(groupBox_com);
|
||
horizontalLayout_29->setObjectName(QString::fromUtf8("horizontalLayout_29"));
|
||
verticalLayout_2 = new QVBoxLayout();
|
||
verticalLayout_2->setObjectName(QString::fromUtf8("verticalLayout_2"));
|
||
verticalLayout_2->setContentsMargins(-1, 0, -1, -1);
|
||
groupBoxMain = new QGroupBox(groupBox_com);
|
||
groupBoxMain->setObjectName(QString::fromUtf8("groupBoxMain"));
|
||
groupBoxMain->setMaximumSize(QSize(200, 16777215));
|
||
groupBoxMain->setAlignment(Qt::AlignCenter);
|
||
groupBoxMain->setFlat(true);
|
||
verticalLayout_6 = new QVBoxLayout(groupBoxMain);
|
||
verticalLayout_6->setObjectName(QString::fromUtf8("verticalLayout_6"));
|
||
horizontalLayout_6 = new QHBoxLayout();
|
||
horizontalLayout_6->setObjectName(QString::fromUtf8("horizontalLayout_6"));
|
||
label_PortName = new QLabel(groupBoxMain);
|
||
label_PortName->setObjectName(QString::fromUtf8("label_PortName"));
|
||
|
||
horizontalLayout_6->addWidget(label_PortName);
|
||
|
||
comboBox_SPortName = new QComboBox(groupBoxMain);
|
||
comboBox_SPortName->setObjectName(QString::fromUtf8("comboBox_SPortName"));
|
||
comboBox_SPortName->setMinimumSize(QSize(80, 0));
|
||
|
||
horizontalLayout_6->addWidget(comboBox_SPortName);
|
||
|
||
|
||
verticalLayout_6->addLayout(horizontalLayout_6);
|
||
|
||
horizontalLayout_9 = new QHBoxLayout();
|
||
horizontalLayout_9->setObjectName(QString::fromUtf8("horizontalLayout_9"));
|
||
horizontalLayout_9->setContentsMargins(-1, 0, -1, -1);
|
||
label_BaudRate = new QLabel(groupBoxMain);
|
||
label_BaudRate->setObjectName(QString::fromUtf8("label_BaudRate"));
|
||
|
||
horizontalLayout_9->addWidget(label_BaudRate);
|
||
|
||
comboBox_SPortBaud = new QComboBox(groupBoxMain);
|
||
comboBox_SPortBaud->addItem("1200");
|
||
comboBox_SPortBaud->addItem("2400");
|
||
comboBox_SPortBaud->addItem("4800");
|
||
comboBox_SPortBaud->addItem("9600");
|
||
comboBox_SPortBaud->addItem("19200");
|
||
comboBox_SPortBaud->addItem("38400");
|
||
comboBox_SPortBaud->addItem("57600");
|
||
comboBox_SPortBaud->addItem("115200");
|
||
horizontalLayout_9->addWidget(comboBox_SPortBaud);
|
||
|
||
verticalLayout_6->addLayout(horizontalLayout_9);
|
||
|
||
horizontalLayout_15 = new QHBoxLayout();
|
||
horizontalLayout_15->setObjectName(QString::fromUtf8("horizontalLayout_15"));
|
||
horizontalLayout_15->setContentsMargins(-1, 0, -1, -1);
|
||
label_DataBit = new QLabel(groupBoxMain);
|
||
label_DataBit->setObjectName(QString::fromUtf8("label_DataBit"));
|
||
|
||
horizontalLayout_15->addWidget(label_DataBit);
|
||
|
||
comboBox_SPortDataBit = new QComboBox(groupBoxMain);
|
||
comboBox_SPortDataBit->addItem("5");
|
||
comboBox_SPortDataBit->addItem("6");
|
||
comboBox_SPortDataBit->addItem("7");
|
||
comboBox_SPortDataBit->addItem("8");
|
||
horizontalLayout_15->addWidget(comboBox_SPortDataBit);
|
||
|
||
|
||
verticalLayout_6->addLayout(horizontalLayout_15);
|
||
|
||
horizontalLayout_17 = new QHBoxLayout();
|
||
horizontalLayout_17->setObjectName(QString::fromUtf8("horizontalLayout_17"));
|
||
horizontalLayout_17->setContentsMargins(-1, 0, -1, -1);
|
||
label_OEBit = new QLabel(groupBoxMain);
|
||
label_OEBit->setObjectName(QString::fromUtf8("label_OEBit"));
|
||
|
||
horizontalLayout_17->addWidget(label_OEBit);
|
||
|
||
comboBox_SPortOEBit = new QComboBox(groupBoxMain);
|
||
comboBox_SPortOEBit->addItem(tr("No"));
|
||
comboBox_SPortOEBit->addItem(tr("Even"));
|
||
comboBox_SPortOEBit->addItem(tr("Odd"));
|
||
comboBox_SPortOEBit->addItem(tr("Space"));
|
||
comboBox_SPortOEBit->addItem(tr("Mark"));
|
||
horizontalLayout_17->addWidget(comboBox_SPortOEBit);
|
||
|
||
verticalLayout_6->addLayout(horizontalLayout_17);
|
||
|
||
horizontalLayout_18 = new QHBoxLayout();
|
||
horizontalLayout_18->setObjectName(QString::fromUtf8("horizontalLayout_18"));
|
||
horizontalLayout_18->setContentsMargins(-1, 0, -1, -1);
|
||
label_StopBit = new QLabel(groupBoxMain);
|
||
label_StopBit->setObjectName(QString::fromUtf8("label_StopBit"));
|
||
|
||
horizontalLayout_18->addWidget(label_StopBit);
|
||
|
||
comboBox_SPortStopBit = new QComboBox(groupBoxMain);
|
||
comboBox_SPortStopBit->addItem("1");
|
||
comboBox_SPortStopBit->addItem("2");
|
||
comboBox_SPortStopBit->addItem("1.5");
|
||
horizontalLayout_18->addWidget(comboBox_SPortStopBit);
|
||
|
||
verticalLayout_6->addLayout(horizontalLayout_18);
|
||
|
||
horizontalLayout_22 = new QHBoxLayout();
|
||
horizontalLayout_22->setObjectName(QString::fromUtf8("horizontalLayout_22"));
|
||
horizontalLayout_22->setContentsMargins(-1, 0, -1, -1);
|
||
label_ComStatus = new QLabel(groupBoxMain);
|
||
label_ComStatus->setObjectName(QString::fromUtf8("label_ComStatus"));
|
||
|
||
horizontalLayout_22->addWidget(label_ComStatus);
|
||
|
||
graphicsView_ComStatus = new QGraphicsView(groupBoxMain);
|
||
graphicsView_ComStatus->setObjectName(QString::fromUtf8("graphicsView_ComStatus"));
|
||
graphicsView_ComStatus->setMaximumSize(QSize(30, 30));
|
||
|
||
horizontalLayout_22->addWidget(graphicsView_ComStatus);
|
||
|
||
|
||
verticalLayout_6->addLayout(horizontalLayout_22);
|
||
|
||
horizontalLayout_4 = new QHBoxLayout();
|
||
horizontalLayout_4->setObjectName(QString::fromUtf8("horizontalLayout_4"));
|
||
pushButtonMainOpen = new QPushButton(groupBoxMain);
|
||
pushButtonMainOpen->setObjectName(QString::fromUtf8("pushButtonMainOpen"));
|
||
pushButtonMainOpen->setMinimumSize(QSize(80, 30));
|
||
|
||
horizontalLayout_4->addWidget(pushButtonMainOpen);
|
||
|
||
|
||
verticalLayout_6->addLayout(horizontalLayout_4);
|
||
|
||
|
||
verticalLayout_2->addWidget(groupBoxMain);
|
||
|
||
|
||
horizontalLayout_29->addLayout(verticalLayout_2);
|
||
|
||
line = new QFrame(groupBox_com);
|
||
line->setFrameShape(QFrame::VLine);
|
||
line->setFrameShadow(QFrame::Sunken);
|
||
horizontalLayout_29->addWidget(line);
|
||
|
||
verticalLayout_3 = new QVBoxLayout();
|
||
verticalLayout_3->setObjectName(QString::fromUtf8("verticalLayout_3"));
|
||
verticalLayout_3->setContentsMargins(0, -1, -1, -1);
|
||
groupBoxAux = new QGroupBox(groupBox_com);
|
||
groupBoxAux->setObjectName(QString::fromUtf8("groupBoxAux"));
|
||
groupBoxAux->setMaximumSize(QSize(200, 16777215));
|
||
groupBoxAux->setAlignment(Qt::AlignCenter);
|
||
groupBoxAux->setFlat(true);
|
||
groupBoxAux->setCheckable(false);
|
||
verticalLayout_8 = new QVBoxLayout(groupBoxAux);
|
||
verticalLayout_8->setObjectName(QString::fromUtf8("verticalLayout_8"));
|
||
horizontalLayout_7 = new QHBoxLayout();
|
||
horizontalLayout_7->setObjectName(QString::fromUtf8("horizontalLayout_7"));
|
||
label_PortNameAux = new QLabel(groupBoxAux);
|
||
label_PortNameAux->setObjectName(QString::fromUtf8("label_PortNameAux"));
|
||
|
||
horizontalLayout_7->addWidget(label_PortNameAux);
|
||
|
||
comboBox_SPortNameAux = new QComboBox(groupBoxAux);
|
||
comboBox_SPortNameAux->setObjectName(QString::fromUtf8("comboBox_SPortNameAux"));
|
||
comboBox_SPortNameAux->setMinimumSize(QSize(80, 0));
|
||
|
||
horizontalLayout_7->addWidget(comboBox_SPortNameAux);
|
||
|
||
|
||
verticalLayout_8->addLayout(horizontalLayout_7);
|
||
|
||
horizontalLayout_24 = new QHBoxLayout();
|
||
horizontalLayout_24->setObjectName(QString::fromUtf8("horizontalLayout_24"));
|
||
label_BaudRateAux = new QLabel(groupBoxAux);
|
||
label_BaudRateAux->setObjectName(QString::fromUtf8("label_BaudRateAux"));
|
||
|
||
horizontalLayout_24->addWidget(label_BaudRateAux);
|
||
|
||
comboBox_SPortBaudAux = new QComboBox(groupBoxAux);
|
||
comboBox_SPortBaudAux->addItem("1200");
|
||
comboBox_SPortBaudAux->addItem("2400");
|
||
comboBox_SPortBaudAux->addItem("4800");
|
||
comboBox_SPortBaudAux->addItem("9600");
|
||
comboBox_SPortBaudAux->addItem("19200");
|
||
comboBox_SPortBaudAux->addItem("38400");
|
||
comboBox_SPortBaudAux->addItem("57600");
|
||
comboBox_SPortBaudAux->addItem("115200");
|
||
horizontalLayout_24->addWidget(comboBox_SPortBaudAux);
|
||
|
||
verticalLayout_8->addLayout(horizontalLayout_24);
|
||
|
||
horizontalLayout_25 = new QHBoxLayout();
|
||
horizontalLayout_25->setObjectName(QString::fromUtf8("horizontalLayout_25"));
|
||
label_DataBitAux = new QLabel(groupBoxAux);
|
||
label_DataBitAux->setObjectName(QString::fromUtf8("label_DataBitAux"));
|
||
|
||
horizontalLayout_25->addWidget(label_DataBitAux);
|
||
|
||
comboBox_SPortDataBitAux = new QComboBox(groupBoxAux);
|
||
comboBox_SPortDataBitAux->addItem("5");
|
||
comboBox_SPortDataBitAux->addItem("6");
|
||
comboBox_SPortDataBitAux->addItem("7");
|
||
comboBox_SPortDataBitAux->addItem("8");
|
||
horizontalLayout_25->addWidget(comboBox_SPortDataBitAux);
|
||
|
||
verticalLayout_8->addLayout(horizontalLayout_25);
|
||
|
||
horizontalLayout_26 = new QHBoxLayout();
|
||
horizontalLayout_26->setObjectName(QString::fromUtf8("horizontalLayout_26"));
|
||
label_OEBitAux = new QLabel(groupBoxAux);
|
||
label_OEBitAux->setObjectName(QString::fromUtf8("label_OEBitAux"));
|
||
|
||
horizontalLayout_26->addWidget(label_OEBitAux);
|
||
|
||
comboBox_SPortOEBitAux = new QComboBox(groupBoxAux);
|
||
comboBox_SPortOEBitAux->addItem(tr("No"));
|
||
comboBox_SPortOEBitAux->addItem(tr("Even"));
|
||
comboBox_SPortOEBitAux->addItem(tr("Odd"));
|
||
comboBox_SPortOEBitAux->addItem(tr("Space"));
|
||
comboBox_SPortOEBitAux->addItem(tr("Mark"));
|
||
horizontalLayout_26->addWidget(comboBox_SPortOEBitAux);
|
||
|
||
verticalLayout_8->addLayout(horizontalLayout_26);
|
||
|
||
horizontalLayout_27 = new QHBoxLayout();
|
||
horizontalLayout_27->setObjectName(QString::fromUtf8("horizontalLayout_27"));
|
||
label_StopBitAux = new QLabel(groupBoxAux);
|
||
label_StopBitAux->setObjectName(QString::fromUtf8("label_StopBitAux"));
|
||
|
||
horizontalLayout_27->addWidget(label_StopBitAux);
|
||
|
||
comboBox_SPortStopBitAux = new QComboBox(groupBoxAux);
|
||
comboBox_SPortStopBitAux->addItem("1");
|
||
comboBox_SPortStopBitAux->addItem("2");
|
||
comboBox_SPortStopBitAux->addItem("1.5");
|
||
horizontalLayout_27->addWidget(comboBox_SPortStopBitAux);
|
||
|
||
|
||
verticalLayout_8->addLayout(horizontalLayout_27);
|
||
|
||
horizontalLayout_28 = new QHBoxLayout();
|
||
horizontalLayout_28->setObjectName(QString::fromUtf8("horizontalLayout_28"));
|
||
label_ComStatusAux = new QLabel(groupBoxAux);
|
||
label_ComStatusAux->setObjectName(QString::fromUtf8("label_ComStatusAux"));
|
||
|
||
horizontalLayout_28->addWidget(label_ComStatusAux);
|
||
|
||
graphicsView_ComStatusAux = new QGraphicsView(groupBoxAux);
|
||
graphicsView_ComStatusAux->setObjectName(QString::fromUtf8("graphicsView_ComStatusAux"));
|
||
graphicsView_ComStatusAux->setMaximumSize(QSize(30, 30));
|
||
|
||
horizontalLayout_28->addWidget(graphicsView_ComStatusAux);
|
||
|
||
|
||
verticalLayout_8->addLayout(horizontalLayout_28);
|
||
|
||
horizontalLayout_5 = new QHBoxLayout();
|
||
horizontalLayout_5->setObjectName(QString::fromUtf8("horizontalLayout_5"));
|
||
pushButtonAuxOpen = new QPushButton(groupBoxAux);
|
||
pushButtonAuxOpen->setObjectName(QString::fromUtf8("pushButtonAuxOpen"));
|
||
pushButtonAuxOpen->setMinimumSize(QSize(80, 30));
|
||
|
||
horizontalLayout_5->addWidget(pushButtonAuxOpen);
|
||
|
||
|
||
verticalLayout_8->addLayout(horizontalLayout_5);
|
||
|
||
|
||
verticalLayout_3->addWidget(groupBoxAux);
|
||
|
||
|
||
horizontalLayout_29->addLayout(verticalLayout_3);
|
||
|
||
pushButtonRefresh = new QPushButton(groupBox_com);
|
||
pushButtonRefresh->setMinimumSize(QSize(80, 40));
|
||
horizontalLayout_29->addWidget(pushButtonRefresh);
|
||
|
||
hBox->addWidget(groupBox_com);
|
||
|
||
groupBox_Network = new QGroupBox(this);
|
||
groupBox_Network->setObjectName(QString::fromUtf8("groupBox_Network"));
|
||
groupBox_Network->setFlat(true);
|
||
groupBox_Network->setCheckable(true);
|
||
groupBox_Network->setChecked(false);
|
||
|
||
hBox->addWidget(groupBox_Network);
|
||
|
||
horizontalSpacer = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
|
||
|
||
hBox->addItem(horizontalSpacer);
|
||
|
||
line = new QFrame;
|
||
line->setFrameShape(QFrame::VLine);
|
||
line->setFrameShadow(QFrame::Sunken);
|
||
hBox->addWidget(line);
|
||
|
||
verticalLayout_9 = new QVBoxLayout();
|
||
verticalLayout_9->setObjectName(QString::fromUtf8("verticalLayout_9"));
|
||
verticalLayout_9->setContentsMargins(-1, 0, -1, -1);
|
||
groupBoxParam = new QGroupBox;
|
||
groupBoxParam->setMaximumSize(QSize(200, 16777215));
|
||
groupBoxParam->setAlignment(Qt::AlignCenter);
|
||
groupBoxParam->setFlat(true);
|
||
verticalLayout_10 = new QVBoxLayout(groupBoxParam);
|
||
verticalLayout_10->setObjectName(QString::fromUtf8("verticalLayout_10"));
|
||
horizontalLayout_20 = new QHBoxLayout();
|
||
horizontalLayout_20->setObjectName(QString::fromUtf8("horizontalLayout_20"));
|
||
label_ResendTimes = new QLabel(groupBoxParam);
|
||
label_ResendTimes->setObjectName(QString::fromUtf8("label_ResendTimes"));
|
||
horizontalLayout_20->addWidget(label_ResendTimes);
|
||
|
||
lineEdit_ResendTimes = new QLineEdit(groupBoxParam);
|
||
lineEdit_ResendTimes->setObjectName(QString::fromUtf8("lineEdit_ResendTimes"));
|
||
lineEdit_ResendTimes->setMaximumSize(QSize(80, 16777215));
|
||
|
||
horizontalLayout_20->addWidget(lineEdit_ResendTimes);
|
||
|
||
|
||
verticalLayout_10->addLayout(horizontalLayout_20);
|
||
|
||
horizontalLayout_23 = new QHBoxLayout();
|
||
|
||
label_DelayMill = new QLabel(groupBoxParam);
|
||
horizontalLayout_23->addWidget(label_DelayMill);
|
||
|
||
lineEdit_DelayMill = new QLineEdit(groupBoxParam);
|
||
lineEdit_DelayMill->setMaximumSize(QSize(80, 16777215));
|
||
horizontalLayout_23->addWidget(lineEdit_DelayMill);
|
||
|
||
|
||
verticalLayout_10->addLayout(horizontalLayout_23);
|
||
|
||
|
||
verticalLayout_9->addWidget(groupBoxParam);
|
||
|
||
verticalSpacer = new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding);
|
||
|
||
verticalLayout_9->addItem(verticalSpacer);
|
||
|
||
|
||
hBox->addLayout(verticalLayout_9);
|
||
|
||
horizontalSpacer_2 = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
|
||
|
||
hBox->addItem(horizontalSpacer_2);
|
||
|
||
|
||
line = new QFrame;
|
||
line->setFrameShape(QFrame::HLine);
|
||
line->setFrameShadow(QFrame::Sunken);
|
||
vBox->addWidget(line);
|
||
|
||
verticalLayout_4 = new QVBoxLayout();
|
||
verticalLayout_4->setObjectName(QString::fromUtf8("verticalLayout_4"));
|
||
horizontalLayout_14 = new QHBoxLayout();
|
||
horizontalLayout_14->setObjectName(QString::fromUtf8("horizontalLayout_14"));
|
||
horizontalLayout_14->setContentsMargins(-1, 2, -1, -1);
|
||
horizontalLayout_16 = new QHBoxLayout();
|
||
horizontalLayout_16->setObjectName(QString::fromUtf8("horizontalLayout_16"));
|
||
horizontalLayout_16->setContentsMargins(-1, 0, -1, -1);
|
||
verticalLayout_5 = new QVBoxLayout();
|
||
verticalLayout_5->setObjectName(QString::fromUtf8("verticalLayout_5"));
|
||
verticalLayout_5->setContentsMargins(-1, 0, -1, -1);
|
||
horizontalLayout_13 = new QHBoxLayout();
|
||
horizontalLayout_13->setObjectName(QString::fromUtf8("horizontalLayout_13"));
|
||
pushButton1 = new QPushButton;
|
||
pushButton1->setObjectName(QString::fromUtf8("pushButton1"));
|
||
pushButton1->setMinimumSize(QSize(40, 40));
|
||
pushButton1->setMaximumSize(QSize(40, 40));
|
||
|
||
horizontalLayout_13->addWidget(pushButton1);
|
||
|
||
pushButton2 = new QPushButton;
|
||
pushButton2->setObjectName(QString::fromUtf8("pushButton2"));
|
||
pushButton2->setMinimumSize(QSize(40, 40));
|
||
pushButton2->setMaximumSize(QSize(40, 40));
|
||
|
||
horizontalLayout_13->addWidget(pushButton2);
|
||
|
||
pushButton3 = new QPushButton;
|
||
pushButton3->setObjectName(QString::fromUtf8("pushButton3"));
|
||
pushButton3->setMinimumSize(QSize(40, 40));
|
||
pushButton3->setMaximumSize(QSize(40, 40));
|
||
|
||
horizontalLayout_13->addWidget(pushButton3);
|
||
|
||
pushButton4 = new QPushButton;
|
||
pushButton4->setObjectName(QString::fromUtf8("pushButton4"));
|
||
pushButton4->setMinimumSize(QSize(40, 40));
|
||
pushButton4->setMaximumSize(QSize(40, 40));
|
||
|
||
horizontalLayout_13->addWidget(pushButton4);
|
||
|
||
pushButton5 = new QPushButton;
|
||
pushButton5->setObjectName(QString::fromUtf8("pushButton5"));
|
||
pushButton5->setMinimumSize(QSize(40, 40));
|
||
pushButton5->setMaximumSize(QSize(40, 40));
|
||
|
||
horizontalLayout_13->addWidget(pushButton5);
|
||
|
||
|
||
verticalLayout_5->addLayout(horizontalLayout_13);
|
||
|
||
horizontalLayout_12 = new QHBoxLayout();
|
||
pushButton6 = new QPushButton;
|
||
pushButton6->setObjectName(QString::fromUtf8("pushButton6"));
|
||
pushButton6->setMinimumSize(QSize(40, 40));
|
||
pushButton6->setMaximumSize(QSize(40, 40));
|
||
|
||
horizontalLayout_12->addWidget(pushButton6);
|
||
|
||
pushButton7 = new QPushButton;
|
||
pushButton7->setObjectName(QString::fromUtf8("pushButton7"));
|
||
pushButton7->setMinimumSize(QSize(40, 40));
|
||
pushButton7->setMaximumSize(QSize(40, 40));
|
||
|
||
horizontalLayout_12->addWidget(pushButton7);
|
||
|
||
pushButton8 = new QPushButton;
|
||
pushButton8->setObjectName(QString::fromUtf8("pushButton8"));
|
||
pushButton8->setMinimumSize(QSize(40, 40));
|
||
pushButton8->setMaximumSize(QSize(40, 40));
|
||
|
||
horizontalLayout_12->addWidget(pushButton8);
|
||
|
||
pushButton9 = new QPushButton;
|
||
pushButton9->setObjectName(QString::fromUtf8("pushButton9"));
|
||
pushButton9->setMinimumSize(QSize(40, 40));
|
||
pushButton9->setMaximumSize(QSize(40, 40));
|
||
|
||
horizontalLayout_12->addWidget(pushButton9);
|
||
|
||
pushButton10 = new QPushButton;
|
||
pushButton10->setObjectName(QString::fromUtf8("pushButton10"));
|
||
pushButton10->setMinimumSize(QSize(40, 40));
|
||
pushButton10->setMaximumSize(QSize(40, 40));
|
||
|
||
horizontalLayout_12->addWidget(pushButton10);
|
||
|
||
|
||
verticalLayout_5->addLayout(horizontalLayout_12);
|
||
|
||
horizontalLayout_11 = new QHBoxLayout();
|
||
horizontalLayout_11->setObjectName(QString::fromUtf8("horizontalLayout_11"));
|
||
pushButton11 = new QPushButton;
|
||
pushButton11->setObjectName(QString::fromUtf8("pushButton11"));
|
||
pushButton11->setMinimumSize(QSize(40, 40));
|
||
pushButton11->setMaximumSize(QSize(40, 40));
|
||
|
||
horizontalLayout_11->addWidget(pushButton11);
|
||
|
||
pushButton12 = new QPushButton;
|
||
pushButton12->setObjectName(QString::fromUtf8("pushButton12"));
|
||
pushButton12->setMinimumSize(QSize(40, 40));
|
||
pushButton12->setMaximumSize(QSize(40, 40));
|
||
|
||
horizontalLayout_11->addWidget(pushButton12);
|
||
|
||
pushButton13 = new QPushButton;
|
||
pushButton13->setObjectName(QString::fromUtf8("pushButton13"));
|
||
pushButton13->setMinimumSize(QSize(40, 40));
|
||
pushButton13->setMaximumSize(QSize(40, 40));
|
||
|
||
horizontalLayout_11->addWidget(pushButton13);
|
||
|
||
pushButton14 = new QPushButton;
|
||
pushButton14->setObjectName(QString::fromUtf8("pushButton14"));
|
||
pushButton14->setMinimumSize(QSize(40, 40));
|
||
pushButton14->setMaximumSize(QSize(40, 40));
|
||
|
||
horizontalLayout_11->addWidget(pushButton14);
|
||
|
||
pushButton15 = new QPushButton;
|
||
pushButton15->setObjectName(QString::fromUtf8("pushButton15"));
|
||
pushButton15->setMinimumSize(QSize(40, 40));
|
||
pushButton15->setMaximumSize(QSize(40, 40));
|
||
|
||
horizontalLayout_11->addWidget(pushButton15);
|
||
|
||
|
||
verticalLayout_5->addLayout(horizontalLayout_11);
|
||
|
||
horizontalLayout_10 = new QHBoxLayout();
|
||
horizontalLayout_10->setObjectName(QString::fromUtf8("horizontalLayout_10"));
|
||
pushButton16 = new QPushButton;
|
||
pushButton16->setObjectName(QString::fromUtf8("pushButton16"));
|
||
pushButton16->setMinimumSize(QSize(40, 40));
|
||
pushButton16->setMaximumSize(QSize(40, 40));
|
||
|
||
horizontalLayout_10->addWidget(pushButton16);
|
||
|
||
pushButton17 = new QPushButton;
|
||
pushButton17->setObjectName(QString::fromUtf8("pushButton17"));
|
||
pushButton17->setMinimumSize(QSize(40, 40));
|
||
pushButton17->setMaximumSize(QSize(40, 40));
|
||
|
||
horizontalLayout_10->addWidget(pushButton17);
|
||
|
||
pushButton18 = new QPushButton;
|
||
pushButton18->setObjectName(QString::fromUtf8("pushButton18"));
|
||
pushButton18->setMinimumSize(QSize(40, 40));
|
||
pushButton18->setMaximumSize(QSize(40, 40));
|
||
|
||
horizontalLayout_10->addWidget(pushButton18);
|
||
|
||
pushButton19 = new QPushButton;
|
||
pushButton19->setMinimumSize(QSize(40, 40));
|
||
pushButton19->setMaximumSize(QSize(40, 40));
|
||
horizontalLayout_10->addWidget(pushButton19);
|
||
|
||
pushButton20 = new QPushButton;
|
||
pushButton20->setMinimumSize(QSize(40, 40));
|
||
pushButton20->setMaximumSize(QSize(40, 40));
|
||
horizontalLayout_10->addWidget(pushButton20);
|
||
|
||
verticalLayout_5->addLayout(horizontalLayout_10);
|
||
|
||
horizontalLayout_16->addLayout(verticalLayout_5);
|
||
|
||
horizontalLayout_14->addLayout(horizontalLayout_16);
|
||
|
||
line = new QFrame;
|
||
line->setFrameShape(QFrame::VLine);
|
||
line->setFrameShadow(QFrame::Sunken);
|
||
horizontalLayout_14->addWidget(line);
|
||
|
||
verticalLayout_7 = new QVBoxLayout();
|
||
verticalLayout_7->setContentsMargins(0, -1, -1, -1);
|
||
horizontalLayout_19 = new QHBoxLayout();
|
||
horizontalLayout_19->setContentsMargins(0, -1, -1, -1);
|
||
label_ProgramNum = new QLabel;
|
||
label_ProgramNum->setMinimumSize(QSize(88, 0));
|
||
horizontalLayout_19->addWidget(label_ProgramNum);
|
||
|
||
spinBox_ProgramIndex = new QSpinBox;
|
||
spinBox_ProgramIndex->setMinimumSize(QSize(60, 0));
|
||
spinBox_ProgramIndex->setMaximum(999);
|
||
spinBox_ProgramIndex->setValue(21);
|
||
horizontalLayout_19->addWidget(spinBox_ProgramIndex);
|
||
|
||
pushButtonSend = new QPushButton;
|
||
pushButtonSend->setMinimumSize(QSize(80, 40));
|
||
horizontalLayout_19->addWidget(pushButtonSend);
|
||
|
||
line = new QFrame;
|
||
line->setFrameShape(QFrame::VLine);
|
||
line->setFrameShadow(QFrame::Sunken);
|
||
horizontalLayout_19->addWidget(line);
|
||
|
||
pushButtonPrevious = new QPushButton;
|
||
pushButtonPrevious->setMinimumSize(QSize(40, 40));
|
||
pushButtonPrevious->setIconSize(QSize(32, 32));
|
||
pushButtonPrevious->setFlat(true);
|
||
horizontalLayout_19->addWidget(pushButtonPrevious);
|
||
|
||
pushButtonNext = new QPushButton;
|
||
pushButtonNext->setMinimumSize(QSize(40, 40));
|
||
pushButtonNext->setIconSize(QSize(32, 32));
|
||
pushButtonNext->setFlat(true);
|
||
horizontalLayout_19->addWidget(pushButtonNext);
|
||
|
||
pushButtonLoop = new QPushButton;
|
||
pushButtonLoop->setMinimumSize(QSize(40, 40));
|
||
pushButtonLoop->setIconSize(QSize(32, 32));
|
||
pushButtonLoop->setFlat(true);
|
||
horizontalLayout_19->addWidget(pushButtonLoop);
|
||
|
||
horizontalSpacer_7 = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
|
||
|
||
horizontalLayout_19->addItem(horizontalSpacer_7);
|
||
|
||
|
||
verticalLayout_7->addLayout(horizontalLayout_19);
|
||
|
||
line = new QFrame;
|
||
line->setFrameShape(QFrame::HLine);
|
||
line->setFrameShadow(QFrame::Sunken);
|
||
verticalLayout_7->addWidget(line);
|
||
|
||
horizontalLayout_21 = new QHBoxLayout();
|
||
label_BrightNess = new QLabel;
|
||
label_BrightNess->setMinimumSize(QSize(88, 0));
|
||
horizontalLayout_21->addWidget(label_BrightNess);
|
||
|
||
spinBox_BrightnessValue = new QSpinBox;
|
||
spinBox_BrightnessValue->setMinimumSize(QSize(60, 0));
|
||
spinBox_BrightnessValue->setMaximum(255);
|
||
spinBox_BrightnessValue->setValue(255);
|
||
horizontalLayout_21->addWidget(spinBox_BrightnessValue);
|
||
|
||
pushButtonBrightnessSet = new QPushButton;
|
||
pushButtonBrightnessSet->setMinimumSize(QSize(80, 40));
|
||
horizontalLayout_21->addWidget(pushButtonBrightnessSet);
|
||
|
||
line = new QFrame;
|
||
line->setFrameShape(QFrame::VLine);
|
||
line->setFrameShadow(QFrame::Sunken);
|
||
horizontalLayout_21->addWidget(line);
|
||
|
||
pushButtonScreenOff = new QPushButton;
|
||
pushButtonScreenOff->setMinimumSize(QSize(80, 40));
|
||
horizontalLayout_21->addWidget(pushButtonScreenOff);
|
||
|
||
pushButtonScreenOn = new QPushButton;
|
||
pushButtonScreenOn->setMinimumSize(QSize(80, 40));
|
||
horizontalLayout_21->addWidget(pushButtonScreenOn);
|
||
|
||
horizontalSpacer_18 = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
|
||
|
||
horizontalLayout_21->addItem(horizontalSpacer_18);
|
||
|
||
|
||
verticalLayout_7->addLayout(horizontalLayout_21);
|
||
|
||
verticalSpacer_2 = new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding);
|
||
|
||
verticalLayout_7->addItem(verticalSpacer_2);
|
||
|
||
horizontalLayout_2 = new QHBoxLayout();
|
||
horizontalLayout_2->setContentsMargins(-1, 20, -1, -1);
|
||
horizontalSpacer_3 = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
|
||
|
||
horizontalLayout_2->addItem(horizontalSpacer_3);
|
||
|
||
pushButtonClearLog = new QPushButton;
|
||
horizontalLayout_2->addWidget(pushButtonClearLog);
|
||
|
||
checkBoxDebug = new QCheckBox;
|
||
checkBoxDebug->setChecked(false);
|
||
|
||
horizontalLayout_2->addWidget(checkBoxDebug);
|
||
|
||
|
||
verticalLayout_7->addLayout(horizontalLayout_2);
|
||
|
||
|
||
horizontalLayout_14->addLayout(verticalLayout_7);
|
||
|
||
|
||
verticalLayout_4->addLayout(horizontalLayout_14);
|
||
|
||
|
||
vBox->addLayout(verticalLayout_4);
|
||
|
||
line = new QFrame;
|
||
line->setFrameShape(QFrame::HLine);
|
||
line->setFrameShadow(QFrame::Sunken);
|
||
vBox->addWidget(line);
|
||
|
||
horizontalLayout_3 = new QHBoxLayout();
|
||
horizontalLayout_8 = new QHBoxLayout();
|
||
textEditReadBuf = new QTextEdit;
|
||
textEditReadBuf->setSizeAdjustPolicy(QAbstractScrollArea::AdjustIgnored);
|
||
textEditReadBuf->setUndoRedoEnabled(false);
|
||
textEditReadBuf->setReadOnly(true);
|
||
|
||
horizontalLayout_8->addWidget(textEditReadBuf);
|
||
|
||
|
||
horizontalLayout_3->addLayout(horizontalLayout_8);
|
||
|
||
vBox->addLayout(horizontalLayout_3);
|
||
|
||
|
||
groupBox_com->setTitle(tr("Com"));
|
||
groupBoxMain->setTitle(tr("Main"));
|
||
label_PortName->setText(tr("PortName"));
|
||
label_BaudRate->setText(tr("BaudRate"));
|
||
|
||
|
||
label_DataBit->setText(tr("DataBit"));
|
||
|
||
|
||
label_OEBit->setText(tr("OEBit"));
|
||
|
||
|
||
label_StopBit->setText(tr("StopBit"));
|
||
|
||
|
||
label_ComStatus->setText(tr("State:Close"));
|
||
pushButtonMainOpen->setText(tr("Open"));
|
||
groupBoxAux->setTitle(tr("Auxiliary"));
|
||
label_PortNameAux->setText(tr("PortName"));
|
||
label_BaudRateAux->setText(tr("BaudRate"));
|
||
|
||
|
||
label_DataBitAux->setText(tr("DataBit"));
|
||
|
||
|
||
label_OEBitAux->setText(tr("OEBit"));
|
||
|
||
|
||
label_StopBitAux->setText(tr("StopBit"));
|
||
|
||
|
||
label_ComStatusAux->setText(tr("State:Close"));
|
||
pushButtonAuxOpen->setText(tr("Open"));
|
||
pushButtonRefresh->setText(tr("Refresh"));
|
||
groupBox_Network->setTitle(tr("Network"));
|
||
groupBoxParam->setTitle(tr("Param configuration"));
|
||
label_ResendTimes->setText(tr("Resend times"));
|
||
lineEdit_ResendTimes->setText(tr("10"));
|
||
label_DelayMill->setText(tr("Delay millsecond"));
|
||
lineEdit_DelayMill->setText(tr("10"));
|
||
pushButton1->setText(tr("1"));
|
||
pushButton2->setText(tr("2"));
|
||
pushButton3->setText(tr("3"));
|
||
pushButton4->setText(tr("4"));
|
||
pushButton5->setText(tr("5"));
|
||
pushButton6->setText(tr("6"));
|
||
pushButton7->setText(tr("7"));
|
||
pushButton8->setText(tr("8"));
|
||
pushButton9->setText(tr("9"));
|
||
pushButton10->setText(tr("10"));
|
||
pushButton11->setText(tr("11"));
|
||
pushButton12->setText(tr("12"));
|
||
pushButton13->setText(tr("13"));
|
||
pushButton14->setText(tr("14"));
|
||
pushButton15->setText(tr("15"));
|
||
pushButton16->setText(tr("16"));
|
||
pushButton17->setText(tr("17"));
|
||
pushButton18->setText(tr("18"));
|
||
pushButton19->setText(tr("19"));
|
||
pushButton20->setText(tr("20"));
|
||
label_ProgramNum->setText(tr("Program number"));
|
||
pushButtonSend->setText(tr("Send"));
|
||
label_BrightNess->setText(tr("Brightness"));
|
||
pushButtonBrightnessSet->setText(tr("Set"));
|
||
pushButtonScreenOff->setText(tr("Screen Off"));
|
||
pushButtonScreenOn->setText(tr("Screen on"));
|
||
pushButtonClearLog->setText(tr("Clear"));
|
||
checkBoxDebug->setText(tr("Debug"));
|
||
|
||
|
||
|
||
|
||
pushButton1->setProperty("ssType", "progManageTool");
|
||
pushButton2->setProperty("ssType", "progManageTool");
|
||
pushButton3->setProperty("ssType", "progManageTool");
|
||
pushButton4->setProperty("ssType", "progManageTool");
|
||
pushButton5->setProperty("ssType", "progManageTool");
|
||
pushButton6->setProperty("ssType", "progManageTool");
|
||
pushButton7->setProperty("ssType", "progManageTool");
|
||
pushButton8->setProperty("ssType", "progManageTool");
|
||
pushButton9->setProperty("ssType", "progManageTool");
|
||
pushButton10->setProperty("ssType", "progManageTool");
|
||
pushButton11->setProperty("ssType", "progManageTool");
|
||
pushButton12->setProperty("ssType", "progManageTool");
|
||
pushButton13->setProperty("ssType", "progManageTool");
|
||
pushButton14->setProperty("ssType", "progManageTool");
|
||
pushButton15->setProperty("ssType", "progManageTool");
|
||
pushButton16->setProperty("ssType", "progManageTool");
|
||
pushButton17->setProperty("ssType", "progManageTool");
|
||
pushButton18->setProperty("ssType", "progManageTool");
|
||
pushButton19->setProperty("ssType", "progManageTool");
|
||
pushButton20->setProperty("ssType", "progManageTool");
|
||
|
||
pushButtonSend->setProperty("ssType", "progManageTool");
|
||
pushButtonPrevious->setProperty("ssType", "progManageTool");
|
||
pushButtonPrevious->setIcon(QIcon(":/res/previous.png"));
|
||
pushButtonNext->setProperty("ssType", "progManageTool");
|
||
pushButtonNext->setIcon(QIcon(":/res/next.png"));
|
||
pushButtonLoop->setProperty("ssType", "progManageTool");
|
||
pushButtonLoop->setIcon(QIcon(":/res/loop.png"));
|
||
pushButtonMainOpen->setProperty("ssType", "progManageTool");
|
||
pushButtonAuxOpen->setProperty("ssType", "progManageTool");
|
||
pushButtonBrightnessSet->setProperty("ssType", "progManageTool");
|
||
pushButtonScreenOn->setProperty("ssType", "progManageTool");
|
||
pushButtonScreenOff->setProperty("ssType", "progManageTool");
|
||
pushButtonRefresh->setProperty("ssType", "progManageTool");
|
||
pushButtonClearLog->setProperty("ssType", "progManageTool");
|
||
m_recvNum = 0;
|
||
m_sendNum = 0;
|
||
sPortThread = new TA_SerialThread;
|
||
sPortThread->SearchPort();
|
||
|
||
for(uint8_t i = 0;i < sPortThread->portCnt;i++)
|
||
{
|
||
comboBox_SPortName->addItem(sPortThread->m_arrSerial[i].portName());
|
||
comboBox_SPortNameAux->addItem(sPortThread->m_arrSerial[i].portName());
|
||
}
|
||
|
||
//0:1200 1:2400 2:4800 3:9600 4:19200 5:38400 6:57600 7:115200
|
||
if(comboBox_SPortName->count()>=1)
|
||
{
|
||
comboBox_SPortBaud->setCurrentIndex(3);
|
||
//0:5 1:6 2:7 3:8
|
||
comboBox_SPortDataBit->setCurrentIndex(3);
|
||
//0:no p 2:e p 3:o p 4:s p 5:m p
|
||
comboBox_SPortOEBit->setCurrentIndex(0);
|
||
//0:1 1:2 2:1.5
|
||
comboBox_SPortStopBit->setCurrentIndex(0);
|
||
|
||
graphicsView_ComStatus->setStyleSheet("background-color: rgb(255, 0, 0);");
|
||
label_ComStatus->setText(tr("State:Off"));
|
||
|
||
comboBox_SPortBaudAux->setCurrentIndex(3);
|
||
comboBox_SPortDataBitAux->setCurrentIndex(3);
|
||
comboBox_SPortOEBitAux->setCurrentIndex(0);
|
||
comboBox_SPortStopBitAux->setCurrentIndex(0);
|
||
graphicsView_ComStatusAux->setStyleSheet("background-color: rgb(255, 0, 0);");
|
||
label_ComStatusAux->setText(tr("State:Off"));
|
||
if(comboBox_SPortName->count()>1)
|
||
{
|
||
comboBox_SPortNameAux->setCurrentIndex(1);
|
||
}
|
||
}
|
||
lineEdit_ResendTimes->setValidator(new QIntValidator(1,1000,this));
|
||
lineEdit_DelayMill->setValidator(new QIntValidator(1,1000,this));
|
||
|
||
|
||
connect(pushButtonMainOpen, SIGNAL(clicked(bool)), this, SLOT(MWOnoffPort()));
|
||
connect(pushButtonAuxOpen, SIGNAL(clicked(bool)), this, SLOT(MWOnoffPortAux()));
|
||
connect(pushButton1, SIGNAL(clicked()), this, SLOT(OnAnsyProgram1()));
|
||
connect(pushButton2, SIGNAL(clicked()), this, SLOT(OnAnsyProgram2()));
|
||
connect(pushButton3, SIGNAL(clicked()), this, SLOT(OnAnsyProgram3()));
|
||
connect(pushButton4, SIGNAL(clicked()), this, SLOT(OnAnsyProgram4()));
|
||
connect(pushButton5, SIGNAL(clicked()), this, SLOT(OnAnsyProgram5()));
|
||
connect(pushButton6, SIGNAL(clicked()), this, SLOT(OnAnsyProgram6()));
|
||
connect(pushButton7, SIGNAL(clicked()), this, SLOT(OnAnsyProgram7()));
|
||
connect(pushButton8, SIGNAL(clicked()), this, SLOT(OnAnsyProgram8()));
|
||
connect(pushButton9, SIGNAL(clicked()), this, SLOT(OnAnsyProgram9()));
|
||
connect(pushButton10, SIGNAL(clicked()), this, SLOT(OnAnsyProgram10()));
|
||
connect(pushButton11, SIGNAL(clicked()), this, SLOT(OnAnsyProgram11()));
|
||
connect(pushButton12, SIGNAL(clicked()), this, SLOT(OnAnsyProgram12()));
|
||
connect(pushButton13, SIGNAL(clicked()), this, SLOT(OnAnsyProgram13()));
|
||
connect(pushButton14, SIGNAL(clicked()), this, SLOT(OnAnsyProgram14()));
|
||
connect(pushButton15, SIGNAL(clicked()), this, SLOT(OnAnsyProgram15()));
|
||
connect(pushButton16, SIGNAL(clicked()), this, SLOT(OnAnsyProgram16()));
|
||
connect(pushButton17, SIGNAL(clicked()), this, SLOT(OnAnsyProgram17()));
|
||
connect(pushButton18, SIGNAL(clicked()), this, SLOT(OnAnsyProgram18()));
|
||
connect(pushButton19, SIGNAL(clicked()), this, SLOT(OnAnsyProgram19()));
|
||
connect(pushButton20, SIGNAL(clicked()), this, SLOT(OnAnsyProgram20()));
|
||
connect(pushButtonClearLog, SIGNAL(clicked()), this, SLOT(OnClearLog()));
|
||
connect(pushButtonSend, SIGNAL(clicked()), this, SLOT(OnAnsyProgramCustom()));
|
||
connect(pushButtonNext, SIGNAL(clicked()), this, SLOT(OnAnsyProgramNext()));
|
||
connect(pushButtonPrevious, SIGNAL(clicked()), this, SLOT(OnAnsyProgramPrevious()));
|
||
connect(pushButtonLoop, SIGNAL(clicked()), this, SLOT(OnAnsyProgramLoop()));
|
||
connect(pushButtonBrightnessSet, SIGNAL(clicked()), this, SLOT(OnBrightnessSet()));
|
||
connect(pushButtonScreenOn, SIGNAL(clicked()), this, SLOT(OnScreenOn()));
|
||
connect(pushButtonScreenOff, SIGNAL(clicked()), this, SLOT(OnScreenOff()));
|
||
connect(spinBox_ProgramIndex, SIGNAL(valueChanged(int)), this, SLOT(OnAnsyProgramCustomByChanged(int)));
|
||
connect(spinBox_BrightnessValue, SIGNAL(valueChanged(int)), this, SLOT(OnBrightnessSetByChanged(int)));
|
||
connect(pushButtonRefresh, SIGNAL(clicked()), this, SLOT(OnRefresh()));
|
||
}
|
||
|
||
void mGuangYingPinWidget::changeEvent(QEvent *event) {
|
||
QWidget::changeEvent(event);
|
||
if(event->type() == QEvent::LanguageChange) {
|
||
pushButtonSend->setText(tr("Send"));
|
||
pushButtonMainOpen->setText(tr("Open"));
|
||
pushButtonAuxOpen->setText(tr("Open"));
|
||
pushButtonBrightnessSet->setText(tr("Set"));
|
||
pushButtonScreenOn->setText(tr("Screen On"));
|
||
pushButtonScreenOff->setText(tr("Screen Off"));
|
||
pushButtonRefresh->setText(tr("Refresh"));
|
||
groupBoxMain->setTitle(tr("Main"));
|
||
groupBoxAux->setTitle(tr("Auxiliary"));
|
||
groupBoxParam->setTitle(tr("Param configuration"));
|
||
label_PortName->setText(tr("PortName"));
|
||
label_BaudRate->setText(tr("BaudRate"));
|
||
label_DataBit->setText(tr("DataBit"));
|
||
label_OEBit->setText(tr("OEBit"));
|
||
label_StopBit->setText(tr("StopBit"));
|
||
label_PortNameAux->setText(tr("PortName"));
|
||
label_BaudRateAux->setText(tr("BaudRate"));
|
||
label_DataBitAux->setText(tr("DataBit"));
|
||
label_OEBitAux->setText(tr("OEBit"));
|
||
label_StopBitAux->setText(tr("StopBit"));
|
||
|
||
label_ResendTimes->setText(tr("Resend times"));
|
||
label_DelayMill->setText(tr("Delay millsecond"));
|
||
label_ProgramNum->setText(tr("Program number"));
|
||
label_BrightNess->setText(tr("Brightness"));
|
||
label_ComStatus->setText(tr("State:Off"));
|
||
label_ComStatusAux->setText(tr("State:Off"));
|
||
pushButtonClearLog->setText(tr("Clear"));
|
||
checkBoxDebug->setText(tr("Debug"));
|
||
groupBox_Network->setTitle(tr("Network"));
|
||
groupBox_com->setTitle(tr("Com"));
|
||
}
|
||
}
|
||
|
||
void mGuangYingPinWidget::OnAnsyProgram1(void)
|
||
{
|
||
MACRO_ANSY_PROGRAM(1)
|
||
}
|
||
void mGuangYingPinWidget::OnAnsyProgram2(void)
|
||
{
|
||
MACRO_ANSY_PROGRAM(2)
|
||
|
||
}void mGuangYingPinWidget::OnAnsyProgram3(void)
|
||
{
|
||
MACRO_ANSY_PROGRAM(3)
|
||
}void mGuangYingPinWidget::OnAnsyProgram4(void)
|
||
{
|
||
MACRO_ANSY_PROGRAM(4)
|
||
}void mGuangYingPinWidget::OnAnsyProgram5(void)
|
||
{
|
||
MACRO_ANSY_PROGRAM(5)
|
||
}void mGuangYingPinWidget::OnAnsyProgram6(void)
|
||
{
|
||
MACRO_ANSY_PROGRAM(6)
|
||
}void mGuangYingPinWidget::OnAnsyProgram7(void)
|
||
{
|
||
MACRO_ANSY_PROGRAM(7)
|
||
}void mGuangYingPinWidget::OnAnsyProgram8(void)
|
||
{
|
||
MACRO_ANSY_PROGRAM(8)
|
||
}void mGuangYingPinWidget::OnAnsyProgram9(void)
|
||
{
|
||
MACRO_ANSY_PROGRAM(9)
|
||
}void mGuangYingPinWidget::OnAnsyProgram10(void)
|
||
{
|
||
MACRO_ANSY_PROGRAM(10)
|
||
}void mGuangYingPinWidget::OnAnsyProgram11(void)
|
||
{
|
||
MACRO_ANSY_PROGRAM(11)
|
||
}void mGuangYingPinWidget::OnAnsyProgram12(void)
|
||
{
|
||
MACRO_ANSY_PROGRAM(12)
|
||
}void mGuangYingPinWidget::OnAnsyProgram13(void)
|
||
{
|
||
MACRO_ANSY_PROGRAM(13)
|
||
}void mGuangYingPinWidget::OnAnsyProgram14(void)
|
||
{
|
||
MACRO_ANSY_PROGRAM(14)
|
||
}void mGuangYingPinWidget::OnAnsyProgram15(void)
|
||
{
|
||
MACRO_ANSY_PROGRAM(15)
|
||
}void mGuangYingPinWidget::OnAnsyProgram16(void)
|
||
{
|
||
MACRO_ANSY_PROGRAM(16)
|
||
}void mGuangYingPinWidget::OnAnsyProgram17(void)
|
||
{
|
||
MACRO_ANSY_PROGRAM(17)
|
||
}void mGuangYingPinWidget::OnAnsyProgram18(void)
|
||
{
|
||
MACRO_ANSY_PROGRAM(18)
|
||
}void mGuangYingPinWidget::OnAnsyProgram19(void)
|
||
{
|
||
MACRO_ANSY_PROGRAM(19)
|
||
}
|
||
void mGuangYingPinWidget::OnAnsyProgram20(void)
|
||
{
|
||
MACRO_ANSY_PROGRAM(20)
|
||
}
|
||
void mGuangYingPinWidget::OnClearLog(void)
|
||
{
|
||
textEditReadBuf->clear();
|
||
}
|
||
void mGuangYingPinWidget::OnAnsyProgramCustom(void)
|
||
{
|
||
int itemp=spinBox_ProgramIndex->value();
|
||
MACRO_ANSY_PROGRAM(itemp)
|
||
|
||
if(checkBoxDebug->isChecked())
|
||
{
|
||
textEditReadBuf->append("OnAnsyProgramCustom");
|
||
}
|
||
}
|
||
void mGuangYingPinWidget::OnAnsyProgramCustomByChanged(int icurIndex)
|
||
{
|
||
MACRO_ANSY_PROGRAM(icurIndex)
|
||
}
|
||
void mGuangYingPinWidget::OnBrightnessSetByChanged(int icurValue)
|
||
{
|
||
if(pushButtonMainOpen->text()==tr("Close"))
|
||
Set_Brightness_buf_and_send(comboBox_SPortName->currentIndex(),icurValue);
|
||
if(pushButtonAuxOpen->text()==tr("Close"))
|
||
Set_Brightness_buf_and_send(comboBox_SPortNameAux->currentIndex(),icurValue);
|
||
}
|
||
|
||
void mGuangYingPinWidget::OnAnsyProgramNext(void)
|
||
{
|
||
spinBox_ProgramIndex->setValue(spinBox_ProgramIndex->value()+1);
|
||
OnAnsyProgramCustom();
|
||
// int itemp=spinBox_ProgramIndex->value();
|
||
// MACRO_ANSY_PROGRAM(itemp)
|
||
// if(pushButtonMainOpen->text()==tr("Close"))
|
||
// NextProgram_buf_and_send(comboBox_SPortName->currentIndex());
|
||
// if(pushButtonAuxOpen->text()==tr("Close"))
|
||
// NextProgram_buf_and_send(comboBox_SPortNameAux->currentIndex());
|
||
|
||
}
|
||
void mGuangYingPinWidget::OnAnsyProgramPrevious(void)
|
||
{
|
||
spinBox_ProgramIndex->setValue(spinBox_ProgramIndex->value()-1);
|
||
OnAnsyProgramCustom();
|
||
// int itemp=spinBox_ProgramIndex->value();
|
||
// MACRO_ANSY_PROGRAM(itemp)
|
||
}
|
||
void mGuangYingPinWidget::OnAnsyProgramLoop(void)
|
||
{
|
||
MACRO_ANSY_PROGRAM(0)
|
||
}
|
||
void mGuangYingPinWidget::OnBrightnessSet(void)
|
||
{
|
||
if(groupBox_com->isChecked())
|
||
{
|
||
if(pushButtonMainOpen->text()==tr("Close"))
|
||
Set_Brightness_buf_and_send(comboBox_SPortName->currentIndex(),spinBox_BrightnessValue->value());
|
||
if(pushButtonAuxOpen->text()==tr("Close"))
|
||
Set_Brightness_buf_and_send(comboBox_SPortNameAux->currentIndex(),spinBox_BrightnessValue->value());
|
||
}
|
||
|
||
if(groupBox_Network->isChecked())
|
||
{
|
||
Set_Brightness_buf_and_send_by_udp(spinBox_BrightnessValue->value());
|
||
}
|
||
}
|
||
void mGuangYingPinWidget::OnScreenOn(void)
|
||
{
|
||
if(groupBox_com->isChecked())
|
||
{
|
||
if(pushButtonMainOpen->text()==tr("Close"))
|
||
Screen_OnOff_buf_and_send(comboBox_SPortName->currentIndex(),0x11);
|
||
if(pushButtonAuxOpen->text()==tr("Close"))
|
||
Screen_OnOff_buf_and_send(comboBox_SPortNameAux->currentIndex(),0x11);
|
||
}
|
||
if(groupBox_Network->isChecked())
|
||
{
|
||
Screen_OnOff_buf_and_send_by_udp(0x11);
|
||
}
|
||
}
|
||
void mGuangYingPinWidget::OnScreenOff(void)
|
||
{
|
||
if(groupBox_com->isChecked())
|
||
{
|
||
if(pushButtonMainOpen->text()==tr("Close"))
|
||
Screen_OnOff_buf_and_send(comboBox_SPortName->currentIndex(),0x10);
|
||
if(pushButtonAuxOpen->text()==tr("Close"))
|
||
Screen_OnOff_buf_and_send(comboBox_SPortNameAux->currentIndex(),0x10);
|
||
}
|
||
if(groupBox_Network->isChecked())
|
||
{
|
||
Screen_OnOff_buf_and_send_by_udp(0x10);
|
||
|
||
}
|
||
}
|
||
void mGuangYingPinWidget::OnRefresh()
|
||
{
|
||
bool resetAllComboxFlag=true;
|
||
if(comboBox_SPortName->count()>0)
|
||
resetAllComboxFlag=false;
|
||
// comboBox_SPortName->clear();
|
||
// comboBox_SPortNameAux->clear();
|
||
|
||
sPortThread->SearchPort();
|
||
// for (int m=0;m<sPortThread->portCnt;m++) {
|
||
|
||
// }
|
||
|
||
|
||
for(uint8_t i = 0;i < sPortThread->portCnt;i++)
|
||
{
|
||
bool iHaveFlag=false;
|
||
for(int j=0;j<comboBox_SPortName->count();j++)
|
||
{
|
||
if(comboBox_SPortName->itemText(j)==sPortThread->m_arrSerial[i].portName())
|
||
{
|
||
iHaveFlag=true;
|
||
break;
|
||
}
|
||
}
|
||
if(iHaveFlag==false)
|
||
{
|
||
comboBox_SPortName->addItem(sPortThread->m_arrSerial[i].portName());
|
||
}
|
||
bool iHaveAuxFlag=false;
|
||
for(int jj=0;jj<comboBox_SPortNameAux->count();jj++)
|
||
{
|
||
if(comboBox_SPortNameAux->itemText(jj)==sPortThread->m_arrSerial[i].portName())
|
||
{
|
||
iHaveAuxFlag=true;
|
||
break;
|
||
}
|
||
}
|
||
if(iHaveAuxFlag==false)
|
||
{
|
||
comboBox_SPortNameAux->addItem(sPortThread->m_arrSerial[i].portName());
|
||
if(comboBox_SPortNameAux->count()>1&&pushButtonAuxOpen->text()==tr("Open"))
|
||
{
|
||
comboBox_SPortNameAux->setCurrentIndex(i);
|
||
}
|
||
|
||
}
|
||
// comboBox_SPortName->addItem(sPortThread->m_arrSerial[i].portName());
|
||
// comboBox_SPortNameAux->addItem(sPortThread->m_arrSerial[i].portName());
|
||
}
|
||
|
||
if(resetAllComboxFlag)
|
||
{
|
||
//0:1200 1:2400 2:4800 3:9600 4:19200 5:38400 6:57600 7:115200
|
||
if(comboBox_SPortName->count()>=1)
|
||
{
|
||
comboBox_SPortBaud->setCurrentIndex(3);
|
||
//0:5 1:6 2:7 3:8
|
||
comboBox_SPortDataBit->setCurrentIndex(3);
|
||
//0:no p 2:e p 3:o p 4:s p 5:m p
|
||
comboBox_SPortOEBit->setCurrentIndex(0);
|
||
//0:1 1:2 2:1.5
|
||
comboBox_SPortStopBit->setCurrentIndex(0);
|
||
|
||
graphicsView_ComStatus->setStyleSheet("background-color: rgb(255, 0, 0);");
|
||
label_ComStatus->setText(tr("State:Off"));
|
||
|
||
comboBox_SPortBaudAux->setCurrentIndex(3);
|
||
comboBox_SPortDataBitAux->setCurrentIndex(3);
|
||
comboBox_SPortOEBitAux->setCurrentIndex(0);
|
||
comboBox_SPortStopBitAux->setCurrentIndex(0);
|
||
graphicsView_ComStatusAux->setStyleSheet("background-color: rgb(255, 0, 0);");
|
||
label_ComStatusAux->setText(tr("State:Off"));
|
||
if(comboBox_SPortName->count()>1)
|
||
{
|
||
comboBox_SPortNameAux->setCurrentIndex(1);
|
||
}
|
||
}
|
||
|
||
}
|
||
|
||
}
|
||
void mGuangYingPinWidget::MWOnoffPort(void)
|
||
{
|
||
uint8_t comIndex = comboBox_SPortName->currentIndex();
|
||
|
||
if(pushButtonMainOpen->text()==tr("Open"))
|
||
{
|
||
sPortThread->InitPortName(comIndex,comboBox_SPortName->currentText());
|
||
sPortThread->InitPortBaudRate(comIndex,comboBox_SPortBaud->currentText().toInt());
|
||
|
||
//qDebug()<<comboBox_SPortDataBit->currentIndex();
|
||
switch(comboBox_SPortDataBit->currentIndex())
|
||
{
|
||
case 0: sPortThread->InitPortDataBits(comIndex,QSerialPort::Data5); break;//0:5
|
||
case 1: sPortThread->InitPortDataBits(comIndex,QSerialPort::Data6); break;//1:6
|
||
case 2: sPortThread->InitPortDataBits(comIndex,QSerialPort::Data7); break;//2:7
|
||
case 3: sPortThread->InitPortDataBits(comIndex,QSerialPort::Data8); break;//3:8
|
||
default: break;
|
||
}
|
||
|
||
switch(comboBox_SPortStopBit->currentIndex())
|
||
{
|
||
case 0:sPortThread->InitPortStopBits(comIndex,QSerialPort::OneStop);break;
|
||
case 1:sPortThread->InitPortStopBits(comIndex,QSerialPort::TwoStop);break;
|
||
case 2:sPortThread->InitPortStopBits(comIndex,QSerialPort::OneAndHalfStop);break;
|
||
default: break;
|
||
}
|
||
|
||
switch(comboBox_SPortOEBit->currentIndex())
|
||
{
|
||
case 0:sPortThread->InitPortParity(comIndex,QSerialPort::NoParity);break;
|
||
case 1:sPortThread->InitPortParity(comIndex,QSerialPort::EvenParity);break;
|
||
case 2:sPortThread->InitPortParity(comIndex,QSerialPort::OddParity);break;
|
||
case 3:sPortThread->InitPortParity(comIndex,QSerialPort::SpaceParity);break;
|
||
case 4:sPortThread->InitPortParity(comIndex,QSerialPort::MarkParity);break;
|
||
default: break;
|
||
}
|
||
if(sPortThread->OpenPort(comIndex))
|
||
{
|
||
connect(&(sPortThread->m_arrSerial[comIndex]), SIGNAL(readyRead()), this, SLOT(MWReadData()));
|
||
|
||
//参数设置禁止
|
||
comboBox_SPortName->setEnabled(false);
|
||
comboBox_SPortBaud->setEnabled(false);
|
||
comboBox_SPortDataBit->setEnabled(false);
|
||
comboBox_SPortOEBit->setEnabled(false);
|
||
comboBox_SPortStopBit->setEnabled(false);
|
||
pushButtonMainOpen->setText(tr("Close"));
|
||
//发送设置使能
|
||
graphicsView_ComStatus->setStyleSheet("background-color: rgb(0, 255, 0);");
|
||
label_ComStatus->setText(tr("State:On"));
|
||
}
|
||
else {
|
||
QMessageBox::information(this, tr("Tip"), tr("OpenPort COM failed"));
|
||
}
|
||
|
||
|
||
}
|
||
else
|
||
{
|
||
sPortThread->ClosePort(comIndex);
|
||
//参数设置使能
|
||
comboBox_SPortName->setEnabled(true);
|
||
comboBox_SPortBaud->setEnabled(true);
|
||
comboBox_SPortDataBit->setEnabled(true);
|
||
comboBox_SPortOEBit->setEnabled(true);
|
||
comboBox_SPortStopBit->setEnabled(true);
|
||
pushButtonMainOpen->setText(tr("Open"));
|
||
//发送设置禁止
|
||
graphicsView_ComStatus->setStyleSheet("background-color: rgb(255, 0, 0);");
|
||
label_ComStatus->setText(tr("State:Off"));
|
||
}
|
||
}
|
||
void mGuangYingPinWidget::MWOnoffPortAux(void)
|
||
{
|
||
uint8_t comIndex = comboBox_SPortNameAux->currentIndex();
|
||
|
||
if(pushButtonAuxOpen->text()==tr("Open"))
|
||
{
|
||
sPortThread->InitPortName(comIndex,comboBox_SPortNameAux->currentText());
|
||
sPortThread->InitPortBaudRate(comIndex,comboBox_SPortBaudAux->currentText().toInt());
|
||
|
||
//qDebug()<<comboBox_SPortDataBit->currentIndex();
|
||
switch(comboBox_SPortDataBitAux->currentIndex())
|
||
{
|
||
case 0: sPortThread->InitPortDataBits(comIndex,QSerialPort::Data5); break;//0:5
|
||
case 1: sPortThread->InitPortDataBits(comIndex,QSerialPort::Data6); break;//1:6
|
||
case 2: sPortThread->InitPortDataBits(comIndex,QSerialPort::Data7); break;//2:7
|
||
case 3: sPortThread->InitPortDataBits(comIndex,QSerialPort::Data8); break;//3:8
|
||
default: break;
|
||
}
|
||
|
||
switch(comboBox_SPortStopBitAux->currentIndex())
|
||
{
|
||
case 0:sPortThread->InitPortStopBits(comIndex,QSerialPort::OneStop);break;
|
||
case 1:sPortThread->InitPortStopBits(comIndex,QSerialPort::TwoStop);break;
|
||
case 2:sPortThread->InitPortStopBits(comIndex,QSerialPort::OneAndHalfStop);break;
|
||
default: break;
|
||
}
|
||
|
||
switch(comboBox_SPortOEBitAux->currentIndex())
|
||
{
|
||
case 0:sPortThread->InitPortParity(comIndex,QSerialPort::NoParity);break;
|
||
case 1:sPortThread->InitPortParity(comIndex,QSerialPort::EvenParity);break;
|
||
case 2:sPortThread->InitPortParity(comIndex,QSerialPort::OddParity);break;
|
||
case 3:sPortThread->InitPortParity(comIndex,QSerialPort::SpaceParity);break;
|
||
case 4:sPortThread->InitPortParity(comIndex,QSerialPort::MarkParity);break;
|
||
default: break;
|
||
}
|
||
if(sPortThread->OpenPort(comIndex))
|
||
{
|
||
connect(&(sPortThread->m_arrSerial[comIndex]), SIGNAL(readyRead()), this, SLOT(MWReadDataAux()));
|
||
|
||
//参数设置禁止
|
||
comboBox_SPortNameAux->setEnabled(false);
|
||
comboBox_SPortBaudAux->setEnabled(false);
|
||
comboBox_SPortDataBitAux->setEnabled(false);
|
||
comboBox_SPortOEBitAux->setEnabled(false);
|
||
comboBox_SPortStopBitAux->setEnabled(false);
|
||
pushButtonAuxOpen->setText(tr("Close"));
|
||
//发送设置使能
|
||
graphicsView_ComStatusAux->setStyleSheet("background-color: rgb(0, 255, 0);");
|
||
label_ComStatusAux->setText(tr("State:On"));
|
||
|
||
}
|
||
else {
|
||
QMessageBox::information(this, tr("Tip"), tr("OpenPort COM failed"));
|
||
}
|
||
|
||
}
|
||
else
|
||
{
|
||
sPortThread->ClosePort(comIndex);
|
||
//参数设置使能
|
||
comboBox_SPortNameAux->setEnabled(true);
|
||
comboBox_SPortBaudAux->setEnabled(true);
|
||
comboBox_SPortDataBitAux->setEnabled(true);
|
||
comboBox_SPortOEBitAux->setEnabled(true);
|
||
comboBox_SPortStopBitAux->setEnabled(true);
|
||
pushButtonAuxOpen->setText(tr("Open"));
|
||
//发送设置禁止
|
||
graphicsView_ComStatusAux->setStyleSheet("background-color: rgb(255, 0, 0);");
|
||
label_ComStatusAux->setText(tr("State:Off"));
|
||
}
|
||
}
|
||
void mGuangYingPinWidget::Set_program_buf_and_send(int iComIndex,int iProgramIndex)
|
||
{
|
||
unsigned char uctemp[3]={0};
|
||
uctemp[0]=0x30+iProgramIndex;
|
||
int m_uiResendTimes=lineEdit_ResendTimes->text().toInt();
|
||
int m_uimillisecond=lineEdit_DelayMill->text().toInt();
|
||
unsigned short iDelayTimes=m_uiResendTimes*m_uimillisecond;
|
||
qint64 dwStart;
|
||
qint64 dwStop;
|
||
dwStart = QDateTime::currentMSecsSinceEpoch();
|
||
dwStop=dwStart;
|
||
for(int i=0;i<(int)m_uiResendTimes;i++)
|
||
{
|
||
int itiaozheng=dwStop-dwStart-m_uimillisecond;//时间发送间隔和参数发送间隔的差异
|
||
if(itiaozheng<0)
|
||
itiaozheng=0;
|
||
unsigned short itemp=(iDelayTimes-i*m_uimillisecond)-itiaozheng;//补充差异,比如实际用了110毫秒,参数100毫秒,则发送过去的协议数据应该是让控制卡减少延时,所以在延时值上再减去补差
|
||
if(itemp<0)
|
||
itemp=0;
|
||
dwStart=dwStop;
|
||
memcpy(&uctemp[1],(unsigned char *)&itemp,2*sizeof(unsigned char));
|
||
MWSendCmd(iComIndex,0x42,uctemp,3,g_iCountCmd);
|
||
|
||
|
||
int itempDelay=0;
|
||
if(itiaozheng>0)
|
||
itempDelay=m_uimillisecond-itiaozheng;
|
||
else
|
||
itempDelay=m_uimillisecond;
|
||
mymidelay(itempDelay);
|
||
dwStop = QDateTime::currentMSecsSinceEpoch();
|
||
if(checkBoxDebug->isChecked())
|
||
{
|
||
textEditReadBuf->append("dwStart="+QString::number(dwStart)+",dwStop="+QString::number(dwStop)+",dwStop-dwStart="+QString::number(dwStop-dwStart)+",Delay="+QString::number(itempDelay)+",buf delay value="+QString::number(itemp)+"\r\n");
|
||
}
|
||
}
|
||
g_iCountCmd++;
|
||
|
||
}
|
||
void mGuangYingPinWidget::Set_program_buf_and_send_by_udp(int iProgramIndex)
|
||
{
|
||
unsigned char uctemp[3]={0};
|
||
uctemp[0]=0x30+iProgramIndex;
|
||
int m_uiResendTimes=lineEdit_ResendTimes->text().toInt();
|
||
int m_uimillisecond=lineEdit_DelayMill->text().toInt();
|
||
unsigned short iDelayTimes=m_uiResendTimes*m_uimillisecond;
|
||
qint64 dwStart;
|
||
qint64 dwStop;
|
||
dwStart = QDateTime::currentMSecsSinceEpoch();
|
||
dwStop=dwStart;
|
||
for(int i=0;i<(int)m_uiResendTimes;i++)
|
||
{
|
||
int itiaozheng=dwStop-dwStart-m_uimillisecond;//时间发送间隔和参数发送间隔的差异
|
||
if(itiaozheng<0)
|
||
itiaozheng=0;
|
||
unsigned short itemp=(iDelayTimes-i*m_uimillisecond)-itiaozheng;//补充差异,比如实际用了110毫秒,参数100毫秒,则发送过去的协议数据应该是让控制卡减少延时,所以在延时值上再减去补差
|
||
if(itemp<0)
|
||
itemp=0;
|
||
dwStart=dwStop;
|
||
memcpy(&uctemp[1],(unsigned char *)&itemp,2*sizeof(unsigned char));
|
||
MWSendCmdByUdp(0x42,uctemp,3,g_iCountCmd);
|
||
|
||
|
||
int itempDelay=0;
|
||
if(itiaozheng>0)
|
||
itempDelay=m_uimillisecond-itiaozheng;
|
||
else
|
||
itempDelay=m_uimillisecond;
|
||
mymidelay(itempDelay);
|
||
dwStop = QDateTime::currentMSecsSinceEpoch();
|
||
if(checkBoxDebug->isChecked())
|
||
{
|
||
textEditReadBuf->append("dwStart="+QString::number(dwStart)+",dwStop="+QString::number(dwStop)+",dwStop-dwStart="+QString::number(dwStop-dwStart)+",Delay="+QString::number(itempDelay)+",buf delay value="+QString::number(itemp)+"\r\n");
|
||
}
|
||
}
|
||
g_iCountCmd++;
|
||
|
||
}
|
||
void mGuangYingPinWidget::Set_Brightness_buf_and_send(int iComIndex,int iBrightnessValue)
|
||
{
|
||
unsigned char uctemp[2]={0};
|
||
uctemp[0]=0xF1;
|
||
uctemp[1]=iBrightnessValue;
|
||
int m_uiResendTimes=lineEdit_ResendTimes->text().toInt();
|
||
int m_uimillisecond=lineEdit_DelayMill->text().toInt();
|
||
for(int i=0;i<(int)m_uiResendTimes;i++)
|
||
{
|
||
MWSendCmd(iComIndex,0x42,uctemp,2,g_iCountCmd);
|
||
if(checkBoxDebug->isChecked())
|
||
{
|
||
textEditReadBuf->append("SetBrightNess="+QString::number(iBrightnessValue));
|
||
}
|
||
mymidelay(m_uimillisecond);
|
||
}
|
||
}
|
||
void mGuangYingPinWidget::Set_Brightness_buf_and_send_by_udp(int iBrightnessValue)
|
||
{
|
||
unsigned char uctemp[2]={0};
|
||
uctemp[0]=0xF1;
|
||
uctemp[1]=iBrightnessValue;
|
||
int m_uiResendTimes=lineEdit_ResendTimes->text().toInt();
|
||
int m_uimillisecond=lineEdit_DelayMill->text().toInt();
|
||
for(int i=0;i<(int)m_uiResendTimes;i++)
|
||
{
|
||
MWSendCmdByUdp(0x42,uctemp,2,g_iCountCmd);
|
||
if(checkBoxDebug->isChecked())
|
||
{
|
||
textEditReadBuf->append("SetBrightNess="+QString::number(iBrightnessValue));
|
||
}
|
||
mymidelay(m_uimillisecond);
|
||
}
|
||
}
|
||
void mGuangYingPinWidget::Screen_OnOff_buf_and_send(int iComIndex,int iScreenOnOff)
|
||
{
|
||
unsigned char uctemp[3]={0};
|
||
uctemp[0]=iScreenOnOff;
|
||
uctemp[1]=0;
|
||
uctemp[2]=0;
|
||
int m_uiResendTimes=lineEdit_ResendTimes->text().toInt();
|
||
int m_uimillisecond=lineEdit_DelayMill->text().toInt();
|
||
for(int i=0;i<(int)m_uiResendTimes;i++)
|
||
{
|
||
MWSendCmd(iComIndex,0x42,uctemp,3,g_iCountCmd);
|
||
if(checkBoxDebug->isChecked())
|
||
{
|
||
if(iScreenOnOff==0x11)
|
||
textEditReadBuf->append("Screen On");
|
||
else
|
||
textEditReadBuf->append("Screen Off");
|
||
}
|
||
mymidelay(m_uimillisecond);
|
||
}
|
||
}
|
||
void mGuangYingPinWidget::Screen_OnOff_buf_and_send_by_udp(int iScreenOnOff)
|
||
{
|
||
unsigned char uctemp[3]={0};
|
||
uctemp[0]=iScreenOnOff;
|
||
uctemp[1]=0;
|
||
uctemp[2]=0;
|
||
int m_uiResendTimes=lineEdit_ResendTimes->text().toInt();
|
||
int m_uimillisecond=lineEdit_DelayMill->text().toInt();
|
||
for(int i=0;i<(int)m_uiResendTimes;i++)
|
||
{
|
||
MWSendCmdByUdp(0x42,uctemp,3,g_iCountCmd);
|
||
if(checkBoxDebug->isChecked())
|
||
{
|
||
if(iScreenOnOff==0x11)
|
||
textEditReadBuf->append("Screen On");
|
||
else
|
||
textEditReadBuf->append("Screen Off");
|
||
}
|
||
mymidelay(m_uimillisecond);
|
||
}
|
||
}
|
||
void mGuangYingPinWidget::NextProgram_buf_and_send(int iComIndex)
|
||
{
|
||
unsigned char uctemp[1]={0};
|
||
uctemp[0]=0xF3;
|
||
int m_uiResendTimes=lineEdit_ResendTimes->text().toInt();
|
||
int m_uimillisecond=lineEdit_DelayMill->text().toInt();
|
||
for(int i=0;i<(int)m_uiResendTimes;i++)
|
||
{
|
||
MWSendCmd(iComIndex,0x42,uctemp,1,g_iCountCmd);
|
||
if(checkBoxDebug->isChecked())
|
||
{
|
||
textEditReadBuf->append("Next Program");
|
||
}
|
||
mymidelay(m_uimillisecond);
|
||
}
|
||
}
|
||
void mGuangYingPinWidget::NextProgram_buf_and_send_by_udp()
|
||
{
|
||
unsigned char uctemp[1]={0};
|
||
uctemp[0]=0xF3;
|
||
int m_uiResendTimes=lineEdit_ResendTimes->text().toInt();
|
||
int m_uimillisecond=lineEdit_DelayMill->text().toInt();
|
||
for(int i=0;i<(int)m_uiResendTimes;i++)
|
||
{
|
||
MWSendCmdByUdp(0x42,uctemp,1,g_iCountCmd);
|
||
if(checkBoxDebug->isChecked())
|
||
{
|
||
textEditReadBuf->append("Next Program");
|
||
}
|
||
mymidelay(m_uimillisecond);
|
||
}
|
||
}
|
||
void mGuangYingPinWidget::mymidelay(int imlsec)
|
||
{
|
||
qint64 dwStart, dwStop;
|
||
dwStart = QDateTime::currentMSecsSinceEpoch();
|
||
do{
|
||
dwStop = QDateTime::currentMSecsSinceEpoch();
|
||
} while(dwStop-imlsec<dwStart);
|
||
}
|
||
|
||
void mGuangYingPinWidget::MWSendCmdByUdp(unsigned char cmd,unsigned char *pUcValue,unsigned int iLength,int iCountCmd)
|
||
{
|
||
ST_ANSY_PROGRAM_PACKET tempStreadPakcet;
|
||
tempStreadPakcet.SyncHead[0]=0x7e;
|
||
tempStreadPakcet.SyncHead[1]=0x7e;
|
||
tempStreadPakcet.SyncHead[2]=0x55;
|
||
tempStreadPakcet.ucCommType=cmd;
|
||
tempStreadPakcet.iBaoLiu=iCountCmd;
|
||
tempStreadPakcet.iLength=iLength;
|
||
memcpy(tempStreadPakcet.pDataBuffer,pUcValue,iLength);
|
||
tempStreadPakcet.pDataBuffer[tempStreadPakcet.iLength]=GetCheckCodeIn8(&tempStreadPakcet.ucCommType,tempStreadPakcet.iLength+sizeof(tempStreadPakcet.iBaoLiu)+sizeof(tempStreadPakcet.ucCommType)+sizeof(tempStreadPakcet.iLength));
|
||
int iLenPacket=3*sizeof(unsigned char)+sizeof(char)+sizeof(int)+sizeof(int)+tempStreadPakcet.iLength+sizeof(char);/////除正文外的协议结构大小;
|
||
QByteArray databuf = QByteArray(reinterpret_cast<char*>(&tempStreadPakcet), iLenPacket);
|
||
//sPortThread->SendDataBuf(iComIndex,databuf);
|
||
|
||
|
||
QList<QNetworkInterface> networkinterfaces = QNetworkInterface::allInterfaces();
|
||
foreach (QNetworkInterface interfaces, networkinterfaces) //networkinterfaces负责提供主机的IP地址和网络接口的列表
|
||
{
|
||
foreach (QNetworkAddressEntry entry, interfaces.addressEntries())//QNetworkAddressEntry存储了一个IP地址,子网掩码和广播地址
|
||
{
|
||
QHostAddress broadcastAddress("255.255.255.255");
|
||
entry.setBroadcast(QHostAddress::Broadcast);
|
||
QUdpSocket *tempUdpSocket= new QUdpSocket(this);
|
||
if(!tempUdpSocket->bind(entry.ip()))
|
||
break;
|
||
int iSendLength=tempUdpSocket->writeDatagram((char *)&tempStreadPakcet,iLenPacket,broadcastAddress,31296);
|
||
if(iSendLength != iLenPacket) {
|
||
char *aa=reinterpret_cast<char*>(&tempStreadPakcet);
|
||
tempUdpSocket->writeDatagram(&aa[iSendLength],iLenPacket-iSendLength,broadcastAddress,31296);
|
||
}
|
||
delete tempUdpSocket;
|
||
}
|
||
}
|
||
if(checkBoxDebug->isChecked()) {
|
||
textEditReadBuf->append("udp:"+tr(databuf.toHex()));
|
||
}
|
||
}
|
||
void mGuangYingPinWidget::MWSendCmd(uint8_t iComIndex,unsigned char cmd,unsigned char *pUcValue,unsigned int iLength,int iCountCmd)
|
||
{
|
||
ST_ANSY_PROGRAM_PACKET tempStreadPakcet;
|
||
tempStreadPakcet.SyncHead[0]=0x7e;
|
||
tempStreadPakcet.SyncHead[1]=0x7e;
|
||
tempStreadPakcet.SyncHead[2]=0x55;
|
||
tempStreadPakcet.ucCommType=cmd;
|
||
tempStreadPakcet.iBaoLiu=iCountCmd;
|
||
tempStreadPakcet.iLength=iLength;
|
||
memcpy(tempStreadPakcet.pDataBuffer,pUcValue,iLength);
|
||
tempStreadPakcet.pDataBuffer[tempStreadPakcet.iLength]=GetCheckCodeIn8(&tempStreadPakcet.ucCommType,tempStreadPakcet.iLength+sizeof(tempStreadPakcet.iBaoLiu)+sizeof(tempStreadPakcet.ucCommType)+sizeof(tempStreadPakcet.iLength));
|
||
int iLenPacket=3*sizeof(unsigned char)+sizeof(char)+sizeof(int)+sizeof(int)+tempStreadPakcet.iLength+sizeof(char);/////除正文外的协议结构大小;
|
||
QByteArray databuf = QByteArray(reinterpret_cast<char*>(&tempStreadPakcet), iLenPacket);
|
||
sPortThread->SendDataBuf(iComIndex,databuf);
|
||
if(checkBoxDebug->isChecked())
|
||
{
|
||
textEditReadBuf->append("com:"+tr(databuf.toHex()));
|
||
}
|
||
//sPortThread->SendDataBuf(comboBox_SPortName->currentIndex(),textEdit->toPlainText().toLatin1());
|
||
// m_sendNum += (textEdit->toPlainText().toLatin1()).length();
|
||
// MWRSNumDisplay();
|
||
}
|
||
|
||
void mGuangYingPinWidget::MWReadData(void)
|
||
{
|
||
QByteArray buf;
|
||
buf = sPortThread->GetDataBuf(comboBox_SPortName->currentIndex());
|
||
if(!buf.isEmpty())
|
||
{
|
||
QString str = tr(buf.toHex());
|
||
if(checkBoxDebug->isChecked())
|
||
{
|
||
textEditReadBuf->moveCursor(QTextCursor::End);
|
||
textEditReadBuf->insertPlainText(str);
|
||
}
|
||
MWRSNumDisplay();
|
||
}
|
||
buf.clear();
|
||
}
|
||
void mGuangYingPinWidget::MWReadDataAux(void)
|
||
{
|
||
QByteArray buf;
|
||
buf = sPortThread->GetDataBuf(comboBox_SPortNameAux->currentIndex());
|
||
if(!buf.isEmpty())
|
||
{
|
||
QString str = tr(buf.toHex());
|
||
if(checkBoxDebug->isChecked())
|
||
{
|
||
textEditReadBuf->moveCursor(QTextCursor::End);
|
||
textEditReadBuf->insertPlainText(str);
|
||
}
|
||
MWRSNumDisplay();
|
||
}
|
||
buf.clear();
|
||
}
|
||
QString mGuangYingPinWidget::ByteArrayToHexString(QByteArray &ba)
|
||
{
|
||
QDataStream out(&ba,QIODevice::ReadWrite); //将str的数据 读到out里面去
|
||
QString buf;
|
||
while(!out.atEnd())
|
||
{
|
||
qint8 outChar = 0;
|
||
out >> outChar; //每次一个字节的填充到 outchar
|
||
QString str = QString("%1").arg(outChar&0xFF,2,16,QLatin1Char('0')).toUpper() + QString(" "); //2 字符宽度
|
||
buf += str;
|
||
}
|
||
return buf;
|
||
}
|
||
void mGuangYingPinWidget::MWClearRecv(void)
|
||
{
|
||
// textBrowser->clear();
|
||
// m_recvNum = 0;
|
||
// m_sendNum = 0;
|
||
// MWRSNumDisplay();
|
||
}
|
||
|
||
void mGuangYingPinWidget::MWRSNumDisplay(void)
|
||
{
|
||
// label_RecvNum->setText(tr("已接收:") + QString::number(m_recvNum,10));
|
||
// label_SendNum->setText(tr("已发送:") + QString::number(m_sendNum,10));
|
||
}
|
||
|
||
|
||
|
||
TA_SerialThread::TA_SerialThread() {
|
||
portCnt = 0;
|
||
portNewCnt=0;
|
||
m_arrSerial = new QSerialPort[10];
|
||
m_arrNewSerial=new QSerialPortInfo[10];
|
||
}
|
||
|
||
void TA_SerialThread::SearchPort(void) {
|
||
portNewCnt=0;
|
||
//查找可用的串口
|
||
foreach(const QSerialPortInfo &info, QSerialPortInfo::availablePorts()) {
|
||
if(portNewCnt > 9) break;
|
||
m_arrNewSerial[portNewCnt]=info;
|
||
portNewCnt++;
|
||
}
|
||
|
||
for (int i=0;i<portNewCnt;i++) {
|
||
bool iHaveFlag=false;
|
||
for(int j=0;j<portCnt;j++)
|
||
{
|
||
if(m_arrSerial[j].portName()==m_arrNewSerial[i].portName())
|
||
{
|
||
iHaveFlag=true;
|
||
break;
|
||
}
|
||
}
|
||
if(!iHaveFlag) {
|
||
m_arrSerial[portCnt].setPort(m_arrNewSerial[i]);
|
||
portCnt++;
|
||
}
|
||
}
|
||
}
|
||
|
||
void TA_SerialThread::InitPortName(uint8_t portIndex,const QString &portName)
|
||
{
|
||
if(portIndex < portCnt)
|
||
m_arrSerial[portIndex].setPortName(portName);//const QString &name
|
||
else
|
||
qDebug()<<"OpenPort port index is out of range!";
|
||
}
|
||
|
||
void TA_SerialThread::InitPortBaudRate(uint8_t portIndex,qint32 baudRate)
|
||
{
|
||
if(portIndex < portCnt)
|
||
m_arrSerial[portIndex].setBaudRate(baudRate);//BaudRate baudRate
|
||
else
|
||
qDebug()<<"OpenPort port index is out of range!";
|
||
}
|
||
|
||
void TA_SerialThread::InitPortDataBits(uint8_t portIndex,QSerialPort::DataBits dataBits)
|
||
{
|
||
if(portIndex < portCnt)
|
||
m_arrSerial[portIndex].setDataBits(dataBits);//DataBits dataBits
|
||
else
|
||
qDebug()<<"OpenPort port index is out of range!";
|
||
}
|
||
|
||
void TA_SerialThread::InitPortParity(uint8_t portIndex,QSerialPort::Parity parity)
|
||
{
|
||
if(portIndex < portCnt)
|
||
m_arrSerial[portIndex].setParity(parity);//Parity parity
|
||
else
|
||
qDebug()<<"OpenPort port index is out of range!";
|
||
}
|
||
|
||
void TA_SerialThread::InitPortStopBits(uint8_t portIndex,QSerialPort::StopBits stopBits)
|
||
{
|
||
if(portIndex < portCnt)
|
||
{
|
||
m_arrSerial[portIndex].setStopBits(stopBits);//StopBits stopBits
|
||
m_arrSerial[portIndex].setFlowControl(QSerialPort::NoFlowControl);
|
||
}
|
||
else
|
||
qDebug()<<"OpenPort port index is out of range!";
|
||
}
|
||
|
||
bool TA_SerialThread::OpenPort(uint8_t portIndex)
|
||
{
|
||
bool result=false;
|
||
if(portIndex < portCnt)
|
||
result=m_arrSerial[portIndex].open(QIODevice::ReadWrite);
|
||
else
|
||
qDebug()<<"OpenPort port index is out of range!";
|
||
return result;
|
||
}
|
||
|
||
void TA_SerialThread::ClosePort(uint8_t portIndex)
|
||
{
|
||
if(portIndex < portCnt)
|
||
{
|
||
//关闭串口
|
||
m_arrSerial[portIndex].clear();
|
||
m_arrSerial[portIndex].close();
|
||
//m_arrSerial[portIndex].deleteLater();
|
||
}
|
||
else
|
||
qDebug()<<"OpenPort port index is out of range!";
|
||
}
|
||
|
||
void TA_SerialThread::SendDataBuf(uint8_t portIndex,const QByteArray &str)
|
||
{
|
||
if(portIndex < portCnt)
|
||
{
|
||
m_arrSerial[portIndex].write(str);
|
||
qDebug()<<str;
|
||
}
|
||
else
|
||
qDebug()<<"SendDataBuf port index is out of range!";
|
||
}
|
||
|
||
QByteArray TA_SerialThread::GetDataBuf(uint8_t portIndex) {
|
||
if(portIndex < portCnt) return m_arrSerial[portIndex].readAll();
|
||
else {
|
||
qDebug()<<"GetDataBuf port index is out of range!";
|
||
return nullptr;
|
||
}
|
||
}
|