177 lines
6.1 KiB
C++
177 lines
6.1 KiB
C++
#ifndef MGUANGYINGPINWIDGET_H
|
|
#define MGUANGYINGPINWIDGET_H
|
|
|
|
#include <QUdpSocket>
|
|
#include <QNetworkInterface>
|
|
#include <QtSerialPort/QSerialPort>
|
|
|
|
#include <QtWidgets/QCheckBox>
|
|
#include <QtWidgets/QComboBox>
|
|
#include <QtWidgets/QFrame>
|
|
#include <QtWidgets/QGraphicsView>
|
|
#include <QtWidgets/QGroupBox>
|
|
#include <QtWidgets/QHBoxLayout>
|
|
#include <QtWidgets/QLabel>
|
|
#include <QtWidgets/QLineEdit>
|
|
#include <QtWidgets/QPushButton>
|
|
#include <QtWidgets/QSpacerItem>
|
|
#include <QtWidgets/QSpinBox>
|
|
#include <QtWidgets/QTextEdit>
|
|
#include <QtWidgets/QVBoxLayout>
|
|
|
|
class TA_SerialThread {
|
|
public:
|
|
TA_SerialThread();
|
|
uint8_t portCnt;
|
|
uint8_t portNewCnt;
|
|
QSerialPort *m_arrSerial;//ptr point to an array,maxium port num is 5
|
|
QSerialPortInfo *m_arrNewSerial;//ptr point to an array,maxium port num is 5
|
|
|
|
void SearchPort(void);
|
|
void InitPortName(uint8_t portIndex,const QString &portName);
|
|
void InitPortBaudRate(uint8_t portIndex,qint32 baudRate);
|
|
void InitPortDataBits(uint8_t portIndex,QSerialPort::DataBits dataBits);
|
|
void InitPortParity(uint8_t portIndex,QSerialPort::Parity parity);
|
|
void InitPortStopBits(uint8_t portIndex,QSerialPort::StopBits stopBits);
|
|
bool OpenPort(uint8_t portIndex);
|
|
void ClosePort(uint8_t portIndex);
|
|
void SendDataBuf(uint8_t portIndex,const QByteArray &str);
|
|
QByteArray GetDataBuf(uint8_t portIndex);
|
|
};
|
|
|
|
class mGuangYingPinWidget : public QWidget {
|
|
Q_OBJECT
|
|
public:
|
|
explicit mGuangYingPinWidget(QWidget *parent = nullptr);
|
|
protected:
|
|
void changeEvent(QEvent *) override;
|
|
void transUi();
|
|
public slots:
|
|
void MWOnoffPort(void);
|
|
void MWOnoffPortAux(void);
|
|
void MWSendCmd(uint8_t iComIndex,unsigned char cmd,unsigned char *pUcValue,unsigned int iLength,int iCountCmd);
|
|
void MWSendCmdByUdp(unsigned char cmd,unsigned char *pUcValue,unsigned int iLength,int iCountCmd);
|
|
|
|
void MWReadData(void);
|
|
void MWReadDataAux(void);
|
|
void MWClearRecv(void);
|
|
void MWRSNumDisplay(void);
|
|
void OnClearLog(void);
|
|
void OnAnsyProgramCustom(void);
|
|
void OnAnsyProgramNext(void);
|
|
void OnAnsyProgramPrevious(void);
|
|
void OnBrightnessSet(void);
|
|
void OnScreenOn(void);
|
|
void OnScreenOff(void);
|
|
void OnAnsyProgramCustomByChanged(int icurIndex);
|
|
void OnBrightnessSetByChanged(int icurValue);
|
|
void OnRefresh(void);
|
|
private:
|
|
TA_SerialThread *sPortThread;
|
|
volatile uint32_t m_recvNum;
|
|
volatile uint32_t m_sendNum;
|
|
int g_iCountCmd=0;
|
|
int m_port=31296;
|
|
void Set_program_buf_and_send(int iComIndex,int iProgramIndex);
|
|
void Set_program_buf_and_send_by_udp(int iProgramIndex);
|
|
void Set_Brightness_buf_and_send(int iComIndex,int iBrightnessValue);
|
|
void Set_Brightness_buf_and_send_by_udp(int iBrightnessValue);
|
|
void Screen_OnOff_buf_and_send(int iComIndex,int iScreenOnOff);
|
|
void Screen_OnOff_buf_and_send_by_udp(int iScreenOnOff);
|
|
void NextProgram_buf_and_send(int iComIndex);
|
|
void NextProgram_buf_and_send_by_udp();
|
|
|
|
|
|
void mymidelay(int imlsec);
|
|
QString ByteArrayToHexString(QByteArray &ba);
|
|
|
|
QGroupBox *groupBox_com;
|
|
QHBoxLayout *horizontalLayout_29;
|
|
QVBoxLayout *verticalLayout_2;
|
|
QGroupBox *groupBoxMain;
|
|
QVBoxLayout *verticalLayout_6;
|
|
QHBoxLayout *horizontalLayout_6;
|
|
QLabel *label_PortName;
|
|
QComboBox *comboBox_SPortName;
|
|
QHBoxLayout *horizontalLayout_9;
|
|
QLabel *label_BaudRate;
|
|
QComboBox *comboBox_SPortBaud;
|
|
QHBoxLayout *horizontalLayout_15;
|
|
QLabel *label_DataBit;
|
|
QComboBox *comboBox_SPortDataBit;
|
|
QHBoxLayout *horizontalLayout_17;
|
|
QLabel *label_OEBit;
|
|
QComboBox *comboBox_SPortOEBit;
|
|
QHBoxLayout *horizontalLayout_18;
|
|
QLabel *label_StopBit;
|
|
QComboBox *comboBox_SPortStopBit;
|
|
QHBoxLayout *horizontalLayout_22;
|
|
QLabel *label_ComStatus;
|
|
QGraphicsView *graphicsView_ComStatus;
|
|
QHBoxLayout *horizontalLayout_4;
|
|
QPushButton *pushButtonMainOpen;
|
|
QVBoxLayout *verticalLayout_3;
|
|
QGroupBox *groupBoxAux;
|
|
QVBoxLayout *verticalLayout_8;
|
|
QHBoxLayout *horizontalLayout_7;
|
|
QLabel *label_PortNameAux;
|
|
QComboBox *comboBox_SPortNameAux;
|
|
QHBoxLayout *horizontalLayout_24;
|
|
QLabel *label_BaudRateAux;
|
|
QComboBox *comboBox_SPortBaudAux;
|
|
QHBoxLayout *horizontalLayout_25;
|
|
QLabel *label_DataBitAux;
|
|
QComboBox *comboBox_SPortDataBitAux;
|
|
QHBoxLayout *horizontalLayout_26;
|
|
QLabel *label_OEBitAux;
|
|
QComboBox *comboBox_SPortOEBitAux;
|
|
QHBoxLayout *horizontalLayout_27;
|
|
QLabel *label_StopBitAux;
|
|
QComboBox *comboBox_SPortStopBitAux;
|
|
QHBoxLayout *horizontalLayout_28;
|
|
QLabel *label_ComStatusAux;
|
|
QGraphicsView *graphicsView_ComStatusAux;
|
|
QHBoxLayout *horizontalLayout_5;
|
|
QPushButton *pushButtonAuxOpen;
|
|
QPushButton *pushButtonRefresh;
|
|
QGroupBox *groupBox_Network;
|
|
QSpacerItem *horizontalSpacer;
|
|
QVBoxLayout *verticalLayout_9;
|
|
QGroupBox *groupBoxParam;
|
|
QVBoxLayout *verticalLayout_10;
|
|
QHBoxLayout *horizontalLayout_20;
|
|
QLabel *label_ResendTimes;
|
|
QLineEdit *lineEdit_ResendTimes;
|
|
QHBoxLayout *horizontalLayout_23;
|
|
QLabel *label_DelayMill;
|
|
QLineEdit *lineEdit_DelayMill;
|
|
QSpacerItem *verticalSpacer;
|
|
QSpacerItem *horizontalSpacer_2;
|
|
QVBoxLayout *verticalLayout_4;
|
|
QHBoxLayout *horizontalLayout_14;
|
|
|
|
QVBoxLayout *verticalLayout_7;
|
|
QHBoxLayout *horizontalLayout_19;
|
|
QLabel *label_ProgramNum;
|
|
QSpinBox *spinBox_ProgramIndex;
|
|
QPushButton *pushButtonSend;
|
|
QSpacerItem *horizontalSpacer_7;
|
|
QHBoxLayout *horizontalLayout_21;
|
|
QLabel *label_BrightNess;
|
|
QSpinBox *spinBox_BrightnessValue;
|
|
QPushButton *pushButtonBrightnessSet;
|
|
QPushButton *pushButtonScreenOff;
|
|
QPushButton *pushButtonScreenOn;
|
|
QSpacerItem *horizontalSpacer_18;
|
|
QSpacerItem *verticalSpacer_2;
|
|
QHBoxLayout *horizontalLayout_2;
|
|
QSpacerItem *horizontalSpacer_3;
|
|
QPushButton *pushButtonClearLog;
|
|
QCheckBox *checkBoxDebug;
|
|
QHBoxLayout *horizontalLayout_3;
|
|
QHBoxLayout *horizontalLayout_8;
|
|
QTextEdit *textEditReadBuf;
|
|
};
|
|
|
|
#endif // MGUANGYINGPINWIDGET_H
|