⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ictatest.c

📁 ICCP Toolkit 是在 Tru64下开发Tase.2通信协议的开发包
💻 C
📖 第 1 页 / 共 4 页
字号:
/************************************************************************//* SISCO SOFTWARE MODULE HEADER *****************************************//************************************************************************//*   (c) Copyright Systems Integration Specialists Company, Inc.,       *//*          1996-2000, All Rights Reserved                              *//*                                                                      *//* MODULE NAME : ICTATEST.C                                            	*//*                                                                      *//* MODULE DESCRIPTION :                                                 *//*   special test functions						*//*                                                                      *//* GLOBAL FUNCTIONS DEFINED IN THIS MODULE :				*//*		void cfgServerCompTest(ICTA_REMOTE_INFO *pstRemote);	*//*		void cfgClientCompTest(ICTA_REMOTE_INFO *pstRemote);	*//*		void serverCompTest(icUserData userdata, icTimerId Id);	*//*		void clientCompTest(icUserData userdata, icTimerId Id); *//*		void cleanUpCompTest(icUserData userdata, icTimerId Id);*//*		void doCompStartEmUp(ICTA_REMOTE_INFO *remoteList);	*//*									*//*                                                                      *//* MODIFICATION LOG :                                                   *//*  Date     Who   Rev                     Comments                     *//* --------  ---  ------   -------------------------------------------  *//* 08/05/02  nav    8      changes to test 8 remote ar names            *//* 05/17/00  nav    7      #ifdef around Tk Device objects		*//* 05/17/00  EJV    6      Changed printf and slog.			*//* 05/11/00  nav    5      Add more logging to comp test		*//* 02/25/00  nav    4      Alloc remote client & server space		*//* 01/19/98  EJV    3      Added typecast in list functions.		*//* 06/20/97  nav    2      Overhaul - One process can be client& server	*//* 06/05/97  nav    1      Convert to MMS-EASE V7.00			*//* 02/26/97  NAV           creation		                        *//************************************************************************/#include "ictamain.h"#include "scrndefs.h"#include "gvaldefs.h"#include "fkeydefs.h"#include "icthread.h"#ifdef SISCO_TEST#include "icsdkt.h"	#include "icapisdk.h"#include "icdevice.h"#endif/************************************************************************//* Global and Local variables						*//************************************************************************/static char	*thisFileName = __FILE__;#define	READ_VAR_NAME	"CT_READ_VAR"#define WRITE_VAR_NAME	"CT_WRITE_VAR"#define DEV_SBO_NAME	"CT_DEV_SBO"#define DEVICE_NAME	"CT_DEVICE"#define CONDITION_NAME  "CT_COND"#define IM_MAX_SIZE	1028static int	anIntVal = 0;static float	aFloatVal = (float) 1.0;static float	profilePrice = (float) .99;static short	targetClass = 0;static float    targetValue = (float) .58;static char msgBuf[10][80];	/* if you have >10 remote comp test blows up	*//************************************************************************//* static function prototypes						*//************************************************************************/static void cfgCompServerVars(ICTA_REMOTE_INFO *pstRemote);static void cfgCompClientVars(ICTA_REMOTE_INFO *pstRemote);static void cfgCompServerMsg(ICTA_REMOTE_INFO *pstRemote);static void cfgCompClientMsg(ICTA_REMOTE_INFO *pstRemote);static void cfgCompServerDevices(ICTA_REMOTE_INFO *pstRemote);static void cfgCompClientDevices(ICTA_REMOTE_INFO *pstRemote);static void cfgCompServerAccts(ICTA_REMOTE_INFO *pstRemote);static void cfgCompClientAccts(ICTA_REMOTE_INFO *pstRemote);static void doSendAcct(ICTA_SIMPLE_ACCT *pstAcct, ICTA_LINK_INFO *pstLink,                       icInt requestId);static void doResultsDetail (void);static ICTA_SIMPLE_ACCT *testFindAccount(ICTA_REMOTE_INFO *pstRemote,				 	 icInt nAcctRef, int who);/************************************************************************//* comprhensive test functions						*//************************************************************************//************************************************************************//* cfgServerCompTest:  configure items the server needs to perform test	*//************************************************************************/void cfgServerCompTest(ICTA_REMOTE_INFO *pstRemote)  {  if (!pstRemote->bCompServerDefined)    {    if (!pstRemote->serverObj)      {      pstRemote->serverObj = chk_calloc(1, sizeof(ICTA_SERVER_INFO));      pstRemote->bIsServer = icTrue;      /* be sure SupportFeatures is set in the iccptest.cfg file  */      }    cfgCompServerVars(pstRemote);    cfgCompServerMsg(pstRemote);    cfgCompServerDevices(pstRemote);    cfgCompServerAccts(pstRemote);    pstRemote->testFlag = 0;    pstRemote->bCompServerDefined = icTrue;    ICA_Log_Flow1("cfgServerCompTest OK for remote %p", pstRemote);    }  }/************************************************************************//* cfgClientCompTest:  configure items the client needs to perform test	*//************************************************************************/void cfgClientCompTest(ICTA_REMOTE_INFO *pstRemote)  {  if (!pstRemote->bCompClientDefined)    {    if (!pstRemote->clientObj)      {      pstRemote->clientObj = chk_calloc(1, sizeof(ICTA_CLIENT_INFO));      pstRemote->bIsClient = icTrue;      }    cfgCompClientVars(pstRemote);    cfgCompClientMsg(pstRemote);    cfgCompClientDevices(pstRemote);    cfgCompClientAccts(pstRemote);    pstRemote->testFlag = 0;    pstRemote->bCompClientDefined = icTrue;    ICA_Log_Flow1("cfgClientCompTest OK for remote %p", pstRemote);    }  }/************************************************************************//* serverCompTest:  timer went off - do server stuff			*//************************************************************************/void serverCompTest(icUserData userdata, icTimerId timerId)  {ICTA_REMOTE_INFO *pstRemote;ICTA_MSG_INFO *pstMsg;ICTA_SIMPLE_ACCT *pstAcct;int nRef, index;icInt status;  pstRemote = (ICTA_REMOTE_INFO *) userdata;  if (!bCompTestInProgress || bStopCompTest)    {				    /* what are you doing here!!!	*/    if (!bMultiThreads && timerId)      {      icRemoveTimeOutHandler(timerId);      pstRemote->timerId = NULL;      }    return;    }  /* skip this if the link is down		*/  if (!pstRemote->linkList->bLinkUp)    {    if (!bMultiThreads && !bStopCompTest && timerId)      icRestartTimeOut (timerId);    return;    }  /* first ditch the timer			*/  if (!bMultiThreads && timerId)    {    icRemoveTimeOutHandler(timerId);    pstRemote->timerId = NULL;    }  /* make sure an association exists	*/  if (!pstRemote->linkList->bLinkUp)    {    printf("\nserverCompTest - linkNotActive for %p", pstRemote);    return;    }  /* send a message		*/  index = 0;  nRef = 100 * (index+1) + index;  pstMsg = findServerMsg(nRef, pstRemote);  sprintf(msgBuf[pstRemote->index], "Message #%d for Remote %d",           pstMsg->numHits, pstRemote->index);  if (pstMsg)    {    status = icSendMessage(pstRemote->linkList->linkId, 			   pstMsg->msgId,			   pstMsg->nRef,			   pstMsg->numHits++,			   pstMsg->numHits,			   strlen(msgBuf[pstRemote->index]),		           (void *) msgBuf[pstRemote->index]);    if (status)      {      ICA_Log_Err2("ERROR:  icSendMessage status =%d %s",                  status, icPerror(status));      ICA_Log_ErrC1("       Msg = %d", nRef);      pstMsg->numErrors++;      }    }  /* now send all accounts	*/  nRef = 1000 * (index+1) + 1;  pstAcct = testFindAccount(pstRemote, nRef, ICTA_SERVER);  if (pstAcct)    {    doSendAcct(pstAcct, pstRemote->linkList, 0);    pstAcct->numHits++;    }  nRef = 1000 * (index+1) + 2;  pstAcct = testFindAccount(pstRemote, nRef, ICTA_SERVER);  if (pstAcct)    {    doSendAcct(pstAcct, pstRemote->linkList, 0);    pstAcct->numHits++;    }  nRef = 1000 * (index+1) + 3;  pstAcct = testFindAccount(pstRemote, nRef, ICTA_SERVER);  if (pstAcct)    {    doSendAcct(pstAcct, pstRemote->linkList, 0);    pstAcct->numHits++;    }  /* reset the timer	*/  if (!bMultiThreads && !bStopCompTest)    {    pstRemote->timerId = icAddTimeOutHandler( compSleepTime*1000, 					      serverCompTest,   				              (icUserData) pstRemote);    }  ICA_Log_Err0 ("serverCompTest: sent 4 info reports.");  }/************************************************************************//* clientCompTest:  timer went off - read/write/request some stuff	*//************************************************************************/void clientCompTest(icUserData userdata, icTimerId timerId)  {ICTA_REMOTE_INFO *pstRemote;ICTA_VAR_INFO *pstVar;ICTA_DEVICE *pstDevice;ICTA_SIMPLE_ACCT *pstAcct;icChar	varName[MAX_ID_LEN];icChar	deviceName[MAX_ID_LEN];icInt status;int nRef, index;#ifdef SISCO_TESTicClientDevice *pTkDev;#endif  pstRemote = (ICTA_REMOTE_INFO *) userdata;  if (!bCompTestInProgress || bStopCompTest)    {				    /* what are you doing here!!!	*/    if (!bMultiThreads && timerId)      {      icRemoveTimeOutHandler(timerId);      pstRemote->timerId = NULL;      }    return;    }  printf ("\nclientComptTest started for remote %p, %s",           pstRemote, pstRemote->remoteName);  /* skip this if the link is down		*/  if (!pstRemote->linkList->bLinkUp)    {    if (!bMultiThreads && !bStopCompTest && timerId)      icRestartTimeOut (timerId);    return;    }  /* first ditch the timer			*/  if (!bMultiThreads && timerId)    {    icRemoveTimeOutHandler(timerId);    pstRemote->timerId = NULL;    }  index = 0;  if (pstRemote->testFlag %3 == 0)    {    /* read a variable	*/    sprintf(varName, "%s_%1d", READ_VAR_NAME, index);    pstVar = findClientVar(pstRemote, varName);    if (pstVar)      {      status = icReadVariable(pstVar->varId, pstRemote->linkList->linkId);      if (status)        {        ICA_Log_Err2("ERROR:  icReadVariable status =%d %s",                    status, icPerror(status));        ICA_Log_ErrC1("       VarName = %s", pstVar->varName);	pstVar->numErrors++;        }      }    /* write a variable	*/    sprintf(varName, "%s_%1d", WRITE_VAR_NAME, index);    pstVar = findClientVar(pstRemote, varName);    if (pstVar)      {      incrementVar(pstVar);#ifdef SISCO_THREADS      status = icWriteVariableEx (pstVar->varId, pstRemote->linkList->linkId,      				  pstVar->extraPtr);#else      status = icWriteVariable(pstVar->varId, pstRemote->linkList->linkId);#endif      if (status)        {        ICA_Log_Err2("ERROR:  icWriteVariable status = %d %s",                      status, icPerror(status));        ICA_Log_ErrC1("       Var=%s", pstVar->varName);	pstVar->numErrors++;        }      }    ICA_Log_Err0 ("clientCompTest read/write data values");    }  if (pstRemote->testFlag %3 == 1)    {    /* select an SBO device - call back function will do the operate call	*/    sprintf(deviceName, "%s_%1d", DEV_SBO_NAME, index);    pstDevice = findClientDevice(deviceName, pstRemote);    if (pstDevice)      {      status = icSelectDevice(pstDevice->deviceId,     			      pstRemote->linkList->linkId,			      ctSelectDevConf,			      (icUserData) pstDevice);      if (status)        {        ICA_Log_Err3("ERROR:  select device %s status =%d %s",                     pstDevice->name, status, icPerror(status));#ifdef SISCO_TEST	pTkDev = (icClientDevice *) pstDevice->deviceId;	ICA_Log_ErrC1 ("device state = %d", pTkDev->state);#endif	pstDevice->numErrors++;        }      }    /* operate a nonSBO device 	*/    sprintf(deviceName, "%s_%1d", DEVICE_NAME, index);    pstDevice = findClientDevice(deviceName, pstRemote);    if (pstDevice)      {      status = icOperateDevice (pstDevice->deviceId,   			        pstRemote->linkList->linkId,			        pstDevice->value,			        ctOperateDevConf,			        (icUserData) pstDevice);      if (status)        {        ICA_Log_Err3("ERROR:  operate device %s status =%d %s",                     pstDevice->name, status, icPerror(status));#ifdef SISCO_TEST	pTkDev = (icClientDevice *) pstDevice->deviceId;	ICA_Log_ErrC1 ("device state = %d", pTkDev->state);#endif	pstDevice->numErrors++;        }      }    ICA_Log_Err0 ("ClientCompTest: select and operate device.");    }  if (pstRemote->testFlag %3 == 2)    {    /* request account #2	*/    nRef = 1000 * (index+1) + 2;    pstAcct = testFindAccount(pstRemote, nRef, ICTA_CLIENT);    if (pstAcct)      {      status = icRequestSimpleAccount (pstRemote->linkList->linkId,   				       pstAcct->variableId, 				       pstAcct->request++,				       time(NULL),				       compSleepTime, 			               (icChar) TAC_ALL);      if (status)        {        ICA_Log_Err3("ERROR:  Request Simple Account %d, status = %d %s",                     pstAcct->nRef, status, icPerror(status));	pstAcct->numErrors++;        }      }    ICA_Log_Err0 ("ClientCompTest requested an account.");    }  pstRemote->testFlag++;  /* reset the timer	*/  if (!bMultiThreads && !bStopCompTest)    {    pstRemote->timerId = icAddTimeOutHandler( compSleepTime*1000,					      clientCompTest,					      (icUserData) pstRemote);    }     }/************************************************************************//* cleanUpCompTest:  							*//************************************************************************/void cleanUpCompTest(void)  {ICTA_REMOTE_INFO *pstRemote, *pstRemoteList;  /* first ditch any timers			*/  if (!bCompTestThreaded)    {    pstRemoteList = pstVCC->remoteList;    pstRemote = pstRemoteList;    while (pstRemote)      {      if (pstRemote->timerId)        icRemoveTimeOutHandler(pstRemote->timerId);      pstRemote = (ICTA_REMOTE_INFO *) list_get_next		  ((ST_VOID *)pstRemoteList, (ST_VOID *)pstRemote);      }    }  /* reset your globals, log results - your done!!!!!! */  bCompTestInProgress = icFalse;  logCompTestResults();  }/************************************************************************//* doCompStartEmUp:  start remotes and links for comprehensive test	*//************************************************************************/void doCompStartEmUp(ICTA_REMOTE_INFO *remoteList)  {ICTA_REMOTE_INFO *pstRemote;ICTA_LINK_INFO *pstLink;icInt status;  pstRemote = remoteList;  while (pstRemote)    {    if (bUseNewStartRem)      {      status = icStartRemoteEx (pstRemote->remoteId,                                 linkUpCallBackEx,                                 linkDownCallBackEx);      }    else      {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -