You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

91 lines
2.2 KiB
C++

#pragma once
#include <QDebug>
#include <QTime>
#include <QDate>
#include <QThread>
#include <string>
// 定义测试环境
//#define _HOME_TEST_
//#define _YN_TEST_
// 是否使用授权
//#define USE_AUTH
const QString gstrOpenSerialPort = "打开串口\nOpen";
const QString gstrCloseSerialPort = "关闭串口\nClose";
const QString gstrSearchSerialPort = "搜索串口\nSearch";
const int gnFontSize = 18;
const QString gstrStyleSheet = "font:bold; font-size:%1px; color:black;";
const int gnFontSizeStatic = 12;
const QString gstrStyleSheetStatic = "font-size:%1px;";
const int gnDefaultTabBarHeight = 26;
const int gnDefaultLabelHeight = 36;
const int gnDefaultComboBoxHeight = 36;
const int gnDefaultPushButtonHeight = 36;
const int gnDefaultLineEditHeight = 36;
typedef enum {SYS_STATUS_IDLE = 0, SYS_STATUS_BUSY } SYS_STATUS;
const int MAX_FRAME_CMD_NAME_COUNT = 22;
const std::string gFrameCmdName[MAX_FRAME_CMD_NAME_COUNT] = {
"",
"设置时间",
"获取时间",
"设置出厂编号",
"获取出厂编号",
"设置设备名称",
"获取设备名称",
"设置设备编号",
"获取设备编号",
"设置锁定状态",
"设置密码",
"设置使用次数",
"获取文件记录",
"清除文件记录",
"设置参数",
"设置操作人名",
"获取操作人名",
"导入数据-扭矩模式",
"导入数据-螺栓模式",
"导入数据-角度模式",
"导入数据-挡位模式",
"导入数据-传感器模式"
};
inline void QDEBUGMSG(QString msg = "")
{
qDebug() << "[" << QDate::currentDate().toString("yyyy-MM-dd").toUtf8().data()
<< QTime::currentTime().toString("hh:mm:ss").toUtf8().data() << "]"
<< "[ tid:" << QThread::currentThreadId() << "]"
<< msg.toUtf8().data();
}
//// 非阻塞延时
//void Delay_MSec(unsigned int msec)
//{
// QTime _Timer = QTime::currentTime().addMSecs(msec);
// while( QTime::currentTime() < _Timer )
// QCoreApplication::processEvents(QEventLoop::AllEvents, 100);
//}
// 阻塞延时
inline void Delay_MSec_Suspend(unsigned int msec)
{
QTime _Timer = QTime::currentTime();
QTime _NowTimer;
do{
_NowTimer=QTime::currentTime();
}while (_Timer.msecsTo(_NowTimer) <= msec);
}