DevBusManager.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. #pragma once
  2. #include <map>
  3. #include "eBus.h"
  4. #include "BusThread.h"
  5. #include "LogicDevice.h"
  6. #include "BusUnitClient.h"
  7. class DevBusManager : public Thread_Base
  8. {
  9. //data
  10. //DeviceBUS *m_pBusLocal;
  11. BusUnitClient *m_pLocalChannelClient;
  12. //BusThread *m_pBusLocalThread;
  13. //Logger *m_pBusLocalLog;
  14. //DeviceBUS *m_pBusEth;
  15. //2025-2-21 BusUnitClient *m_pEthChannelClient;
  16. //BusThread *m_pBusEthThread;
  17. //Logger *m_pBusEthLog;
  18. pthread_mutex_t m_Critical = PTHREAD_MUTEX_INITIALIZER;
  19. int m_EnableEth;
  20. ResDataObject m_EthRouterIp;
  21. ResDataObject m_EthConnection;
  22. ResDataObject m_LocalConnection;
  23. BusUnitClient *m_prootClient;
  24. protected:
  25. //thread
  26. virtual bool OnStartThread();
  27. virtual bool OnEndThread();
  28. virtual bool Exec(void);
  29. void UpdateEthConnectOption(int Enable, ResDataObject &routerIp);
  30. void AdjustEthConnection(int Enable, ResDataObject &routerIp);
  31. //internal actions
  32. bool DoRootDevPrcedure(void);
  33. bool DoLocalChannelPrcedure(void);
  34. bool DoEthChannelPrcedure(void);
  35. map<string,DeviceDescript> m_LocalChannelDevList;
  36. map<string, DeviceDescript> m_EthChannelDevList;
  37. void UpdateChannelList(bool Local);
  38. void ClearChannelList(bool Local);
  39. bool TryConnectChannel(bool Local);
  40. bool TryDisConnectChannel(bool Local);
  41. void InitLog();
  42. public:
  43. DevBusManager();
  44. virtual ~DevBusManager();
  45. CCOS_PACKET_ROUTE GetBusIdDirection(string &BusId);
  46. bool ExecFunc();
  47. //init functions
  48. bool LoadBusDrv();
  49. bool UnloadBusDrv();
  50. void NotifyChannel(bool Local, bool Connect);
  51. //interface
  52. bool SendSMPacket(ResDataObject &packet, bool Local, string &TargetbusId, unsigned long long nShareMemID);
  53. bool SendPacket(ResDataObject &packet, bool Local, string &TargetbusId, char* pBlockData = NULL, DWORD Size = 0);
  54. void UnRegistThread(DWORD Tid);
  55. };
  56. extern DevBusManager g_BusManager;