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 "../Telemetry/DC_PUSTelemetryModeManager.h"
00015
#include "../Telemetry/DC_PUSDataReportingPacket.h"
00016
#include "../Telemetry/CC_TelemetryPacketFactory.h"
00017
#include "../Utilities/TestCaseWithFactories.h"
00018
#include "TestCasePUSTelemetryModeManager_1.h"
00019
00020
#include <string.h>
00021
00022 TestCasePUSTelemetryModeManager_1::TestCasePUSTelemetryModeManager_1(
void) :
00023
TestCasePUSFull(ID_PUSTELEMETRYMODEMANAGER*10+1,"
TestCasePUSTelemetryModeManager_1") {
00024
return;
00025 }
00026
00027 void TestCasePUSTelemetryModeManager_1::runTestCase(
void) {
00028
00029
00030
CC_TelemetryPacketFactory* pFct =
CC_TelemetryPacketFactory::getInstance();
00031
00032
00033
unsigned short defPacketSize =
PUS_DRP_DEF_BUF_SIZE_SMALL-2;
00034
unsigned int valBufferSize =
PUS_DRP_VAL_BUF_SIZE_SMALL-2;
00035
DC_PUSDataReportingPacket* pTMP_a = pFct->
allocatePUSDataReportingPacket(defPacketSize,valBufferSize,0);
00036
DC_PUSDataReportingPacket* pTMP_b = pFct->
allocatePUSDataReportingPacket(defPacketSize,valBufferSize,0);
00037
00038
00039
TD_SID sid_a = 12;
00040
TD_SID sid_b = 13;
00041
TD_PUSCollectionInterval collectionInterval = 1;
00042
TD_PUSNumberOfParameters NPAR1 = 1;
00043
TD_DataPoolId par1 = 1;
00044
00045
unsigned char* packet =
new unsigned char[defPacketSize];
00046
unsigned int offset = 0;
00047 memcpy(packet+offset,&sid_a,
sizeof(
TD_SID));
00048 offset +=
sizeof(
TD_SID);
00049 memcpy(packet+offset,&collectionInterval,
sizeof(
TD_PUSCollectionInterval));
00050 offset +=
sizeof(
TD_PUSCollectionInterval);
00051 memcpy(packet+offset,&NPAR1,
sizeof(
TD_PUSNumberOfParameters));
00052 offset +=
sizeof(
TD_PUSNumberOfParameters);
00053 memcpy(packet+offset,&par1,
sizeof(
TD_DataPoolId));
00054 offset +=
sizeof(
TD_DataPoolId);
00055
00056
00057 pTMP_a->
setSubType(
PUS_ST_DATA_REP_PAR_HK_REP);
00058
if ( !pTMP_a->
isObjectConfigured() )
00059 { setTestResult(
TEST_FAILURE,
"Wrong configuration status");
00060
return;
00061 }
00062 pTMP_b->
setSubType(
PUS_ST_DATA_REP_PAR_HK_REP);
00063
if ( !pTMP_b->
isObjectConfigured() )
00064 { setTestResult(
TEST_FAILURE,
"Wrong configuration status");
00065
return;
00066 }
00067
00068
00069
for (
unsigned short j=0; j<offset; j++)
00070 pTMP_a->
setDefinitionBuffer(j,packet[j]);
00071
00072
00073 memcpy(packet,&sid_b,
sizeof(
TD_SID));
00074
for (
unsigned short j=0; j<offset; j++)
00075 pTMP_b->
setDefinitionBuffer(j,packet[j]);
00076
00077
00078
DC_PUSTelemetryModeManager* pMM =
getTelemetryModeManager();
00079
00080
00081
if ( pMM->
getClassId() != ID_PUSTELEMETRYMODEMANAGER )
00082 { setTestResult(
TEST_FAILURE,
"Wrong class identifier");
00083
return;
00084 }
00085
00086
00087
if ( pMM->
getMaxNumberOfPackets()!=
TM_MODE_MAN_MAX_N_PACKETS )
00088 { setTestResult(
TEST_FAILURE,
"Wrong max number of TM packets");
00089
return;
00090 }
00091
00092
00093 pMM->
reset();
00094
if ( !pMM->
isObjectConfigured() )
00095 { setTestResult(
TEST_FAILURE,
"Wrong configuration status");
00096
return;
00097 }
00098
00099
00100 pMM->
loadPacket(pTMP_a);
00101 pMM->
loadPacket(pTMP_b);
00102
if ( pMM->
getNumberOfPackets()!=2 )
00103 { setTestResult(
TEST_FAILURE,
"Wrong number of packets");
00104
return;
00105 }
00106
00107
00108
for (
unsigned int j=2; j<
TM_MODE_MAN_MAX_N_PACKETS; j++)
00109 pMM->
loadPacket(pTMP_b);
00110
00111
00112
if ( !pMM->
isFull() )
00113 { setTestResult(
TEST_FAILURE,
"Wrong full status");
00114
return;
00115 }
00116
00117
00118
unsigned int nEvt =
getNumberOfEvents();
00119 pMM->
loadPacket(pTMP_a);
00120
if ( !verifyLatestEvent(nEvt+1,EVT_ILLEGAL_MM) )
00121
return;
00122
00123
00124
for (
unsigned int j=2; j<
TM_MODE_MAN_MAX_N_PACKETS; j++)
00125 pMM->
unloadPacket(sid_b);
00126
00127
00128
DC_PUSDataReportingPacket* pItem;
00129
unsigned int i=0;
00130
bool sid_a_found=
false;
00131
bool sid_b_found=
false;
00132
for (pMM->
first(); !pMM->
isIterationFinished(); pMM->
next()) {
00133 pItem=(
DC_PUSDataReportingPacket*)pMM->
getIterationTelemetryPacket();
00134 i++;
00135
00136
if ( pItem->
getSID()==pTMP_a->
getSID() && !sid_a_found ) {
00137 sid_a_found =
true;
00138
continue;
00139 }
00140
00141
if ( pItem->
getSID()==pTMP_b->
getSID() && !sid_b_found ) {
00142 sid_b_found =
true;
00143
continue;
00144 }
00145
00146 setTestResult(
TEST_FAILURE,
"Wrong iteration number");
00147
return;
00148 }
00149
if (!sid_a_found || !sid_b_found || (i!=2) )
00150 { setTestResult(
TEST_FAILURE,
"Wrong iteration number");
00151
return;
00152 }
00153
00154
00155
if ( !pMM->
isSIDLoaded(pTMP_a->
getSID()) )
00156 { setTestResult(
TEST_FAILURE,
"Wrong presence check result");
00157
return;
00158 }
00159
if ( pMM->
isSIDLoaded(pTMP_a->
getSID()+2) )
00160 { setTestResult(
TEST_FAILURE,
"Wrong presence check result");
00161
return;
00162 }
00163
00164
00165 pMM->
unloadPacket(pTMP_b->
getSID());
00166
if ( pMM->
getNumberOfPackets()!=1 )
00167 { setTestResult(
TEST_FAILURE,
"Wrong number of packets");
00168
return;
00169 }
00170
if ( pMM->
isFull() )
00171 { setTestResult(
TEST_FAILURE,
"Wrong full status");
00172
return;
00173 }
00174
00175
00176 nEvt =
getNumberOfEvents();
00177 pMM->
unloadPacket(sid_b+2);
00178
if ( !verifyLatestEvent(nEvt+1,EVT_SID_NOT_FOUND) )
00179
return;
00180
00181
00182 i = 0;
00183 sid_a_found=
false;
00184
for (pMM->
first(); !pMM->
isIterationFinished(); pMM->
next()) {
00185 pItem=(
DC_PUSDataReportingPacket*)pMM->
getIterationTelemetryPacket();
00186 i++;
00187
00188
if ( pItem->
getSID()==pTMP_a->
getSID() && !sid_a_found ) {
00189 sid_a_found =
true;
00190
continue;
00191 }
00192
00193 setTestResult(
TEST_FAILURE,
"Wrong iteration number");
00194
return;
00195 }
00196
if (!sid_a_found || (i!=1) )
00197 { setTestResult(
TEST_FAILURE,
"Wrong iteration number");
00198
return;
00199 }
00200
00201
00202 pMM->
loadPacket(pTMP_b);
00203 pMM->
unloadPacket(pTMP_a->
getSID());
00204
if ( pMM->
getNumberOfPackets()!=1 )
00205 { setTestResult(
TEST_FAILURE,
"Wrong number of packets");
00206
return;
00207 }
00208
if ( pMM->
isFull() )
00209 { setTestResult(
TEST_FAILURE,
"Wrong full status");
00210
return;
00211 }
00212
00213
00214 i = 0;
00215 sid_b_found=
false;
00216
for (pMM->
first(); !pMM->
isIterationFinished(); pMM->
next()) {
00217 pItem=(
DC_PUSDataReportingPacket*)pMM->
getIterationTelemetryPacket();
00218 i++;
00219
00220
if ( pItem->
getSID()==pTMP_b->
getSID() && !sid_b_found ) {
00221 sid_b_found =
true;
00222
continue;
00223 }
00224
00225 setTestResult(
TEST_FAILURE,
"Wrong iteration number");
00226
return;
00227 }
00228
if (!sid_b_found || (i!=1) )
00229 { setTestResult(
TEST_FAILURE,
"Wrong iteration number");
00230
return;
00231 }
00232
00233
00234 pMM->
unloadPacket(pTMP_b->
getSID());
00235
if ( pMM->
getNumberOfPackets()!=0 )
00236 { setTestResult(
TEST_FAILURE,
"Wrong number of packets");
00237
return;
00238 }
00239
if ( pMM->
isFull() )
00240 { setTestResult(
TEST_FAILURE,
"Wrong full status");
00241
return;
00242 }
00243
00244
00245
bool flag =
false;
00246
for (pMM->
first(); !pMM->
isIterationFinished(); pMM->
next()) {
00247 flag =
true;
00248 }
00249
if (flag)
00250 { setTestResult(
TEST_FAILURE,
"Wrong iteration number");
00251
return;
00252 }
00253
00254 setTestResult(
TEST_SUCCESS,
"Test Successful");
00255
return;
00256 }