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

TestCaseTelecommandManager_3.cpp

00001 // 00002 // Copyright 2004 P&P Software GmbH - All Rights Reserved 00003 // 00004 // TestCaseTelecommandManager_3.cpp 00005 // 00006 // Version 1.1 00007 // Date 11.04.03 00008 // Author A. Pasetti (P&P Software) 00009 00010 #include "../GeneralInclude/CompilerSwitches.h" 00011 #include "../GeneralInclude/ClassId.h" 00012 #include "../GeneralInclude/TestConstants.h" 00013 #include "../Base/CC_RootObject.h" 00014 #include "../Event/DC_EventRepository.h" 00015 #include "../Telecommand/DC_DummyTelecommandLoader.h" 00016 #include "../Telecommand/CC_TelecommandManager.h" 00017 #include "../System/DC_DummyObsClock.h" 00018 #include "../Telecommand/TelecommandLoader.h" 00019 #include "../Telecommand/DC_DummyTelecommand.h" 00020 #include "TestCaseTelecommandManager_3.h" 00021 00022 TestCaseTelecommandManager_3::TestCaseTelecommandManager_3(void) : 00023 TestCaseGenericSetUp(ID_TELECOMMANDMANAGER*10+3,"TestCaseTelecommandManager_3") { 00024 return; 00025 } 00026 00027 void TestCaseTelecommandManager_3::runTestCase(void) { 00028 00029 // Retrieve the event repository 00030 DC_EventRepository* pRep = CC_RootObject::getEventRepository(); 00031 00032 // Create the telecommand manager 00033 CC_TelecommandManager* pTcm = new CC_TelecommandManager(); 00034 00035 // Define the identifiers and time tags for the dummy telecommands 00036 TD_ObsTime tcTt1 = 0; 00037 TD_ObsTime tcTt2 = 0; 00038 TD_ObsTime tcTt3 = 0; 00039 TD_TelecommandId tcId1 = 1; 00040 TD_TelecommandId tcId2 = 2; 00041 TD_TelecommandId tcId3 = 3; 00042 00043 // Create and load an OBS clock 00044 DC_DummyObsClock* pClk = new DC_DummyObsClock(); 00045 pClk->setTime(tcTt1+1); 00046 pClk->setCycle(0); 00047 pTcm->setObsClock(pClk); 00048 00049 // Create and configure the dummy telecommands 00050 DC_DummyTelecommand* pTc1 = new DC_DummyTelecommand(); 00051 DC_DummyTelecommand* pTc2 = new DC_DummyTelecommand(); 00052 DC_DummyTelecommand* pTc3 = new DC_DummyTelecommand(); 00053 pTc1->setTelecommandId(tcId1); 00054 pTc2->setTelecommandId(tcId2); 00055 pTc3->setTelecommandId(tcId3); 00056 pTc1->setTimeTag(tcTt1); 00057 pTc2->setTimeTag(tcTt2); 00058 pTc3->setTimeTag(tcTt3); 00059 pTc1->setExecutionCheckValue(TC_CANNOT_EXECUTE); 00060 pTc2->setValidityCheckValue(NOT_VALID); 00061 00062 // Create, configure and load a dummy telecommand loader 00063 DC_DummyTelecommandLoader* pTcl = new DC_DummyTelecommandLoader(); 00064 pTcl->setSampleTelecommand(0,pTc1); 00065 pTcl->setSampleTelecommand(1,pTc2); 00066 pTcl->setSampleTelecommand(2,pTc3); 00067 pTcm->setTelecommandLoader(pTcl); 00068 pTcl->setTelecommandManager(pTcm); 00069 00070 // Set the pending telecommand list size 00071 pTcm->setPendingTelecommandListSize(2); 00072 00073 // Check that the telecommand manager is configured 00074 if ( !pTcm->isObjectConfigured() ) 00075 { setTestResult(TEST_FAILURE, "Wrong configuration status"); 00076 return; 00077 } 00078 00079 // Activate the telecommand loader twice and check that the 00080 // second telecommand is rejected because its validity check fails 00081 pTcl->activate(); 00082 pTcl->activate(); 00083 pRep->latest(); 00084 if ( (pRep->getEventType() != EVT_TC_NOT_VALID) ) 00085 { setTestResult(TEST_FAILURE, "Wrong event type"); 00086 return; 00087 } 00088 00089 // Replace the second telecommand in the telecommand loader, 00090 // activate the telecommand loader twice and check that the 00091 // last load attempt is rejected because the pending telecommand 00092 // list is full 00093 pTcl->setSampleTelecommand(1,pTc3); 00094 pTcl->activate(); // load TC3 (second entry in dummy TC Loader 00095 pTcl->activate(); // load TC3 (third entry in dummy TC Loader 00096 pRep->latest(); 00097 if ( (pRep->getEventType() != EVT_TC_LIST_FULL) ) 00098 { setTestResult(TEST_FAILURE, "Wrong event type"); 00099 return; 00100 } 00101 00102 // Activate the telecommand manager and check that the second 00103 // telecommand is executed but the first 00104 // is not executed because its execution check fails 00105 pTcm->activate(); 00106 if (pTc3->getExecutionCounter() != 1) 00107 { setTestResult(TEST_FAILURE, "Third telecommand was not executed"); 00108 return; 00109 } 00110 if (pTc1->getExecutionCounter() != 0) 00111 { setTestResult(TEST_FAILURE, "First telecommand was executed"); 00112 return; 00113 } 00114 00115 // Check generation of event to record telecommand unloading 00116 pRep->latest(); // TC 3 punctual action was executed 00117 pRep->previous(); // TC 3 was successfully executed 00118 pRep->previous(); // TC 1 execution check failed 00119 if ( (pRep->getEventType() != EVT_TC_EXEC_CHECK_FAIL) ) 00120 { setTestResult(TEST_FAILURE, "Wrong event type"); 00121 return; 00122 } 00123 00124 // Check allocation counter value 00125 if ( pTcl->getAllocationCounter() != 0 ) 00126 { setTestResult(TEST_FAILURE, "Wrong allocation counter value"); 00127 return; 00128 } 00129 00130 // Activate the telecommand loader three times and verify that two 00131 // telecommands are loaded 00132 pTcl->activate(); 00133 pTcl->activate(); 00134 pTcl->activate(); 00135 if ( pTcm->getPendingTelecommands()!=2 ) 00136 { setTestResult(TEST_FAILURE, "Wrong number of pending telecommands"); 00137 return; 00138 } 00139 if ( pTcl->getAllocationCounter() != 2 ) 00140 { setTestResult(TEST_FAILURE, "Wrong allocation counter value"); 00141 return; 00142 } 00143 00144 // Reset telecommand manager and verify number of pending telecommands 00145 unsigned int nEvt = pRep->getCounter(); 00146 pTcm->reset(); 00147 if ( pTcm->getPendingTelecommands()!=0 ) 00148 { setTestResult(TEST_FAILURE, "Wrong number of pending telecommands"); 00149 return; 00150 } 00151 00152 // Verify events generated as a result of the reset 00153 if ( (pRep->getCounter() != nEvt+2) ) 00154 { setTestResult(TEST_FAILURE, "Wrong number of events"); 00155 return; 00156 } 00157 pRep->latest(); 00158 if ( (pRep->getEventType() != EVT_TC_ABORTED) ) 00159 { setTestResult(TEST_FAILURE, "Wrong event type"); 00160 return; 00161 } 00162 pRep->previous(); 00163 if ( (pRep->getEventType() != EVT_TC_ABORTED) ) 00164 { setTestResult(TEST_FAILURE, "Wrong event type"); 00165 return; 00166 } 00167 00168 // Check allocation counter value 00169 if ( pTcl->getAllocationCounter() != 0 ) 00170 { setTestResult(TEST_FAILURE, "Wrong allocation counter value"); 00171 return; 00172 } 00173 00174 // Activate the telecommand loader three times and verify that two 00175 // telecommands are loaded 00176 pTcl->activate(); 00177 pTcl->activate(); 00178 pTcl->activate(); 00179 if ( pTcm->getPendingTelecommands()!=2 ) 00180 { setTestResult(TEST_FAILURE, "Wrong number of pending telecommands"); 00181 return; 00182 } 00183 if ( pTcl->getAllocationCounter() != 2 ) 00184 { setTestResult(TEST_FAILURE, "Wrong allocation counter value"); 00185 return; 00186 } 00187 00188 // Abort the first telecommand 00189 nEvt = pRep->getCounter(); 00190 pTcm->abort(pTc1->getTelecommandId()); 00191 if ( pTcm->getPendingTelecommands()!=1 ) 00192 { setTestResult(TEST_FAILURE, "Wrong number of pending telecommands"); 00193 return; 00194 } 00195 if ( pTcl->getAllocationCounter() != 1 ) 00196 { setTestResult(TEST_FAILURE, "Wrong allocation counter value"); 00197 return; 00198 } 00199 00200 // Check abort event 00201 if ( (pRep->getCounter() != nEvt+1) ) 00202 { setTestResult(TEST_FAILURE, "Wrong number of events"); 00203 return; 00204 } 00205 pRep->latest(); 00206 if ( (pRep->getEventType() != EVT_TC_ABORTED) ) 00207 { setTestResult(TEST_FAILURE, "Wrong event type"); 00208 return; 00209 } 00210 00211 // Abort the last telecommand 00212 pTcm->abort(pTc3); 00213 if ( pTcm->getPendingTelecommands()!=0 ) 00214 { setTestResult(TEST_FAILURE, "Wrong number of pending telecommands"); 00215 return; 00216 } 00217 if ( pTcl->getAllocationCounter() != 0 ) 00218 { setTestResult(TEST_FAILURE, "Wrong allocation counter value"); 00219 return; 00220 } 00221 00222 // Check abort event 00223 if ( (pRep->getCounter() != nEvt+2) ) 00224 { setTestResult(TEST_FAILURE, "Wrong number of events"); 00225 return; 00226 } 00227 pRep->latest(); 00228 if ( (pRep->getEventType() != EVT_TC_ABORTED) ) 00229 { setTestResult(TEST_FAILURE, "Wrong event type"); 00230 return; 00231 } 00232 00233 setTestResult(TEST_SUCCESS,"Test Successful"); 00234 return; 00235 00236 }
Copyright 2003 P&P Software GmbH - All Rights Reserved