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

📄 ictatest.c

📁 ICCP Toolkit 是在 Tru64下开发Tase.2通信协议的开发包
💻 C
📖 第 1 页 / 共 4 页
字号:
				       &pstAcct->variableId,				       (icUserData)pstAcct,				       ctSendTACallBack,				       ctTACondCallBack);  if (status)    {    ICA_Log_Err3("ERROR:  DefineServerAccount %d status = %d %s",	          pstAcct->nRef, status, icPerror(status));    }  else    {    pstAcct->bAcctDefined = icTrue;    ICA_Log_Flow1("ServerAccount ref %d defined ok.", pstAcct->nRef);    }  /* a float account	*/  pstAcct = chk_calloc(1, sizeof(ICTA_SIMPLE_ACCT));  pstAcct->nRef = 1000 * (index+1) + 2;  pstAcct->scope = IC_SCOPE_VMD;  pstAcct->acctType = IC_TYPE_PERIODIC;  pstAcct->valueType = IC_FLOAT_ACCOUNT;  pstAcct->rows = 10;  pstAcct->matrixRef = 0;  pstAcct->variableId = NULL;  pstAcct->bAcctDefined = icFalse;  pstAcct->numHits = 0;  pstAcct->numRequests = 0;  pstAcct->numErrors = 0;  pstAcct->numConditionHits=0;  pstAcct->numConditionErrs = 0;  pstAcct->request = 0;  list_add_last ((ST_VOID **)&pstRemote->serverObj->accountList, pstAcct);  status = icDefineServerSimpleAccount(pstRemote->remoteId,				       pstAcct->nRef,				       pstAcct->scope,				       pstAcct->acctType,				       NULL,				       pstAcct->valueType,				       &pstAcct->variableId,				       (icUserData)pstAcct,				       ctSendTACallBack,				       ctTACondCallBack);  if (status)    {    ICA_Log_Err3("ERROR:  DefineServerAccount %d status = %d %s",	          pstAcct->nRef, status, icPerror(status));    }  else    {    pstAcct->bAcctDefined = icTrue;    ICA_Log_Flow1("ServerAccount ref %d defined ok.", pstAcct->nRef);    }  /* a profile account	*/  pstAcct = chk_calloc(1, sizeof(ICTA_SIMPLE_ACCT));  pstAcct->nRef = 1000 * (index+1) + 3;  pstAcct->scope = IC_SCOPE_VMD;  pstAcct->acctType = IC_TYPE_PROFILE;  pstAcct->valueType = IC_PROFILE_ACCOUNT;  pstAcct->rows = 10;  pstAcct->matrixRef = 0;  pstAcct->variableId = NULL;  pstAcct->bAcctDefined = icFalse;  pstAcct->numHits = 0;  pstAcct->numRequests = 0;  pstAcct->numErrors = 0;  pstAcct->numConditionHits=0;  pstAcct->numConditionErrs = 0;  pstAcct->request = 0;  list_add_last ((ST_VOID **)&pstRemote->serverObj->accountList, pstAcct);  status = icDefineServerSimpleAccount(pstRemote->remoteId,				       pstAcct->nRef,				       pstAcct->scope,				       pstAcct->acctType,				       NULL,				       pstAcct->valueType,				       &pstAcct->variableId,				       (icUserData)pstAcct,				       ctSendTACallBack,				       ctTACondCallBack);  if (status)    {    ICA_Log_Err3("ERROR:  DefineServerAccount %d status = %d %s",	          pstAcct->nRef, status, icPerror(status));    }  else    {    pstAcct->bAcctDefined = icTrue;    ICA_Log_Flow1("ServerAccount ref %d defined ok.", pstAcct->nRef);    }  }/************************************************************************//* cfgCompClientAccts:  define comp test client accounts		*//************************************************************************/static void cfgCompClientAccts(ICTA_REMOTE_INFO *pstRemote)  {ST_INT index;icInt status;ICTA_SIMPLE_ACCT *pstAcct;ICTA_TA_CONDITION *pstCond;ICTA_LINK_INFO *pstLink;  index = 0;  pstLink = pstRemote->linkList;	/* always use the first link	*/  /* an int account	*/  pstAcct = chk_calloc(1, sizeof(ICTA_SIMPLE_ACCT));  pstAcct->nRef = 1000 * (index+1) + 1;  pstAcct->scope = IC_SCOPE_VMD;  pstAcct->acctType = IC_TYPE_NAME_PRD;  pstAcct->valueType = IC_INTEGER_ACCOUNT;  pstAcct->rows = 10;  pstAcct->matrixRef = 0;  pstAcct->variableId = NULL;  pstAcct->bAcctDefined = icFalse;  pstAcct->numHits = 0;  pstAcct->numRequests = 0;  pstAcct->numErrors = 0;  pstAcct->numConditionHits=0;  pstAcct->numConditionErrs = 0;  pstAcct->request = 0;  list_add_last ((ST_VOID **)&pstRemote->clientObj->accountList, pstAcct);  status = icDefineClientSimpleAccount(pstRemote->remoteId,				       pstAcct->nRef,				       pstAcct->scope,				       pstAcct->acctType,				       NULL,	       				       pstAcct->valueType,				       &pstAcct->variableId,				       (icUserData)pstAcct,				       ctRecvTACallBack);   if (status)    {    ICA_Log_Err3("ERROR:  DefineClientAccount %d status = %d %s",	          pstAcct->nRef, status, icPerror(status));    }  else    {    pstAcct->bAcctDefined = icTrue;    ICA_Log_Flow1("ClientAccount ref %d defined ok.", pstAcct->nRef);    }  /* a float account	*/  pstAcct = chk_calloc(1, sizeof(ICTA_SIMPLE_ACCT));  pstAcct->nRef = 1000 * (index+1) + 2;  pstAcct->scope = IC_SCOPE_VMD;  pstAcct->acctType = IC_TYPE_PERIODIC;  pstAcct->valueType = IC_FLOAT_ACCOUNT;  pstAcct->rows = 10;  pstAcct->matrixRef = 0;  pstAcct->variableId = NULL;  pstAcct->bAcctDefined = icFalse;  pstAcct->numHits = 0;  pstAcct->numRequests = 0;  pstAcct->numErrors = 0;  pstAcct->numConditionHits=0;  pstAcct->numConditionErrs = 0;  pstAcct->request = 0;  list_add_last ((ST_VOID **)&pstRemote->clientObj->accountList, pstAcct);  status = icDefineClientSimpleAccount(pstRemote->remoteId,				       pstAcct->nRef,				       pstAcct->scope,				       pstAcct->acctType,				       NULL,	       				       pstAcct->valueType,				       &pstAcct->variableId,				       (icUserData)pstAcct,				       ctRecvTACallBack);  if (status)    {    ICA_Log_Err3("ERROR:  DefineClientAccount %d status = %d %s",	          pstAcct->nRef, status, icPerror(status));    }  else    {    pstAcct->bAcctDefined = icTrue;    ICA_Log_Flow1("ClientAccount ref %d defined ok.", pstAcct->nRef);    }  /* a profile account	*/  pstAcct = chk_calloc(1, sizeof(ICTA_SIMPLE_ACCT));  pstAcct->nRef = 1000 * (index+1) + 3;  pstAcct->scope = IC_SCOPE_VMD;  pstAcct->acctType = IC_TYPE_PROFILE;  pstAcct->valueType = IC_PROFILE_ACCOUNT;  pstAcct->rows = 10;  pstAcct->matrixRef = 0;  pstAcct->variableId = NULL;  pstAcct->bAcctDefined = icFalse;  pstAcct->numHits = 0;  pstAcct->numRequests = 0;  pstAcct->numErrors = 0;  pstAcct->numConditionHits=0;  pstAcct->numConditionErrs = 0;  pstAcct->request = 0;  list_add_last ((ST_VOID **)&pstRemote->clientObj->accountList, pstAcct);  status = icDefineClientSimpleAccount(pstRemote->remoteId,				       pstAcct->nRef,				       pstAcct->scope,				       pstAcct->acctType,				       NULL,	       				       pstAcct->valueType,				       &pstAcct->variableId,				       (icUserData)pstAcct,				       ctRecvTACallBack);  if (status)    {    ICA_Log_Err3("ERROR:  DefineClientAccount %d status = %d %s",	          pstAcct->nRef, status, icPerror(status));    }  else    {    pstAcct->bAcctDefined = icTrue;    ICA_Log_Flow1("ClientAccount ref %d defined ok.", pstAcct->nRef);    }  /* client accounts need conditions - use TAC_ALL		*/  pstCond = chk_calloc(1, sizeof(ICTA_TA_CONDITION));  strcpy(pstCond->linkName, pstRemote->linkList->linkName);  pstCond->condition = (icChar) TAC_ALL;  pstCond->bCondDefined = icFalse;  list_add_last ((ST_VOID **)&pstRemote->clientObj->conditionList, pstCond);  status = icDefineTAConditions(pstRemote->linkList->linkId,	  			pstRemote->clientObj->accountList->variableId, 				pstCond->condition);  if (status)    {    ICA_Log_Err2("ERROR: Define Conditions status %d %s",                 status, icPerror(status));    }  else    pstCond->bCondDefined = icTrue;  }/************************************************************************//* doSendAcct:  do the grunt work to send an account			*//************************************************************************/#define MAX_TRAN_PERIODS	10static void doSendAcct(ICTA_SIMPLE_ACCT *pstAcct, ICTA_LINK_INFO *pstLink,                       icInt requestId)  {ST_CHAR name[MAX_ID_LEN], periodResol[MAX_ID_LEN];icInt status;icTypeAccountHeader acctHdrPtr;void *acctValPtr;int 			intVals[MAX_TRAN_PERIODS], i;float			floatVals[MAX_TRAN_PERIODS];icTypeProfileValue	profVal[MAX_TRAN_PERIODS];  sprintf(name, "name%d", pstAcct->nRef);  sprintf(periodResol, "prdRsl%d", pstAcct->nRef);   acctHdrPtr.SendUtility = ICTA_UTIL_SEND;  acctHdrPtr.RecvUtility = ICTA_UTIL_RECEIVE;  acctHdrPtr.SellingUtility = ICTA_UTIL_SELLING;  acctHdrPtr.BuyerUtility = ICTA_UTIL_BUYING;  acctHdrPtr.TimeStamp = time(NULL);  acctHdrPtr.StartTime = acctHdrPtr.TimeStamp - 60;  acctHdrPtr.NumberLocalRef = 0;  acctHdrPtr.NumberSegments = 0;  strcpy(acctHdrPtr.Name, name);  strcpy(acctHdrPtr.PeriodResolution, periodResol);  switch (pstAcct->valueType)    {    case IC_INTEGER_ACCOUNT:      acctHdrPtr.TransferAccountRef = pstAcct->nRef;      acctHdrPtr.NumberFloatIds = 0;      acctHdrPtr.NumberIntegerIds = 1;      acctHdrPtr.NumberProfileVals = 0;      acctHdrPtr.NumberPeriods = pstAcct->rows;      for (i=0; i<pstAcct->rows; i++)        {        intVals[i] = anIntVal++;        }      acctValPtr = (void *) intVals;      break;    case IC_FLOAT_ACCOUNT:      acctHdrPtr.TransferAccountRef = pstAcct->nRef;      acctHdrPtr.NumberFloatIds = 1;      acctHdrPtr.NumberIntegerIds = 0;      acctHdrPtr.NumberProfileVals = 0;      acctHdrPtr.NumberPeriods = pstAcct->rows;      aFloatVal = (float) 1.075;		      for (i=0; i<pstAcct->rows; i++)        {	floatVals[i] = aFloatVal;	aFloatVal *= (float) 1.25;	}      acctValPtr = (void *) floatVals;      break;    case IC_PROFILE_ACCOUNT:      acctHdrPtr.TransferAccountRef = pstAcct->nRef;      acctHdrPtr.NumberFloatIds = 0;      acctHdrPtr.NumberIntegerIds = 0;      acctHdrPtr.NumberProfileVals = pstAcct->rows;      acctHdrPtr.NumberPeriods = 0;      targetValue = (float) 0.58;      profilePrice = (float).99;      for (i=0; i<pstAcct->rows; i++)        {        profVal[i].RampStartTime = time(NULL);        profVal[i].RampDuration = profVal[i].RampStartTime + 120;        profVal[i].ProfilePrice = profilePrice;        profVal[i].ProfileTargetClass = targetClass;        profVal[i].ProfileTarget =  targetValue;        profilePrice *= (float) 1.05;	targetClass++;	targetClass = targetClass % 3;	targetValue *= (float) 1.22;	}      acctValPtr = (void *) profVal;      break;    default:      ICA_Log_Err2("Server Account Ref %d has an invalid value type %d",                    pstAcct->nRef, pstAcct->valueType);      break;    }	/* end the switch	*/  status = icSendSimpleAccount(pstLink->linkId,			       pstAcct->variableId,			       (icChar) TAC_ALL,			       requestId,			       0,			       &acctHdrPtr,			       acctValPtr,			       NULL,			       NULL);  if (status)    {    if (bCompTestVerbose)      {      printf("\nSend Simple Account Failed (status =%d %s)",              status, icPerror(status));      }    ICA_Log_Err3("ERROR:  Send Simple Account %d, status = %d %s",                  pstAcct->nRef, status, icPerror(status));    pstAcct->numErrors++;    }  }/************************************************************************//* call back functions							*//************************************************************************//************************************************************************//* ctClientWriteCallBack: Called by API *after* confirmed write to peer	*/ /************************************************************************/void ctClientWriteCallBack(icInt status, icUserData data)  {ICTA_VAR_INFO *pstVar;  pstVar = (ICTA_VAR_INFO *) data;  if (bCompTestVerbose)    printf("\nClientWriteCallback for variable %s", pstVar->varName);  ICA_Log_Flow1("\nClientWriteCallback for Var %s", pstVar->varName);  if (status == IC_OK)     pstVar->numWrites++;  else     pstVar->numErrors++;  } /************************************************************************//* ctClientReadCallBack:  Called by API *after* confirmed read from peer  *//************************************************************************/void ctClientReadCallBack(icInt status, icUserData data)  {ICTA_VAR_INFO *pstVar;  pstVar = (ICTA_VAR_INFO *) data;  if (bCompTestVerbose)    printf("\nClientReadCallback for variable %s", pstVar->varName);  ICA_Log_Flow1("\nClientReadCallback for Var %s", pstVar->varName);  if (status == IC_OK)    pstVar->numReads++;  else    pstVar->numErrors++;  }/************************************************************************//* ctServerWriteCallBack: Called by API *after* var written to by peer	*/ /************************************************************************/void ctServerWriteCallBack( icInt status, icUserData data )  {ICTA_VAR_INFO *pstVar;  pstVar = (ICTA_VAR_INFO *) data;  if (bCompTestVerbose)    printf("\nServerWriteCallback for variable %s", pstVar->varName);  ICA_Log_Flow1("\nServerWriteCallback for Var %s", pstVar->varName);  if (status==IC_OK)     pstVar->numWrites++;  else     pstVar->numErrors++;  } /************************************************************************//* ctServerReadCallBack:  Called by API *before* variable read by peer	*//************************************************************************/void ctServerReadCallBack(icInt status, icUserData data)  {ICTA_VAR_INFO *pstVar;  pstVar = (ICTA_VAR_INFO *) data;  if (bCompTestVerbose)    printf("\nServerReadCallback for variable %s", pstVar->varName);  ICA_Log_Flow1("\nServerReadCallback for Var %s", pstVar->varName);  if (status == IC_OK)    {    incrementVar(pstVar);    pstVar->numReads++;    }  else    pstVar->numErrors++;  }/************************************************************************//* ctRecvMsgCallBack:  Client Received a Message			*//* 		     called by API when receiv Info Message Objects 	*//************************************************************************/void ctRecvMsgCallBack(icInt status, icInt infoRefNum, icInt localRef,     	   	     icInt messageId, icInt  msgSize, void *msgByteArrayPtr,                     icUserData  userData)  {ICTA_MSG_INFO *pstInfo;  pstInfo = (ICTA_MSG_INFO *) userData;  if (bCompTestVerbose)    printf("\nClientInfoMessageReciept for message %d w/status=%d", pstInfo->nRef, status);

⌨️ 快捷键说明

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