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

TestCasePUSControlDataReporting_1.cpp

00001 // 00002 // Copyright 2004 P&P Software GmbH - All Rights Reserved 00003 // 00004 // TestCasePUSControlDataReporting_1.cpp 00005 // 00006 // Version 1.0 00007 // Date 04.01.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 "../Telecommand/DC_PUSControlDataReporting.h" 00015 #include "../Telemetry/DC_PUSDataReportingPacket.h" 00016 #include "../Telemetry/CC_TelemetryPacketFactory.h" 00017 #include "../Data/DC_SampleFullDataPool.h" 00018 #include "../Utilities/TestCaseWithFactories.h" 00019 #include "TestCasePUSControlDataReporting_1.h" 00020 00021 #include <assert.h> 00022 #include <string.h> 00023 00024 TestCasePUSControlDataReporting_1::TestCasePUSControlDataReporting_1(void) : 00025 TestCaseWithFactories(ID_PUSCONTROLDATAREPORTING*10+1,"TestCasePUSControlDataReporting_1") { 00026 return; 00027 } 00028 00029 void TestCasePUSControlDataReporting_1::runTestCase(void) { 00030 00031 // Retrieve the packet factory 00032 CC_TelemetryPacketFactory* pFct = CC_TelemetryPacketFactory::getInstance(); 00033 00034 // Allocate the two telemetry packets 00035 unsigned short defPacketSize = PUS_DRP_DEF_BUF_SIZE_SMALL-2; 00036 unsigned int valBufferSize = PUS_DRP_VAL_BUF_SIZE_SMALL-2; 00037 DC_PUSDataReportingPacket* pTMP_a = pFct->allocatePUSDataReportingPacket(defPacketSize,valBufferSize,0); 00038 DC_PUSDataReportingPacket* pTMP_b = pFct->allocatePUSDataReportingPacket(defPacketSize,valBufferSize,0); 00039 00040 // Construct the packet 00041 TD_SID sid_a = 12; 00042 TD_SID sid_b = 13; 00043 TD_PUSCollectionInterval collectionInterval = 1; 00044 TD_PUSNumberOfParameters NPAR1 = 1; 00045 TD_DataPoolId par1 = 1; 00046 00047 unsigned char* packet = new unsigned char[defPacketSize]; 00048 unsigned int offset = 0; 00049 memcpy(packet+offset,&sid_a,sizeof(TD_SID)); 00050 offset += sizeof(TD_SID); 00051 memcpy(packet+offset,&collectionInterval,sizeof(TD_PUSCollectionInterval)); 00052 offset += sizeof(TD_PUSCollectionInterval); 00053 memcpy(packet+offset,&NPAR1,sizeof(TD_PUSNumberOfParameters)); 00054 offset += sizeof(TD_PUSNumberOfParameters); 00055 memcpy(packet+offset,&par1,sizeof(TD_DataPoolId)); 00056 offset += sizeof(TD_DataPoolId); 00057 00058 assert(offset<defPacketSize); 00059 00060 // Configure the two packets and check that they are configured 00061 pTMP_a->setSubType(PUS_ST_DATA_REP_PAR_HK_REP); 00062 pTMP_a->setTimeTag(0); 00063 if ( !pTMP_a->isObjectConfigured() ) 00064 { setTestResult(TEST_FAILURE,"Wrong configuration status"); 00065 return; 00066 } 00067 pTMP_b->setSubType(PUS_ST_DATA_REP_PAR_HK_REP); 00068 pTMP_b->setTimeTag(0); 00069 if ( !pTMP_b->isObjectConfigured() ) 00070 { setTestResult(TEST_FAILURE,"Wrong configuration status"); 00071 return; 00072 } 00073 00074 // Load the packet definitions for the first TM packet 00075 for (unsigned short i=0; i<offset; i++) 00076 pTMP_a->setDefinitionBuffer(i,packet[i]); 00077 00078 // Load the packet definitions for the second TM packet 00079 memcpy(packet,&sid_b,sizeof(TD_SID)); 00080 for (unsigned short i=0; i<offset; i++) 00081 pTMP_b->setDefinitionBuffer(i,packet[i]); 00082 00083 // Create the telecommand 00084 DC_PUSControlDataReporting* pTC = new DC_PUSControlDataReporting(); 00085 00086 // Check the value of the class identifier 00087 if ( pTC->getClassId() != ID_PUSCONTROLDATAREPORTING ) 00088 { setTestResult(TEST_FAILURE, "Wrong class identifier"); 00089 return; 00090 } 00091 00092 // Check configuration status 00093 if ( pTC->isObjectConfigured() ) 00094 { setTestResult(TEST_FAILURE, "Wrong configuration status"); 00095 return; 00096 } 00097 00098 // Set the number of SIDs and check success 00099 pTC->setMaxNumberSID(2); 00100 if ( pTC->getNumberOfRawData()!=(2*sizeof(TD_SID)+1) ) 00101 { setTestResult(TEST_FAILURE, "Wrong configuration value"); 00102 return; 00103 } 00104 00105 // Complete configuration of telecommand and check configuration status 00106 TD_TelecommandSource tcSource = 1; 00107 TD_TelecommandId tcId = 2; 00108 pTC->setSource(tcSource); 00109 pTC->setSubType(PUS_ST_DATA_REP_ENB_HK); 00110 pTC->setTelecommandId(tcId); 00111 pTC->setTimeTag(0); 00112 if ( !pTC->isObjectConfigured() ) 00113 { setTestResult(TEST_FAILURE, "Wrong configuration status"); 00114 return; 00115 } 00116 00117 // set up data structures to hold telecommand raw data 00118 unsigned int maxNSID = 3; 00119 TD_SID* temp = new TD_SID[maxNSID+1]; 00120 TD_SID* sid = &temp[1]; 00121 unsigned char* rawData = ((unsigned char*)sid)-1; 00122 00123 // Load raw data in telecommandand 00124 rawData[0]=1; 00125 sid[0]=sid_a; 00126 for (unsigned int i=0; i<(1+1*sizeof(TD_SID)); i++) 00127 pTC->setRawData(i,rawData[i]); 00128 pTC->setSubType(PUS_ST_DATA_REP_ENB_HK); 00129 00130 // Check validity 00131 if ( !pTC->isValid() ) 00132 { setTestResult(TEST_FAILURE, "Wrong validity status"); 00133 return; 00134 } 00135 00136 // Execute telecommand and check success 00137 TD_ActionOutcome ao = pTC->execute(); 00138 if ( ao!=ACTION_SUCCESS ) 00139 { setTestResult(TEST_FAILURE, "Wrong action outcome"); 00140 return; 00141 } 00142 if ( !pTMP_a->isEnabled() ) 00143 { setTestResult(TEST_FAILURE, "Wrong enable status"); 00144 return; 00145 } 00146 00147 // Load raw data in telecommandand and configure telecommand 00148 rawData[0]=1; 00149 sid[0]=sid_a; 00150 for (unsigned int i=0; i<(1+1*sizeof(TD_SID)); i++) 00151 pTC->setRawData(i,rawData[i]); 00152 pTC->setSubType(PUS_ST_DATA_REP_DIS_HK); 00153 00154 // Check validity 00155 if ( !pTC->isValid() ) 00156 { setTestResult(TEST_FAILURE, "Wrong validity status"); 00157 return; 00158 } 00159 00160 // Execute telecommand and check success 00161 ao = pTC->execute(); 00162 if ( ao!=ACTION_SUCCESS ) 00163 { setTestResult(TEST_FAILURE, "Wrong action outcome"); 00164 return; 00165 } 00166 if ( pTMP_a->isEnabled() ) 00167 { setTestResult(TEST_FAILURE, "Wrong enable status"); 00168 return; 00169 } 00170 00171 // Load raw data in telecommandand and configure telecommand 00172 rawData[0]=2; 00173 sid[0]=sid_a; 00174 sid[1]=sid_b; 00175 for (unsigned int i=0; i<(1+2*sizeof(TD_SID)); i++) 00176 pTC->setRawData(i,rawData[i]); 00177 pTC->setSubType(PUS_ST_DATA_REP_ENB_HK); 00178 00179 // Check validity 00180 if ( !pTC->isValid() ) 00181 { setTestResult(TEST_FAILURE, "Wrong validity status"); 00182 return; 00183 } 00184 00185 // Execute telecommand and check success 00186 ao = pTC->execute(); 00187 if ( ao!=ACTION_SUCCESS ) 00188 { setTestResult(TEST_FAILURE, "Wrong action outcome"); 00189 return; 00190 } 00191 if ( (!pTMP_a->isEnabled()) || (!pTMP_b->isEnabled()) ) 00192 { setTestResult(TEST_FAILURE, "Wrong enable status"); 00193 return; 00194 } 00195 00196 // Load illegal raw data in telecommandand and configure telecommand 00197 if (isNonNominalCheckAllowed()) { 00198 rawData[0]=3; 00199 sid[0]=sid_a; 00200 sid[1]=sid_b; 00201 sid[2]=sid_a; 00202 for (unsigned int i=0; i<(1+3*sizeof(TD_SID)); i++) 00203 pTC->setRawData(i,rawData[i]); 00204 pTC->setSubType(PUS_ST_DATA_REP_ENB_HK); 00205 00206 // Check validity 00207 if ( pTC->isValid() || (pTC->getValidityCheckCode()!=VC_TOO_MANY_RAW_DATA) ) 00208 { setTestResult(TEST_FAILURE, "Wrong validity status"); 00209 return; 00210 } 00211 } 00212 00213 // Try to load too many raw data and check validity 00214 if (isNonNominalCheckAllowed()) { 00215 rawData[0]=2; 00216 sid[0]=sid_a; 00217 sid[1]=sid_b; 00218 for (unsigned int i=0; i<(2+2*sizeof(TD_SID)); i++) 00219 pTC->setRawData(i,rawData[i]); 00220 00221 // Check validity 00222 if ( pTC->isValid() || pTC->getValidityCheckCode()!=VC_TOO_MANY_RAW_DATA ) 00223 { setTestResult(TEST_FAILURE, "Wrong validity status"); 00224 return; 00225 } 00226 } 00227 00228 // Try to load an inconsistent number of raw data and check validity 00229 rawData[0]=2; 00230 sid[0]=sid_a; 00231 sid[1]=sid_b; 00232 for (unsigned int i=0; i<(2*sizeof(TD_SID)); i++) 00233 pTC->setRawData(i,rawData[i]); 00234 00235 // Check validity 00236 if ( pTC->isValid() || pTC->getValidityCheckCode()!=VC_INCONSISTENT_RAW_DATA ) 00237 { setTestResult(TEST_FAILURE, "Wrong validity status"); 00238 return; 00239 } 00240 00241 // Load raw data in telecommandand and configure telecommand 00242 rawData[0]=2; 00243 sid[0]=sid_a+10; 00244 sid[1]=sid_b; 00245 for (unsigned int i=0; i<(1+2*sizeof(TD_SID)); i++) 00246 pTC->setRawData(i,rawData[i]); 00247 pTC->setSubType(PUS_ST_DATA_REP_DIS_HK); 00248 00249 // Check validity 00250 if ( !pTC->isValid() ) 00251 { setTestResult(TEST_FAILURE, "Wrong validity status"); 00252 return; 00253 } 00254 00255 // Execute telecommand and check success 00256 ao = pTC->execute(); 00257 if ( ao!=ACTION_FAILURE ) 00258 { setTestResult(TEST_FAILURE, "Wrong action outcome"); 00259 return; 00260 } 00261 00262 setTestResult(TEST_SUCCESS,"Test Successful"); 00263 return; 00264 }
Copyright 2003 P&P Software GmbH - All Rights Reserved