devicePlayer.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. #ifndef __DevicePLAYER_H_
  2. #define __DevicePLAYER_H_
  3. #include <iostream>
  4. #include "deviceBase.h"
  5. #include "PlayerControl.h"
  6. #include "PlayerDeviceList.h"
  7. #include "PlayerLogin.h"
  8. #include "PlayerLogout.h"
  9. #include "PlayerStatus.h"
  10. #include "ExpelDevice.h"
  11. class devicePlayer:public deviceBase
  12. {
  13. private:
  14. std::string did = "";
  15. std::string cname = "";
  16. std::string dtype = "全向声波 R360XS2";
  17. public:
  18. devicePlayer(): deviceBase(){
  19. this->setDeviceToken(http);
  20. this->setDeviceInfo("深圳宝安机场 派尔云驱鸟设备协议");
  21. }
  22. ~devicePlayer() {}
  23. void serialization(){}
  24. bool deserialization(){}
  25. bool Consumer(uint8_t *data, int len, int &msg_id){return true;}
  26. bool getStatusMsg(int &msg_id){ return false;};
  27. /**
  28. * @description: 构建数据信息
  29. * @param {SendDevice&} sendDevice
  30. * @return {*}
  31. */
  32. void BuildDeviceInfo(SendDevice& sendDevice) {
  33. // sendDevice.deviceId = this->getDeviceId().c_str();
  34. // sendDevice.commandCode = "1";
  35. // sendDevice.status = 1;
  36. // sendDevice.workStatus = 1;
  37. // sendDevice.powerStatus = 1;
  38. // sendDevice.batteryStatus = 1;
  39. // sendDevice.num = 0;
  40. // sendDevice.oxyPressure = 0;
  41. // sendDevice.gasPressure = 0;
  42. // sendDevice.remark = "";
  43. };
  44. int32_t Open(std::string DeviceId,uint8_t* data, int& length){
  45. PlayerControl playerControl;
  46. playerControl.cid = "coperate";
  47. playerControl.did = DeviceId;
  48. playerControl.cname = ServerCname;
  49. playerControl.dtype = "全向声波 R360XS2";
  50. PlayerCommand playerCommand;
  51. playerCommand.device = "audioplayer";
  52. playerCommand.ctype = "play";
  53. playerCommand.param = "";
  54. playerControl.command.push_back(playerCommand);
  55. std::string json;
  56. playerControl.objectToJson(json);
  57. memcpy(data, json.c_str(), json.length());
  58. length = json.length();
  59. return 0;
  60. };
  61. int32_t Close(std::string DeviceId, uint8_t* data, int&length){
  62. PlayerControl playerControl;
  63. playerControl.cid = "coperate";
  64. playerControl.did = DeviceId;
  65. playerControl.cname = ServerCname;
  66. playerControl.dtype = "全向声波 R360XS2";
  67. PlayerCommand playerCommand;
  68. playerCommand.device = "audioplayer";
  69. playerCommand.ctype = "stop";
  70. playerCommand.param = "";
  71. playerControl.command.push_back(playerCommand);
  72. std::string json;
  73. playerControl.objectToJson(json);
  74. memcpy(data, json.c_str(), json.length());
  75. length = json.length();
  76. return 0;
  77. };
  78. int32_t Fire(std::string DeviceId, uint8_t* data, int& length){
  79. return this->Open(DeviceId, data, length);
  80. };
  81. int32_t Status(std::string DeviceId, uint8_t* data, int& length){
  82. PlayerInquire playerInquire;
  83. playerInquire.cid = "cstatus";
  84. playerInquire.ctype = "windows";
  85. playerInquire.cname = ServerCname;
  86. playerInquire.dtype = "全向声波 R360XS2";
  87. playerInquire.did = DeviceId;
  88. std::string json;
  89. playerInquire.objectToJson(json);
  90. memcpy(data, json.c_str(), json.length());
  91. length = json.length();
  92. return 0;
  93. };
  94. };
  95. #endif