135 lines
2.9 KiB
C++
135 lines
2.9 KiB
C++
#ifndef GLOBALPARAMETERS_H
|
|
#define GLOBALPARAMETERS_H
|
|
#pragma execution_character_set("utf-8")
|
|
|
|
#include <QStringList>
|
|
|
|
#include "singleton.h"
|
|
|
|
class QAbstractTableModel;
|
|
class QTableView;
|
|
class MyTableModel;
|
|
|
|
//采集设备参数所处的状态
|
|
typedef enum _tagSignalStatus
|
|
{
|
|
STATUS_NORMAL = 0,
|
|
STATUS_WARN = 1,
|
|
STATUS_ERROR = 2,
|
|
STATUS_INFO = 3,
|
|
} SignalStatus;
|
|
|
|
typedef struct _ModelItem
|
|
{
|
|
SignalStatus status;
|
|
std::string ParameterName;
|
|
std::string value;
|
|
std::string unit;
|
|
std::string sampleTime;
|
|
} ModelItem;
|
|
|
|
typedef QList<ModelItem> TableData;
|
|
|
|
//用来处理串口各种参数的ComboBox的Model
|
|
|
|
//设置奇偶检验
|
|
#define EMS_PARITY_NONE 0
|
|
#define EMS_PARITY_ODD 1
|
|
#define EMS_PARITY_EVEN 2
|
|
|
|
typedef std::pair<int,QString> ParityItemData;
|
|
typedef std::vector<ParityItemData> vecParityItemData;
|
|
|
|
//设置数据位
|
|
#define EMS_DATA_8_BITS 8
|
|
#define EMS_DATA_7_BITS 7
|
|
|
|
typedef std::pair<int,QString> DataBitsItemData;
|
|
typedef std::vector<DataBitsItemData> vecDataBitsItemData;
|
|
|
|
//设置停止位
|
|
#define EMS_1_STOP_BITS 1
|
|
#define EMS_2_STOP_BITS 2
|
|
|
|
typedef std::pair<int,QString> StopBitsItemData;
|
|
typedef std::vector<StopBitsItemData> vecStopBitsItemData;
|
|
|
|
//设置串口模式
|
|
#define EMS_RTU_MODE 1
|
|
#define EMS_ASCII_MODE 2
|
|
|
|
typedef std::pair<int,QString> PortModeItemData;
|
|
typedef std::vector<PortModeItemData> vecPortModeItemData;
|
|
|
|
//设置串口类型
|
|
#define EMS_SERIALPORT_TYPE 1
|
|
#define EMS_CANPORT_TYPE 2
|
|
|
|
typedef std::pair<int,QString> PortTypeItemData;
|
|
typedef std::vector<PortTypeItemData> vecPortTypeItemData;
|
|
|
|
|
|
//设置串口类型
|
|
#define EMS_BAUND_2400 2400
|
|
#define EMS_BAUND_4800 4800
|
|
#define EMS_BAUND_9600 9600
|
|
#define EMS_BAUND_19200 19200
|
|
#define EMS_BAUND_38400 38400
|
|
#define EMS_BAUND_57600 57600
|
|
#define EMS_BAUND_115200 115200
|
|
#define EMS_BAUND_128000 128000
|
|
#define EMS_BAUND_153600 153600
|
|
#define EMS_BAUND_230400 230400
|
|
#define EMS_BAUND_460800 460800
|
|
#define EMS_BAUND_921600 921600
|
|
|
|
typedef std::pair<int,QString> BaundItemData;
|
|
typedef std::vector<BaundItemData> vecBaundItemData;
|
|
|
|
class CWaitorCursor
|
|
{
|
|
public:
|
|
CWaitorCursor();
|
|
~CWaitorCursor();
|
|
};
|
|
|
|
//全局变量
|
|
class AppData:public Singleton<AppData>
|
|
{
|
|
public:
|
|
AppData(token);
|
|
~AppData();
|
|
AppData(const AppData &other) = delete;
|
|
AppData& operator=(const AppData &other) = delete;
|
|
|
|
public:
|
|
//数据表格的表头
|
|
QStringList lstDataTableHeaderText;
|
|
|
|
//定时刷新间隔
|
|
int nTimeOut;
|
|
|
|
//目标机器IP
|
|
QString qsDestinationIp;
|
|
|
|
//最后的错误信息
|
|
QString qsLastErrorString;
|
|
};
|
|
|
|
|
|
//全局通用类
|
|
class AppCommon:public Singleton<AppCommon>
|
|
{
|
|
public:
|
|
AppCommon(token);
|
|
~AppCommon();
|
|
|
|
AppCommon(const AppCommon&)=delete;
|
|
AppCommon& operator =(const AppCommon&)= delete;
|
|
|
|
public:
|
|
void InitializeTableView(MyTableModel* model,QTableView* tableView);
|
|
};
|
|
|
|
#endif // GLOBALPARAMETERS_H
|