testcase TestNM_TG3_TC7_2_Check_RSS2PBM2RMSConversion_Test()
{
message NM_ZONE_FTM nmMessage;
double currentTime;
float elapsedTime;
float totalElapsedTime;
float TInitTime;
float TMessageStartTime;
float TNMImmediateCycleTime;
float TNetWorkWakeupTime;
int index = 0;
dword rxMessageNum;
byte fisrtNMMessageFlag;
byte NetworkStateChangeFail;
byte NetworkStateChangeReasult;
TestwaitforTimeout(10000);
TestNM_WaitDutSleep();
TestNM_ValueInit();
testStep("TestNM_TG3_TC7_2_Check_RSS2PBM2RMSConversion_Test","Test DUT the state switch of BSM-RMS-RSS-PBM-RMS");
TESTCAN_StartTrace("TestNM_TG3_TC7_2_Check_RSS2PBM2RMSConversion_Test.asc");
output(nmMessage);
testResult = testWaitForMessage(NM_FI_RR, 100);
if(TRUE == testResult)
{
rxMessageNum = onRxMessageIndex[NM_FI_RR_RX_MESSAGE] + onRxMessageIndex[FI_R_01_RX_MESSAGE] + onRxMessageIndex[DIAG_RESP_FI_R_R_RX_MESSAGE];
if(TRUE == rxMessageNum)
{
fisrtNMMessageFlag = TRUE;
}
else
{
fisrtNMMessageFlag = FALSE;
}
index++;
TInitTime = TestGetLastWaitElapsedTimeNS();
TInitTime = TInitTime / 1000000;
testResult = testWaitForMessage(FI_R_01, 100);
if(TRUE == testResult)
{
TMessageStartTime = TestGetLastWaitElapsedTimeNS();
TMessageStartTime = TMessageStartTime / 1000000;
}
}
for(;index < 10;)
{
testResult = testWaitForMessage(NM_FI_RR, 680);
if(TRUE == testResult)
{
index++;
elapsedTime = TestGetLastWaitElapsedTimeNS();
elapsedTime = elapsedTime / 1000000;
totalElapsedTime = totalElapsedTime + elapsedTime;
TNMImmediateCycleTime = totalElapsedTime / ((index - 1) * 1.0);
}
else
{
break;
}
}
table = TR_TableHead5Columns();
UTIL_Num2String(1, testStepStr);
strncpy(testContentStr, "when DUT in BSM send a NM message", 1024);
strncpy(testExpectStr, "N_ImmediateNM_TIMES=0-9(Default: 5)", 1024);
UTIL_Num2String(index, testResultStr);
if(5 == index)
{
TR_TableRow5Columns(table, testStepStr, testContentStr, testExpectStr, testResultStr, "pass");
TableTestStep(table, 0);
}
else
{
TR_TableRow5Columns(table, testStepStr, testContentStr, testExpectStr, testResultStr, "fail");
TableTestStep(table, 1);
}
table = TR_TableHead5Columns();
UTIL_Num2String(2, testStepStr);
strncpy(testContentStr, "when DUT in BSM send a NM message", 1024);
strncpy(testExpectStr, "T_NM_ImmediateCycleTime = 640±10%", 1024);
UTIL_Float2String(TNMImmediateCycleTime, testResultStr);
if((576 <= TNMImmediateCycleTime) && (TNMImmediateCycleTime <= 704))
{
TR_TableRow5Columns(table, testStepStr, testContentStr, testExpectStr, testResultStr, "pass");
TableTestStep(table, 0);
}
else
{
TR_TableRow5Columns(table, testStepStr, testContentStr, testExpectStr, testResultStr, "fail");
TableTestStep(table, 1);
}
table = TR_TableHead5Columns();
UTIL_Num2String(3, testStepStr);
strncpy(testContentStr, "when DUT in BSM send a NM message", 1024);
strncpy(testExpectStr, "The first message DUT send out is NM message", 1024);
UTIL_Num2String(fisrtNMMessageFlag, testResultStr);
if(TRUE == fisrtNMMessageFlag)
{
TR_TableRow5Columns(table, testStepStr, testContentStr, testExpectStr, testResultStr, "pass");
TableTestStep(table, 0);
}
else
{
TR_TableRow5Columns(table, testStepStr, testContentStr, testExpectStr, testResultStr, "fail");
TableTestStep(table, 1);
}
table = TR_TableHead5Columns();
UTIL_Num2String(4, testStepStr);
strncpy(testContentStr, "when DUT in BSM send a NM message", 1024);
strncpy(testExpectStr, "T_init ≤ 100 ms", 1024);
UTIL_Float2String(TInitTime, testResultStr);
if(TInitTime <= 100)
{
TR_TableRow5Columns(table, testStepStr, testContentStr, testExpectStr, testResultStr, "pass");
TableTestStep(table, 0);
}
else
{
TR_TableRow5Columns(table, testStepStr, testContentStr, testExpectStr, testResultStr, "fail");
TableTestStep(table, 1);
}
table = TR_TableHead5Columns();
UTIL_Num2String(5, testStepStr);
strncpy(testContentStr, "when DUT in BSM send a NM message", 1024);
strncpy(testExpectStr, "T_MessageStart test ≤ 100ms", 1024);
UTIL_Float2String(TMessageStartTime, testResultStr);
if(TMessageStartTime <= 100)
{
TR_TableRow5Columns(table, testStepStr, testContentStr, testExpectStr, testResultStr, "pass");
TableTestStep(table, 0);
}
else
{
TR_TableRow5Columns(table, testStepStr, testContentStr, testExpectStr, testResultStr, "fail");
TableTestStep(table, 1);
}
table = TR_TableHead5Columns();
UTIL_Num2String(6, testStepStr);
strncpy(testContentStr, "when DUT in BSM send a NM message", 1024);
strncpy(testExpectStr, "T_NetworkWakeup test ≤ 300ms", 1024);
TNetWorkWakeupTime = TInitTime + TMessageStartTime;
UTIL_Float2String(TNetWorkWakeupTime, testResultStr);
if(TNetWorkWakeupTime <= 300)
{
TR_TableRow5Columns(table, testStepStr, testContentStr, testExpectStr, testResultStr, "pass");
TableTestStep(table, 0);
}
else
{
TR_TableRow5Columns(table, testStepStr, testContentStr, testExpectStr, testResultStr, "fail");
TableTestStep(table, 1);
}
table = TR_TableHead5Columns();
UTIL_Num2String(7, testStepStr);
strncpy(testContentStr, "when DUT in BSM send a NM message", 1024);
strncpy(testExpectStr, "Repeat Message Timer = 2560 ± 1% ms", 1024);
totalElapsedTime = totalElapsedTime + TMessageStartTime;
UTIL_Float2String(totalElapsedTime, testResultStr);
if((2534 <= totalElapsedTime) && (totalElapsedTime <= 2586))
{
TR_TableRow5Columns(table, testStepStr, testContentStr, testExpectStr, testResultStr, "pass");
TableTestStep(table, 0);
}
else
{
TR_TableRow5Columns(table, testStepStr, testContentStr, testExpectStr, testResultStr, "fail");
TableTestStep(table, 1);
}
TestwaitforTimeout(10000);
index = 0;
currentTime = 0;
elapsedTime = 0;
TestNM_ValueInit();
TestNM_WaitDutSleep();
/*初始化请求网络*/
TestNetworkRequest();
table = TR_TableHead5Columns();
UTIL_Num2String(8, testStepStr);
strncpy(testContentStr, "wake up DUT by NM message", 1024);
strncpy(testExpectStr, "Time_NormalNM_Cycle =640±1% ms", 1024);
TestNM_StartWakeUpNM();
TESTCAN_StartTxCycleMessage(ZONE_288_TX_MESSAGE);
TESTCAN_StartTxCycleMessage(ZONE_13C_TX_MESSAGE);
TestwaitforTimeout(5000);
testResult = testWaitForMessage(NM_FI_RR, 680);
if(TRUE == testResult)
{
for(index = 0; index < 10;)
{
testResult = testWaitForMessage(NM_FI_RR, 680);
if(TRUE == testResult)
{
index++;
currentTime = TestGetLastWaitElapsedTimeNS();
currentTime = currentTime / 1000000;
elapsedTime = elapsedTime + currentTime;
if(10 == index)
{
elapsedTime = elapsedTime / 10.0;
UTIL_Float2String(elapsedTime, testResultStr);
if((633 <= elapsedTime) && (elapsedTime <= 647))
{
TR_TableRow5Columns(table, testStepStr, testContentStr, testExpectStr, testResultStr, "pass");
TableTestStep(table, 0);
}
else
{
TR_TableRow5Columns(table, testStepStr, testContentStr, testExpectStr, testResultStr, "fail");
TableTestStep(table, 1);
}
break;
}
}
else
{
UTIL_Num2String(testResult, testResultStr);
TR_TableRow5Columns(table, testStepStr, testContentStr, testExpectStr, testResultStr, "fail");
TableTestStep(table, 1);
break;
}
}
}
else
{
UTIL_Num2String(testResult, testResultStr);
TR_TableRow5Columns(table, testStepStr, testContentStr, testExpectStr, testResultStr, "fail");
TableTestStep(table, 1);
}
TestNM_StopWakeUpNM();
TESTCAN_StopTxCycleMessage(ZONE_288_TX_MESSAGE);
TESTCAN_StopTxCycleMessage(ZONE_13C_TX_MESSAGE);
TestwaitforTimeout(10000);
/*测试从BusSleep→Repeat Message→Ready Sleep→Prepare Bus Sleep→Bus Sleep*/
output(nmMessage);
TestwaitforTimeout(3000);/*测试将暂停3000ms,确保已进入Ready Sleep*/
testResult = testWaitForMessage(NM_FI_RR, 672);/*设置网络报文等待超时时间*/
if(TRUE == testResult)/*1-收到网络报文,0-超时未收到网络报文*/
{
NetworkStateChangeFail = TRUE;/*进入Ready Sleep仍收到网络报文则跳转失败*/
}
testResult = testWaitForMessage(FI_R_01, 110);/*设置应用报文等待超时时间*/
if(FALSE == testResult)/*1-收到应用报文,0-超时未收到应用报文*/
{
NetworkStateChangeFail = TRUE;/*进入Ready Sleep仍收到网络报文则跳转失败*/
}
TestwaitforTimeout(1000);/*测试将暂停1s,确保已进入Prepare Bus Sleep*/
/*Prepare Bus Sleep→Repeat Message*/
output(nmMessage);
testResult = testWaitForMessage(NM_FI_RR, 100);/*设置网络报文等待超时时间*/
table = TR_TableHead5Columns();/*创建测试信息表*/
UTIL_Num2String(9, testStepStr);
strncpy(testContentStr, "DUT BSM-RMS-RSS-PBM-RMS Network State", 1024);
strncpy(testExpectStr, "The Network Status change is normal", 1024);
UTIL_Num2String(testResult, testResultStr);
if(TRUE == testResult)/*超时时间收到应用报文*/
{
testResult = testWaitForMessage(FI_R_01, 110);/*设置应用报文等待超时时间*/
if(TRUE == testResult)/*超时时间收到应用报文*/
{
if(FALSE == NetworkStateChangeFail)/*网络跳转全过程未失败*/
{
TR_TableRow5Columns(table, testStepStr, testContentStr, testExpectStr, testResultStr, "pass");
TableTestStep(table, 0);
}
else
{
TR_TableRow5Columns(table, testStepStr, testContentStr, testExpectStr, testResultStr, "fail");
TableTestStep(table, 1);
}
}
else
{
TR_TableRow5Columns(table, testStepStr, testContentStr, testExpectStr, testResultStr, "fail");
TableTestStep(table, 1);
}
}
else
{
TR_TableRow5Columns(table, testStepStr, testContentStr, testExpectStr, testResultStr, "fail");
TableTestStep(table, 1);
}
TESTCAN_StopTrace();
}逐行解析这个函数
最新发布