l2task.cpp

来自「一个非常好的人工智能开发工具开源软件」· C++ 代码 · 共 118 行

CPP
118 行
字号
/*** *** See the file "L2_RTI_EO1/disclaimers-and-notices-L2.txt" for  *** information on usage and redistribution of this file,  *** and for a DISCLAIMER OF ALL WARRANTIES. ***/#if defined( PRAGMA ) && ! defined( PRAGMA_IMPLEMENTED )#pragma implementation "L2Task.hpp"#endif#include "L2Task.hpp"// ICS:#include <vxWorks.h>#include <msgQLib.h>#include <semLib.h>#include <sysLib.h>#include <taskLib.h>// The Livingstone engine#include <api/livingstone.h>// The RTI#include "ExceptionAction.hpp"#include "Logging.hpp"#include "RTIMessage.hpp"L2Task::L2Task(Livingstone& livingstone) :  d_livingstone(livingstone), d_reporter(livingstone) {}L2Task::~L2Task( void ) {  Logging::log(Logging::L2_DEBUG, "L2:: Sent LOG_EXIT to Log\n");  Logging::log(Logging::LOG_EXIT, "L2:: Sent LOG_EXIT to Log\n");}void L2Task::dequeueRealTimeInput( void ) {  while (true) {    RTIMessage rtiMessage;    if (msgQReceive(RTI_TO_L2_MQID,		    (char*)&rtiMessage,		    sizeof(RTIMessage),		    WAIT_FOREVER) ==	ERROR) {      ExceptionAction::receiveFailure(ExceptionAction::RCV_LIVINGSTONE_DISPATCHER,				      errno);    } else {      // actionLivingstone() returns false on exit      if (!actionLivingstone(rtiMessage)) { return; }    }  }}int L2Task::actionLivingstone(const RTIMessage&					     livingstoneMessage) {  // switch on the function specified, parse arguments accordingly  switch(livingstoneMessage.getOpcode()) {  case COMMAND:    d_livingstone.command(livingstoneMessage.getVariableID(),			  livingstoneMessage.getValueIndex());    break;  case OBSERVATION:    d_livingstone.observe(livingstoneMessage.getVariableID(),			  livingstoneMessage.getValueIndex());        break;  case FIND_CANDIDATES:    d_livingstone.diagnose();    break;  case PROGRESS:    d_livingstone.idle();    break;  case REPORT_FULL_STATE:    d_reporter.reportFullState();    break;  case REPORT_COMMAND:    d_reporter.reportCommand(livingstoneMessage.getTimeStamp().seconds,			     livingstoneMessage.getTimeStamp().nanosec,			     livingstoneMessage.getVariableID(),			     livingstoneMessage.getValueIndex());    break;  case REPORT_OBSERVATION:    d_reporter.reportObservation(livingstoneMessage.getTimeStamp().seconds,				 livingstoneMessage.getTimeStamp().nanosec,				 livingstoneMessage.getVariableID(),				 livingstoneMessage.getValueIndex());    break;  case REPORT_FIND_CANDIDATES:    d_reporter.reportFindCandidates();    break;  case REPORT_DIAGNOSIS:    d_reporter.reportDiagnosis(livingstoneMessage.getTimeStamp().seconds,			       livingstoneMessage.getTimeStamp().nanosec);     break;  case REPORT_PROGRESS:    d_reporter.reportIdle(livingstoneMessage.getTimeStamp().seconds,			  livingstoneMessage.getTimeStamp().nanosec);     break;  case L2_EXIT:    Logging::log(Logging::L2_DEBUG, "L2::Received L2_EXIT\n");    return false; // do not continue running  default:    ExceptionAction::unhandledDispatcherOpcode(livingstoneMessage.getOpcode());    break;  }  return true; // continue running}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?