00001
00002
00003
00004
00005
00006
00007
00008
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_PUSClearDataReporting.h"
00015
#include "../Telemetry/DC_PUSDataReportingPacket.h"
00016
#include "../Telemetry/CC_TelemetryPacketFactory.h"
00017
#include "../Telemetry/DC_PUSTelemetryModeManager.h"
00018
#include "../Data/DC_SampleFullDataPool.h"
00019
#include "../Utilities/TestCasePUSFull.h"
00020
#include "TestCasePUSClearDataReporting_1.h"
00021
00022
#include <assert.h>
00023
#include <string.h>
00024
00025 TestCasePUSClearDataReporting_1::TestCasePUSClearDataReporting_1(
void) :
00026
TestCasePUSFull(ID_PUSCLEARDATAREPORTING*10+1,"
TestCasePUSClearDataReporting_1") {
00027
return;
00028 }
00029
00030 void TestCasePUSClearDataReporting_1::runTestCase(
void) {
00031
00032
00033
CC_TelemetryPacketFactory* pFct =
CC_TelemetryPacketFactory::getInstance();
00034
00035
00036
DC_PUSTelemetryModeManager* pTMM =
getTelemetryModeManager();
00037
00038
00039
unsigned short defPacketSize =
PUS_DRP_DEF_BUF_SIZE_SMALL-2;
00040
unsigned int valBufferSize =
PUS_DRP_VAL_BUF_SIZE_SMALL-2;
00041
DC_PUSDataReportingPacket* pTMP_a = pFct->
allocatePUSDataReportingPacket(defPacketSize,valBufferSize,0);
00042
DC_PUSDataReportingPacket* pTMP_b = pFct->
allocatePUSDataReportingPacket(defPacketSize,valBufferSize,0);
00043
if ( (pTMP_a==pNULL) || (pTMP_b==pNULL) )
00044 { setTestResult(
TEST_FAILURE,
"Failure to allocate telemetry packets");
00045
return;
00046 }
00047
00048
00049
TD_SID sid_a = 121;
00050
TD_SID sid_b = 131;
00051
TD_PUSCollectionInterval collectionInterval = 1;
00052
TD_PUSNumberOfParameters NPAR1 = 1;
00053
TD_DataPoolId par1 = 1;
00054
00055
unsigned char* packet =
new unsigned char[defPacketSize];
00056
unsigned int offset = 0;
00057 memcpy(packet+offset,&sid_a,
sizeof(
TD_SID));
00058 offset +=
sizeof(
TD_SID);
00059 memcpy(packet+offset,&collectionInterval,
sizeof(
TD_PUSCollectionInterval));
00060 offset +=
sizeof(
TD_PUSCollectionInterval);
00061 memcpy(packet+offset,&NPAR1,
sizeof(
TD_PUSNumberOfParameters));
00062 offset +=
sizeof(
TD_PUSNumberOfParameters);
00063 memcpy(packet+offset,&par1,
sizeof(
TD_DataPoolId));
00064 offset +=
sizeof(
TD_DataPoolId);
00065
00066 assert(offset<defPacketSize);
00067
00068
00069 pTMP_a->
setSubType(
PUS_ST_DATA_REP_PAR_HK_REP);
00070 pTMP_a->
setTimeTag(0);
00071
if ( !pTMP_a->
isObjectConfigured() )
00072 { setTestResult(
TEST_FAILURE,
"Wrong configuration status");
00073
return;
00074 }
00075 pTMP_b->
setSubType(
PUS_ST_DATA_REP_PAR_HK_REP);
00076 pTMP_b->
setTimeTag(0);
00077
if ( !pTMP_b->
isObjectConfigured() )
00078 { setTestResult(
TEST_FAILURE,
"Wrong configuration status");
00079
return;
00080 }
00081
00082
00083
for (
unsigned short i=0; i<offset; i++)
00084 pTMP_a->
setDefinitionBuffer(i,packet[i]);
00085
00086
00087 memcpy(packet,&sid_b,
sizeof(
TD_SID));
00088
for (
unsigned short i=0; i<offset; i++)
00089 pTMP_b->
setDefinitionBuffer(i,packet[i]);
00090
00091
00092 pTMM->
loadPacket(pTMP_b);
00093
if ( !pTMM->
isSIDLoaded(sid_b) )
00094 { setTestResult(
TEST_FAILURE,
"TM packet is not loaded");
00095
return;
00096 }
00097
00098
00099
DC_PUSClearDataReporting* pTC =
new DC_PUSClearDataReporting();
00100
00101
00102
if ( pTC->
getClassId() != ID_PUSCLEARDATAREPORTING )
00103 { setTestResult(
TEST_FAILURE,
"Wrong class identifier");
00104
return;
00105 }
00106
00107
00108
if ( pTC->
isObjectConfigured() )
00109 { setTestResult(
TEST_FAILURE,
"Wrong configuration status");
00110
return;
00111 }
00112
00113
00114 pTC->
setMaxNumberSID(2);
00115
if ( pTC->
getNumberOfRawData()!=(2*
sizeof(
TD_SID)+1) )
00116 { setTestResult(
TEST_FAILURE,
"Wrong configuration value");
00117
return;
00118 }
00119
00120
00121 pTC->
setPUSTelemetryModeManager(pTMM);
00122
if ( pTC->
getPUSTelemetryModeManager()!=pTMM )
00123 { setTestResult(
TEST_FAILURE,
"Wrong configuration value");
00124
return;
00125 }
00126
00127
00128
TD_TelecommandSource tcSource = 1;
00129
TD_TelecommandId tcId = 2;
00130 pTC->
setSource(tcSource);
00131 pTC->
setSubType(
PUS_ST_DATA_REP_CLR_HK);
00132 pTC->
setTelecommandId(tcId);
00133 pTC->
setTimeTag(0);
00134
if ( !pTC->
isObjectConfigured() )
00135 { setTestResult(
TEST_FAILURE,
"Wrong configuration status");
00136
return;
00137 }
00138
00139
00140
unsigned int maxNSID = 2;
00141
TD_SID* temp =
new TD_SID[maxNSID+1];
00142
TD_SID* sid = &temp[1];
00143
unsigned char* rawData = ((
unsigned char*)sid)-1;
00144
00145
00146 rawData[0]=2;
00147 sid[0]=sid_a;
00148 sid[1]=sid_b;
00149
for (
unsigned int i=0; i<(1+2*
sizeof(
TD_SID)); i++)
00150 pTC->
setRawData(i,rawData[i]);
00151
00152
00153
if ( !pTC->
isValid() )
00154 { setTestResult(
TEST_FAILURE,
"Wrong validity status");
00155
return;
00156 }
00157
00158
00159
if ( !pTMP_a->
isInUse() )
00160 { setTestResult(
TEST_FAILURE,
"Wrong enable status");
00161
return;
00162 }
00163
if ( !pTMP_b->
isInUse() )
00164 { setTestResult(
TEST_FAILURE,
"Wrong enable status");
00165
return;
00166 }
00167
if ( !pTMM->
isSIDLoaded(sid_b) )
00168 { setTestResult(
TEST_FAILURE,
"Wrong load status");
00169
return;
00170 }
00171
00172
TD_ActionOutcome ao = pTC->
execute();
00173
if ( ao!=ACTION_SUCCESS )
00174 { setTestResult(
TEST_FAILURE,
"Wrong action outcome");
00175
return;
00176 }
00177
if ( pTMP_a->
isInUse() )
00178 { setTestResult(
TEST_FAILURE,
"Wrong enable status");
00179
return;
00180 }
00181
if ( pTMP_b->
isInUse() )
00182 { setTestResult(
TEST_FAILURE,
"Wrong enable status");
00183
return;
00184 }
00185
if ( pTMM->
isSIDLoaded(sid_b) )
00186 { setTestResult(
TEST_FAILURE,
"Wrong enable status");
00187
return;
00188 }
00189
00190
00191 ao = pTC->
execute();
00192
if ( ao!=ACTION_FAILURE )
00193 { setTestResult(
TEST_FAILURE,
"Wrong action outcome");
00194
return;
00195 }
00196
00197
00198 rawData[0]=3;
00199 sid[0]=sid_a;
00200 sid[1]=sid_b;
00201
for (
unsigned int i=0; i<(1+2*
sizeof(
TD_SID)); i++)
00202 pTC->
setRawData(i,rawData[i]);
00203
00204
00205
if ( pTC->
isValid() || pTC->
getValidityCheckCode()!=
VC_TOO_MANY_SIDS )
00206 { setTestResult(
TEST_FAILURE,
"Wrong validity status");
00207
return;
00208 }
00209
00210
00211
if (
isNonNominalCheckAllowed()) {
00212 rawData[0]=2;
00213 sid[0]=sid_a;
00214 sid[1]=sid_b;
00215
for (
unsigned int i=0; i<(2+2*
sizeof(
TD_SID)); i++)
00216 pTC->
setRawData(i,rawData[i]);
00217
00218
00219
if ( pTC->
isValid() || pTC->
getValidityCheckCode()!=
VC_TOO_MANY_RAW_DATA )
00220 { setTestResult(
TEST_FAILURE,
"Wrong validity status");
00221
return;
00222 }
00223 }
00224
00225
00226 rawData[0]=2;
00227 sid[0]=sid_a;
00228 sid[1]=sid_b;
00229
for (
unsigned int i=0; i<(2*
sizeof(
TD_SID)); i++)
00230 pTC->
setRawData(i,rawData[i]);
00231
00232
00233
if ( pTC->
isValid() || pTC->
getValidityCheckCode()!=
VC_INCONSISTENT_RAW_DATA )
00234 { setTestResult(
TEST_FAILURE,
"Wrong validity status");
00235
return;
00236 }
00237
00238 setTestResult(
TEST_SUCCESS,
"Test Successful");
00239
return;
00240 }