emsApplication/applications/emsConfigurer/globalparameters.h

163 lines
3.6 KiB
C
Raw Normal View History

2024-09-12 16:23:44 +08:00
#ifndef GLOBALPARAMETERS_H
#define GLOBALPARAMETERS_H
#pragma execution_character_set("utf-8")
#include <QStringList>
#include "singleton.h"
#include "hv_tcpclient.h"
#define DEVICE_SERVER_PORT (44242)
2024-09-12 16:23:44 +08:00
class QAbstractTableModel;
class QTableView;
class MyTableModel;
//采集设备参数所处的状态
typedef enum _tagSignalStatus
{
STATUS_NORMAL = 0,
STATUS_WARN = 1,
STATUS_ERROR = 2,
STATUS_INFO = 3,
2024-10-17 20:25:43 +08:00
} SignalStatus;
2024-09-12 16:23:44 +08:00
typedef struct _ModelItem
{
SignalStatus status;
std::string ParameterName;
std::string value;
std::string unit;
std::string sampleTime;
2024-10-17 20:25:43 +08:00
} ModelItem;
2024-09-12 16:23:44 +08:00
typedef QList<ModelItem> TableData;
2024-10-17 20:25:43 +08:00
//用来处理串口各种参数的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;
2024-09-12 16:23:44 +08:00
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;
bool readConfiguration(QString iniFile);
2024-09-12 16:23:44 +08:00
public:
//数据表格的表头
QStringList lstDataTableHeaderText;
//定时刷新间隔
int nTimeOut;
//目标机器IP
QString qsDestinationIp;
//最后的错误信息
QString qsLastErrorString;
//串口数量
int SerialPortCount;
//串口字符串前缀
QString SerialPortPrefix;
2024-09-12 16:23:44 +08:00
};
//全局通用类
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);
};
typedef std::function<void(const hv::SocketChannelPtr&, hv::Buffer*)> onMessageCallbackFunc;
class AppTcpClient:public Singleton<AppTcpClient>
{
public:
AppTcpClient(token);
~AppTcpClient();
AppTcpClient(const AppTcpClient&)=delete;
AppTcpClient& operator =(const AppTcpClient&)= delete;
int Initialize(QString remote_host,int remote_port=DEVICE_SERVER_PORT);
void resetOnMessageCallbackFunction(onMessageCallbackFunc& func);
public:
hv::TcpClient* m_tcpclient;
int m_connfd;
};
2024-09-12 16:23:44 +08:00
#endif // GLOBALPARAMETERS_H