ConsistencyResult.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. #ifndef CONSISTENCYRESULT_H_
  2. #define CONSISTENCYRESULT_H_
  3. #include "GlobalVariable.h"
  4. #include "ChannelParam.h"
  5. #include <QDateTime>
  6. enum ERetPythonCompareFile
  7. {
  8. ERCF_0_CompareFile_FALSE = 0, // 对比返回不一致
  9. ERCF_1_CompareFile_TRUE = 1, // 对比返回一致
  10. ERCF_2_CompareFile_NOT = 2, // 未启动文件对比(如服务地址为空)
  11. ERCF_3_CompareFile_Unkonw = 3, // 对比返回未知,判断不出一致性
  12. };
  13. // 保存1次一致性比较的结果,大概1秒钟的数据
  14. struct StConsistencyResult
  15. {
  16. StConsistencyResult();
  17. StConsistencyResult(StConsistencyParam &param);
  18. virtual ~StConsistencyResult();
  19. StConsistencyResult(const StConsistencyResult& obj);
  20. StConsistencyResult& operator=(const StConsistencyResult& obj);
  21. void Init();
  22. std::string OutPutConsistencyInfo(const bool bConsistencyInfo);
  23. int AddResult(const float f, const int iDelN);
  24. int GetCount() const { return iCurPos; }
  25. int GetMaxResult() const;
  26. // 这个一致性不能用于判定是否一致性,一致性判定要在CConsistencyList里面判定,计算一致性的个数
  27. bool IsConsistency() const;
  28. bool IsNotConsistency() const;
  29. bool m_bIsNoiseOfCur;
  30. StConsistencyParam m_stConsistencyParam;
  31. StConsistencyParam m_stNoiseConsistencyParam;
  32. int GetConsistencyThresholdNum() const;
  33. int GetConsistencyThresholdNotNum() const;
  34. int GetConsistencyThresholdWarningNum() const;
  35. int GetDelNAt(const int nIndex = 0) const { return aryOfDelN[nIndex]; }
  36. // Python对比结果
  37. // int m_nRetPythonCompareFile;
  38. // AI对比结果
  39. void InitAICompareFile();
  40. int AddRetAICompareFile(float fVal);
  41. // nThresholdNum表示持续次数, dThresholdNum判断阀值
  42. bool IsAIConsistency(int nThresholdNum, float dThreshold, std::string &strAIValue);
  43. bool IsAINotConsistency(int nThresholdNum, float dThreshold, std::string &strAIValue);
  44. int GetLastRetAICompareFile();
  45. private:
  46. QDateTime m_tLastAITime;
  47. int m_nLastRetAICompareFile;
  48. // AI对比结果,范围[0,1]
  49. float aryOfAICompareFile[10];
  50. /*
  51. fResult 相似度 delN 偏差(时间偏移)
  52. 这里的偏差就是错位的意思,相似度是在这个错位下计算出来的,如下:
  53. 1010001011010101110
  54. xxx1010001011010101110
  55. xxx的位数就是偏差量了
  56. */
  57. int aryOfDelN[RESULT_NUM_OF_ONETIME_COMPARE];
  58. // 相似度数组
  59. float aryOfSimilarity[RESULT_NUM_OF_ONETIME_COMPARE];
  60. // 数组实际保存了多少个数据,当前可以填充数据的位置
  61. int iCurPos;
  62. };
  63. #endif // CONSISTENCYRESULT_H_