📄 cli.c
字号:
/* Only start calls on precise boundary */
while (TBX_TRUE)
{
TBX_INT32 n32ElapsedMs;
/* Make sure we are not processing in the futur */
n32ElapsedMs = (TBX_INT32)(un32Timer - un32LastTimeWhereACallWasMade);
n32ElapsedMs *= TBX_MSEC_PER_TICKS;
if (n32ElapsedMs < 0)
{
un32LastTimeWhereACallWasMade = un32Timer;
break;
}
/* Do we need to make a call ? */
un32ElapsedMs = un32Timer - un32LastTimeWhereACallWasMade;
un32ElapsedMs *= TBX_MSEC_PER_TICKS;
if (un32ElapsedMs < un32StressDelayBetweenCalls)
{
break;
}
/* We cannot make more than x calls per seconds even if we are "behind" our schedule */
if (un32StressDelayBetweenCalls < 1000)
{
un32ElapsedMs = un32Timer - un32LastTimeWhereACallWasMade;
un32ElapsedMs *= TBX_MSEC_PER_TICKS;
if( un32ElapsedMs >= (1000 / TB640_ISDN_CLI_MIN_TIME_BETWEEN_STRESS_CALLS) )
{
un32LastTimeWhereACallWasMade = un32Timer - (1000 / TB640_ISDN_CLI_MIN_TIME_BETWEEN_STRESS_CALLS);
}
}
if( (n32SStressNbCallToPerform != -1) && (n32SStressNbCallToPerform <= 0) )
{
TBX_UINT32 un32NbTotalOpening = 0;
TBX_SEM_GET (g_StressStatsSem, TBX_SEM_WAIT_FOREVER);
un32NbTotalOpening = g_StressStats.un32NbCallOpeningSuccess + g_StressStats.un32NbCallOpeningFailure + g_StressStats.un32NbCallOpeningOutOfRes;
TBX_SEM_GIV (g_StressStatsSem);
/*if( g_StressStats.un32NbCallClosingTotal >= un32NbTotalOpening )*/
if( TB640IsdnOpLibraryEmpty() )
{
TBX_SEM_GET (g_StressStatsSem, TBX_SEM_WAIT_FOREVER);
g_StressStats.fStatsActivated = TBX_FALSE;
TBX_SEM_GIV (g_StressStatsSem);
fAutomaticCallGenerationActivated = TBX_FALSE;
TB640_ISDN_LOG (TRACE_LEVEL_4, "Stopped stress testing\n");
TB640_ISDN_LOG (TRACE_LEVEL_4, " Instantaneous calls per sec. : %08d Instantaneous BHCC : %08d\n",
un32NbCallPerSeconds, un32NbBHCA);
TB640_ISDN_LOG (TRACE_LEVEL_4," Call opening successful : %08d Call completed : %08d\n",
StatsCopy.un32NbCallOpeningSuccess, StatsCopy.un32NbCallCompleted);
TB640_ISDN_LOG (TRACE_LEVEL_4," Call opening with out-of-res. : %08d Call closing total : %08d\n",
StatsCopy.un32NbCallOpeningOutOfRes, StatsCopy.un32NbCallClosingTotal);
TB640_ISDN_LOG (TRACE_LEVEL_4," Nb incoming call collision : %08d Nb outgoing call collision : %08d\n",
StatsCopy.un32NbIncomingCallCollision, StatsCopy.un32NbOutgoingCallCollision);
TB640_ISDN_LOG (TRACE_LEVEL_4, " Call opening failure : %08d Nb timeout events : %08d\n",
StatsCopy.un32NbCallOpeningFailure, StatsCopy.un32NbTimeoutOccured);
TB640_ISDN_LOG (TRACE_LEVEL_4, " Restart sent : %08d Reset sent : %08d\n",
StatsCopy.un32NbRestartAttempt, StatsCopy.un32NbResetAttempt);
TB640_ISDN_LOG (TRACE_LEVEL_4," No free tmslot for stress tst : %08d Nb elapsed sec. since start : %08d\n",
StatsCopy.un32NbCallNoFreeTimeslotToOpen, ((StatsCopy.un32CurrentTimestamp - StatsCopy.un32StartTimestamp) / 1000));
g_fRefreshDisplay |= (TB640_ISDN_CLI_REFRESH_DISPLAY | TB640_ISDN_CLI_CLEAR_BEFORE_REFRESH);
break;
}
}
else
{
/* Select timeslot to use for call generation */
Result = TB640IsdnSelectCallForAutomaticCall(un32StressOutgoingTimeslotMinIdleMsec, &un32Adapter, &un32Trunk, &un32Timeslot);
if (TBX_RESULT_SUCCESS(Result))
{
if( n32SStressNbCallToPerform != -1) n32SStressNbCallToPerform--;
TB640IsdnMakeCall (un32Adapter, un32Trunk, un32Timeslot, un32StressMinCallDuration, un32StressMaxCallDuration, TBX_FALSE,0);
}
else
{
TB640_ISDN_INCREMENT_STATS (un32NbCallNoFreeTimeslotToOpen, 1);
g_fRefreshDisplay |= TB640_ISDN_CLI_REFRESH_DISPLAY;
}
}
/* Wait until next time delay is expired before making another call */
un32LastTimeWhereACallWasMade += un32StressDelayBetweenCalls;
}
/* Only restart timeslot on precise boundary */
if (un32StressDelayBetweenRestart > 0)
{
while (TBX_TRUE)
{
TBX_INT32 n32ElapsedMs;
/* Make sure we are not processing in the futur */
n32ElapsedMs = (TBX_INT32)(un32Timer - un32LastTimeWhereARestartWasMade);
n32ElapsedMs *= TBX_MSEC_PER_TICKS;
if (n32ElapsedMs < 0)
{
un32LastTimeWhereARestartWasMade = un32Timer;
break;
}
/* Do we need to do a restart ? */
un32ElapsedMs = un32Timer - un32LastTimeWhereARestartWasMade;
un32ElapsedMs *= TBX_MSEC_PER_TICKS;
if( un32ElapsedMs < un32StressDelayBetweenRestart)
{
break;
}
/* Send the restart */
Result = TB640IsdnSelectCallForAutomaticRestart(&un32Adapter, &un32Trunk, &un32Timeslot);
if (TBX_RESULT_SUCCESS(Result))
{
TB640IsdnRestartTimeslot (un32Adapter, un32Trunk, un32Timeslot);
}
/* Wait until next time delay is expired before restarting another timeslot */
un32LastTimeWhereARestartWasMade += un32StressDelayBetweenRestart;
}
}
}
}
/* Print all error/status on the standard output from now on */
g_fPrintInErrorBuffer = TBX_FALSE;
/* End of the code (skip to cleanup) */
TBX_EXIT_SUCCESS (TBX_RESULT_OK);
}
/*---------------------------------------------------------------------------------------------------------------------------
| Error handling section
*--------------------------------------------------------------------------------------------------------------------------*/
ERROR_HANDLING
{
/* Print error message */
TB640_ISDN_LOG (TRACE_LEVEL_ALWAYS, "%s (Result = 0x%08X, %s, line %d)\n", TBX_ERROR_DESCRIPTION, TBX_ERROR_RESULT, __FILE__, TBX_ERROR_LINE);
}
/*---------------------------------------------------------------------------------------------------------------------------
| Cleanup section
*--------------------------------------------------------------------------------------------------------------------------*/
CLEANUP
{
TBXCliCls ();
TB640_ISDN_DISPLAY_PRINT ("Exiting from the application\n\n");
}
RETURN;
}
/*--------------------------------------------------------------------------------------------------------------------------------
| Utility functions
*------------------------------------------------------------------------------------------------------------------------------*/
/*-------------------------------------------------------------------------------------------------------------------------------
|
| TB640IsdnCliPageDown: This function adjust display pointers for a PageDown
|
| Note : ~
|
| Return : ~
|
*------------------------------------------------------------------------------------------------------------------------------*/
TBX_VOID
TB640IsdnCliPageDown ( TBX_VOID )
{
TBX_UINT32 un32Tmp;
/*---------------------------------------------------------------------------------------------------------------------------
| Code section
*--------------------------------------------------------------------------------------------------------------------------*/
CODE
{
TBX_SEM_GET (g_AppContext->DisplaySem, TBX_SEM_WAIT_FOREVER);
/* Make sure there is something in the buffer */
if (g_un32ErrorLineReadIndex != g_un32ErrorLineWriteIndex)
{
un32Tmp = g_un32ErrorLineReadIndex + 25;
if (un32Tmp >= TB640_ISDN_CLI_MAX_NB_ERROR_LINES)
{
/* Wrap around case */
un32Tmp = 0 + (un32Tmp - TB640_ISDN_CLI_MAX_NB_ERROR_LINES);
if (g_un32ErrorLineReadIndex > g_un32ErrorLineWriteIndex)
{
if (un32Tmp < g_un32ErrorLineWriteIndex)
{
/* No overflow */
g_un32ErrorLineReadIndex = un32Tmp;
}
else
{
/* Overflow */
g_un32ErrorLineReadIndex = (g_un32ErrorLineWriteIndex - 1);
}
}
else
{
/* Overflow */
g_un32ErrorLineReadIndex = (g_un32ErrorLineWriteIndex - 1);
}
}
else
{
/* No wrap-around case */
if (g_un32ErrorLineReadIndex < g_un32ErrorLineWriteIndex)
{
if (un32Tmp < g_un32ErrorLineWriteIndex)
{
/* No overflow */
g_un32ErrorLineReadIndex = un32Tmp;
}
else
{
/* Overflow */
g_un32ErrorLineReadIndex = (g_un32ErrorLineWriteIndex - 1);
}
}
else
{
/* No overflow possible - the write pointer is behind us */
g_un32ErrorLineReadIndex = un32Tmp;
}
}
}
TBX_SEM_GIV (g_AppContext->DisplaySem);
/* End of the code (skip to cleanup) */
TBX_EXIT_SUCCESS (TBX_RESULT_OK);
}
/*---------------------------------------------------------------------------------------------------------------------------
| Error handling section
*--------------------------------------------------------------------------------------------------------------------------*/
ERROR_HANDLING
{
}
/*---------------------------------------------------------------------------------------------------------------------------
| Cleanup section
*--------------------------------------------------------------------------------------------------------------------------*/
CLEANUP
{
}
RETURN_VOID;
}
/*-------------------------------------------------------------------------------------------------------------------------------
|
| TB640IsdnCliPageUp: This function adjust display pointers for a PageUp
|
| Note : ~
|
| Return : ~
|
*------------------------------------------------------------------------------------------------------------------------------*/
TBX_VOID
TB640IsdnCliPageUp ( TBX_VOID )
{
TBX_UINT32 un32Tmp;
/*---------------------------------------------------------------------------------------------------------------------------
| Code section
*--------------------------------------------------------------------------------------------------------------------------*/
CODE
{
TBX_SEM_GET (g_AppContext->DisplaySem, TBX_SEM_WAIT_FOREVER);
/* Make sure there is something in the buffer */
if (g_un32ErrorLineReadIndex != g_un32ErrorLineWriteIndex)
{
if (g_un32ErrorLineReadIndex < 25)
{
/* Wrap around case */
un32Tmp = (TB640_ISDN_CLI_MAX_NB_ERROR_LINES - g_un32ErrorLineReadIndex);
if (g_un32ErrorLineReadIndex < g_un32ErrorLineWriteIndex)
{
if (un32Tmp > g_un32ErrorLineWriteIndex)
{
/* No underflow */
g_un32ErrorLineReadIndex = un32Tmp;
}
else
{
/* underflow */
g_un32ErrorLineReadIndex = (g_un32ErrorLineWriteIndex + 1);
if (g_un32ErrorLineReadIndex >= TB640_ISDN_CLI_MAX_NB_ERROR_LINES)
{
g_un32ErrorLineReadIndex = 0;
}
}
}
else
{
/* underflow */
g_un32ErrorLineReadIndex = (g_un32ErrorLineWriteIndex + 1);
}
}
else
{
/* No wrap-around case */
un32Tmp = g_un32ErrorLineReadIndex - 25;
if (g_un32ErrorLineReadIndex > g_un32ErrorLineWriteIndex)
{
if (un32Tmp > g_un32ErrorLineWriteIndex)
{
/* No underflow */
g_un32ErrorLineReadIndex = un32Tmp;
}
else
{
/* underflow */
g_un32ErrorLineReadIndex = (g_un32ErrorLineWriteIndex + 1);
}
}
else
{
/* No underflow possible - the write pointer is in front of us */
g_un32ErrorLineReadIndex = un32Tmp;
}
}
}
TBX_SEM_GIV (g_AppContext->DisplaySem);
/* End of the code (skip to cleanup) */
TBX_EXIT_SUCCESS (TBX_RESULT_OK);
}
/*---------------------------------------------------------------------------------------------------------------------------
| Error handling section
*--------------------------------------------------------------------------------------------------------------------------*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -