70 lines
1.5 KiB
C++
70 lines
1.5 KiB
C++
#ifndef MODBUSSERIAL_H
|
|
#define MODBUSSERIAL_H
|
|
#include <QThread>
|
|
//#include <QObject>
|
|
#include "../SysPara.h"
|
|
#include <stdint.h>
|
|
#include <QMutex>
|
|
#include <QTimer>
|
|
//#include <QTcpServer>
|
|
|
|
#define PRINT_START_COMMAND 0x01
|
|
#define PRINT_PAUSE_COMMAND 0x02
|
|
#define PRINT_STOP_COMMAND 0x03
|
|
#define UPDATE_QRCODE 0x04
|
|
#define NULL_COMMAND 0x00
|
|
//enum {
|
|
// TCP,
|
|
// TCP_PI,
|
|
// RTU
|
|
//};
|
|
//enum ThreadState
|
|
//{
|
|
// STOPPED,
|
|
// RUNNING,
|
|
// SHUTDOWN
|
|
//};
|
|
|
|
class ModbusSerial:public QObject
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
ModbusSerial(ModbusPrintParas *mPara, const ModbusPrintStatus* mStatus);
|
|
~ModbusSerial();
|
|
|
|
uint16_t* input_registers;
|
|
uint16_t* holding_registers;
|
|
uint8_t modbus_up_QRCODE;
|
|
// QThread serial_thread;
|
|
|
|
// enum ThreadState Serial_PollThreadState;
|
|
// enum ThreadState Serial_GetPollingThreadState();
|
|
// void Serial_SetPollingThreadState( enum ThreadState eNewState );
|
|
qint32 getModbusStatus();
|
|
|
|
|
|
Q_SIGNALS:
|
|
void updateQRcode();
|
|
void startPrint();
|
|
void pausePrint();
|
|
void stopPrint();
|
|
void openFile(QString,bool);
|
|
void faultResume();
|
|
void writeCalendar();
|
|
void mbLineAndCharSpace(int lineSpace, int charSpace);
|
|
|
|
public slots:
|
|
//void processCommands();
|
|
qint32 processCommands(qint32 index);
|
|
// void vPollingThread();
|
|
|
|
private:
|
|
QTimer* modbus_timer;
|
|
qint32 modbus_status;
|
|
uint16_t port_num;
|
|
// QMutex modbusThreadMutex;
|
|
|
|
};
|
|
#endif
|
|
|