CommonLogicClient.cpp 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. #include "stdafx.h"
  2. #include "CommonLogicClient.h"
  3. CommonLogicClient::CommonLogicClient()
  4. {
  5. pLogicDeivce = (LogicDevice*)this;
  6. m_pSysIF->SetLogicDevice(pLogicDeivce);
  7. }
  8. CommonLogicClient::~CommonLogicClient()
  9. {
  10. }
  11. CommonLogicClient& CommonLogicClient::operator = (const CommonLogicClient &tValue)
  12. {
  13. //strongly recommended do not assign a client to another one
  14. if (this != &tValue)
  15. {
  16. m_FileFlags = tValue.m_FileFlags;
  17. (*m_pFilePath) = (*(tValue.m_pFilePath));
  18. //do open
  19. if (tValue.m_ClosedFlag == false)
  20. {
  21. if (Open((tValue.m_pFilePath)->c_str(), (CCOS_FILE_FLAGS)tValue.m_FileFlags) <= 0)
  22. {
  23. //failed here
  24. //put some log
  25. printf("Thread:%d,Open Failed\n", GetCurrentThreadId());
  26. }
  27. }
  28. }
  29. return (*this);
  30. }
  31. PACKET_CMD CommonLogicClient::ReadCmd(ResDataObject &CmdObject)
  32. {
  33. PACKET_CMD ret = PACKET_CMD_NONE;
  34. while (IsDataArrived())
  35. {
  36. ret = LogicClient::ReadCmd(CmdObject);
  37. if (ret != PACKET_CMD_NONE)
  38. {
  39. return ret;
  40. }
  41. }
  42. return ret;
  43. }
  44. bool SYSTEM_CALL CommonLogicClient::GetDeviceType(GUID &DevType)
  45. {
  46. if (IsClosed())
  47. {
  48. return RET_FAILED;
  49. }
  50. return (LogicClient::GetDeviceType(DevType) == RET_SUCCEED);
  51. }
  52. //get device resource
  53. RET_STATUS SYSTEM_CALL CommonLogicClient::GetDeviceResource(ResDataObject PARAM_OUT *pDeviceResource)
  54. {
  55. if (IsClosed())
  56. {
  57. return RET_FAILED;
  58. }
  59. return LogicClient::GetDeviceResource(pDeviceResource);
  60. }
  61. //ResourceCommand Request In and Response Out
  62. RET_STATUS SYSTEM_CALL CommonLogicClient::Request(ResDataObject PARAM_IN *pRequest, ResDataObject PARAM_OUT *pResponse)
  63. {
  64. //do nothing
  65. return RET_NOSUPPORT;
  66. }
  67. //notify to lower layer
  68. //notify&response from real logic device
  69. RET_STATUS SYSTEM_CALL CommonLogicClient::CmdToLogicDev(ResDataObject PARAM_IN *pCmd)
  70. {
  71. //response and notify comes here
  72. //printf("Driver Thread:%d,CommonLogicClient got Packet\n", GetCurrentThreadId());
  73. PacketArrived(pCmd);
  74. return RET_SUCCEED;
  75. }