HIKNvr.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #pragma once
  2. #include "json.hpp"
  3. #include "HIKBase.h"
  4. #include "DecisionPlatform.h"
  5. #include "DataTime.h"
  6. #include <vector>
  7. #define NVR_SUC 0
  8. #define NVR_ERR_HIK 6
  9. #define NVR_ERR_CONNECT_7 7
  10. struct TimeRecord
  11. {
  12. DateTime TimeStart;
  13. DateTime TimeEnd;
  14. long long tmTimeStart;
  15. long long tmTimeEnd;
  16. // 目前是针对每天记录比对,所以只比对time即可。
  17. bool IsInRecord(DateTime time_in)
  18. {
  19. if (TimeStart < time_in && TimeEnd > time_in)
  20. {
  21. return true;
  22. }
  23. return false;
  24. }
  25. };
  26. class HIKNvr : public HIKBase
  27. {
  28. public:
  29. HIKNvr();
  30. //初始化 Nvr
  31. bool InitNvr(std::string ip, std::string port, std::string username, std::string password, int channel);
  32. //按月查询
  33. int CheckTimeRegionWithMonth(DateTime select_time, std::vector<int> &available_date_vec);
  34. //按日查询
  35. int CheckTimeRegionWithDay(DateTime select_time, std::vector<TimeRecord> &available_time_vec);
  36. //though input SelectTime get the time region
  37. bool GetTimeRegion(DateTime select_time,int value ,DateTime &time_start,DateTime &time_end);
  38. bool GetNvrUTCDiff();
  39. int nDiffTotalMin;
  40. public:
  41. // 将时间转换成json
  42. nlohmann::json TimeToJson(DateTime Time,std::vector<int> *pAvailableDateVec);
  43. nlohmann::json TimeToJsonInDay(DateTime Time,std::vector<TimeRecord> *pAvailableTimeVec);
  44. private:
  45. //record the time in the Nvr
  46. std::vector<TimeRecord> m_TimeRecords;
  47. //Nvr channel
  48. int m_Channel;
  49. };