|
- #pragma once
-
- #include <QByteArray>
- #include <QObject>
- #include <QString>
- #include <map>
- #include <vector>
-
- #include "CurveWidget.h"
- #include "VideoWidget.h"
-
- struct DataStore {
- QString m_strStoreType; // 离线或在线
- QString m_strDateTime; // 数据日期
- QString m_strDataPath; // 数据路径
- };
-
- struct Frame {
- QString m_strHead; // 帧头
- unsigned int m_uiRow; // 行数
- unsigned int m_uiColumn; // 列数
- unsigned int m_uiFrameLen; // 帧长
- unsigned short m_usHeadAddr; // 帧头位置
- unsigned short m_usSubFrameType; // 副帧类型
- unsigned short m_usIdAddr; // Id副帧位置
- unsigned short m_usIdStart; // Id副帧起始值
- unsigned short m_usIdEnd; // Id结束值
- double m_dFrameTime; // 每帧发送间隔
- QByteArray m_headArray; // 帧头
- QByteArray m_subHeadArray; // 反码副帧
- unsigned short m_usBeforeHeadLen;
- DataStore m_dataStore; // 数据存储路径
- };
-
- class Channel
- {
- public:
- Channel() : m_uiMinorFrame(0), m_uiSubFrame(0), m_uiAbsolutePos(0)
- {}
- ~Channel()
- {}
-
- public:
- unsigned int m_uiMinorFrame;
- unsigned int m_uiSubFrame;
- unsigned int m_uiAbsolutePos;
- };
-
- class ChannelGroup
- {
- public:
- ChannelGroup() : m_uiChannelNum(0)
- {}
- ~ChannelGroup()
- {}
- unsigned int m_uiChannelNum;
- std::vector<Channel*> m_vecChannel;
- };
-
- struct Formula {
- int equaNum = 0; // 最高次方
- double Equation[10] = {0.0}; // 系数公式
- };
-
- class Param : public QObject
- {
- Q_OBJECT
- public:
- Param(QObject* parent = Q_NULLPTR);
- ~Param();
- void setCurveWidget(CurveWidget* curveWidget);
- CurveWidget* getCurveWidget();
- void setVideoWidget(VideoWidget* videoWidget);
- VideoWidget* getVideoWidget();
-
- unsigned int m_uiId; // 参数编号
- QString m_strCode; // 代号
- QString m_strTitle; // 名称
- QString m_strChannelGroup; // 通道
- ChannelGroup* m_pChannelGroup = nullptr; // 参数通道结构
- unsigned short m_usModel; // 参数类型:模拟量、数字量、视频、状态量
- QString m_strFill; // 无效填充
- QByteArray m_fillArray;
- unsigned short m_usType; // 基本数据类型
- QString m_strBit; // 状态量比特位十六进制表示
- unsigned short m_usOrder; // 大小端
- QString m_strFormula; // 转换公式
- Formula m_formula; // 公式信息
- QString m_strUnit; // 物理单位
- // 图像特有
- unsigned short m_usFormat; // 图像格式
- unsigned int m_uiWidth; // 图像宽度
- unsigned int m_uiHeight; // 图像高度
- private:
- CurveWidget* m_pCurveWidget; // 曲线窗口
- VideoWidget* m_pVideoWidget; // 视频窗口
- };
-
- struct ConfigInfo {
- QString m_strValidName;
- Frame* m_pFrame = nullptr;
- std::map<unsigned int, Param*> m_mapUIntParam;
- };
-
- static double GetBCDTimeCode(const unsigned char* pData)
- {
- double d = 0.0;
- d += (*pData & 0x0F) * 0.1; // 低位 //0.1ms
- d += ((*pData & 0xF0) >> 4); // 1ms
- d += (*(pData + 1) & 0x0F) * 10; // 10ms
- d += ((*(pData + 1) & 0xF0) >> 4) * 100; // 100ms
- d += (*(pData + 2) & 0x0F) * 1000; // 1000ms(1s)
- d += ((*(pData + 2) & 0xF0) >> 4) * 10000; // 10s
- d += (*(pData + 3) & 0x0F) * 60000; // 60s(1min)
- d += ((*(pData + 3) & 0xF0) >> 4) * 600000; // 10min
- d += (*(pData + 4) & 0x0F) * 3600000; // 60min(1hour)
- d += ((*(pData + 4) & 0x30) >> 4) * 36000000; // 高位 //10hour
- return d;
- }
- // 获取时分秒形式时码值
- static QString GetBCDTimeCodeHMS(const unsigned char* pData)
- {
- double dMillSecond = 0.0;
- dMillSecond += (*pData & 0x0F) * 0.1; // 低位 //0.1ms
- dMillSecond += ((*pData & 0xF0) >> 4); // 1ms
- dMillSecond += (*(pData + 1) & 0x0F) * 10; // 10ms
- dMillSecond += ((*(pData + 1) & 0xF0) >> 4) * 100; // 100ms
- QString strMillSecond = QString::number(dMillSecond, 'f', 1);
- int iSecond = 0;
- iSecond += (*(pData + 2) & 0x0F) * 1; // 1000ms(1s)
- iSecond += ((*(pData + 2) & 0xF0) >> 4) * 10; // 10s
- QString strSecond = QString::number(iSecond);
- int iMinute = 0;
- iMinute += (*(pData + 3) & 0x0F) * 1; // 60s(1min)
- iMinute += ((*(pData + 3) & 0xF0) >> 4) * 10; // 10min
- QString strMinute = QString::number(iMinute);
- int iHour = 0;
- iHour += (*(pData + 4) & 0x0F) * 1; // 60min(1hour)
- iHour += ((*(pData + 4) & 0x30) >> 4) * 10; // 高位 //10hour
- QString strHour = QString::number(iHour);
- QString strTime = strHour + "h" + strMinute + "m" + strSecond + "s" + strMillSecond + "ms";
- return strTime;
- }
|