Main Page | Modules | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

TestCasePUSEventRepository_1.cpp

00001 // 00002 // Copyright 2004 P&P Software GmbH - All Rights Reserved 00003 // 00004 // TestCasePUSEventRepository_1.cpp 00005 // 00006 // Version 1.0 00007 // Date 04.02.04 00008 // Author A. Pasetti (P&P Software) 00009 00010 #include "../GeneralInclude/CompilerSwitches.h" 00011 #include "../GeneralInclude/ClassId.h" 00012 #include "../GeneralInclude/BasicTypes.h" 00013 #include "../GeneralInclude/Constants.h" 00014 #include "../System/DC_DummyObsClock.h" 00015 #include "../Event/DC_PUSEventRepository.h" 00016 #include "../Manoeuvre/CC_ManoeuvreFactory.h" 00017 #include "../Manoeuvre/DC_DummyConfigurableManoeuvre.h" 00018 #include "../Telemetry/CC_TelemetryManager.h" 00019 #include "../Telemetry/CC_TelemetryPacketFactory.h" 00020 #include "../Telecommand/CC_TelecommandFactory.h" 00021 #include "../Telecommand/CC_TelecommandManager.h" 00022 #include "../Telecommand/DC_TestPUSTelecommand.h" 00023 #include "../Telecommand/DC_BasicPUSTcLoader.h" 00024 #include "../Telemetry/DC_PUSTcVerificationPacket.h" 00025 #include "../Data/DC_SampleFullDataPool.h" 00026 #include "../Utilities/TestCasePUSFull.h" 00027 #include "TestCasePUSEventRepository_1.h" 00028 00029 00030 TestCasePUSEventRepository_1::TestCasePUSEventRepository_1(void) : 00031 TestCasePUSFull(ID_PUSEVENTREPOSITORY*10+1,"TestCasePUSEventRepository_1") { 00032 return; 00033 } 00034 00035 void TestCasePUSEventRepository_1::runTestCase(void) { 00036 00037 unsigned int nEvt; 00038 const TD_TelecommandId tcId_1 = 121; 00039 const TD_TelecommandId tcId_2 = 122; 00040 00041 CC_TelecommandFactory* pTCF = CC_TelecommandFactory::getInstance(); 00042 if ( pTCF->getNumberTestPUSTelecommand()!=0 ) 00043 { setTestResult(TEST_FAILURE,"Wrong number of telecommands"); 00044 return; 00045 } 00046 if ( pTCF->getCapacityTestPUSTelecommand()<1 ) 00047 { setTestResult(TEST_FAILURE,"Insufficient TC factory capacity"); 00048 return; 00049 } 00050 DC_TestPUSTelecommand* pTC = pTCF->allocateTestPUSTelecommand(); 00051 pTC->setTelecommandId(tcId_1); 00052 00053 CC_ManoeuvreFactory* pMF = CC_ManoeuvreFactory::getInstance(); 00054 if ( pMF->getNumberTestPUSConfigurableManoeuvre()!=0 ) 00055 { setTestResult(TEST_FAILURE,"Wrong number of manoeuvres"); 00056 return; 00057 } 00058 if ( pMF->getCapacityTestPUSConfigurableManoeuvre()<1 ) 00059 { setTestResult(TEST_FAILURE,"Insufficient manoeuvre factory capacity"); 00060 return; 00061 } 00062 DC_TestPUSConfigurableManoeuvre* pMan = pMF->allocateTestPUSConfigurableManoeuvre(); 00063 pMan->setTelecommandId(tcId_2); 00064 00065 DC_PUSEventRepository* pEvtRep = getEventRepository(); 00066 00067 // Check the correctness of the class identifier 00068 if ( (pEvtRep->getClassId() != ID_PUSEVENTREPOSITORY) ) 00069 { setTestResult(TEST_FAILURE,"Wrong class identifier"); 00070 return; 00071 } 00072 00073 // Flush telemetry manager to make sure that there are no pending packets in the 00074 // immediate dispatch queu 00075 pEvtRep->getTelemetryManager()->activate(); 00076 00077 // Make repeated call to the create method for telecommands and check success 00078 const TD_CheckCode VAL_CODE = 100; 00079 const TD_CheckCode EXEC_CODE = 101; 00080 const TD_CheckCode CONT_CODE = 102; 00081 00082 nEvt = getNumberOfEvents(); 00083 pTC->setAcknowledgeLevel(1); // acceptance acknowledge flag is set 00084 pEvtRep->create(pTC,EVT_TC_LOADED); 00085 if ( !checkTmPacket(pEvtRep,PUS_ST_TC_VER_ACC_SC,tcId_1,getObsClock()->getTime(),0) ) 00086 { setTestResult(TEST_FAILURE,"Wrong packet configuration"); 00087 return; 00088 } 00089 if ( !verifyLatestEvent(nEvt+1,EVT_TC_LOADED) ) 00090 return; 00091 00092 pTC->setAcknowledgeLevel(0); // acceptance acknowledge flag is reset 00093 pEvtRep->create(pTC,EVT_TC_LOADED); 00094 if ( !checkNoTmPacket(pEvtRep) ) 00095 { setTestResult(TEST_FAILURE,"Unexpected packet"); 00096 return; 00097 } 00098 00099 pTC->setValidityCheckCode(0); 00100 pEvtRep->create(pTC,EVT_TC_NOT_VALID); 00101 if ( !checkTmPacket(pEvtRep,PUS_ST_TC_VER_ACC_FL,tcId_1,getObsClock()->getTime(),EVT_TC_NOT_VALID) ) 00102 { setTestResult(TEST_FAILURE,"Wrong packet configuration"); 00103 return; 00104 } 00105 00106 pTC->setValidityCheckCode(VAL_CODE); 00107 pEvtRep->create(pTC,EVT_TC_NOT_VALID); 00108 if ( !checkTmPacket(pEvtRep,PUS_ST_TC_VER_ACC_FL,tcId_1,getObsClock()->getTime(),VAL_CODE) ) 00109 { setTestResult(TEST_FAILURE,"Wrong packet configuration"); 00110 return; 00111 } 00112 00113 pEvtRep->create(pTC,EVT_TC_LIST_FULL); 00114 if ( !checkTmPacket(pEvtRep,PUS_ST_TC_VER_ACC_FL,tcId_1,getObsClock()->getTime(),EVT_TC_LIST_FULL) ) 00115 { setTestResult(TEST_FAILURE,"Wrong packet configuration"); 00116 return; 00117 } 00118 00119 nEvt = getNumberOfEvents(); 00120 pMan->setStartAckFlag(true); 00121 pEvtRep->create(pMan,EVT_MAN_STARTED); 00122 if ( !checkTmPacket(pEvtRep,PUS_ST_TC_EXE_STR_SC,tcId_2,getObsClock()->getTime(),0) ) 00123 { setTestResult(TEST_FAILURE,"Wrong packet configuration"); 00124 return; 00125 } 00126 if ( !verifyLatestEvent(nEvt+1,EVT_MAN_STARTED) ) 00127 return; 00128 00129 pMan->setStartAckFlag(false); 00130 pEvtRep->create(pMan,EVT_MAN_STARTED); 00131 if ( !checkNoTmPacket(pEvtRep) ) 00132 { setTestResult(TEST_FAILURE,"Unexpected packet"); 00133 return; 00134 } 00135 00136 pEvtRep->create(pMan,EVT_MAN_LIST_FULL); 00137 if ( !checkTmPacket(pEvtRep,PUS_ST_TC_EXE_STR_FL,tcId_2,getObsClock()->getTime(),EVT_MAN_LIST_FULL) ) 00138 { setTestResult(TEST_FAILURE,"Wrong packet configuration"); 00139 return; 00140 } 00141 00142 pTC->setExecutionCheckCode(0); 00143 pEvtRep->create(pTC,EVT_TC_EXEC_CHECK_FAIL); 00144 if ( !checkTmPacket(pEvtRep,PUS_ST_TC_EXE_STR_FL,tcId_1,getObsClock()->getTime(),EVT_TC_EXEC_CHECK_FAIL) ) 00145 { setTestResult(TEST_FAILURE,"Wrong packet configuration"); 00146 return; 00147 } 00148 00149 pTC->setExecutionCheckCode(EXEC_CODE); 00150 pEvtRep->create(pTC,EVT_TC_EXEC_CHECK_FAIL); 00151 if ( !checkTmPacket(pEvtRep,PUS_ST_TC_EXE_STR_FL,tcId_1,getObsClock()->getTime(),EXEC_CODE) ) 00152 { setTestResult(TEST_FAILURE,"Wrong packet configuration"); 00153 return; 00154 } 00155 00156 pEvtRep->create(pTC,EVT_TC_ABORTED); 00157 if ( !checkTmPacket(pEvtRep,PUS_ST_TC_EXE_STR_FL,tcId_1,getObsClock()->getTime(),EVT_TC_ABORTED) ) 00158 { setTestResult(TEST_FAILURE,"Wrong packet configuration"); 00159 return; 00160 } 00161 00162 pMan->setProgressAckFlag(true); 00163 pEvtRep->create(pMan,EVT_MAN_PROGRESS); 00164 if ( !checkTmPacket(pEvtRep,PUS_ST_TC_EXE_PRO_SC,tcId_2,getObsClock()->getTime(),0) ) 00165 { setTestResult(TEST_FAILURE,"Wrong packet configuration"); 00166 return; 00167 } 00168 00169 pMan->setProgressAckFlag(false); 00170 pEvtRep->create(pMan,EVT_MAN_PROGRESS); 00171 if ( !checkNoTmPacket(pEvtRep) ) 00172 { setTestResult(TEST_FAILURE,"Unexpected packet"); 00173 return; 00174 } 00175 00176 pTC->setAcknowledgeLevel(8); // set completion acknowledge flag 00177 pEvtRep->create(pTC,EVT_TC_EXEC_SUCC); 00178 if ( !checkTmPacket(pEvtRep,PUS_ST_TC_EXE_END_SC,tcId_1,getObsClock()->getTime(),0) ) 00179 { setTestResult(TEST_FAILURE,"Wrong packet configuration"); 00180 return; 00181 } 00182 00183 pTC->setAcknowledgeLevel(0); // reset acknowledge flags 00184 pEvtRep->create(pTC,EVT_TC_EXEC_SUCC); 00185 if ( !checkNoTmPacket(pEvtRep) ) 00186 { setTestResult(TEST_FAILURE,"Unexpected packet"); 00187 return; 00188 } 00189 00190 pTC->setActionOutcome(true); 00191 pEvtRep->create(pTC,EVT_TC_EXEC_FAIL); 00192 if ( !checkTmPacket(pEvtRep,PUS_ST_TC_EXE_END_FL,tcId_1,getObsClock()->getTime(), 00193 (TD_CheckCode)ACTION_SUCCESS) ) 00194 { setTestResult(TEST_FAILURE,"Wrong packet configuration"); 00195 return; 00196 } 00197 00198 pMan->setContinuationCheckCode(0); 00199 pEvtRep->create(pMan,EVT_MAN_ABORTED); 00200 if ( !checkTmPacket(pEvtRep,PUS_ST_TC_EXE_PRO_FL,tcId_2,getObsClock()->getTime(),EVT_MAN_ABORTED) ) 00201 { setTestResult(TEST_FAILURE,"Wrong packet configuration"); 00202 return; 00203 } 00204 00205 pMan->setContinuationCheckCode(CONT_CODE); 00206 pEvtRep->create(pMan,EVT_MAN_ABORTED); 00207 if ( !checkTmPacket(pEvtRep,PUS_ST_TC_EXE_PRO_FL,tcId_2,getObsClock()->getTime(),CONT_CODE) ) 00208 { setTestResult(TEST_FAILURE,"Wrong packet configuration"); 00209 return; 00210 } 00211 00212 pMan->setCompletionAckFlag(true); 00213 pEvtRep->create(pMan,EVT_MAN_TERMINATED); 00214 if ( !checkTmPacket(pEvtRep,PUS_ST_TC_EXE_END_SC,tcId_2,getObsClock()->getTime(),0) ) 00215 { setTestResult(TEST_FAILURE,"Wrong packet configuration"); 00216 return; 00217 } 00218 00219 pMan->setCompletionAckFlag(false); 00220 pEvtRep->create(pMan,EVT_MAN_TERMINATED); 00221 if ( !checkNoTmPacket(pEvtRep) ) 00222 { setTestResult(TEST_FAILURE,"Wrong packet configuration"); 00223 return; 00224 } 00225 00226 // Force a situation where the telemetry packet factory in the 00227 // PUS event repository runs out of telemetry packets and check that correct event is generated 00228 CC_TelemetryPacketFactory* pTMF = CC_TelemetryPacketFactory::getInstance(); 00229 while ( pTMF->isFreePUSTcVerificationPacket() ) 00230 pEvtRep->create(pMan,EVT_MAN_ABORTED); 00231 nEvt = getNumberOfEvents(); 00232 pEvtRep->create(pMan,EVT_MAN_TERMINATED); 00233 if ( getNumberOfEvents()!=nEvt+2 ) 00234 { setTestResult(TEST_FAILURE,"Wrong number of events"); 00235 return; 00236 } 00237 if (!verifySpecificEvent(nEvt+1,EVT_TM_PCK_ALLOC_FAILURE)) 00238 return; 00239 00240 // If this point is reached, the test was successful 00241 setTestResult(TEST_SUCCESS,"Test Successful"); 00242 return; 00243 } 00244 00245 bool TestCasePUSEventRepository_1::checkTmPacket( 00246 DC_PUSEventRepository* pEvtRep, TD_TelemetrySubType tmSubType, 00247 TD_TelecommandId tcId, TD_ObsTime tt, TD_CheckCode errCode) { 00248 00249 CC_TelemetryManager* pTMM = pEvtRep->getTelemetryManager(); 00250 TelemetryPacket* pTemp = pTMM->getImmediateQueueEntry(0); 00251 if ( pTemp == pNULL ) 00252 return false; 00253 00254 if ( pTemp->getClassId()!=ID_PUSTCVERIFICATIONPACKET ) 00255 return false; 00256 00257 DC_PUSTcVerificationPacket* pTM = (DC_PUSTcVerificationPacket*)pTemp; 00258 00259 if ( pTM->getSubType()!=tmSubType ) 00260 return false; 00261 00262 if ( pTM->getTelecommandId()!=tcId ) 00263 return false; 00264 00265 if ( pTM->getTimeTag()!=tt ) 00266 return false; 00267 00268 if ( pTM->getType()!=PUS_TYPE_TC_VER ) 00269 return false; 00270 00271 if ( errCode!=0 ) 00272 if ( pTM->getErrorCode()!=errCode ) 00273 return false; 00274 00275 // Flush telemetry manager 00276 pTMM->activate(); 00277 00278 return true; 00279 } 00280 00281 bool TestCasePUSEventRepository_1::checkNoTmPacket(DC_PUSEventRepository* pEvtRep) { 00282 00283 CC_TelemetryManager* pTMM = pEvtRep->getTelemetryManager(); 00284 TelemetryPacket* pTemp = pTMM->getImmediateQueueEntry(0); 00285 if ( pTemp == pNULL ) 00286 return true; 00287 else 00288 return false; 00289 }
Copyright 2003 P&P Software GmbH - All Rights Reserved