SendPassengerFlow.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. /*
  2. * @Author: your name
  3. * @Date: 2021-11-18 22:53:19
  4. * @LastEditTime: 2021-11-19 11:39:00
  5. * @LastEditors: lishengyin
  6. * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
  7. * @FilePath: /MIVA/modules/dataType/include/SendPassengerFlow.h
  8. */
  9. #pragma once
  10. #include <iostream>
  11. using namespace std;
  12. #include <rapidjson/document.h>
  13. #include <rapidjson/rapidjson.h>
  14. #include <rapidjson/stringbuffer.h>
  15. #include <rapidjson/writer.h>
  16. #include <vector>
  17. class PassengerFlow
  18. {
  19. public:
  20. // 检测设备
  21. std::string deviceIp;
  22. // 车辆编号
  23. std::string carCode;
  24. // 车厢编号
  25. std::string carriageCode;
  26. // 拥挤度检测值
  27. int crNum = 0;
  28. // 拥挤度,1/2/3
  29. int crType;
  30. // 车厢人数
  31. int personNum;
  32. // 检测时间
  33. std::string detectionTime;
  34. // 流播放地址
  35. std::string detectionVideo;
  36. // 备注
  37. std::string remark;
  38. // 扩展字段
  39. std::string attr1;
  40. std::string attr2;
  41. std::string attr3;
  42. public:
  43. PassengerFlow() {}
  44. ~PassengerFlow() {}
  45. void objectToJson(rapidjson::Writer<rapidjson::StringBuffer>& writer)
  46. {
  47. writer.StartObject();
  48. writer.Key("deviceIp");
  49. writer.String(deviceIp.c_str());
  50. writer.Key("carCode");
  51. writer.String(carCode.c_str());
  52. writer.Key("carriageCode");
  53. writer.String(carriageCode.c_str());
  54. writer.Key("crNum");
  55. writer.Int(crNum);
  56. writer.Key("crType");
  57. writer.Int(crType);
  58. writer.Key("personNum");
  59. writer.Int(personNum);
  60. writer.Key("detectionTime");
  61. writer.String(detectionTime.c_str());
  62. writer.Key("detectionVideo");
  63. writer.String(detectionVideo.c_str());
  64. writer.Key("remark");
  65. writer.String(remark.c_str());
  66. writer.Key("attr1");
  67. writer.String(attr1.c_str());
  68. writer.Key("attr2");
  69. writer.String(attr2.c_str());
  70. writer.Key("attr3");
  71. writer.String(attr3.c_str());
  72. writer.EndObject();
  73. }
  74. };
  75. class SendPassengerFlow
  76. {
  77. public:
  78. vector<PassengerFlow> PassengerFlows;
  79. public:
  80. SendPassengerFlow() {}
  81. ~SendPassengerFlow() {}
  82. void objectToJson(rapidjson::Writer<rapidjson::StringBuffer>& writer)
  83. {
  84. writer.StartArray();
  85. for(auto& passengerFlow: PassengerFlows){
  86. passengerFlow.objectToJson(writer);
  87. }
  88. writer.EndArray();
  89. }
  90. };