PIDSDataDefine.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. #pragma once
  2. #include <iostream>
  3. #include "user_app.h"
  4. #include "Crc16.h"
  5. #include "Util/logger.h"
  6. #include <time.h>
  7. #include <ctime>
  8. #include <list>
  9. using namespace std;
  10. #define PIDS_DATA_HEAD (0xFD) // 帧头
  11. #define PIDS_DATA_END (0xFE) // 帧尾
  12. #define PIDS_SRC_TC1 (0x01) // 源设备车厢编号:TC1
  13. #define PIDS_SRC_TC2 (0x02) // 源设备车厢编号:TC2
  14. #define PIDS_SRC_TYPE_PIDS (0x03) // PIDS设备
  15. #define PIDS_SRC_TYPE_MIVA (0x28) // 视频分析服务器设备
  16. #define HEX2BCD(x) (((x) % 10) + ((((x) / 10) % 10) << 4)) /*20 -> 20H*/
  17. struct CarLoadData{
  18. int NoLoad;
  19. int DynamicLoad;
  20. };
  21. struct CarInferData{
  22. std::string uri;
  23. int num;
  24. };
  25. struct CarData{
  26. CarLoadData loadData;
  27. std::list<CarInferData> inferData;
  28. };
  29. struct ResultData{
  30. int Grade;
  31. int Num;
  32. };
  33. void getBCDTime(uint8_t *out)
  34. {
  35. time_t t;
  36. int i = 0;
  37. struct tm *tp = NULL;
  38. t = time(NULL);
  39. tp = localtime(&t);
  40. out[i++] = HEX2BCD(tp->tm_year-100);
  41. out[i++] = HEX2BCD(tp->tm_mon+1);
  42. out[i++] = HEX2BCD(tp->tm_mday);
  43. out[i++] = HEX2BCD(tp->tm_hour);
  44. out[i++] = HEX2BCD(tp->tm_min);
  45. out[i++] = HEX2BCD(tp->tm_sec);
  46. }
  47. void getDataTime(char *ctime)
  48. {
  49. time_t rawtime;
  50. struct tm *info;
  51. time(&rawtime);
  52. info = localtime(&rawtime);
  53. strftime(ctime, 80, "%Y-%m-%d %H:%M:%S", info);
  54. }