qt/LedOK/globaldefine.h

346 lines
12 KiB
C
Raw Normal View History

2022-01-04 18:11:48 +08:00
#ifndef GLOBALDEFINE_H
#define GLOBALDEFINE_H
#include <QString>
#define MACRO_FENGEFU "/"
#define MACRO_FENGEDANFU "/"
#define MACRO_DANYINFANXIEGAN '\\'
#define MACRO_DANYINXIEGAN '/'
#include <QJsonValue>
#include <QJsonObject>
#include <QJsonDocument>
#include <communication/hpptclient.h>
//#define MACRO_YUANHENG_VERSION
enum {
ENUM_MAIN_TOOL_DEVICESMANAGER=0,
ENUM_MAIN_TOOL_PROGRAM,
// ENUM_MAIN_TOOL_PROGRAM_A,
ENUM_MAIN_TOOL_DEVICESCONTROL,
ENUM_MAIN_TOOL_GUANGYINPIN,
ENUM_MAIN_TOOL_END,
};
enum {
ENUM_IMPORT_DLG=1,
ENUM_EXPORT_DLG=2,
ENUM_DELETE_DLG=3,
ENUM_SAVEAS_DLG=4,
ENUM_SELECT_NETWORK=5,
};
#define STREAM_SYNC_HEAD_NUM 3
#define STREAM_SYNC_HEAD 0x7e
typedef struct _SYSTIMER
{
int y; //获取年份
int m; //获取当前月份
int d; //获得几号
int h; //获取当前为几时
int mm; //获取分钟
int s; //获取秒
int w; //获取星期几注意1为星期天7为星期六
}SYSTIMER,*P_SYSTIMER;
typedef struct _RESTORE_IP
{
char cNewIp[20];
char cMask[20];
char cGateway[20];
char cDns[20];
// char cLocalIp[20];
}RESTORE_IP,*P_RESTORE_IP;
typedef struct _STREAM_PACKET
{
unsigned char SyncHead[STREAM_SYNC_HEAD_NUM];
unsigned char ucCommType;
char ucSerialCode[20];
unsigned int iLength;
char pDataBuffer[2049];
}STREAM_PACKET,* P_STREAM_PACKET;
enum _NET_COMMU_TYPE
{
COMMAND_SAVE_ADVANCE_PARAM_NOT_RESET=0x40,
COMMAND_ONLY_RESET_CARD_IP=0X43,
COMMAND_SET_M31_DOUBLE_HUB=0X44,
COMMAND_CONNECT_COLSE =0x7A,
COMMAND_UPGRADE = 0x80,
COMMAND_SIGNLE_FILE_UPGRADE ,
COMMAND_LOOPCHECK ,
COMMAND_VERIFY_CLOCK ,
COMMAND_SCREEN_OPERATOR,//0x84
COMMAND_SET_SERIAL_NUM,
NET_COMMU_TYPE_PLAY_IN_LINE , // 网络同步在线播放.
NET_COMMU_TYPE_PREVIEW_IN_LINE, // 网络在线预览.
NET_COMMU_TYPE_UPGRADE_SYSTEM, // 系统升级.
NET_COMMU_TYPE_RECOVER_SYSTEM, // 系统还原到上一次正确的启动.
SCREEN_OPERATOR_COMM_PARAMS_SAVE, // 参数保存.
NET_COMMU_TYPE_COMM_EXIT,//普通退出,不重启
NET_COMMU_TYPE_AUDIO_PLAY,//0X8C
NET_COMMU_TYPE_IO,
NET_COMMU_TYPE_IO_CHECK,
NET_COMMU_TYPE_LIMITE_TIME,
NET_COMMU_TYPE_SYSTEM_BROADCAST,//0X90
NET_COMMU_TYPE_REALTIME_INSERT_PLAY,
//NET_COMMU_TYPE_SHANSUO_INSERT_PLAY,
NET_COMMU_TYPE_MODIFY_SERIAL_ID,
NET_COMMU_TYPE_KERNEL_UPGRADE_SYSTEM,
NET_COMMU_TYPE_UPGRADE_FINISHED_EXIT,
NET_COMMU_TYPE_REAL_TIME_INSERT_PLAY_WITH_LIST_EXIT,
NET_COMMU_TYPE_ZNSZ,// 智能设置命令.
NET_COMMU_TYPE_SELECT_PROGRAM_PLAY,// 选节目播放.0x97
NET_COMMU_TYPE_SELECT_MULI_PROGRAM_PLAY,//98选播多个节目
NET_COMMU_TYPE_GET_PROGRAM_NAME,//99获取所有节目的名称
NET_COMMU_TYPE_GET_CUR_PLAY_STATUS,//9a查询当前播放的详细信息
NET_COMMU_TYPE_POWER_PANEL_ON_OR_OFF,//9b开关大屏幕
NET_COMMU_TYPE_ADJUST_BRIGHTNESS,//9c调节亮度
NET_COMMU_TYPE_GET_SYSTEM_STATUS,//9d获取系统状态
NET_COMMU_TYPE_VERIFY_SIGN,//校验签名9e
NET_COMMU_TYPE_SET_WEB_SERVER_PARAM,//配置web服务器参数
NET_COMMU_TYPE_GET_WEB_SERVER_PARAM,//a0
NET_COMMU_TYPE_SET_WIFI_PARAM,//a1配置wifi参数
NET_COMMU_TYPE_GET_WIFI_PARAM,//a2获取wifi参数
NET_COMMU_TYPE_SCAN_AP_WIFI_PARAM,//a3获取ap热点的名称
NET_COMMU_TYPE_GET_ANDROID=0xa4,
NET_COMMU_TYPE_INSTALL_APK=0xa5,
NET_COMMU_TYPE_UNINSTALL_APK=0xa6,
NET_COMMU_TYPE_SET_DNS=0xa7,
NET_COMMU_TYPE_GET_DNS=0xa8,
NET_COMMU_TYPE_SET_PROXY=0xa9,
NET_COMMU_TYPE_GET_PROXY=0xaa,
NET_COMMU_TYPE_SET_ANDROID_COMMUNICATION=0xab,
NET_COMMU_TYPE_GET_ANDROID_COMMUNICATION=0xac,
NET_COMMU_TYPE_GET_SIM_STATUS=0xad,
NET_COMMU_TYPE_GET_APN_PARAM=0xae,
NET_COMMU_TYPE_GET_APK_VERSION=0xaf,
NET_COMMU_TYPE_SET_REALTIME_PARAM=0xb0,
NET_COMMU_TYPE_GET_REALTIME_PARAM=0xb1,
NET_COMMU_TYPE_SET_REALTIME_LINSTEN_PARAM=0xb2,
NET_COMMU_TYPE_GET_REALTIME_LINSTEN_PARAM=0xb3,
NET_COMMU_TYPE_SET_HUAWEI_4G=0xB4,
NET_COMMU_TYPE_GET_HUAWEI_4G=0xB5,
NET_COMMU_TYPE_CLEAR_ANDROID_PROGRAM=0xB6,
NET_COMMU_TYPE_SET_AP_PARAM=0xB7,
NET_COMMU_TYPE_GET_AP_PARAM=0xB8,
GET_REALY_RESOLUTION=0xB9,
GET_REALY_ANDROID_FIRMWARE_INFO=0xBA,
NET_COMMU_TYPE_NUM,
COMMAND_UPGRADE_ANSWER =0xC0,
COMMAND_SIGNLE_FILE_UPGRADE_ANSWER ,
COMMAND_LOOPCHECK_ANSWER ,
COMMAND_VERIFY_CLOCK_ANSWER ,
COMMAND_SCREEN_OPERATOR_ANSWER,
COMMAND_SET_SERIAL_NUM_ANSWER,
NET_COMMU_TYPE_PLAY_IN_LINE_ANSWER , // 网络同步在线播放.
NET_COMMU_TYPE_PREVIEW_IN_LINE_ANSWER, // 网络在线预览.
NET_COMMU_TYPE_UPGRADE_SYSTEM_ANSWER, // 系统升级.
NET_COMMU_TYPE_RECOVER_SYSTEM_ANSWER, // 系统还原到上一次正确的启动.
SCREEN_OPERATOR_COMM_PARAMS_SAVE_ANSWER,
NET_COMMU_TYPE_COMM_EXIT_ANSWER,
NET_COMMU_TYPE_AUDIO_PLAY_ANSWER,//0XcC
NET_COMMU_TYPE_IO_ANSWER,
NET_COMMU_TYPE_IO_CHECK_ANSWER,
NET_COMMU_TYPE_LIMITE_TIME_ANSWER,
////
NET_COMMU_TYPE_SYSTEM_BROADCAST_ANSWER,
NET_COMMU_TYPE_REALTIME_INSERT_PLAY_ANSWER,
NET_COMMU_TYPE_REALTIME_INSERT_PLAY_WITH_GLINT_ANSWER , //带闪烁功能的实时插播
NET_COMMU_TYPE_KERNEL_UPGRADE_SYSTEM_ANSWER,
NET_COMMU_TYPE_UPGRADE_FINISHED_EXIT_ANSWER,//0xd4
NET_COMMU_TYPE_REAL_TIME_INSERT_PLAY_WITH_LIST_EXIT_ANSWER,
NET_COMMU_TYPE_ZNSZ_ANSWER,// 智能设置命令.
NET_COMMU_TYPE_SELECT_PROGRAM_PLAY_ANSWER,//0x97 选节目播放.
NET_COMMU_TYPE_SELECT_MULI_PROGRAM_PLAY_ANSWER,
NET_COMMU_TYPE_GET_PROGRAM_NAME_ANSWER,
NET_COMMU_TYPE_GET_CUR_PLAY_STATUS_ANSWER,
NET_COMMU_TYPE_POWER_PANEL_ON_OR_OFF_ANSWER,
NET_COMMU_TYPE_ADJUST_BRIGHTNESS_ANSWER,
NET_COMMU_TYPE_GET_SYSTEM_STATUS_ANSWER,//获取系统状态
NET_COMMU_TYPE_NUM_ANSWER,
COMMAND_CONNECT_COLSE_ANSWER
};
extern QString m_globalstrSavePath;
extern bool m_globBoolFontantialiasing;
extern bool m_globBoolGuangYingPin;
extern bool isTextValid(const QString &strIP);
extern quint64 dirFileSize(const QString &path);
extern QString calcFileCRC(QString fileName);
extern QString calcFilePathNameStringCRC(QString strfileNamePath);
extern quint32 calcCRC32(const QByteArray &data);
extern bool isFileExist(QString fullFileName);
extern QString getRandomString(int length);
extern void HttpPostByTypeJsonObject(HpptClient *pHpptClient, QString strUrl,QJsonObject json);
extern bool copyDir(const QString &source, const QString &destination, bool override);
extern unsigned char GetCheckCodeIn8(unsigned char * pBuffer,unsigned int uiSize);
enum _ENUM_CONTRL_WIDGET
{
ENUM_CONTRL_WIDGET_BRIGHTNESS=0,
ENUM_CONTRL_WIDGET_POWERCONTROL,
ENUM_CONTRL_WIDGET_NETCONFIG,
ENUM_CONTRL_WIDGET_VERIFYCLOCK,
ENUM_CONTRL_WIDGET_ENCRYPT,
ENUM_CONTRL_WIDGET_HDMIINPUT,
ENUM_CONTRL_WIDGET_VOLUME,
ENUM_CONTRL_WIDGET_ADVPARAM,
ENUM_CONTRL_WIDGET_TEST,
// ENUM_CONTRL_WIDGET_LORA,
ENUM_CONTRL_WIDGET_END,
};
#define MACRO_DEFINE_NO_SELECTED_CARD_TIP \
if(m_pLedlist!=nullptr)\
{\
if(m_pLedlist->count()==1)\
{\
if(m_pLedCard==nullptr)\
{\
X_UIMsgBoxOk *pDlg=new X_UIMsgBoxOk(tr("Tip"),tr("NoSelectedController"),this,1);\
pDlg->exec();\
return;\
} \
}\
else if(m_pLedlist->count()==0){\
X_UIMsgBoxOk *pDlg=new X_UIMsgBoxOk(tr("Tip"),tr("NoSelectedController"),this,1);\
pDlg->exec();\
return;\
}\
}
#define MACRO_DEFINE_TIPDLG_FUCN(TIP,SUCCESS,FAILED) \
if(m_pLedlist!=nullptr)\
{\
if(m_pLedlist->count()<=1)\
{\
if(m_pLedCard!=nullptr)\
{\
HttpPostByTypeJsonObject(pHpptClient,m_strUrl,json);\
if(m_PostingDlg==nullptr)\
{\
m_PostingDlg = new LoEmptyDialog(this);\
connect(m_PostingDlg,SIGNAL(sigClose()),this,SLOT(DeletePostingDlg()));\
connect(m_pGetAskTimer,SIGNAL(timeout()),m_PostingDlg,SLOT(TimerOutUnlock()));\
m_PostingDlg->lock(TIP,SUCCESS,FAILED);\
m_pGetAskTimer->start(5000);\
m_PostingDlg->exec();\
}\
}\
}\
else {\
emit sigSend(json,TIP);\
}\
}
#define MACRO_DEFINE_TIPDLG_ALL_FUCN(READBACK,SUCCESS,FAILED) \
if(m_pLedCard!=nullptr)\
{\
if(m_PostingDlg==nullptr)\
{\
m_PostingDlg = new LoEmptyDialog(this);\
connect(m_PostingDlg,SIGNAL(sigClose()),this,SLOT(DeletePostingDlg()));\
connect(m_pGetAskTimer,SIGNAL(timeout()),m_PostingDlg,SLOT(TimerOutUnlock()));\
m_PostingDlg->lock(READBACK+" "+m_pLedCard->m_strCardId,SUCCESS,FAILED);\
m_pGetAskTimer->start(5000);\
m_PostingDlg->exec();\
}\
}\
#define MARCO_DEFINE_CONTROL_FUNC2(PARENT,PARENT1) \
pHpptClient = new HpptClient(this);\
connect(pHpptClient,SIGNAL(httpPostRspReady(QString , QString , QByteArray )),this,SLOT(OnProHttpResponse(QString , QString , QByteArray)));\
pHpptClientAll = new HpptClient(this);\
connect(pHpptClientAll,SIGNAL(httpPostRspReady(QString , QString , QByteArray )),this,SLOT(OnProHttpResponseAll(QString , QString , QByteArray)));\
m_pGetAskTimer=new QTimer(this);\
connect(PARENT1,SIGNAL(sigSwitchIndexChanged(int)),this,SLOT(OnControlTypeSwitchIndexChanged(int)));\
connect(PARENT,SIGNAL(sigSelectedDeviceList(QList<LedCard *> *)),this,SLOT(onSelectedDeviceList(QList<LedCard *> *)));\
connect(this,SIGNAL(sigSend(QJsonObject &,QString)),PARENT,SLOT(OnControlSendJson(QJsonObject &,QString)));\
connect(PARENT,SIGNAL(sigChangeLanguage()),this,SLOT(refreshLable()));\
onSelectedDeviceList(list);
#define MACRO_ASKTIME_STOP \
if(m_pGetAskTimer!=nullptr)\
if(m_pGetAskTimer->isActive())\
m_pGetAskTimer->stop();\
#define MACRO_POSTING_DLG_UNLOCK \
if(m_PostingDlg!=nullptr)\
{\
if(m_PostingDlg->getLockStatus())\
{\
m_PostingDlg->unlock();\
}\
}
//delete m_PostingDlg;\
//m_PostingDlg=nullptr;\
#define MACRO_DEFINE_CONTROL_FUNC3 \
if(m_pLedlist!=nullptr)\
{\
if(m_pLedlist->count()==1)\
{\
m_pLedCard=list->at(0);\
m_strUrl="http://"+m_pLedCard->m_strCardIp+":2016/settings";\
if(m_oldLedlist!=m_pLedCard&&m_bSelected==true)\
{\
m_oldLedlist=m_pLedCard;\
onReadbackAllThisPage();\
}\
}\
}
#define MACRO_EFFECT_STR_NO "no"
#define MACRO_EFFECT_STR_RANDOM "random"
#define MACRO_EFFECT_STR_RIGHT_TO_LEFT "right to left"
#define MACRO_EFFECT_STR_BOTTOM_TO_TOP "bottom to top"
#define MACRO_EFFECT_STR_LEFT_TO_RIGHT "left to right"
#define MACRO_EFFECT_STR_TOP_TO_BOTTOM "top to bottom"
#define MACRO_FONT_FAN_JUCHI(MYFONT) \
if(!m_globBoolFontantialiasing)\
{\
MYFONT.setLetterSpacing(QFont::AbsoluteSpacing,m_attr.wordSpacing);\
MYFONT.setStyleStrategy(QFont::NoAntialias);\
}\
else\
MYFONT.setHintingPreference(QFont::PreferNoHinting);
#define MACRO_FONT_FANG_JUCHI_2(MYFONT) \
if(!m_globBoolFontantialiasing)\
MYFONT.setStyleStrategy(QFont::NoAntialias);\
else\
{\
MYFONT.setStyleStrategy(QFont::PreferAntialias);\
}
#define MACRO_FAN_JUCHI(PAINT) \
// if(m_globBoolFontantialiasing)\
// {\
// PAINT->setRenderHint(QPainter::TextAntialiasing, true);\
// PAINT->setRenderHint(QPainter::SmoothPixmapTransform, true);\
// PAINT->setRenderHint(QPainter::Antialiasing, true);\
// }\
// else \
// {\
// PAINT->setRenderHint(QPainter::TextAntialiasing, false);\
// PAINT->setRenderHint(QPainter::SmoothPixmapTransform, false);\
// PAINT->setRenderHint(QPainter::Antialiasing, false);\
// }
typedef struct _ST_ANSY_PROGRAM_PACKET
{
unsigned char SyncHead[3];
unsigned char ucCommType;
int iBaoLiu;
unsigned int iLength;
unsigned char pDataBuffer[20];
}ST_ANSY_PROGRAM_PACKET,*P_ST_ANSY_PROGRAM_PACKET;
#define TIME_STRING_FORMAT "HH:mm:ss.zzz"
#endif // GLOBALDEFINE_H