BusThread.cpp 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. // BusThread.cpp : 定义 DLL 应用程序的导出函数。
  2. //
  3. #include "stdafx.h"
  4. #include "BusThread.h"
  5. #include "Logger.h"
  6. #include "CDInterface.h"
  7. #include <iostream>
  8. BusThread::BusThread(void)
  9. {
  10. m_bLocal = true;
  11. }
  12. BusThread::~BusThread(void)
  13. {
  14. }
  15. //work
  16. bool BusThread::Exec()
  17. {
  18. while (WaitForInQue())
  19. {
  20. bool status = true;
  21. //pump In&Out que
  22. while (status)
  23. {
  24. ResDataObject Packet;
  25. status = false;
  26. //check req first
  27. if (PopReqDataObject(Packet))
  28. {
  29. status = true;
  30. //send it to cdi
  31. std::cout << "From Ebus" << Packet.encode() << endl;
  32. #ifndef TEMP_COMP
  33. CDInterface *p = CDInterface::GetCDI();
  34. if (m_bLocal)
  35. {
  36. p->ReceivedFromLocalBus(Packet);
  37. }
  38. else
  39. {
  40. p->ReceivedFromEthBus(Packet);
  41. }
  42. //p->ReceivedFromBus(Packet);
  43. #endif
  44. }
  45. }
  46. }
  47. return true;
  48. }
  49. bool BusThread::OnStartThread(void)
  50. {
  51. printf("========== BusThread::OnStartThread 0X%08X \n", GetCurrentThreadId());
  52. #ifndef TEMP_COMP
  53. TPRINTA_INFO("Bus Thread Begin Entry.....");
  54. #endif
  55. return true;
  56. }
  57. bool BusThread::OnEndThread(void)
  58. {
  59. printf("========== BusThread::OnEndThread 0X%08X \n", GetCurrentThreadId());
  60. #ifndef TEMP_COMP
  61. Logger *pLog = (Logger*)m_pThreadLogger;
  62. PRINTA_INFO(pLog, "Bus Thread End Exit.....");
  63. #endif
  64. return true;
  65. }