plc_task.cpp 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #include "plc_task.h"
  2. Plc_Task::Plc_Task(){
  3. m_task_type = Task_type::PLC_TASK;
  4. mb_result_set_flag = false;
  5. }
  6. Plc_Task::~Plc_Task(){
  7. }
  8. Error_manager Plc_Task::init(){
  9. m_measure_result.terminal_id = -1;
  10. m_measure_result.correctness = false;
  11. m_measure_result.x = 0;
  12. m_measure_result.y = 0;
  13. m_measure_result.angle = 0;
  14. m_measure_result.length = 0;
  15. m_measure_result.width = 0;
  16. m_measure_result.height = 0;
  17. m_measure_result.wheel_base = 0;
  18. m_task_statu = Task_statu::TASK_CREATED;
  19. return SUCCESS;
  20. }
  21. Error_manager Plc_Task::get_result(struct measure_result &result){
  22. if(mb_result_set_flag)
  23. {
  24. memcpy(&result, &m_measure_result, sizeof(m_measure_result));
  25. return Error_manager(Error_code::SUCCESS, Error_level::NORMAL, "成功获取测量结果");
  26. }
  27. else
  28. {
  29. return Error_manager(Error_code::PLC_EMPTY_TASK, Error_level::NEGLIGIBLE_ERROR, "未获得测量结果,或许是由于在set之前被调用");
  30. }
  31. }
  32. Error_manager Plc_Task::set_result(struct measure_result result){
  33. memcpy(&m_measure_result, &result, sizeof(result));
  34. mb_result_set_flag = true;
  35. return Error_manager(Error_code::SUCCESS, Error_level::NORMAL, "设置测量结果成功");
  36. }
  37. bool Plc_Task::get_result_set_flag(){
  38. return mb_result_set_flag;
  39. }