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

TestCaseTelecommandManager_2.cpp

00001 // 00002 // Copyright 2004 P&P Software GmbH - All Rights Reserved 00003 // 00004 // TestCaseTelecommandManager_2.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_2.h" 00021 00022 TestCaseTelecommandManager_2::TestCaseTelecommandManager_2(void) : 00023 TestCaseGenericSetUp(ID_TELECOMMANDMANAGER*10+2,"TestCaseTelecommandManager_2") { 00024 return; 00025 } 00026 00027 void TestCaseTelecommandManager_2::runTestCase(void) { 00028 00029 // Create the telecommand manager 00030 CC_TelecommandManager* pTcm = new CC_TelecommandManager(); 00031 00032 // Define the identifiers and time tags for the dummy telecommands 00033 TD_ObsTime tcTt1 = 3; 00034 TD_ObsTime tcTt2 = 5; 00035 TD_ObsTime tcTt3 = 0; 00036 TD_TelecommandId tcId1 = 1; 00037 TD_TelecommandId tcId2 = 2; 00038 TD_TelecommandId tcId3 = 3; 00039 00040 // Create and load an OBS clock 00041 DC_DummyObsClock* pClk = new DC_DummyObsClock(); 00042 pClk->setTime(tcTt1-1); 00043 pClk->setCycle(0); 00044 pTcm->setObsClock(pClk); 00045 00046 // Create and configure the three dummy telecommands 00047 DC_DummyTelecommand* pTc1 = new DC_DummyTelecommand(); 00048 DC_DummyTelecommand* pTc2 = new DC_DummyTelecommand(); 00049 DC_DummyTelecommand* pTc3 = new DC_DummyTelecommand(); 00050 pTc1->setTelecommandId(tcId1); 00051 pTc2->setTelecommandId(tcId2); 00052 pTc3->setTelecommandId(tcId3); 00053 pTc1->setTimeTag(tcTt1); 00054 pTc2->setTimeTag(tcTt2); 00055 pTc3->setTimeTag(tcTt3); 00056 00057 // Create, configure and load a dummy telecommand loader 00058 DC_DummyTelecommandLoader* pTcl = new DC_DummyTelecommandLoader(); 00059 pTcl->setSampleTelecommand(0,pTc1); 00060 pTcl->setSampleTelecommand(1,pTc2); 00061 pTcl->setSampleTelecommand(2,pTc3); 00062 pTcm->setTelecommandLoader(pTcl); 00063 pTcl->setTelecommandManager(pTcm); 00064 00065 // Set the pending telecommand list size 00066 pTcm->setPendingTelecommandListSize(10); 00067 00068 // Check that the telecommand manager is configured 00069 if ( !pTcm->isObjectConfigured() ) 00070 { setTestResult(TEST_FAILURE, "Wrong configuration status"); 00071 return; 00072 } 00073 00074 // Activate the telecommand loader three times and check that dummy 00075 // telecommands were loaded in telecommand manager 00076 pTcl->activate(); 00077 pTcl->activate(); 00078 pTcl->activate(); 00079 if ( pTcm->getPendingTelecommands() != 3 ) 00080 { setTestResult(TEST_FAILURE, "Wrong number of pending telecommands"); 00081 return; 00082 } 00083 00084 // Check allocation counter value 00085 if ( pTcl->getAllocationCounter() != 3 ) 00086 { setTestResult(TEST_FAILURE, "Wrong allocation counter value"); 00087 return; 00088 } 00089 00090 // Activate the telecommand manager and check that the third 00091 // telecommand is executed 00092 pTcm->activate(); 00093 if (pTc3->getExecutionCounter() != 1) 00094 { setTestResult(TEST_FAILURE, "Third telecommand was not executed"); 00095 return; 00096 } 00097 00098 // Check number of pending telecommands 00099 if ( pTcm->getPendingTelecommands() != 2 ) 00100 { setTestResult(TEST_FAILURE, "Wrong number of pending telecommands"); 00101 return; 00102 } 00103 00104 // Check generation of event to record telecommand successful execution and unloading 00105 DC_EventRepository* pRep = CC_RootObject::getEventRepository(); 00106 pRep->latest(); 00107 if ( (pRep->getEventType() != EVT_TC_EXEC_SUCC) ) 00108 { setTestResult(TEST_FAILURE, "Wrong unload event"); 00109 return; 00110 } 00111 00112 // Activate telecommand manager and advance dummy time to the point 00113 // where the first telecommand should be executed and check execution 00114 pTcm->activate(); 00115 pTcm->activate(); 00116 pClk->setTime(tcTt1+1); 00117 pClk->setCycle(0); 00118 pTcm->activate(); 00119 if (pTc1->getExecutionCounter() != 1) 00120 { setTestResult(TEST_FAILURE, "First telecommand was not executed"); 00121 return; 00122 } 00123 00124 // Check number of pending telecommands 00125 if ( pTcm->getPendingTelecommands() != 1 ) 00126 { setTestResult(TEST_FAILURE, "Wrong number of pending telecommands"); 00127 return; 00128 } 00129 00130 // Activate telecommand manager and advance dummy time to the point 00131 // where the second telecommand should be executed and check execution 00132 pTcm->activate(); 00133 pTcm->activate(); 00134 pClk->setTime(tcTt2+1); 00135 pClk->setCycle(0); 00136 pTcm->activate(); 00137 if (pTc2->getExecutionCounter() != 1) 00138 { setTestResult(TEST_FAILURE, "Second telecommand was not executed"); 00139 return; 00140 } 00141 00142 // Check number of pending telecommands 00143 if ( pTcm->getPendingTelecommands() != 0 ) 00144 { setTestResult(TEST_FAILURE, "Wrong number of pending telecommands"); 00145 return; 00146 } 00147 00148 // Check allocation counter value 00149 if ( pTcl->getAllocationCounter() != 0 ) 00150 { setTestResult(TEST_FAILURE, "Wrong allocation counter value"); 00151 return; 00152 } 00153 00154 setTestResult(TEST_SUCCESS,"Test Successful"); 00155 return; 00156 00157 }
Copyright 2003 P&P Software GmbH - All Rights Reserved