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_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
00032
CC_TelemetryPacketFactory* pFct =
CC_TelemetryPacketFactory::getInstance();
00033
00034
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
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
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
00075
for (
unsigned short i=0; i<offset; i++)
00076 pTMP_a->
setDefinitionBuffer(i,packet[i]);
00077
00078
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
00084
DC_PUSControlDataReporting* pTC =
new DC_PUSControlDataReporting();
00085
00086
00087
if ( pTC->
getClassId() != ID_PUSCONTROLDATAREPORTING )
00088 { setTestResult(
TEST_FAILURE,
"Wrong class identifier");
00089
return;
00090 }
00091
00092
00093
if ( pTC->
isObjectConfigured() )
00094 { setTestResult(
TEST_FAILURE,
"Wrong configuration status");
00095
return;
00096 }
00097
00098
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
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
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
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
00131
if ( !pTC->
isValid() )
00132 { setTestResult(
TEST_FAILURE,
"Wrong validity status");
00133
return;
00134 }
00135
00136
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
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
00155
if ( !pTC->
isValid() )
00156 { setTestResult(
TEST_FAILURE,
"Wrong validity status");
00157
return;
00158 }
00159
00160
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
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
00180
if ( !pTC->
isValid() )
00181 { setTestResult(
TEST_FAILURE,
"Wrong validity status");
00182
return;
00183 }
00184
00185
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
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
00207
if ( pTC->
isValid() || (pTC->
getValidityCheckCode()!=
VC_TOO_MANY_RAW_DATA) )
00208 { setTestResult(
TEST_FAILURE,
"Wrong validity status");
00209
return;
00210 }
00211 }
00212
00213
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
00222
if ( pTC->
isValid() || pTC->
getValidityCheckCode()!=
VC_TOO_MANY_RAW_DATA )
00223 { setTestResult(
TEST_FAILURE,
"Wrong validity status");
00224
return;
00225 }
00226 }
00227
00228
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
00236
if ( pTC->
isValid() || pTC->
getValidityCheckCode()!=
VC_INCONSISTENT_RAW_DATA )
00237 { setTestResult(
TEST_FAILURE,
"Wrong validity status");
00238
return;
00239 }
00240
00241
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
00250
if ( !pTC->
isValid() )
00251 { setTestResult(
TEST_FAILURE,
"Wrong validity status");
00252
return;
00253 }
00254
00255
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 }