You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

82 lines
3.6 KiB

​
​
​
2 years ago
​
​
​
​
​
​
​
​
​
​
​
​
2 years ago
2 years ago
​
​
​
​
​
​
​
​
​
2 years ago
​
2 years ago
2 years ago
​
​
​
​
​
2 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
2 years ago
​
2 years ago
​
​
​
2 years ago
​
2 years ago
​
​
  1. #ifndef __MOJO_REMOTE_CLIENT_HEADER__
  2. #define __MOJO_REMOTE_CLIENT_HEADER__
  3. #include "../../components/base/basicLogCollection.h"
  4. #include "../../components/base/basicThread.h"
  5. #include "../../data/net/clientPort.h"
  6. #include "../../data/protocol/protocol.h"
  7. #include "../../data/protocol/protocolARGUS_DATA.h"
  8. class mojoKernel;
  9. typedef struct S_RPC_CMD_RECORD{
  10. uint8_t CMD;
  11. size_t DATA_SIZE;
  12. void * DATA;
  13. }RPC_CMD_RECORD;
  14. typedef basicRing<RPC_CMD_RECORD> RPC_CMD_QUEUE;
  15. class mojoRemoteClient: public basicThread, public protocolParser{
  16. private:
  17. basicLogCollection * m_pLog;
  18. mojoKernel * m_pMaster;
  19. clientPort * m_pPort;
  20. basicMutex m_mQueryProtector;
  21. basicMutex m_mAutomationStageProtector;
  22. basicMutex m_mAutomationFreezer;
  23. RPC_CMD_QUEUE * m_qCMD;
  24. basicMutex m_mCurrentCMDProtector;
  25. RPC_CMD_RECORD * m_pCurrentCMD;
  26. uint32_t m_nQueryMessage;
  27. uint32_t m_nInbondSerial;
  28. uint32_t m_nOutbondSerial;
  29. uint8_t m_bAutomationStage;
  30. uint8_t m_bTOCounter;
  31. bool m_bShutdownCommunication;
  32. bool m_bCommunicationEstablished;
  33. bool m_bRegisteredWithRemotePeer;
  34. uint8_t m_pBuffer[4096];
  35. basicMutex m_mBufferProtector;
  36. bool peer_send_evt( ARGUS_DATA_EVENT *ptr );
  37. bool peer_send_hello( ARGUS_DATA_MOJO_INFO *ptr );
  38. bool peer_send_reg_req( CSTR identity );
  39. bool peer_send_status( ARGUS_DATA_MOJO_STATUS *ptr );
  40. bool peer_send_time_sync_req( ARGUS_DATA_TIME_SYNC_REQ *ptr );
  41. bool peer_send_rpc_pack( RPC_CMD_RECORD *ptr);
  42. void enqueueInfoMsg();
  43. void enqueueStatMsg();
  44. void enqueueTimeReq();
  45. uint8_t getAutomationStage( );
  46. void setAutomationStage( uint8_t stg );
  47. bool validateTransaction();
  48. bool pushNewTransaction( RPC_CMD_RECORD *ptr );
  49. bool fetchNewTransaction();
  50. void finishTransaction();
  51. void flushTransactions();
  52. basicMutex m_mTOProtoctor;
  53. void setTO( uint8_t seconds );
  54. bool decTO();
  55. protected:
  56. virtual int packetChecker( U8 *Buffer, size_t BufferSize);
  57. virtual protocolPackage * packetExtractor( U8 *Buffer, size_t BufferSize);
  58. virtual bool packetHandler( protocolPackage *Package );
  59. virtual void m_fThreadProc( void );
  60. public:
  61. explicit mojoRemoteClient( mojoKernel *ptr );
  62. ~mojoRemoteClient();
  63. virtual bool create();
  64. bool createVideoTransferTask( ARGUS_DATA_VIDEO_SEGMENT *ptr );
  65. bool validate();
  66. bool addEvent( EVENT_CONTAINER *ptr );
  67. };
  68. #endif