代码拉取完成,页面将自动刷新
同步操作将从 tinnu/EXC_Screen_Modbus_Server 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
#ifndef MODBUSUI_H
#define MODBUSUI_H
#include "ui_modbusui.h"
#include <QMainWindow>
#include <QThread>
#include <QSpinBox>
#include <QTimer>
#include <QModbusDataUnit>
#include <sys/time.h>
#include <QVector>
#include <QQueue>
#include <QMetaType>
#include <QVariant>
#include <QLocalServer>
#include <QLocalSocket>
//#define _MODBUS_DEBUG_PRINT_
#define _MODBUS_DISPLAY
#define _MODBUS_START_ADDR_ 0x63
#define _MODBUS_DATA_SIZE_ 0x60
#define _MODBUS_END_ADDR_ _MODBUS_START_ADDR_+_MODBUS_DATA_SIZE_
#define _MODBUS_READ_STEP 0x60
class QModbusClient;
class ModbusInterface;
class ModbusThread;
struct _modbusWorkStruct{
bool readOrNot;
int addr;
int delayTime;
quint16 amount; //read
QVector <quint16> vec; //write
};
QT_BEGIN_NAMESPACE
namespace Ui { class ModbusUI; }
QT_END_NAMESPACE
class ModbusUI : public QMainWindow
{
Q_OBJECT
public:
ModbusUI(QWidget *parent = nullptr);
~ModbusUI();
public slots:
//向上接口
// void SL_writeImpulse(int addr);
// void SL_writeData(int addr, quint16 data);
signals:
//向上接口
// void SN_readFinsih(QVector<quint16>);
//向下接口
void SN_modbusConnect(QString comText);
void SN_modbusRead(int addr, quint16 amount, int delayTime);
void SN_modbusWrite(int addr, quint16 data, int delayTime);
void SN_modbusWriteArray(int addr, QVector<quint16> data, int delayTime);
private:
Ui::ModbusUI *ui;
//modbus
ModbusInterface * m_modbusInterface;
ModbusThread *m_modbusThread;
//timer
QTimer *m_readPeriodTimer;
QTimer *m_delayTimer1, *m_delayTimer2;
bool m_writeLastFlag;
//LocalServer
QLocalServer *m_server;
QLocalSocket *m_clientConnection;
void startPeriodTimer();
void stopPeriodTimer();
//专门为reg的地址提供355(0x163)的数据转化
inline void ModbusReadReg(int addr, quint16 amount, int delayTime){
SN_modbusRead(addr+355, amount, delayTime);}
private slots:
void on_btn_scan_clicked();
void on_btn_impulse_clicked();
void on_btn_writetest_clicked();
void on_btn_readGroup_clicked();
void on_btn_readtest_clicked();
void on_sb_stationNum_valueChanged(int arg1);
void on_btn_startTimer_clicked();
//localserver slot
void on_btn_socketConnect_clicked();
void on_btn_connect_com_clicked();
void on_btn_connect_tcp_clicked();
void on_tabWidget_currentChanged(int index);
// void on_checkBox_stateChanged(int arg1);
void on_cb_displaymsg_stateChanged(int arg1);
void on_sb_delay_read_valueChanged(int arg1);
void on_sb_delay_write_valueChanged(int arg1);
void on_sb_modserverperiod_valueChanged(int arg1);
};
class ModbusInterface: public QThread
{
Q_OBJECT
public:
ModbusInterface();
~ModbusInterface();
int m_stationNum;
QQueue<struct _modbusWorkStruct> m_queueModbusWork;
QModbusClient *modbusDevice;
public slots:
void SL_modbusRead(int addr, quint16 amount, int delayTime);
void SL_modbusWrite(int addr, quint16 data, int delayTime);
void SL_modbusWriteArray(int addr, QVector<quint16> data, int delayTime);
signals:
void SN_readFinsih(QByteArray);
void SN_queuePop();
void SN_queuePush();
//1-ui->pte_readText; 2-ui->pte_readText2; 3-ui->statusBar;
void SN_printMsg(int, QString);
//1-ProtocolError; 2-other error
void SN_modbusError(int);
private:
QTimer *m_timerModbusDelay;
QVector<quint16> m_vecReadBuf;
bool m_flagModbusWork;
QByteArray m_byteArraySendData;
void modbusStart();
};
#endif // MODBUSUI_H
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。