66 lines
1.5 KiB
C++
66 lines
1.5 KiB
C++
#ifndef MODBUSTCP_H
|
|
#define MODBUSTCP_H
|
|
#include <QThread>
|
|
//#include <QObject>
|
|
#include "../SysPara.h"
|
|
#include <stdint.h>
|
|
#include <QMutex>
|
|
#include <QTcpServer>
|
|
#include "myinclude.h"
|
|
|
|
#define PRINT_START_COMMAND 0x01
|
|
#define PRINT_PAUSE_COMMAND 0x02
|
|
#define PRINT_STOP_COMMAND 0x03
|
|
enum {
|
|
TCP,
|
|
TCP_PI,
|
|
RTU
|
|
};
|
|
enum ThreadState
|
|
{
|
|
STOPPED,
|
|
RUNNING,
|
|
SHUTDOWN
|
|
};
|
|
class ModbusTcp:public QObject
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
ModbusTcp(ModbusPrintParas *mPara, const ModbusPrintStatus* mStatus);
|
|
~ModbusTcp();
|
|
|
|
uint16_t* input_registers;
|
|
uint16_t* holding_registers;
|
|
uint8_t modbus_up_QRCODE;
|
|
// QThread m_thread;
|
|
enum ThreadState ePollThreadState;
|
|
enum ThreadState eGetPollingThreadState();
|
|
void eSetPollingThreadState( enum ThreadState eNewState );
|
|
qint32 getModbusStatus();
|
|
qint32 processCommands(qint32 index);
|
|
|
|
Q_SIGNALS:
|
|
void startPrint();
|
|
void pausePrint();
|
|
void stopPrint();
|
|
void openFile(QString,bool);
|
|
void faultResume();
|
|
void writeCalendar();
|
|
void mbLineAndCharSpace(int lineSpace, int charSpace);
|
|
void updateQRcode();
|
|
void writeCalendar1();
|
|
void writeCalendar1EndValue();
|
|
void writeCalendar2EndValue();
|
|
void writeCalendar2RepeatValue();
|
|
void writeCalendar2InitValue();
|
|
void CNTResetNow();
|
|
|
|
public slots:
|
|
void pvPollingThread();
|
|
private:
|
|
qint32 modbus_status;
|
|
QMutex modbusThreadMutex;
|
|
};
|
|
|
|
#endif // MODBUSTCP_H
|