00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 #include "ippMockExecutor.h"
00013 
00014 
00015 
00016 ippMockExecutor::ippMockExecutor()
00017 {
00018   _g_count = 0;
00019   _OnScanReportCmd = new ippOnScanReportCommand(0);
00020   _OnScanReportCmd->setDefault();
00021   _GetDMEVersionCounter =-1;
00022 }
00023 
00024 bool ippMockExecutor::readyToProcessSlowQueueCommand() const 
00025 {
00026   return _g_count ==0; 
00027 }
00028 
00029 void ippMockExecutor::executeAbortE()
00030 {
00031 
00032 }
00033 
00034 void ippMockExecutor::AbortCurrentCommand()
00035 {
00036   if (_g_count  ) {
00037     _g_count = 0; 
00038   }
00039   ippExecutor::AbortCurrentCommand();
00040 }
00041 
00042 
00043 ippResponseList ippMockExecutor::checkStatus()
00044 {
00045 
00046   if (_g_count >0) {
00047     int tagNum = _currentCommand->getTag().getTagNumber();
00048     _returningValues.push_back(ProduceFakeScanReport(tagNum,(double)_g_count,(double)_g_count,(double)_g_count));
00049     _g_count--;
00050     if (_g_count == 0 ) {
00051       
00052       generateCompletedResponse();
00053     }
00054   }
00055   return ippExecutor::checkStatus();
00056 }
00057 
00058 void ippMockExecutor::executeStartSession()
00059 {
00060   _GetDMEVersionCounter = 0;
00061   generateCompletedResponse();
00062 }
00063 
00064 void ippMockExecutor::executeEndSession()         
00065 {
00066   generateCompletedResponse();
00067 }
00068 
00069 void ippMockExecutor::executeScanOnLine(){
00070 
00071   IPP_ASSERT_MSG(_g_count==0, " a ScanOnLine command is probably being executed already");
00072   _g_count = 10; 
00073 }
00074 
00075 void ippMockExecutor::executeGetDMEVersion()
00076 {
00077   _GetDMEVersionCounter++;
00078   generateCompletedResponse();
00079 }
00080 
00081 void ippMockExecutor::executeIsHomed()
00082 {
00083   generateCompletedResponse();
00084 }
00085 
00086 ippResponsePtr ippMockExecutor::ProduceFakeScanReport(int tagNum,double X,double Y,double Z)
00087 {
00088   ippOnScanReportBuilderPtr _scanReportBuilder = new ippOnScanReportBuilder(_OnScanReportCmd);
00089   _scanReportBuilder->StartPoint();
00090 
00091   
00092   _scanReportBuilder->setValue(ippOnScanReportCommand::Q,0);
00093   _scanReportBuilder->setValue(ippOnScanReportCommand::X,X);
00094   _scanReportBuilder->setValue(ippOnScanReportCommand::Y,Y);
00095   _scanReportBuilder->setValue(ippOnScanReportCommand::Z,Z);
00096   _scanReportBuilder->setValues(ippOnScanReportCommand::IJK  , 0.0,0.0,1.0);
00097   _scanReportBuilder->setValue(ippOnScanReportCommand::IJKAct , 1);
00098   _scanReportBuilder->Commit();
00099   ippScanResponsePtr x = _scanReportBuilder->FlushAndGetResponse(tagNum);
00100   return x;
00101 }