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

TestCasePUSFull.cpp

00001 // 00002 // Copyright 2004 P&P Software GmbH - All Rights Reserved 00003 // 00004 // TestCasePUSFull.cpp 00005 // 00006 // Version 1.0 00007 // Date 13.01.04 00008 // Author A. Pasetti (P&P Software) 00009 00010 #include "TestCasePUSFull.h" 00011 #include "../GeneralInclude/CompilerSwitches.h" 00012 #include "../GeneralInclude/TestConstants.h" 00013 #include "../GeneralInclude/ClassId.h" 00014 #include "../GeneralInclude/Constants.h" 00015 #include "../Base/CC_RootObject.h" 00016 #include "../System/DC_DummyObsClock.h" 00017 #include "../Event/DC_PUSEventRepository.h" 00018 #include "../Data/DC_DummyDataPool.h" 00019 #include "../Data/DC_DummyDatabase.h" 00020 #include "../Manoeuvre/CC_ManoeuvreManager.h" 00021 #include "../Telemetry/CC_TelemetryManager.h" 00022 #include "../Telemetry/DC_PUSTelemetryModeManager.h" 00023 #include "../Telemetry/DC_PUSDataReportingPacket.h" 00024 #include "../Telemetry/DC_PUSTmLogger.h" 00025 #include "../Telemetry/TelemetryPacket.h" 00026 #include "../Telecommand/CC_TelecommandManager.h" 00027 #include "../Telecommand/DC_BasicPUSTcLoader.h" 00028 #include "../Telecommand/TelecommandLoader.h" 00029 #include "../Telecommand/PUSTelecommand.h" 00030 00031 #include <string.h> 00032 #include <assert.h> 00033 00034 bool TestCasePUSFull::firstActivation = true; 00035 00036 CC_TelemetryManager* TestCasePUSFull::pTmManager = pNULL; 00037 DC_PUSTelemetryModeManager* TestCasePUSFull::pTmModeMan = pNULL; 00038 CC_TelecommandManager* TestCasePUSFull::pTcManager = pNULL; 00039 CC_ManoeuvreManager* TestCasePUSFull::pManManager = pNULL; 00040 DC_PUSTmLogger* TestCasePUSFull::pTmLogger = pNULL; 00041 DC_BasicPUSTcLoader* TestCasePUSFull::pTcLoader = pNULL; 00042 DC_PUSEventRepository* TestCasePUSFull::pEvtRep = pNULL; 00043 DC_DummyObsClock* TestCasePUSFull::pObsClock = pNULL; 00044 00045 unsigned char TestCasePUSFull::tcCommandArea[TC_COMMAND_AREA_MAX_N_TC*TC_COMMAND_AREA_MAX_TC_LEN]; 00046 00047 TestCasePUSFull::TestCasePUSFull(int testId, char* testName): 00048 TestCaseWithFactories(testId,testName) { 00049 return; 00050 } 00051 00052 bool TestCasePUSFull::setUpTestCase(void) { 00053 00054 if (!TestCaseWithFactories::setUpTestCase()) 00055 return INITIALIZATION_FAILURE; 00056 00057 if (firstActivation) { 00058 00059 // Create the components 00060 pTmManager = new CC_TelemetryManager(); 00061 pTmModeMan = new DC_PUSTelemetryModeManager(); 00062 pTcManager = new CC_TelecommandManager(); 00063 pManManager = new CC_ManoeuvreManager(); 00064 pTmLogger = new DC_PUSTmLogger(); 00065 pTcLoader = new DC_BasicPUSTcLoader(); 00066 pEvtRep = new DC_PUSEventRepository(); 00067 pObsClock = new DC_DummyObsClock(); 00068 00069 // Configure the non-changeable part of the tc manager 00070 if ( pTcManager->isObjectConfigured() ) 00071 return false; 00072 pTcManager->setPendingTelecommandListSize(TC_MAN_PEND_TC_LIST_SIZE); 00073 00074 // Configure the non-changeable part of the tm mode manager 00075 if ( pTmModeMan->isObjectConfigured() ) 00076 return false; 00077 pTmModeMan->setMaxNumberOfPackets(TM_MODE_MAN_MAX_N_PACKETS); 00078 00079 // Configure the non-changeable part of the tm manager 00080 if ( pTmManager->isObjectConfigured() ) 00081 return false; 00082 pTmManager->setImmediateQueueSize(TM_MAN_IMMEDIATE_QUEUE); 00083 00084 // Configure the non-changeable part of the manoeuvre manager 00085 if ( pManManager->isObjectConfigured() ) 00086 return false; 00087 pManManager->setPendingManoeuvreListSize(MAN_MAN_PENDING_MAN_LIST_SIZE); 00088 00089 // Configure the non-changeable part of the tc loader 00090 if ( pTcLoader->isObjectConfigured() ) 00091 return false; 00092 00093 // Configure the non-changeable part of the tm stream 00094 if ( pTmLogger->isObjectConfigured() ) 00095 return false; 00096 pTmLogger->setBufferCapacity(TM_LOGGER_BUFFER_CAPACITY); 00097 pTmLogger->setMaxPacketLength(TM_LOGGER_MAX_TM_LENGTH); 00098 if ( !pTmLogger->isObjectConfigured() ) 00099 return false; 00100 00101 // Configure the non-changeable part of the evt repository 00102 if ( pEvtRep->isObjectConfigured() ) 00103 return false; 00104 pEvtRep->setRepositorySize(PUS_EVT_REP_SIZE); 00105 00106 firstActivation = false; 00107 } 00108 00109 // Configure the updatable part of the tc manager 00110 pTcManager->setObsClock(getObsClock()); 00111 pTcManager->setTelecommandLoader(pTcLoader); 00112 if ( !pTcManager->isObjectConfigured() ) 00113 return false; 00114 00115 // Configure the updatable part of the tm mode manager 00116 pTmModeMan->reset(); 00117 if ( !pTmModeMan->isObjectConfigured() ) 00118 return false; 00119 00120 // Configure the updatable part of the tm manager 00121 pTmManager->setTelemetryStream(pTmLogger); 00122 pTmManager->setTelemetryModeManager(pTmModeMan); 00123 if ( !pTmManager->isObjectConfigured() ) 00124 return false; 00125 00126 // Configure the updatable part of the manoeuvre manager 00127 if ( !pManManager->isObjectConfigured() ) 00128 return false; 00129 00130 // Configure the updatable part of the tc loader 00131 pTcLoader->setMaxNumberOfTc(TC_COMMAND_AREA_MAX_N_TC); 00132 pTcLoader->setMaxTcLength(TC_COMMAND_AREA_MAX_TC_LEN); 00133 pTcLoader->setTcLoadAreaStart(tcCommandArea); 00134 pTcLoader->setTelecommandManager(pTcManager); 00135 if ( !pTcLoader->isObjectConfigured() ) 00136 return false; 00137 00138 // Configure the updatable part of the evt repository 00139 pEvtRep->setObsClock(getObsClock()); 00140 pEvtRep->setTelemetryManager(pTmManager); 00141 if ( !pEvtRep->isObjectConfigured() ) 00142 return false; 00143 00144 // Swap the event repository 00145 pOldEvtRep = CC_RootObject::getEventRepository(); 00146 CC_RootObject::setEventRepository(pEvtRep); 00147 00148 // Reset the telecommand load area 00149 resetCommandLoadArea(); 00150 00151 // Clear the mode manager of any packets that were loaded in previous tests 00152 for (pTmModeMan->first(); !pTmModeMan->isIterationFinished(); pTmModeMan->next()) { 00153 TelemetryPacket* pTP = pTmModeMan->getIterationTelemetryPacket(); 00154 00155 if (pTP->getClassId()!=ID_PUSDATAREPORTINGPACKET) 00156 00157 return INITIALIZATION_FAILURE; 00158 00159 else 00160 00161 pTmModeMan->unloadPacket( ((DC_PUSDataReportingPacket*)pTP)->getSID()); 00162 00163 } 00164 00165 00166 // Flush the functionality managers 00167 pTcManager->activate(); 00168 pTmManager->activate(); 00169 pTmManager->activate(); 00170 00171 return INITIALIZATION_SUCCESS; 00172 } 00173 00174 bool TestCasePUSFull::shutDownTestCase(void) { 00175 00176 // restore the event repository 00177 CC_RootObject::setEventRepository(pOldEvtRep); 00178 00179 return SHUTDOWN_SUCCESS; 00180 } 00181 00182 CC_TelecommandManager* TestCasePUSFull::getTelecommandManager(void) const { 00183 return pTcManager; 00184 } 00185 00186 CC_TelemetryManager* TestCasePUSFull::getTelemetryManager(void) const { 00187 return pTmManager; 00188 } 00189 00190 DC_PUSTelemetryModeManager* TestCasePUSFull::getTelemetryModeManager(void) const { 00191 return pTmModeMan; 00192 } 00193 00194 CC_ManoeuvreManager* TestCasePUSFull::getManoeuvreManager(void) const { 00195 return pManManager; 00196 } 00197 00198 DC_BasicPUSTcLoader* TestCasePUSFull::getTcLoader(void) const { 00199 return pTcLoader; 00200 } 00201 00202 DC_PUSTmLogger* TestCasePUSFull::getTmStream(void) const { 00203 return pTmLogger; 00204 } 00205 00206 DC_DummyObsClock* TestCasePUSFull::getObsClock(void) const { 00207 return pObsClock; 00208 } 00209 00210 DC_PUSEventRepository* TestCasePUSFull::getEventRepository(void) const { 00211 return pEvtRep; 00212 } 00213 00214 void TestCasePUSFull::resetCommandLoadArea(void) { 00215 tcCmdPos = 1; 00216 tcCommandArea[0] = 0; 00217 } 00218 00219 void TestCasePUSFull::writeTcHeader(unsigned short length, unsigned short packetSeqControl) { 00220 TD_PUSPacketId id = PUSTelecommand::getPacketId(); 00221 assert(sizeof(TD_PUSPacketId)==2); 00222 memcpy(tcCommandArea+tcCmdPos,&id,2); 00223 memcpy(tcCommandArea+tcCmdPos+2,&packetSeqControl,2); 00224 memcpy(tcCommandArea+tcCmdPos+4,&length,2); 00225 tcCmdPos = tcCmdPos+6; 00226 } 00227 00228 bool TestCasePUSFull::writeTestPUSTelecommand( 00229 unsigned char ackField, unsigned int execCounter, bool execCheckVal, 00230 bool valCheckVal, TD_CheckCode execCheckCode, 00231 TD_CheckCode valCheckCode, bool execOutcome, 00232 unsigned short packetSeqControl) { 00233 00234 // Check that TC packet fits in command load area 00235 unsigned short appDataLength = 6; 00236 unsigned short packetLength = 11+sizeof(TD_TelecommandSource)+appDataLength; 00237 if ( (tcCmdPos+packetLength)>TC_COMMAND_AREA_MAX_N_TC*TC_COMMAND_AREA_MAX_TC_LEN ) 00238 return false; 00239 00240 // Write TC packet header 00241 writeTcHeader(packetLength-6,packetSeqControl); 00242 00243 // Write packet data field header 00244 *(unsigned char*)(tcCommandArea+tcCmdPos) = ackField; 00245 *(unsigned char*)(tcCommandArea+tcCmdPos+1) = PUS_TYPE_TEST; 00246 *(unsigned char*)(tcCommandArea+tcCmdPos+2) = PUS_ST_TC_TEST; 00247 TD_TelecommandSource tcSrc = DEF_PUS_TC_SOURCE; 00248 memcpy(tcCommandArea+tcCmdPos+3,&tcSrc,sizeof(TD_TelecommandSource)); 00249 tcCmdPos = tcCmdPos+3+sizeof(TD_TelecommandSource); 00250 00251 // Write application data 00252 *(unsigned char*)(tcCommandArea+tcCmdPos) = (unsigned char)execCounter; 00253 *(unsigned char*)(tcCommandArea+tcCmdPos+1) = execCheckVal; 00254 *(unsigned char*)(tcCommandArea+tcCmdPos+2) = valCheckVal; 00255 *(unsigned char*)(tcCommandArea+tcCmdPos+3) = (unsigned char)execCheckCode; 00256 *(unsigned char*)(tcCommandArea+tcCmdPos+4) = (unsigned char)valCheckCode; 00257 *(unsigned char*)(tcCommandArea+tcCmdPos+5) = execOutcome; 00258 tcCmdPos = tcCmdPos+6; 00259 00260 // Write packet error control bytes 00261 *(unsigned char*)(tcCommandArea+tcCmdPos) = 0; 00262 *(unsigned char*)(tcCommandArea+tcCmdPos+1) = 0; 00263 tcCmdPos = tcCmdPos+2; 00264 00265 return true; 00266 } 00267 00268 bool TestCasePUSFull::writePUSDataReportingControl( 00269 unsigned char ackField, unsigned char NSID, TD_SID* sid, 00270 TD_TelecommandSubType tcSubType, unsigned short packetSeqControl) { 00271 00272 // Check that TC packet fits in command load area 00273 unsigned short appDataLength = 1+NSID*sizeof(TD_SID); 00274 unsigned short packetLength = 11+sizeof(TD_TelecommandSource)+appDataLength; 00275 if ( (tcCmdPos+packetLength)>TC_COMMAND_AREA_MAX_N_TC*TC_COMMAND_AREA_MAX_TC_LEN ) 00276 return false; 00277 00278 // Write TC packet header 00279 writeTcHeader(packetLength-6,packetSeqControl); 00280 00281 // Write packet data field header 00282 *(unsigned char*)(tcCommandArea+tcCmdPos) = ackField; 00283 *(unsigned char*)(tcCommandArea+tcCmdPos+1) = PUS_TYPE_DATA_REP; 00284 *(unsigned char*)(tcCommandArea+tcCmdPos+2) = tcSubType; 00285 TD_TelecommandSource tcSrc = DEF_PUS_TC_SOURCE; 00286 memcpy(tcCommandArea+tcCmdPos+3,&tcSrc,sizeof(TD_TelecommandSource)); 00287 tcCmdPos = tcCmdPos+3+sizeof(TD_TelecommandSource); 00288 00289 // Write application data 00290 *(unsigned char*)(tcCommandArea+tcCmdPos) = (unsigned char)NSID; 00291 tcCmdPos++; 00292 for (unsigned char i=0; i<NSID; i++) { 00293 memcpy(tcCommandArea+tcCmdPos,&sid[i],sizeof(TD_SID)); 00294 tcCmdPos = tcCmdPos + sizeof(TD_SID); 00295 } 00296 00297 // Write packet error control bytes 00298 *(unsigned char*)(tcCommandArea+tcCmdPos) = 0; 00299 *(unsigned char*)(tcCommandArea+tcCmdPos+1) = 0; 00300 tcCmdPos = tcCmdPos+2; 00301 00302 return true; 00303 } 00304 00305 bool TestCasePUSFull::writePUSDefineDataReporting( 00306 unsigned char ackField, TD_PUSCollectionInterval collectionInterval, TD_SID sid, 00307 TD_DataPoolId par, unsigned short packetSeqControl, TD_TelecommandSubType tcSubType) { 00308 00309 // Check that TC packet fits in command load area 00310 unsigned short appDataLength = sizeof(TD_SID)+sizeof(TD_PUSCollectionInterval)+ 00311 sizeof(TD_PUSNumberOfParameters)+sizeof(TD_DataPoolId); 00312 unsigned short packetLength = 11+sizeof(TD_TelecommandSource)+appDataLength; 00313 if ( (tcCmdPos+packetLength)>TC_COMMAND_AREA_MAX_N_TC*TC_COMMAND_AREA_MAX_TC_LEN ) 00314 return false; 00315 00316 // Write TC packet header 00317 writeTcHeader(packetLength-6,packetSeqControl); 00318 00319 // Write packet data field header 00320 *(unsigned char*)(tcCommandArea+tcCmdPos) = ackField; 00321 *(unsigned char*)(tcCommandArea+tcCmdPos+1) = PUS_TYPE_DATA_REP; 00322 *(unsigned char*)(tcCommandArea+tcCmdPos+2) = tcSubType; 00323 TD_TelecommandSource tcSrc = DEF_PUS_TC_SOURCE; 00324 memcpy(tcCommandArea+tcCmdPos+3,&tcSrc,sizeof(TD_TelecommandSource)); 00325 tcCmdPos = tcCmdPos+3+sizeof(TD_TelecommandSource); 00326 00327 // Write application data 00328 memcpy(tcCommandArea+tcCmdPos,&sid,sizeof(TD_SID)); 00329 tcCmdPos = tcCmdPos+sizeof(TD_SID); 00330 00331 memcpy(tcCommandArea+tcCmdPos,&collectionInterval,sizeof(TD_PUSCollectionInterval)); 00332 tcCmdPos = tcCmdPos+sizeof(TD_PUSCollectionInterval); 00333 00334 TD_PUSNumberOfParameters npTemp = 1; 00335 memcpy(tcCommandArea+tcCmdPos,&npTemp,sizeof(TD_PUSNumberOfParameters)); 00336 tcCmdPos = tcCmdPos+sizeof(TD_PUSNumberOfParameters); 00337 00338 memcpy(tcCommandArea+tcCmdPos,&par,sizeof(TD_DataPoolId)); 00339 tcCmdPos = tcCmdPos+sizeof(TD_DataPoolId); 00340 00341 // Write packet error control bytes 00342 *(unsigned char*)(tcCommandArea+tcCmdPos) = 0; 00343 *(unsigned char*)(tcCommandArea+tcCmdPos+1) = 0; 00344 tcCmdPos = tcCmdPos+2; 00345 00346 return true; 00347 } 00348
Copyright 2003 P&P Software GmbH - All Rights Reserved