📄 ictamain.c
字号:
/************************************************************************//* SISCO SOFTWARE MODULE HEADER *****************************************//************************************************************************//* (c) Copyright Systems Integration Specialists Company, Inc., *//* 1996-2002, All Rights Reserved *//* *//* MODULE NAME : ICTAMAIN.C *//* *//* MODULE DESCRIPTION : *//* handle menus in ICCP test application *//* *//* GLOBAL FUNCTIONS DEFINED IN THIS MODULE : *//* *//* MODIFICATION LOG : */ /* Date Who Rev Comments *//* -------- --- ------ ------------------------------------------- *//* 08/22/02 nav 35 Modify sig handlers - no mutex calls *//* 08/05/02 nav 34 Changes to test 8 remote ar names *//* 02/07/02 EJV 33 _AIX: Added threads support. *//* Moved include icthread.h to ictamain.h *//* 02/05/02 EJV 32 Changed copyright year to 2002 *//* 09/24/01 EJV 31 Changed SISCO phone to (586) 254-0020. *//* 06/27/01 EJV 30 Removed noecho, now set to off in term_init()*//* 05/18/01 NAV 29 Add Block8 Test *//* 05/17/01 EJV 28 UNIX: Revised code (ukey.c changed, term_init*//* 03/27/01 EJV 27 Changed year to 2001 in showHeading *//* 08/24/00 nav 26 Check for LinkDefined before icStartLink *//* 05/31/00 nav 25 Check for error on calls to unDef & reDef *//* a remote *//* 05/22/00 nav 24 Add option to getDataSetNames *//* 05/16/00 EJV 23 Digital UNIX: Added logging of mutex and *//* condVal structs after initialization. *//* Added code to wait if pthread_cond_timedwait *//* does not return status=ETIMEDOUT. *//* 05/08/00 nav 22 Fix problems with comp test *//* 05/05/00 nav 21 Get rid of press a key in comp test *//* 02/23/00 nav 20 Changes for WIN32 multithreaded tests *//* 02/04/00 nav 19 Add Identity *//* 06/29/99 nav 18 Add Quality Test stuff *//* 06/10/99 nav 17 Prep for PLC Acceptance test *//* 06/03/99 nav 16 Add bIncrementVars global *//* 01/05/99 EJV 15 Changed year to 1999. *//* 08/13/98 nav 14 Watch for APIStarted in the sig funs *//* 07/23/98 nav 13 Add example of icUnDefineRemote *//* 05/19/98 nav 12 Add POSIX 1003.1 thread support *//* 05/15/98 nav 11 Add example of icReDefineRemote *//* 04/09/98 nav 10 Add new block4 and block 8 function menus *//* 03/24/98 NAV 9 Add ctrlTranGroup *//* 01/16/98 EJV 8 Changed arg to fun sigfun,sigbus for SYS_5. *//* More type conv VOID->ST_VOID, TRUE->ST_TRUE. *//* Added typecast in list functions. *//* 12/11/97 nav 7 Add icDefineDomainNames when defining remote *//* 06/20/97 nav 6 Overhaul - One process can be client& server *//* 06/05/97 nav 5 Convert to MMS-EASE V7.00 *//* 04/04/97 nav 4 change starttime for tran group *//* 02/25/97 nav 3 additions for comprehensive test *//* 02/11/97 NAV 2 separate types and variables menu *//* 02/10/97 NAV 1 finish defCfgAll, defCfgServer, defCfgClient *//* 12/19/96 NAV creation *//************************************************************************/#include "ictamain.h"#include "scrndefs.h"#include "gvaldefs.h"#include "fkeydefs.h"#include "suicacse.h"#if defined(_AIX) || defined(__alpha)#if defined(__alpha)#include <sys/time.h>#endif#include <sys/select.h>#include <errno.h>#endif#if (SYSTEM_SEL & (SYS_5))#include <signal.h>void sigfun(int sig);void sigbus(int sig);#endif#if defined (_WIN32)#include <windows.h>extern HANDLE kbdEvent; #endif#if defined (_WIN32)void ShutDown( int p1 );#endifstatic char *thisFileName = __FILE__;/************************************************************************//* Global and Local variables *//************************************************************************/#define MAIN_MENU 0#define ASSOC_MENU 1#define TYPE_MENU 2#define VAR_MENU 3#define TRAN_MENU 4#define INFO_MENU 5#define DEVICE_MENU 6#define ACCT_MENU 7#define CONFIG_MENU 8#define UTIL_MENU 9#define B4B8_MENU 10int theCurrentMenu = MAIN_MENU;ICTA_VCC *pstVCC;int currChannelNum = 0;ST_DOUBLE beginTime, endTime; /* for elapsed time */icBoolean bMultiThreads = icFalse;icBoolean bCompTestInProgress = icFalse;icBoolean bCompTestThreaded = icFalse;icBoolean bStopCompTest = icFalse;icBoolean bCompTestVerbose = icFalse;icBoolean bAutoResponse = icFalse;icBoolean bIncrementVars = icFalse;icBoolean bUseNewB4B8 = icFalse;icBoolean bUseNewDefLink = icFalse;icBoolean bUseNewStartRem = icFalse;ST_INT compSleepTime;time_t compStartTime, compStopTime;icBoolean bAPIStarted = icFalse;#ifdef SISCO_THREADS#ifndef _WIN32/* to maintain the threads */pthread_t threadIDs[100];pthread_mutex_t mutex;pthread_cond_t condVar;int nLastThread = 0;#if defined (_POSIX_C_SOURCE) && (_POSIX_C_SOURCE >= 199506L)void *doRemoteThread (void *argP);#elsevoid doRemoteThread (pthread_addr_t argP);#endif#elseint nLastThread = 0;LPDWORD threadIDs[100];HANDLE threadHandles[100];DWORD WINAPI doRemoteThread (LPVOID argP);#endif#endifstatic icTimerId keyCheckTimer;extern ST_VOID (*funct_menu) (ST_VOID);static ST_VOID (*callingMenu) (ST_VOID);static ST_BOOLEAN bShutItDown = SD_FALSE; /* sig handlers will set this true *//************************************************************************//* Static Function Declarations *//************************************************************************/ST_VOID setMainMenu (ST_VOID);ST_VOID showHeading (ST_VOID);ST_VOID testNoFun (ST_VOID);#ifdef SISCO_TESTST_VOID setMoreMenu (ST_VOID);#endifstatic ST_VOID assocMgtMenu (ST_VOID);static ST_VOID typeMenu (ST_VOID);static ST_VOID varMenu (ST_VOID);static ST_VOID infoMsgMenu (ST_VOID);static ST_VOID deviceMenu (ST_VOID);static ST_VOID acctMenu (ST_VOID);static ST_VOID configMenu (ST_VOID);static ST_VOID utilMenu (ST_VOID);static ST_VOID newB4B8Menu (ST_VOID);static ST_VOID exitTestApp (ST_VOID);static ST_VOID switchMenu(ST_VOID);static ST_VOID testSetMain (ST_VOID);static ST_VOID tranSetMenu (ST_VOID);static ST_VOID ictaExit (ST_VOID);static ST_VOID scrnLogOff (ST_VOID);static ST_VOID scrnLogOn (ST_VOID);static ST_VOID showSizes (ST_VOID);static ST_VOID chgTraceLevel (ST_VOID);static ST_VOID reDefARem (ST_VOID);static ST_VOID unDefARem (ST_VOID);static ST_VOID enableIncVar (ST_VOID);static ST_VOID disableIncVar (ST_VOID);#ifdef QUALITY_TESTstatic ST_VOID doSlogQualityTest (ST_VOID);#endif/************************************************************************//* main: entry point *//************************************************************************/ void main( int argc, char *argv[] ) { icInt status; m_mem_debug = SD_TRUE; /* m_mem_debug = SD_FALSE; */ /* First do any system specific initialization, for screen, etc. */#if (SYSTEM_SEL & (SYS_5)) term_init(); (*signal) (SIGINT, sigfun); (*signal) (SIGBUS, sigbus); (*signal) (SIGSEGV, sigbus); (*signal) (SIGTERM, sigfun); #endif#if defined(_WIN32) term_init(); signal(SIGINT, ShutDown); signal(SIGTERM,ShutDown);#endif /* prepare for logging */ m_set_log_config (MMS_LOG_CFG_FILE); m_mlog_install(); /* read the config file */ if (ictaConfigure() != SD_SUCCESS) { printf("Configuration File Errors - check log file."); exit(1); }#if defined(SISCO_THREADS) && (defined(__alpha) || defined(_AIX)) if (bMultiThreads) { IC_PTHREAD_MUTEX_INIT (&mutex, NULL, status); if (status) { printf("\n mutex init failed."); pause_msg("Press a key"); } IC_PTHREAD_MUTEX_LOCK (&mutex, status); if (status) { printf("\nLock Mutex Failed."); pause_msg("Press a key"); } else { /* log the mutex structure */#if !defined(_AIX) SLOGALWAYS1( "Initialize mutex.lock=%d", mutex._Pfield(lock)); SLOGCALWAYS1( " mutex.valid=%d", mutex._Pfield(valid)); if (mutex._Pfield(name)) { SLOGCALWAYS1( " mutex.name=%s", mutex._Pfield(name)); } else { SLOGCALWAYS0( " mutex.name=NULL"); } SLOGCALWAYS1( " mutex.arg=%d", mutex._Pfield(arg)); SLOGCALWAYS1( " mutex.depth=%d", mutex._Pfield(depth)); SLOGCALWAYS1( " mutex.sequence=%ld",mutex._Pfield(sequence)); SLOGCALWAYS1( " mutex.owner=%ld", mutex._Pfield(owner)); SLOGCALWAYS1( " mutex.block=%X", mutex._Pfield(block));#endif /* !defined(_AIX) */ } IC_PTHREAD_COND_INIT(&condVar, NULL, status); if (status) { printf("\nCondition Variable Init failed."); pause_msg("Press a key"); } else { /* log the condVar structure */#if !defined(_AIX) SLOGALWAYS1( "Initialize condVar.state=%d", condVar._Pfield(state)); SLOGCALWAYS1( " condVar.valid=%d", condVar._Pfield(valid)); if (condVar._Pfield(name)) { SLOGCALWAYS1( " condVar.name=%s", condVar._Pfield(name)); } else { SLOGCALWAYS0( " condVar.name=NULL"); } SLOGCALWAYS1( " condVar.arg=%d", condVar._Pfield(arg)); SLOGCALWAYS1( " condVar.sequence=%ld",condVar._Pfield(sequence)); SLOGCALWAYS1( " condVar.block=%X", condVar._Pfield(block));#endif /* !defined(_AIX) */ } IC_PTHREAD_MUTEX_UNLOCK (&mutex, status); if (status) { pause_msg("Unlock mutex failed - Press a key"); } }#endif#if defined(SISCO_THREADS) && defined(_WIN32) if (bMultiThreads) icEnableThreadSupport ();#endif /* set Identify information */ icIdentity = chk_calloc (1, sizeof (IDENT_RESP_INFO)); strcpy (icIdentity->vend, "ICCP ToolKit Test Application"); strcpy (icIdentity->model, "ApplicModel"); strcpy (icIdentity->rev, ICCP_RELEASE); icIdentity->num_as = 0; /* toolKit initialization */ if (status = icInitializeAPI() ) { printf("icInitialize failed %d %s\n", status, icPerror(status)); exit(1); } ICA_Log_Always0("Initialize API Successful."); /* set up error callback function */ if (status = icInitializeErrorCallback(errorCallBack) ) { printf("icInitializeErrorCallback failed %d %s\n", status, icPerror(status)); exit(1); } ICA_Log_Always0("Initialize ErrorCallBack Successful."); /* set toolkit to maximum trace levels */ /* this is max trace output *//* icSetupTrace(IC_TRACE_LOG, 10, NULL, "", dyn_iccp_slog_fun); */ /* this is min trace output */ icSetupTrace(IC_TRACE_LOG, 1, NULL, "", dyn_iccp_slog_fun); printf("Tracing has been started!\n"); /* setup local control center */ status = icDefineLocal(pstVCC->stLocal.localName, pstVCC->stLocal.nMaxTransferSets, pstVCC->stLocal.nMaxDataSets, pstVCC->stLocal.nMaxMMSMsgSize); if (status != IC_OK) { printf("Unable to Define Local, status = %d \n\t error='%s'\n", status, icPerror(status)); exit(1); } bAPIStarted = icTrue; ICA_Log_Flow0("ICCP TestApplication Initialized OK."); /* set a timer to poll for keystrokes */ keyCheckTimer = icAddTimeOutHandler( 200, testCheckKey, (icUserData) "checkKey" ); printf("\nTimer handler installed\n"); setMainMenu();#ifdef _WIN32 icMainLoop( icLoopForever );#else icMainLoop( icLoopForever, NULL ) ; #endif } /* end main *//************************************************************************//* testCheckKey *//* handle keystrokes *//************************************************************************/void testCheckKey(icUserData userdata, icTimerId timerid) { if (keyCheckTimer) { icRemoveTimeOutHandler(keyCheckTimer); keyCheckTimer = NULL; } if (bShutItDown) { printf("\n[[[[ Shutting Down ]]]]\n"); if (bAPIStarted) icCloseAPI(); freeVCC(); term_rest(); exit(1); } if (check_key () == 1) switchMenu(); keyCheckTimer = icAddTimeOutHandler( 200, testCheckKey, (icUserData) "checkKey" ); }/************************************************************************//* showHeading *//************************************************************************/ST_VOID showHeading (ST_VOID) { printf("\n\n\n"); printf ("************************************************************\n"); printf ("*** ICCP TOOLKIT for MMS-EASE V%-6s ***\n", ICCP_RELEASE); printf ("*** (c) 1996-2002 SISCO, Inc. ***\n"); printf ("*** (586) 254-0020 ***\n"); printf ("************************************************************"); }/************************************************************************//* switchMenu *//************************************************************************/static ST_VOID switchMenu(ST_VOID) { if (theCurrentMenu == MAIN_MENU) { if (ask ("\n\n Really want to exit (N)? ",SD_FALSE)) ictaExit();#ifdef SISCO_TEST else if (ask ("\n\n See the More Menu (N)?", SD_FALSE)) setMoreMenu ();#endif else setMainMenu(); } else if (theCurrentMenu == B4B8_MENU) (*callingMenu)(); else setMainMenu(); }/************************************************************************//* showCurrMenu *//* display the appropriate menu *//************************************************************************/ST_VOID showCurrMenu(ST_VOID) { switch (theCurrentMenu)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -