task_command_manager.cpp 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. #include "task_command_manager.h"
  2. #include "../laser/Laser.h"
  3. #include "../laser/laser_manager.h"
  4. #include "../locate/locate_manager.h"
  5. //对外的接口函数,所有的任务发送方,都必须使用该函数。
  6. //execute_task在内部解析了Task_Base里面的Task_type,然后转发给具体某个模块的实例对象。
  7. //input:p_task_base 任务单,基类的指针,指向子类的实例,(多态)
  8. Error_manager Task_command_manager::execute_task(Task_Base* p_task_base)
  9. {
  10. Error_manager t_error;
  11. void * tp_tast_receiver = p_task_base->get_tast_receiver();
  12. switch ( p_task_base->get_task_type() )
  13. {
  14. case UNKNOW_TASK:
  15. t_error.error_manager_reset(Error_code::TASK_TYPE_IS_UNKNOW, Error_level::MINOR_ERROR,
  16. " p_task_base->get_task_type() is UNKNOW_TASK ");
  17. break;
  18. case LASER_MANGER_SCAN_TASK:
  19. if ( tp_tast_receiver != NULL )
  20. {
  21. t_error = ((Laser_manager*)tp_tast_receiver)->execute_task(p_task_base);
  22. }
  23. else
  24. {
  25. t_error = Laser_manager::get_instance_references().execute_task(p_task_base);
  26. }
  27. break;
  28. case LASER_BASE_SCAN_TASK:
  29. if ( tp_tast_receiver != NULL )
  30. {
  31. t_error = ((Laser_base*)tp_tast_receiver)->execute_task(p_task_base);
  32. }
  33. else
  34. {
  35. return Error_manager(Error_code::TASK_NO_RECEIVER, Error_level::MINOR_ERROR,
  36. " Task_command_manager::execute_task have not receiver ");
  37. }
  38. break;
  39. case LOCATE_MANGER_TASK:
  40. if ( tp_tast_receiver != NULL )
  41. {
  42. t_error = ((Locate_manager*)tp_tast_receiver)->execute_task(p_task_base);
  43. }
  44. else
  45. {
  46. t_error = Locate_manager::get_instance_references().execute_task(p_task_base);
  47. }
  48. break;
  49. case PLC_TASK:
  50. ;
  51. break;
  52. case WJ_TASK:
  53. ;
  54. break;
  55. default:
  56. t_error.error_manager_reset(Error_code::TASK_TYPE_IS_UNKNOW, Error_level::MINOR_ERROR,
  57. " p_task_base->get_task_type() is UNKNOW_TASK ");
  58. break;
  59. }
  60. return t_error;
  61. }