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

📄 ictaacct.c

📁 ICCP Toolkit 是在 Tru64下开发Tase.2通信协议的开发包
💻 C
📖 第 1 页 / 共 3 页
字号:
        {	if (pstAcct->matrixRef == pstMatrix->matrixRef)	  {	  switch (pstAcct->valueType)	    {	    case IC_INTEGER_ACCOUNT:	      intIds[numInts++] = pstAcct->variableId;	      break;	       	    case IC_FLOAT_ACCOUNT:	      floatIds[numFloats++] = pstAcct->variableId;	      break;	    }	/* end switch	*/	  }	/* end if	*/	pstAcct = (ICTA_SIMPLE_ACCT *) list_get_next		  ((ST_VOID *)pstRemote->clientObj->accountList, (ST_VOID *)pstAcct);	}	/* end while pstAcct	*/      /* make the API call	*/      if (numFloats+numInts >0)        {        status = icDefineClientMatrixAccount (pstRemote->remoteId,					      pstMatrix->matrixRef,					      pstMatrix->matrixScope,					      numFloats,					      floatIds,					      numInts,					      intIds,					      &pstMatrix->variableId,					      (icUserData)pstMatrix);        if (status != IC_OK)	  {	  printf("DefineClientMatrixAccount for %d status %d '%s'",	          pstMatrix->matrixRef, status, icPerror(status));          ICA_Log_Err3("ERROR:  DefineClientMatrixAccount %d status = %d %s",	                pstMatrix->matrixRef, status, icPerror(status));	  }	else	  {	  pstMatrix->bMatrixDefined = icTrue;	  ICA_Log_Flow1("ClientMatrixAccount ref %d defined ok.", 	                 pstMatrix->matrixRef);	  }	}      pstMatrix = (ICTA_MATRIX_ACCT *) list_get_next		  ((ST_VOID *)pstRemote->clientObj->matrixList, (ST_VOID *)pstMatrix);      } 	/* end while pstMatrix	*/    pstRemote = (ICTA_REMOTE_INFO *) list_get_next		((ST_VOID *)remoteList, (ST_VOID *)pstRemote);    }		/* end while pstRemote	*/  }		/* your done!		*//************************************************************************//* doDefConditions:  define all conditions for the client		*//************************************************************************/ST_RET doDefConditions (void)  {ICTA_REMOTE_INFO  *pstRemote;ICTA_LINK_INFO    *pstLink;ICTA_TA_CONDITION *pstCond;ICTA_SIMPLE_ACCT  *pstAcct;icInt		  status;ST_RET		  rtnVal = SD_SUCCESS;ST_BOOLEAN	 bIsClient = SD_FALSE;  printf("\n\nDefine Conditions . . .\n");  pstRemote = pstVCC->remoteList;  while (pstRemote && !bIsClient)    {    bIsClient = pstRemote->bIsClient;    pstRemote = (ICTA_REMOTE_INFO *) list_get_next		((ST_VOID *)pstVCC->remoteList, (ST_VOID *)pstRemote);    }  if (!bIsClient)    {    printf("\nDefineConditions is a Client Option ONLY!");    pause_msg("\nPress a key to continue!");    showCurrMenu();    return SD_FALSE;    }  pstRemote = pstVCC->remoteList;  while (pstRemote)    {    if (!pstRemote->bRemoteDefined || !pstRemote->bIsClient)      {      pstRemote = (ICTA_REMOTE_INFO *) list_get_next		  ((ST_VOID *)pstVCC->remoteList, (ST_VOID *)pstRemote);      continue;      }    pstCond = pstRemote->clientObj->conditionList;    while (pstCond)      {      if (!pstCond->bCondDefined)        {        pstLink = findLink(pstRemote, pstCond->linkName);	if (!pstLink)	  {	  ICA_Log_Err1("Define Conditions:  Link %s Not Found.",	  		pstCond->linkName);	  rtnVal = SD_FAILURE;	  }	else	  {  	  pstAcct = pstRemote->clientObj->accountList; /* any acct will do*/	  if (!pstAcct)	    {	    ICA_Log_Err0("Define Conditions:  Account Not Found.")	    rtnVal = SD_FAILURE;	    }	  else	    {            status = icDefineTAConditions(pstLink->linkId,					  pstAcct->variableId, 					  pstCond->condition);	    if (status)	      {	      ICA_Log_Err2("ERROR: Define Conditions status %d %s",	                   status, icPerror(status));	      rtnVal = SD_FAILURE;	      }	    else	      pstCond->bCondDefined = icTrue;	    }	  }	}  /* end if !defined		*/      pstCond = (ICTA_TA_CONDITION *) list_get_next		((ST_VOID *)pstRemote->clientObj->conditionList, (ST_VOID *)pstCond);      }			/* end while pstCond		*/    pstRemote = (ICTA_REMOTE_INFO *) list_get_next		((ST_VOID *)pstVCC->remoteList, (ST_VOID *)pstRemote);    }				/* end while pstRemote		*/  return rtnVal;  }/************************************************************************//* API CallBack Functions						*//************************************************************************//* recvTACallBack:  called when received requested  TranAcct object	*//*						(client function)	*//************************************************************************/void  recvTACallBack (icInt status,   		      icChar condition, 		      icInt requestId,		      icGMTBasedSType timeStamp, 		      icReferenceNumType *localRefPtr,		      icTypeAccountHeader *accountHdrPtr, 		      void *accountValPtr,		      icTypeTransmissionSeg *segmentHdrPtr, 		      void *segmentValPtr,		      icUserData data)  {int         i, j, NumberPeriods, segValIndex;int         *intValPtr;float       *floatValPtr;icTypeProfileValue *valPtr;char	    buffer[100];icTypeTransmissionSeg *segHdrPtr;  printf ("\n>>>>> Account received under condition (%x), requestId (%d), time(%d)",          condition, requestId, timeStamp );  printf ("\n      Account Header =========> ") ;  printf ("\n      TransferAccountRef    = %d", accountHdrPtr->TransferAccountRef);  printf ("\n      SendUtility           = %d",	accountHdrPtr->SendUtility);  printf ("\n      RecvUtility           = %d",	accountHdrPtr->RecvUtility);  printf ("\n      BuyerUtility          = %d",	accountHdrPtr->BuyerUtility);  printf ("\n      SellingUtility        = %d",	accountHdrPtr->SellingUtility);  printf ("\n      TimeStamp             = %s", ctime ((time_t *)&accountHdrPtr->TimeStamp));  printf ("      NumberLocalRef        = %d", accountHdrPtr->NumberLocalRef);  printf ("\n      NumberSegments        = %d",	accountHdrPtr->NumberSegments);  printf ("\n      NumberFloatIds        = %d",	accountHdrPtr->NumberFloatIds);  printf ("\n      NumberIntegerIds      = %d",	accountHdrPtr->NumberIntegerIds);  printf ("\n      NumberProfileVals     = %d",	accountHdrPtr->NumberProfileVals);  printf ("\n      Name                  = %s", accountHdrPtr->Name);  printf ("\n      PeriodResolution      = %s",	accountHdrPtr->PeriodResolution);  if (!bAutoResponse)    pause_msg("Press a Key for Account Values!");  if (accountHdrPtr->NumberProfileVals > 0)    {    valPtr = (icTypeProfileValue*)accountValPtr;    printf ("\n     profile Value  =========> ") ;    printf ("\nValue  RampStartTime  RampDuration  ProfilePrice TargetClass  Target");    for ( i = 0; i < accountHdrPtr->NumberProfileVals; i++)      {      strncpy(buffer, ctime((time_t *)&valPtr->RampStartTime), 20);      buffer[19] = '\0';      printf("\n  %2d  ", i);      printf("%20s  ", buffer);      printf("%5d    ", valPtr->RampDuration - valPtr->RampStartTime);      printf("%10f   ", valPtr->ProfilePrice);      printf("%5d    ", valPtr->ProfileTargetClass);      printf("%10f", valPtr->ProfileTarget);      valPtr++;      }    }  else    {    printf ("\n     Account Value  =========>\n") ;    if ( accountHdrPtr->NumberLocalRef > 0 )      {      intValPtr = (int*)localRefPtr;      for ( i = 0; i < accountHdrPtr->NumberLocalRef; i++)        {        printf ("      local Reference (%d) Value    = %d\n",  i,              *(intValPtr+i) );        }      }    NumberPeriods =  accountHdrPtr->NumberPeriods;    if ( accountHdrPtr->NumberIntegerIds > 0 )      {      intValPtr = (int*)accountValPtr;      for ( i = 0; i < NumberPeriods; i++)        {        printf ("      integer Period (%d) Value    = %d\n",  i,              *(intValPtr+i) );        }      }    if ( accountHdrPtr->NumberFloatIds > 0 )      {      floatValPtr = (float*)accountValPtr;      for ( i = 0; i < NumberPeriods; i++)        {        printf ("      float Period (%d) Value    = %f\n",  i,              *(floatValPtr+i) );        }      }    }  if (accountHdrPtr->NumberSegments > 0)    {    segHdrPtr = segmentHdrPtr;    segValIndex = 0;    if ( segmentHdrPtr->NumberIntegerIds > 0 )      intValPtr = (int*)segmentValPtr;    else      floatValPtr = (float*)segmentValPtr;    for (i=0; i<accountHdrPtr->NumberSegments; i++, segHdrPtr++)      {      if (!bAutoResponse)        pause_msg("Press a Key for Segment Data!");      printf ("\tSegmentTransRef = %d\n", segHdrPtr->TransmissionRef);      printf ("\tUtilWheeling = %d\n", segHdrPtr->UtilWheeling);      printf ("\tUtilPaying = %d\n", segHdrPtr->UtilPaying);      printf ("\tTranSegType = %d\n", segHdrPtr->TransmissionSegType);      printf ("\tUtilIn = %d\n", segHdrPtr->UtilIn);      printf ("\tUtilOut = %d\n", segHdrPtr->UtilOut);      printf ("\tNumberIntegerIds = %d\n", segHdrPtr->NumberIntegerIds);      printf ("\tNumberFloatIds = %d\n", segHdrPtr->NumberFloatIds);      for (j=0; j<NumberPeriods; j++)        {        if ( segmentHdrPtr->NumberIntegerIds > 0 )	  {          printf ("      integer Segment (%d) Value    = %d\n",  j,                 *(intValPtr++) );	  } 	else	  {          printf ("      float Segment (%d) Value    = %f\n",  j,                 floatValPtr[segValIndex++] );	  }	}      }    }  }/************************************************************************//* sendTACallBack:  called by API when received request of Transfer 	*//*		    Account Objects     (server function)		*//************************************************************************/void  sendTACallBack (icInt status,    		      icLinkId lp,    		      icInt requestId,    		      icScheduleTimeType startTime,    		      icDurationType duration,    		      icInt reference,    		      icChar conditionRequested,    		      icUserData data)  {ICTA_SIMPLE_ACCT *pstAcct;  pstAcct = (ICTA_SIMPLE_ACCT *) data;  printf ("\n>>>> Server Application Received Info request ... ") ;  printf ("\n     Account Reference:  %d", pstAcct->nRef);  printf ("\n     requestId requested is  %d ", requestId) ;  printf ("\n     startTime requested is  %s ", ctime ((time_t *)&startTime)) ;  printf ("    duration  requested is  %d ", duration) ;  printf ("\n     Reference requested is  %d ", reference) ;  printf ("\n     Condition requested is  0x%x ", conditionRequested) ;  }/************************************************************************//* TACondCallBack:   called by API when received request of Transfer 	*//*                   Account condition 		  (server function)	*//************************************************************************/void  TACondCallBack (icInt status, icLinkId lp,		      icChar conditions, icUserData data)  {ICTA_SIMPLE_ACCT *pstAcct;  pstAcct = (ICTA_SIMPLE_ACCT *) data;  printf ("\n>>>>> server application received TAConditions ... ") ;  printf ("        \nAccountRef (%d)", pstAcct->nRef);  printf ("        \nCondition requested is  0x%x", conditions) ;  }

⌨️ 快捷键说明

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