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

TestCaseTelemetryManager_2.cpp

00001 // 00002 // Copyright 2004 P&P Software GmbH - All Rights Reserved 00003 // 00004 // TestCaseTelemetryManager_2.cpp 00005 // 00006 // Version 1.1 00007 // Date 04.03.04 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 "../GeneralInclude/Constants.h" 00014 #include "../Base/CC_RootObject.h" 00015 #include "../Event/DC_EventRepository.h" 00016 #include "../Telemetry/DC_SimpleTelemetryModeManager.h" 00017 #include "../Telemetry/DC_ByteArrayTelemetryStream.h" 00018 #include "../Telemetry/DC_DummyTelemetryPacket.h" 00019 #include "../Telemetry/CC_TelemetryManager.h" 00020 #include "../Telemetry/TelemetryModeManager.h" 00021 #include "TestCaseTelemetryManager_2.h" 00022 00023 00024 TestCaseTelemetryManager_2::TestCaseTelemetryManager_2(void) : 00025 TestCaseWithEvtCheck(ID_TELEMETRYMANAGER*10+2,"TestCaseTelemetryManager_2") { 00026 return; 00027 } 00028 00029 void TestCaseTelemetryManager_2::runTestCase(void) { 00030 00031 // Retrieve the event repository and the event counter 00032 unsigned int nEvt = getNumberOfEvents(); 00033 00034 // Create the telemetry manager 00035 CC_TelemetryManager* pTm = new CC_TelemetryManager(); 00036 00037 // Create and configure the dummy telemetry packets 00038 unsigned char d11 = 11; 00039 unsigned char d12 = 12; 00040 unsigned char d21 = 21; 00041 unsigned char d22 = 22; 00042 DC_DummyTelemetryPacket* pTW1 = new DC_DummyTelemetryPacket(); 00043 DC_DummyTelemetryPacket* pTW2 = new DC_DummyTelemetryPacket(); 00044 pTW1->setNumberOfBytes(2); 00045 pTW1->setValue(0,d11); 00046 pTW1->setValue(1,d12); 00047 pTW2->setNumberOfBytes(2); 00048 pTW2->setValue(0,d21); 00049 pTW2->setValue(1,d22); 00050 00051 // Create, configure and load the telemetry mode manager 00052 DC_SimpleTelemetryModeManager* pTmMm = new DC_SimpleTelemetryModeManager(); 00053 pTmMm->setListLength(0,2); 00054 pTmMm->setListItem(0,0,pTW1); 00055 pTmMm->setListItem(0,1,pTW2); 00056 pTmMm->reset(); 00057 pTm->setTelemetryModeManager(pTmMm); 00058 00059 // Create, configure and load the telemetry stream 00060 unsigned int const size = 8; 00061 unsigned char tmData[size]; // TM data are written here 00062 for (unsigned int i=0; i<size; i++) 00063 tmData[i] = 0; 00064 DC_ByteArrayTelemetryStream* pTmSt = new DC_ByteArrayTelemetryStream(); 00065 pTmSt->setCapacity(size); 00066 pTmSt->setStartingAddress(tmData); 00067 pTm->setTelemetryStream(pTmSt); 00068 pTm->setImmediateQueueSize(2); 00069 00070 // Check that the components are configured 00071 if ( ( !pTm->isObjectConfigured() ) || 00072 ( !pTmMm->isObjectConfigured() ) || 00073 ( !pTmSt->isObjectConfigured() ) || 00074 ( !pTW1->isObjectConfigured() ) || 00075 ( !pTW2->isObjectConfigured() ) ) 00076 { setTestResult(TEST_FAILURE, "Wrong configuration status"); 00077 return; 00078 } 00079 00080 // Reset "in use" status 00081 pTW1->setInUse(true); 00082 pTW2->setInUse(true); 00083 00084 // Load the TM packets, unload them and check success (try to unload pTW2 twice) 00085 if (pTm->isImmediateQueueFull()) 00086 { setTestResult(TEST_FAILURE, "Wrong status of immediate dispatch queue"); 00087 return; 00088 } 00089 if (pTm->getImmediateQueueLoaded()!=0) 00090 { setTestResult(TEST_FAILURE, "Wrong number of entries in immediate dispatch queue"); 00091 return; 00092 } 00093 pTm->sendTelemetryPacket(pTW1); 00094 pTm->sendTelemetryPacket(pTW2); 00095 if (pTm->getImmediateQueueLoaded()!=2) 00096 { setTestResult(TEST_FAILURE, "Wrong number of entries in immediate dispatch queue"); 00097 return; 00098 } 00099 if (!pTm->isImmediateQueueFull()) 00100 { setTestResult(TEST_FAILURE, "Wrong status of immediate dispatch queue"); 00101 return; 00102 } 00103 pTm->unloadTelemetryPacket(pTW2); 00104 if (pTm->getImmediateQueueLoaded()!=1) 00105 { setTestResult(TEST_FAILURE, "Wrong number of entries in immediate dispatch queue"); 00106 return; 00107 } 00108 if (pTm->isImmediateQueueFull()) 00109 { setTestResult(TEST_FAILURE, "Wrong status of immediate dispatch queue"); 00110 return; 00111 } 00112 pTm->unloadTelemetryPacket(pTW2); 00113 if (pTm->getImmediateQueueLoaded()!=1) 00114 { setTestResult(TEST_FAILURE, "Wrong number of entries in immediate dispatch queue"); 00115 return; 00116 } 00117 pTm->unloadTelemetryPacket(pTW1); 00118 if (pTm->getImmediateQueueLoaded()!=0) 00119 { setTestResult(TEST_FAILURE, "Wrong number of entries in immediate dispatch queue"); 00120 return; 00121 } 00122 00123 // Activate telemetry manager and check correctness of values sent to TM stream 00124 // (Recall that the values encapsulated in the DC_DummyTelemetryPacket component 00125 // are incremented by 1 every time the component receives an update request) 00126 pTm->activate(); 00127 if ( ( tmData[0] != d11+1 ) || ( tmData[1] != d12+1 ) ) 00128 { setTestResult(TEST_FAILURE, "Wrong data written to telemetry stream"); 00129 return; 00130 } 00131 if ( ( tmData[2] != d21+1 ) || ( tmData[3] != d22+1 ) ) 00132 { setTestResult(TEST_FAILURE, "Wrong data written to telemetry stream"); 00133 return; 00134 } 00135 00136 // Check that "in use" status has not been changed 00137 if ( !pTW1->isInUse() ) 00138 { setTestResult(TEST_FAILURE, "Wrong inUse status"); 00139 return; 00140 } 00141 if ( !pTW2->isInUse() ) 00142 { setTestResult(TEST_FAILURE, "Wrong inUse status"); 00143 return; 00144 } 00145 00146 // Submit telemetry packets for immediate dispatch, activate telemetry manager 00147 // and check that telemetry data are correctly written to telemetry stream 00148 pTm->sendTelemetryPacket(pTW1); 00149 pTm->sendTelemetryPacket(pTW2); 00150 pTm->activate(); 00151 if ( ( tmData[0] != d11+2 ) || ( tmData[1] != d12+2 ) ) 00152 { setTestResult(TEST_FAILURE, "Wrong data written to telemetry stream"); 00153 return; 00154 } 00155 if ( ( tmData[2] != d21+2 ) || ( tmData[3] != d22+2 ) ) 00156 { setTestResult(TEST_FAILURE, "Wrong data written to telemetry stream"); 00157 return; 00158 } 00159 if ( ( tmData[4] != d11+3 ) || ( tmData[5] != d12+3 ) ) 00160 { setTestResult(TEST_FAILURE, "Wrong data written to telemetry stream"); 00161 return; 00162 } 00163 if ( ( tmData[6] != d21+3 ) || ( tmData[7] != d22+3 ) ) 00164 { setTestResult(TEST_FAILURE, "Wrong data written to telemetry stream"); 00165 return; 00166 } 00167 00168 // Check that "in use" status has been set to "not in use" 00169 if ( pTW1->isInUse() ) 00170 { setTestResult(TEST_FAILURE, "Wrong inUse status"); 00171 return; 00172 } 00173 if ( pTW2->isInUse() ) 00174 { setTestResult(TEST_FAILURE, "Wrong inUse status"); 00175 return; 00176 } 00177 00178 // Reset "in use" status 00179 pTW1->setInUse(true); 00180 pTW2->setInUse(true); 00181 00182 // Reset the array where telemetry data are written 00183 for (unsigned int i=0; i<size; i++) 00184 tmData[i] = 0; 00185 00186 // Force the first telemetry packet to be "not valid" 00187 pTW1->setValidStatus(NOT_VALID); 00188 00189 // Activate telemetry manager and check that only the second telemetry packet 00190 // is sent to TM stream 00191 pTm->activate(); 00192 if ( ( tmData[0] != d21+4 ) || ( tmData[1] != d22+4 ) ) 00193 { setTestResult(TEST_FAILURE, "Wrong data written to telemetry stream"); 00194 return; 00195 } 00196 if ( ( tmData[2] != 0 ) || ( tmData[3] != 0 ) ) 00197 { setTestResult(TEST_FAILURE, "Wrong data written to telemetry stream"); 00198 return; 00199 } 00200 00201 // Check that the correct event was generated 00202 if ( !verifyLatestEvent(nEvt+1,EVT_TM_ITEM_NOT_VALID) ) 00203 return; 00204 nEvt++; 00205 00206 // Decrease the size of the telemetry stream and make the telemetry 00207 // valid again 00208 pTmSt->setCapacity(3); 00209 pTW1->setValidStatus(VALID); 00210 00211 // Activate the telemetry manager and check that the correct event is generated 00212 // (The second telemetry packet should have been rejected) 00213 pTm->activate(); 00214 if ( !verifyLatestEvent(nEvt+1,EVT_TOO_MANY_TM_BYTES ) ) 00215 return; 00216 nEvt++; 00217 00218 // Reset the array where telemetry data are written, reset the 00219 // size of the telemetry stream, and reset the values of the telemetry packets 00220 pTmSt->setCapacity(size); 00221 pTW1->setValue(0,d11); 00222 pTW1->setValue(1,d12); 00223 pTW2->setValue(0,d21); 00224 pTW2->setValue(1,d22); 00225 for (unsigned int i=0; i<size; i++) 00226 tmData[i] = 0; 00227 00228 // Force the first telemetry packet to be "not valid" and submit it for 00229 // immediate dispatch to the telemetry stream. Activate the telemetry manager. 00230 // The immediate dispatch packet should not be written to the telemetry stream. 00231 // Two events should be generated (the telemetry packet is sent twice!) 00232 pTW1->setValidStatus(NOT_VALID); 00233 pTm->sendTelemetryPacket(pTW1); 00234 pTm->activate(); 00235 if ( ( tmData[4] != 0 ) || ( tmData[5] != 0 ) ) 00236 { setTestResult(TEST_FAILURE, "Wrong data written to telemetry stream"); 00237 return; 00238 } 00239 if ( !verifyLatestEvent(nEvt+2,EVT_TM_ITEM_NOT_VALID) ) 00240 return; 00241 if ( !verifySpecificEvent(nEvt+1,EVT_TM_ITEM_NOT_VALID) ) 00242 return; 00243 nEvt++; 00244 nEvt++; 00245 00246 // Check that "in use" status of pTW1 has been set to "not in use" 00247 if ( pTW1->isInUse() ) 00248 { setTestResult(TEST_FAILURE, "Wrong inUse status"); 00249 return; 00250 } 00251 if ( !pTW2->isInUse() ) 00252 { setTestResult(TEST_FAILURE, "Wrong inUse status"); 00253 return; 00254 } 00255 00256 // Reset "in use" status 00257 pTW1->setInUse(true); 00258 pTW2->setInUse(true); 00259 00260 // Reset the array where telemetry data are written 00261 for (unsigned int i=0; i<size; i++) 00262 tmData[i] = 0; 00263 00264 // Decrease the size of the telemetry stream to make it too small for the 00265 // telemetry packet, make the telemetry valid again, and resubmit for sending 00266 // to the TM stream 00267 // Nothing should be written to the TM stream and two events should be generated 00268 // (one for the repetitive packet and one for the immediate dispatch packet) 00269 pTmSt->setCapacity(1); 00270 pTW1->setValidStatus(VALID); 00271 pTm->sendTelemetryPacket(pTW1); 00272 pTm->activate(); 00273 if ( ( tmData[0] != 0 ) || ( tmData[1] != 0 ) ) 00274 { setTestResult(TEST_FAILURE, "Wrong data written to telemetry stream"); 00275 return; 00276 } 00277 if ( !verifyLatestEvent(nEvt+2,EVT_TOO_MANY_TM_BYTES) ) 00278 return; 00279 if ( !verifySpecificEvent(nEvt+1,EVT_TOO_MANY_TM_BYTES) ) 00280 return; 00281 nEvt++; 00282 nEvt++; 00283 00284 // Check that "in use" status of pTW1 has been set to "not in use" 00285 if ( pTW1->isInUse() ) 00286 { setTestResult(TEST_FAILURE, "Wrong inUse status"); 00287 return; 00288 } 00289 if ( !pTW2->isInUse() ) 00290 { setTestResult(TEST_FAILURE, "Wrong inUse status"); 00291 return; 00292 } 00293 00294 // Reset "in use" status 00295 pTW1->setInUse(true); 00296 pTW2->setInUse(true); 00297 // Try to submit three packets for immediate dispatch (the capacity of the 00298 // imemdiate dispatch queue is 2) and check that the correct event is generated 00299 pTm->sendTelemetryPacket(pTW1); 00300 pTm->sendTelemetryPacket(pTW1); 00301 pTm->sendTelemetryPacket(pTW1); 00302 if ( !verifyLatestEvent(nEvt+1,EVT_TM_QUEUE_FULL) ) 00303 return; 00304 nEvt++; 00305 00306 setTestResult(TEST_SUCCESS,"Test Successful"); 00307 return; 00308 }
Copyright 2003 P&P Software GmbH - All Rights Reserved