00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
#include "../GeneralInclude/CompilerSwitches.h"
00011
#include "../GeneralInclude/ClassId.h"
00012
#include "../GeneralInclude/TestConstants.h"
00013
#include "../Base/CC_RootObject.h"
00014
#include "../Event/DC_EventRepository.h"
00015
#include "../Telecommand/DC_DummyTelecommandLoader.h"
00016
#include "../Telecommand/CC_TelecommandManager.h"
00017
#include "../System/DC_DummyObsClock.h"
00018
#include "../Telecommand/TelecommandLoader.h"
00019
#include "../Telecommand/DC_DummyTelecommand.h"
00020
#include "TestCaseTelecommandManager_2.h"
00021
00022 TestCaseTelecommandManager_2::TestCaseTelecommandManager_2(
void) :
00023
TestCaseGenericSetUp(ID_TELECOMMANDMANAGER*10+2,"
TestCaseTelecommandManager_2") {
00024
return;
00025 }
00026
00027 void TestCaseTelecommandManager_2::runTestCase(
void) {
00028
00029
00030
CC_TelecommandManager* pTcm =
new CC_TelecommandManager();
00031
00032
00033
TD_ObsTime tcTt1 = 3;
00034
TD_ObsTime tcTt2 = 5;
00035
TD_ObsTime tcTt3 = 0;
00036
TD_TelecommandId tcId1 = 1;
00037
TD_TelecommandId tcId2 = 2;
00038
TD_TelecommandId tcId3 = 3;
00039
00040
00041
DC_DummyObsClock* pClk =
new DC_DummyObsClock();
00042 pClk->
setTime(tcTt1-1);
00043 pClk->
setCycle(0);
00044 pTcm->
setObsClock(pClk);
00045
00046
00047
DC_DummyTelecommand* pTc1 =
new DC_DummyTelecommand();
00048 DC_DummyTelecommand* pTc2 =
new DC_DummyTelecommand();
00049 DC_DummyTelecommand* pTc3 =
new DC_DummyTelecommand();
00050 pTc1->
setTelecommandId(tcId1);
00051 pTc2->
setTelecommandId(tcId2);
00052 pTc3->
setTelecommandId(tcId3);
00053 pTc1->
setTimeTag(tcTt1);
00054 pTc2->
setTimeTag(tcTt2);
00055 pTc3->
setTimeTag(tcTt3);
00056
00057
00058
DC_DummyTelecommandLoader* pTcl =
new DC_DummyTelecommandLoader();
00059 pTcl->
setSampleTelecommand(0,pTc1);
00060 pTcl->
setSampleTelecommand(1,pTc2);
00061 pTcl->
setSampleTelecommand(2,pTc3);
00062 pTcm->
setTelecommandLoader(pTcl);
00063 pTcl->
setTelecommandManager(pTcm);
00064
00065
00066 pTcm->
setPendingTelecommandListSize(10);
00067
00068
00069
if ( !pTcm->
isObjectConfigured() )
00070 { setTestResult(
TEST_FAILURE,
"Wrong configuration status");
00071
return;
00072 }
00073
00074
00075
00076 pTcl->
activate();
00077 pTcl->
activate();
00078 pTcl->
activate();
00079
if ( pTcm->
getPendingTelecommands() != 3 )
00080 { setTestResult(
TEST_FAILURE,
"Wrong number of pending telecommands");
00081
return;
00082 }
00083
00084
00085
if ( pTcl->
getAllocationCounter() != 3 )
00086 { setTestResult(
TEST_FAILURE,
"Wrong allocation counter value");
00087
return;
00088 }
00089
00090
00091
00092 pTcm->
activate();
00093
if (pTc3->
getExecutionCounter() != 1)
00094 { setTestResult(
TEST_FAILURE,
"Third telecommand was not executed");
00095
return;
00096 }
00097
00098
00099
if ( pTcm->
getPendingTelecommands() != 2 )
00100 { setTestResult(
TEST_FAILURE,
"Wrong number of pending telecommands");
00101
return;
00102 }
00103
00104
00105
DC_EventRepository* pRep =
CC_RootObject::getEventRepository();
00106 pRep->
latest();
00107
if ( (pRep->
getEventType() != EVT_TC_EXEC_SUCC) )
00108 { setTestResult(
TEST_FAILURE,
"Wrong unload event");
00109
return;
00110 }
00111
00112
00113
00114 pTcm->
activate();
00115 pTcm->
activate();
00116 pClk->
setTime(tcTt1+1);
00117 pClk->
setCycle(0);
00118 pTcm->
activate();
00119
if (pTc1->
getExecutionCounter() != 1)
00120 { setTestResult(
TEST_FAILURE,
"First telecommand was not executed");
00121
return;
00122 }
00123
00124
00125
if ( pTcm->
getPendingTelecommands() != 1 )
00126 { setTestResult(
TEST_FAILURE,
"Wrong number of pending telecommands");
00127
return;
00128 }
00129
00130
00131
00132 pTcm->
activate();
00133 pTcm->
activate();
00134 pClk->
setTime(tcTt2+1);
00135 pClk->
setCycle(0);
00136 pTcm->
activate();
00137
if (pTc2->
getExecutionCounter() != 1)
00138 { setTestResult(
TEST_FAILURE,
"Second telecommand was not executed");
00139
return;
00140 }
00141
00142
00143
if ( pTcm->
getPendingTelecommands() != 0 )
00144 { setTestResult(
TEST_FAILURE,
"Wrong number of pending telecommands");
00145
return;
00146 }
00147
00148
00149
if ( pTcl->
getAllocationCounter() != 0 )
00150 { setTestResult(
TEST_FAILURE,
"Wrong allocation counter value");
00151
return;
00152 }
00153
00154 setTestResult(
TEST_SUCCESS,
"Test Successful");
00155
return;
00156
00157 }