Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

ippBasicExecutor.cpp

Go to the documentation of this file.
00001 // 
00002 // DISCLAIMER: 
00003 //  This software was produced by the National Institute of Standards 
00004 //  and Technology (NIST), an agency of the U.S. government, and by statute is 
00005 //  not subject to copyright in the United States.  Recipients of this 
00006 //  software assume all responsibility associated with its operation,
00007 //  modification,maintenance, and subsequent redistribution. 
00008 //
00009 //  See NIST Administration Manual 4.09.07 b and Appendix I. 
00010 //
00011 #include "stdafx.h"
00012 
00013 #include "ippdme/Executor/ippBasicExecutor.h"
00014 #include "ippdme/world.h"
00015 
00016 
00017 #include "ippdme/Response/ippGetDMEVersionResponse.h"
00018 #include "ippdme/Response/ippKeyPressEResponse.h"
00019 #include "ippdme/Response/responses.h"
00020 
00021 #include "ippdme/Property/ippOnePropertyId.h"
00022 #include "ippdme/Property/ippOnePropertyName.h"
00023 #include "ippdme/Property/ippOnePropertyNumber.h"
00024 
00025 #include "ippdme/Command/ippStopDaemonCommand.h"
00026 #include "ippdme/Command/ippGetPropCommand.h"
00027 #include "ippdme/Command/ippChangeToolCommand.h"
00028 #include "ippdme/Command/ippFindToolCommand.h"
00029 #include "ippdme/Command/ippSetToolCommand.h"
00030 #include "ippdme/Command/ippGetCommand.h"
00031 #include "ippdme/Command/ippGetCsyTransformationCommand.h"
00032 #include "ippdme/Command/ippEnumAllPropCommand.h"
00033 #include "ippdme/Command/ippEnumPropCommand.h"
00034 
00035 #include "ippdme/misc/ippPropDefinition.h"
00036 
00037 #include "ippdme/assert.h"
00038 
00039 #ifdef _DEBUG
00040 #define new DEBUG_NEW
00041 #undef THIS_FILE
00042 static char THIS_FILE[] = __FILE__;
00043 #endif
00044 
00045 //=============================================================================
00046 ippBasicExecutor::ippBasicExecutor(world& w)
00047 //-----------------------------------------------------------------------------
00048 :_world(w)
00049 {
00050  //xx _previousTool = getTools()->getActiveTool();
00051 
00052 }
00053 
00054 
00055 //=============================================================================
00056 void ippBasicExecutor::resetExecutor()
00057 //-----------------------------------------------------------------------------
00058 {
00059   ippExecutor::resetExecutor();
00060   _world.stopAllDaemons();
00061 }
00062 
00063 
00064 
00065 //=============================================================================
00066 void  ippBasicExecutor::executeIsHomed()
00067 //-----------------------------------------------------------------------------
00068 {
00069         unsigned int tag_num = _currentCommand->getTag().getTagNumber();
00070         ippIsHomedResponsePtr x = new ippIsHomedResponse (tag_num, _world.getIsHomed());
00071         _returningValues.push_back(x);
00072         generateCompletedResponse();
00073 } 
00074 
00075 
00076 //=============================================================================
00077 void ippBasicExecutor::StopAllDaemons()
00078 //-----------------------------------------------------------------------------
00079 {
00080   _world.stopAllDaemons();
00081 }
00082 
00083 //=============================================================================
00084 int  ippBasicExecutor::DaemonCount() const
00085 //-----------------------------------------------------------------------------
00086 {
00087   return _world.daemonCount();
00088 }
00089 
00090 
00091 
00092 
00093 //=============================================================================
00094 void ippBasicExecutor::executeStartSession()
00095 //-----------------------------------------------------------------------------
00096 {
00097   _world.update(_currentCommand);  // world performs update
00098   _world.setReadiness(ready);
00099   generateCompletedResponse();
00100 } 
00101 
00102 //=============================================================================
00103 void ippBasicExecutor::executeEndSession()
00104 //-----------------------------------------------------------------------------
00105 {
00106   _world.update(_currentCommand);   // Execution world model changes
00107   generateCompletedResponse(); 
00108 } 
00109 
00110 //=============================================================================
00111 void ippBasicExecutor::executeStopDaemon()
00112 //-----------------------------------------------------------------------------
00113 {
00114   ippStopDaemonCommandPtr cmd=static_cast<ippStopDaemonCommand*>(_currentCommand.get());
00115 
00116   int daemon_tag = cmd->getDaemonTag().getTagNumber();
00117   if (!_world.daemonExists(daemon_tag)) {
00118     generateErrorResponse(DaemonDoesNotExist,"");
00119   } else {
00120     _world.stopDaemon(daemon_tag);
00121   }
00122   generateCompletedResponse();
00123 }
00124 
00125 //=============================================================================
00126 void ippBasicExecutor::executeStopAllDaemons()
00127 //-----------------------------------------------------------------------------
00128 {
00129   if(_world.daemonCount() == 0 ) { 
00130     generateErrorResponse(NoDaemonsAreActive,"");
00131   }
00132   _world.stopAllDaemons();
00133   generateCompletedResponse();
00134 }
00135 
00136 //==============================================================================
00137 void ippBasicExecutor::executeGetDMEVersion()
00138 //-----------------------------------------------------------------------------
00139 {
00140   
00141   unsigned int tag_num = _currentCommand->getTag().getTagNumber();
00142   ippResponsePtr r= new ippGetDMEVersionResponse(tag_num, "1.5");
00143   _returningValues.push_back(r);
00144   generateCompletedResponse();
00145 }
00146 
00147 //==============================================================================
00148 void ippBasicExecutor::executeOnMoveReportE()
00149 //-----------------------------------------------------------------------------
00150 {
00151 
00152   ippOnMoveReportECommandPtr currentOnMoveReportE = 
00153   static_cast<ippOnMoveReportECommand*>(_currentCommand.get());
00154 
00155   int daemon_tag  =_currentCommand->getTag().getTagNumber();
00156    
00157   if (_world.daemonExists(_currentCommand->getTag().getTagNumber())) { 
00158     // a daemon with this tag already exists
00159     generateErrorResponse(DaemonAlreadyExists,"");
00160   } else {
00161     _world.addDaemon(currentOnMoveReportE.get());
00162   }
00163 
00164   generateCompletedResponse();
00165   
00166 } // end executeOnMoveReportE()
00167 
00168 //==============================================================================
00169 void  ippBasicExecutor::executeOnPtMeasReport()
00170 //-----------------------------------------------------------------------------
00171 {
00172   _world.update(_currentCommand);
00173   generateCompletedResponse();
00174 
00175 } 
00176 
00177 //==============================================================================
00178 void ippBasicExecutor::executeOnScanReport()
00179 //-----------------------------------------------------------------------------
00180 {
00181   _world.update(_currentCommand);
00182   generateCompletedResponse();
00183 
00184 } 
00185 
00186 
00187 ippOnePropertyPtr ippBasicExecutor::GetToolProperty(
00188   ippKToolConstPtr theTool,
00189   const ippProp& prop
00190 )
00191 {
00192   IPP_ASSERT(theTool.get());
00193 
00194   double val =0;
00195   if (prop.getKey2() == Alignment) {   
00196     return _world.getCurrentAlignment();    
00197 
00198   } else if (prop.getKey2() == CollisionVolume) {
00199     return theTool->getCollisionVolume();
00200   } else if (prop.getKey2() == AvrRadius) {
00201     val = theTool->getRadius();
00202     return new ippOnePropertyNumber(prop,val);  
00203   } else if (prop.getKey2() == Id) {
00204       return new ippOnePropertyId(prop.getKey1(), theTool->getId());
00205 
00206   } else if (prop.getKey2() == Name) {
00207      return new ippOnePropertyName(prop.getKey1(), theTool->getName());
00208 
00209   } else if (prop.getKey2() == GoToPar /*&& theTool != getTools()->getUnDefTool()*/) {
00210         
00211     bool bSuccess = false;
00212     ippGoToParsPtr pars1 = theTool->getGoToPar();
00213     switch (prop.getKey3()) {
00214       case Speed:
00215         bSuccess = pars1->getSpeed().getProperty(prop.getKey4(),val);
00216         break;
00217       case Accel:
00218         bSuccess = pars1->getAccel().getProperty(prop.getKey4(),val);
00219         break;
00220     default:
00221         break;
00222     }
00223     if (bSuccess) {
00224      return new ippOnePropertyNumber(prop,val);
00225    }
00226 
00227 
00228   } else if (prop.getKey2() == PtMeasPar /*&& theTool != getTools()->getNoTool()*/) {   
00229     bool bSuccess = false;
00230     ippPtMeasParsPtr pars2 = theTool->getPtMeasPar();
00231     switch (prop.getKey3()) {
00232       case Speed:
00233         bSuccess = pars2->getSpeed().getProperty(prop.getKey4(),val);
00234         break;
00235       case Accel:
00236         bSuccess = pars2->getAccel().getProperty(prop.getKey4(),val);
00237         break;
00238       case Approach:
00239         bSuccess = pars2->getApproach().getProperty(prop.getKey4(),val);
00240         break;
00241       case Retract:
00242         bSuccess = pars2->getRetract().getProperty(prop.getKey4(),val);
00243         break;
00244       case Search:
00245         bSuccess = pars2->getSearch().getProperty(prop.getKey4(),val);
00246         break;
00247       default:
00248         break;
00249     }
00250     if (bSuccess) return new ippOnePropertyNumber(prop,val);
00251   
00252   } else if (prop.getKey2() == ScanPar /*&& theTool != getTools()->getNoTool()*/) {  
00253     bool bSuccess = false;
00254     ippScanParsPtr pars = theTool->getScanPar();
00255     IPP_ASSERT(pars);
00256     if (pars) {
00257       switch (prop.getKey3()) {
00258         case Speed:
00259           bSuccess = pars->getSpeed().getProperty(prop.getKey4(),val);
00260           break;
00261         case Accel:
00262           bSuccess = pars->getAccel().getProperty(prop.getKey4(),val);
00263           break;
00264         case Retract:
00265           bSuccess = pars->getRetract().getProperty(prop.getKey4(),val);
00266           break;
00267         default:
00268           break;
00269       }
00270     }
00271     if (bSuccess) return new ippOnePropertyNumber(prop,val);
00272  } 
00273  return 0;
00274 }
00275 
00276 
00277 //=============================================================================
00278 void ippBasicExecutor::beforeExecuteGet()
00279 //
00280 //
00281 //-----------------------------------------------------------------------------
00282 {
00283   IPP_ASSERT_FAIL("Should be overridden by the derived class->in this method\n"
00284               " the implementation should make sure that the world objects"
00285               " reflects the actual state of the connected DME ");
00286 }
00287 
00288 //=============================================================================
00289 void  ippBasicExecutor::executeGet()
00290 //-----------------------------------------------------------------------------
00291 {
00292   beforeExecuteGet();
00293 
00294   double er=0, i=0, j=0, k=0, r=0, x=0, y=0, z=0, toolA=0, toolB=0, toolC=0;
00295 
00296   int ijkAct=0;
00297 
00298   bool hasER = false, hasIJK = false, hasR = false;
00299   bool hasX = false, hasY = false, hasZ = false;
00300   bool hasToolA = false, hasToolB = false, hasToolC = false;
00301   bool hasIJKAct = false;
00302   bool hasQ = false;
00303   double q=0;
00304 
00305   ippGetCommandPtr  cmd = static_cast<ippGetCommand *>(_currentCommand.get());
00306 
00307   
00308   if (cmd->getHasR()){
00309           r = _world.getCurrentR();
00310           hasR = true;
00311   }
00312 
00313 
00314   if (cmd->getHasX()){
00315     x = _world.getCurrentX();
00316     hasX = true;
00317   }
00318   if (cmd->getHasY()){
00319     y = _world.getCurrentX();
00320     hasY = true;
00321   }
00322   if (cmd->getHasZ()){
00323     z = _world.getCurrentX();
00324     hasZ = true;
00325   }
00326   if (cmd->getHasToolA()){
00327     toolA = _world.getCurrentToolA();
00328     hasToolA = true;
00329   }
00330   if (cmd->getHasToolB()){
00331     toolB = _world.getCurrentToolB();
00332     hasToolB = true;
00333   }
00334   if (cmd->getHasToolC()){
00335     toolC = _world.getCurrentToolC();
00336     hasToolC = true;
00337   }
00338 //  if (cmd->getHasIJKAct()){
00339 //    IJKAct =0;
00340 //    hasIJKAct = true;
00341 //  }
00342 //
00343   if(hasER==true || hasIJK==true || hasR==true || hasX==true || hasY==true || hasZ==true || 
00344                 hasToolA==true || hasToolB==true || hasToolC==true)
00345   {
00346     unsigned int tag_num = _currentCommand->getTag().getTagNumber();
00347     ippPtMeasOrGetResponsePtr res = new ippPtMeasOrGetResponse(tag_num, 
00348                 hasER, hasIJK, hasIJKAct, hasQ, hasR, hasToolA, hasToolB, hasToolC, hasX, hasY, hasZ, 
00349             er, i, j, k, ijkAct, q, r, toolA, toolB, toolC, x, y, z);
00350   
00351     _returningValues.push_back(res);
00352 
00353     generateCompletedResponse();
00354   } else {
00355     generateCompletedResponse();
00356   }
00357 
00358 }  
00359 
00360 //=============================================================================
00361 ippToolChangerPtr ippBasicExecutor::getTools()
00362 //-----------------------------------------------------------------------------
00363 {
00364   IPP_ASSERT(_world.getTools());
00365   return  _world.getTools();
00366 }
00367 
00368 
00369 //==============================================================================
00370 void ippBasicExecutor::executeGetProp()
00371 //-----------------------------------------------------------------------------
00372 {
00373   // [TODO] there is plenty of scope to rationalize and remove code duplication here.
00374   //        between executeGetProp and executeGetPropE !
00375   ippGetPropCommandConstPtr cmd = static_cast<ippGetPropCommand*>(_currentCommand.get());
00376 
00377   int numberProps = cmd->getNumberProps();
00378 
00379   ippGetPropResponsePtr res = new ippGetPropResponse(
00380     _currentCommand->getTag().getTagNumber(),
00381     _currentCommand->getTag().getTagType());
00382 
00383   for (int n=0; n<numberProps; n++){
00384 
00385     const ippProp& prop = cmd->getProp(n);
00386 
00387     ippKToolConstPtr theTool;
00388 
00389     if (prop.getKey1() == Tool) {
00390       theTool = getTools()->getActiveTool();
00391     } else if (prop.getKey1() == FoundTool){
00392       theTool = getTools()->getFoundTool();
00393       // Note: what should happen if found tool is the UnDefTOol here ?
00394       //       We must assume that at least FindTool has been called once.
00395     }
00396     ippOnePropertyPtr p = GetToolProperty(theTool,prop);
00397     if (p) res->append(p);
00398 
00399   }
00400 
00401   _returningValues.push_back(res);
00402 
00403   generateCompletedResponse();
00404 }
00405 
00406 
00407 //==============================================================================
00408 void ippBasicExecutor::executeGetPropE()
00409 //-----------------------------------------------------------------------------
00410 {
00411    executeGetProp();
00412 } // end executeGetPropE()
00413 
00414 //==============================================================================
00415 void ippBasicExecutor::generateOnMoveReport()
00416 //-----------------------------------------------------------------------------
00417 {
00418 
00419   if (_world.daemonCount() == 0 ) return;
00420 
00421   double r = -1, x = -1, y = -1, z = -1, toolA = -1, toolB = -1, toolC = -1;
00422   bool hasR = false, hasX = false, hasY = false, hasZ = false;
00423   bool hasToolA = false, hasToolB = false, hasToolC = false;
00424   
00425   ippDaemonConstPtr daemon = _world.getDaemon();
00426   
00427   ippOnMoveReportECommandConstPtr cmd = daemon->getOnMoveReportECommand();
00428 
00429   if (cmd->getHasR()){
00430    r = _world.getCurrentR();
00431    hasR = true;
00432   }
00433   if (cmd->getHasX()){
00434    x = _world.getCurrentX();
00435    hasX = true;
00436   }
00437   if (cmd->getHasY()){
00438    y = _world.getCurrentY();
00439    hasY = true;
00440   }
00441    if (cmd->getHasZ()){
00442     z = _world.getCurrentZ();
00443     hasZ = true;
00444   }
00445    if (cmd->getHasToolA()){
00446    toolA = _world.getCurrentToolA();
00447    hasToolA = true;
00448   }
00449    if (cmd->getHasToolB()){
00450    toolB = _world.getCurrentToolB();
00451    hasToolB = true;
00452   }
00453    if (cmd->getHasToolC()){
00454    toolC = _world.getCurrentToolC();
00455    hasToolC = true;
00456   }
00457    if(hasR==true || hasX==true || hasY==true || hasZ==true || 
00458     hasToolA==true || hasToolB==true || hasToolC==true){
00459 
00460     unsigned int tag_num = cmd->getTag().getTagNumber();
00461 
00462     ippOnMoveReportEResponsePtr res = new ippOnMoveReportEResponse 
00463     (tag_num, hasR, hasToolA, hasToolB, hasToolC, hasX, hasY, hasZ, 
00464               r, toolA, toolB, toolC, x, y, z);
00465   
00466     _returningValues.push_back(res);
00467    }
00468 }
00469 
00470 
00471 //==============================================================================
00472 void ippBasicExecutor::generatePtMeasReport()
00473 // 9.5.3 Pick manual point
00474 //-----------------------------------------------------------------------------
00475 {
00476   // Generate response based on data request by the last OnPtmeasReport command
00477   double r = -1, x = -1, y = -1, z = -1, toolA = -1, toolB = -1, toolC = -1, 
00478     er = -1, i = -1, j = -1, k = -1;
00479   bool hasR = false, hasX = false, hasY = false, hasZ = false, hasER = false;
00480   bool hasToolA = false, hasToolB = false, hasToolC = false, hasIJK = false;
00481   bool hasIJKAct = false;
00482   bool hasQ = false;
00483   int ijkAct = 1;
00484   double q = -1.0;
00485   
00486   //    unsigned int tag_num = _currentPtMeas->getTag().getTagNumber();
00487 
00488   ippOnPtMeasReportCommandConstPtr cmd = _world.getOnPtMeasReportCommand();
00489 
00490   if (cmd->getHasR()){
00491     r = _world.getCurrentR();
00492     hasR = true;
00493   }
00494   if (cmd->getHasX()){
00495     x = _world.getCurrentX();
00496     hasX = true;
00497   }
00498   if (cmd->getHasY()){
00499     y = _world.getCurrentY();
00500     hasY = true;
00501   }
00502   if (cmd->getHasZ()){
00503     z = _world.getCurrentZ();
00504     hasZ = true;
00505   }
00506   if (cmd->getHasToolA()){
00507     toolA = _world.getCurrentToolA();
00508     hasToolA = true;
00509   }
00510   if (cmd->getHasToolB()){
00511     toolB = _world.getCurrentToolB();
00512     hasToolB = true;
00513   }
00514   if (cmd->getHasToolC()){
00515     toolC = _world.getCurrentToolC();
00516     hasToolC = true;
00517   }
00518   if (cmd->getHasER()){
00519     er = _world.getProbeRadius();
00520     hasER = true;
00521   }
00522   if (cmd->getHasQ()){
00523     q = _world.getCurrentQ();
00524     hasQ = true;
00525   }
00526   if (cmd->getHasIJKAct()){
00527     ijkAct = _world.getIJKAct();
00528     hasIJKAct = true;
00529   }
00530   
00531   if (cmd->getHasIJK()){
00532     // Note if _scanning us 001, however, if
00533     // single point must compute ijk from 
00534     // start and destination.
00535     i = 0;
00536     j = 0;
00537     k = 1;
00538     hasIJK = true;
00539   }
00540   
00541   int tag_num = 0;
00542   if (_currentCommand) {
00543     tag_num = _currentCommand->getTag().getTagNumber();
00544   }  else {
00545     // unsollicited contact 
00546   }
00547 
00548   if(hasR || hasX|| hasY || hasZ || 
00549     hasToolA || hasToolB|| hasToolC||
00550     hasIJK || hasER || hasQ || hasIJKAct) {
00551     
00552     ippResponsePtr  res = new ippPtMeasOrGetResponse(tag_num,
00553       hasER, hasIJK, hasIJKAct, hasQ,
00554       hasR, hasToolA, hasToolB, hasToolC, hasX, hasY, hasZ, 
00555       er,i, j, k, ijkAct,q,r, toolA, toolB, toolC, x, y, z);
00556     _returningValues.push_back(res);
00557   }
00558 }
00559 
00560 //==============================================================================
00561 void ippBasicExecutor::generateIntermediatePointReport()
00562 //
00563 // 9.5.2. Clearance or intermediate point set
00564 //
00565 //-----------------------------------------------------------------------------
00566 {
00567 
00568 
00569 }
00570 //==============================================================================
00571 void ippBasicExecutor::generateKeyPress(const char* key)
00572 //
00573 // 9.5.2. Clearance or intermediate point set
00574 //
00575 //-----------------------------------------------------------------------------
00576 {
00577   ippKeyPressEResponsePtr res = new ippKeyPressEResponse(key);
00578   _returningValues.push_back(res);
00579 
00580 }
00581 //==============================================================================
00582 void ippBasicExecutor::executeEnumTools()
00583 //-----------------------------------------------------------------------------
00584 {
00585 
00586   UpdateTools();
00587 
00588   const std::vector<ippKToolPtr>& listOfTools = getTools()->getToolList();
00589   std::vector<ippKToolPtr>::const_iterator p;
00590 
00591   unsigned int tag_num = _currentCommand->getTag().getTagNumber();
00592 
00593   for (p = listOfTools.begin(); p != listOfTools.end(); p++)
00594   {
00595     ippKToolPtr kt = *p;
00596     if( strcmp(kt->getName(),"UnDefTool") !=0 && strcmp(kt->getName(),"BaseTool")!=0) {
00597         ippResponsePtr r = new ippStringResponse(tag_num, kt->getName());
00598         _returningValues.push_back(r);
00599     }
00600   }
00601   
00602   generateCompletedResponse();
00603 
00604 } // end executeEnumTools()
00605 
00606 //==============================================================================
00607 void  ippBasicExecutor::executeFindTool()
00608 //-----------------------------------------------------------------------------
00609 {
00610  
00611   const ippFindToolCommand * theFind =
00612       static_cast<const ippFindToolCommand *>(_currentCommand.get());
00613 
00614   ippKToolPtr foundTool = getTools()->findTool(theFind->getToolName());
00615   
00616   if (!foundTool || strcmp(foundTool->getName(),"UnDefTool") ==0 ){
00617     std::string  cmdStr =_currentCommand->getCommandString();
00618     ippResponsePtr x = new ippErrorResponse(_currentCommand->getTag(),ToolNotFound, cmdStr.c_str());
00619     _returningValues.push_back(x);
00620   }
00621 
00622   _world.update(_currentCommand);   //World updates found tool
00623   generateCompletedResponse();
00624 
00625 } // end executeFindTool()
00626 
00627 //==============================================================================
00628 void ippBasicExecutor::executeGetChangeToolAction()
00629 //-----------------------------------------------------------------------------
00630 {
00631   double toolDiff = 0;
00632   toolDiff = _previousTool->getLength() - (getTools()->getActiveTool()->getLength()); 
00633 
00634   unsigned int tag_num = _currentCommand->getTag().getTagNumber();
00635 
00636   ippResponsePtr res = new ippGetChangeToolActionResponse(
00637       tag_num,Switch,0,0,toolDiff);
00638                                       //  changeToolActionType inChangeType,
00639                                       //  double inX, double inY, double inZ);
00640 
00641   _returningValues.push_back(res);
00642 
00643   generateCompletedResponse();
00644 
00645 }
00646 
00647 //=============================================================================
00648 void  ippBasicExecutor::executeChangeTool()
00649 //-----------------------------------------------------------------------------
00650 {
00651   ippChangeToolCommandConstPtr cmd =
00652       static_cast<const ippChangeToolCommand *>(_currentCommand.get());
00653 
00654   ippKToolPtr foundTool = getTools()->findTool(cmd->getToolName());
00655   
00656   if (!foundTool ||
00657     strcmp(foundTool->getName(),"UnDefTool") ==0 ||
00658     strcmp(foundTool->getName(),"BaseTool") ==0 ) {
00659     std::string  cmdStr =_currentCommand->getCommandString();
00660 
00661     ippResponsePtr x = new ippErrorResponse(_currentCommand->getTag(),
00662                                 ToolNotFound, cmdStr.c_str());
00663 
00664     _returningValues.push_back(x);
00665   }
00666   
00667   _previousTool = getTools()->getActiveTool();
00668 
00669   setTool(foundTool);
00670 
00671   _world.update(_currentCommand); // Execution world model changes
00672                                         // Sets the active tool
00673 
00674   generateCompletedResponse();
00675 
00676 } // end executeChangeTool()
00677 
00678 
00679  //==============================================================================
00680 void ippBasicExecutor::UpdateTools()
00681 //-----------------------------------------------------------------------------
00682 {
00683   IPP_ASSERT_FAIL("Should be overridden by the derived class->in this method\n"
00684               " the implementation should make sure that the tool collection"
00685               " of the world object reflects the actual state of the connected DME ");
00686 
00687 }
00688  //==============================================================================
00689 void ippBasicExecutor::setTool(ippKToolPtr& tool)
00690 //-----------------------------------------------------------------------------
00691 {
00692   IPP_ASSERT_FAIL("Should be overridden by the derived class->in this method\n"
00693               " the implementation should make sure that the specified tool is"
00694               " is set on the connected DME ");
00695 
00696 }
00697 //=============================================================================
00698 void  ippBasicExecutor::executeSetTool()
00699 //-----------------------------------------------------------------------------
00700 {
00701 
00702    ippSetToolCommandConstPtr cmd =
00703       static_cast<const ippSetToolCommand *>(_currentCommand.get());
00704 
00705   ippKToolPtr foundTool = getTools()->findTool(cmd->getToolName());
00706   
00707   if (!foundTool) {
00708     // [TO DO] it is unclear what other tool might be disallowed here
00709     std::string  cmdStr =_currentCommand->getCommandString();
00710 
00711     ippResponsePtr x = new ippErrorResponse(_currentCommand->getTag(),
00712                                ToolNotFound, cmdStr.c_str());
00713 
00714     _returningValues.push_back(x);
00715   }
00716 
00717   setTool(foundTool);
00718   _world.update(_currentCommand);  // world performs update
00719 
00720 
00721   generateCompletedResponse();
00722 
00723 } 
00724 
00725 
00726 //==============================================================================
00727 void  ippBasicExecutor::executeGetMachineClass()
00728 //-----------------------------------------------------------------------------
00729 {
00730   unsigned int tag_num = _currentCommand->getTag().getTagNumber();
00731 
00732   ippGetMachineClassResponsePtr r = new ippGetMachineClassResponse(tag_num);
00733   r->setMachineClass(_world.getMachineClass());
00734   _returningValues.push_back(r);
00735   generateCompletedResponse();
00736 
00737 } 
00738 
00739 
00740 
00741 //=============================================================================
00742 void  ippBasicExecutor::executeDisableUser()
00743 //-----------------------------------------------------------------------------
00744 {
00745   _world.update(_currentCommand); // Execution world model changes
00746                                   // WM user_enabled flag to false
00747   generateCompletedResponse();
00748 
00749 } 
00750 
00751 
00753 
00754 //=============================================================================
00755 void  ippBasicExecutor::executeEnableUser()
00756 //-----------------------------------------------------------------------------
00757 {
00758   _world.update(_currentCommand); // Execution world model changes
00759                                   // WM user_enabled flag to true
00760   generateCompletedResponse();
00761 } 
00762 
00763 
00764 //=============================================================================
00765 void  ippBasicExecutor::executeIsUserEnabled()
00766 //-----------------------------------------------------------------------------
00767 {
00768   unsigned int tag_num = _currentCommand->getTag().getTagNumber();
00769   
00770   ippIsUserEnabledResponse *x = new ippIsUserEnabledResponse(
00771     tag_num, _world.getUserEnabled());
00772  
00773   _returningValues.push_back(x);
00774 
00775   generateCompletedResponse();
00776 
00777 } 
00778 
00779 
00780 //==============================================================================
00781 void  ippBasicExecutor::executeGetCoordSystem()
00782 //-----------------------------------------------------------------------------
00783 {
00784   unsigned int tag_num = _currentCommand->getTag().getTagNumber();
00785   ippCoordSysType i = _world.getCurrentCsy();
00786   ippResponsePtr x = new ippGetCoordSystemResponse(tag_num, i);
00787   _returningValues.push_back(x);
00788   generateCompletedResponse();
00789 
00790 } 
00791 
00792 //==============================================================================
00793 void  ippBasicExecutor::executeGetCsyTransformation()
00794 //-----------------------------------------------------------------------------
00795 {
00796   unsigned int tag_num =  _currentCommand->getTag().getTagNumber();
00797   ippGetCsyTransformationCommandConstPtr gcsytc
00798     = boost::static_pointer_cast<ippGetCsyTransformationCommand>(_currentCommand);
00799 
00800   ippCoordSysType cst = gcsytc->getCoordSys();
00801  
00802   ippCsyTransform * cT = 0;
00803  
00804   switch (cst){
00805 
00806     case JogDisplayCsy :
00807       cT = _world.getJogDisplayCsyTransform();
00808       break;
00809     case JogMoveCsy :
00810       cT = _world.getJogMoveCsyTransform();
00811       break;
00812     case MoveableMachineCsy :
00813       cT = _world.getMoveableCsyTransform();
00814       break;
00815     case MultipleArmCsy :
00816       cT = _world.getMultipleCsyTransform();
00817       break;
00818     case PartCsy :
00819       cT = _world.getPartCsyTransform();
00820       break;
00821     case SensorCsy :
00822       cT = _world.getSensorCsyTransform(); 
00823       break;
00824     default:
00825      IPP_ASSERT_FAIL("INVALID case");
00826 
00827   }
00828  
00829   ippResponsePtr x = new ippGetCsyTransformationResponse(
00830                           tag_num, 
00831                           cT->getX(), cT->getY(), cT->getZ(), 
00832                           cT->getTheta(), cT->getPsi(), cT->getPhi()
00833                         );
00834 
00835 
00836   _returningValues.push_back(x);
00837 
00838   generateCompletedResponse();
00839 
00840 } 
00841 
00842 //=============================================================================
00843 void  ippBasicExecutor::executeSetCoordSystem()
00844 //-----------------------------------------------------------------------------
00845 {
00846   _world.update(_currentCommand);
00847   generateCompletedResponse();
00848 
00849 } 
00850 
00851 
00852 
00853 //=============================================================================
00854 void  ippBasicExecutor::executeSetCsyTransformation()
00855 //-----------------------------------------------------------------------------
00856 {
00857   _world.update(_currentCommand);  // world performs update
00858   generateCompletedResponse();
00859 
00860 } 
00861 
00862 
00863 
00864 //=============================================================================
00865 void ippBasicExecutor::executeEnumAllProp()
00866 //-----------------------------------------------------------------------------
00867 {
00868   ippEnumAllPropCommandConstPtr 
00869   cmd  = static_cast<const ippEnumAllPropCommand*>(_currentCommand.get());
00870   
00871   const ippProp& prop = cmd->getProp();
00872 
00873   GenerateEnumAllPropResponses(cmd,_returningValues);
00874 
00875   generateCompletedResponse();
00876 
00877 }  
00878 
00879 //==============================================================================
00880 void ippBasicExecutor::executeEnumProp() 
00881 //-----------------------------------------------------------------------------
00882 {
00883   ippEnumPropCommandConstPtr theSet
00884     = boost::static_pointer_cast<ippEnumPropCommand>(_currentCommand);
00885   const ippProp& prop = theSet->getProp();
00886 
00887   GenerateEnumPropResponses(theSet,_returningValues);
00888   generateCompletedResponse();
00889 
00890 } 
00891 
00892 //=============================================================================
00893 void  ippBasicExecutor::executeScanOnCircleHint()
00894 //-----------------------------------------------------------------------------
00895 {
00896   _world.update(_currentCommand);
00897   generateCompletedResponse();
00898 
00899 }
00900 //=============================================================================
00901 void  ippBasicExecutor::executeScanOnLineHint()
00902 //-----------------------------------------------------------------------------
00903 {
00904   _world.update(_currentCommand);
00905   generateCompletedResponse();
00906 } 
00907 //=============================================================================
00908 void  ippBasicExecutor::executeScanUnknownHint()
00909 //-----------------------------------------------------------------------------
00910 {
00911   _world.update(_currentCommand);
00912   generateCompletedResponse();
00913 }
00914 //=============================================================================
00915 void ippBasicExecutor::executeScanOnCurveHint()
00916 //-----------------------------------------------------------------------------
00917 {
00918   // TO DO : provide a suitable implementation
00919   executeNotImplemented();
00920 }
00921 
00922 
00923 //==============================================================================
00924 void ippBasicExecutor::executeNotImplemented()
00925 //
00926 // History
00927 // DICC  Who When       What
00928 // ----- --- ---------- -------------------------------------------------------
00929 // <xxx> ER  20/05/2005 Written.
00930 //-----------------------------------------------------------------------------
00931 {
00932   generateErrorResponse(UnsupportedCommand," Command is currently not implemented" );
00933   generateCompletedResponse();
00934 }

Generated on Wed Nov 8 00:20:03 2006 for IPPDME by  doxygen 1.4.1