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

📄 ictab8ts.c

📁 ICCP Toolkit 是在 Tru64下开发Tase.2通信协议的开发包
💻 C
📖 第 1 页 / 共 3 页
字号:
/************************************************************************//* SISCO SOFTWARE MODULE HEADER *****************************************//************************************************************************//*   (c) Copyright Systems Integration Specialists Company, Inc.,       *//*          1996-2001, All Rights Reserved                              *//*                                                                      *//* MODULE NAME : ictab8test.c                                          	*//*                                                                      *//* MODULE DESCRIPTION :                                                 *//*   Send Block 8 Tranfse Reports					*//*                                                                      *//* GLOBAL FUNCTIONS DEFINED IN THIS MODULE :				*//*									*//*                                                                      *//* MODIFICATION LOG :                                                   *//*  Date     Who   Rev                     Comments                     *//* --------  ---  ------   -------------------------------------------  *//* 06/27/01  EJV           Deleted ; from  ';;'				*//* 05/18/01  NAV           creation		                        *//************************************************************************/#include "ictamain.h"#include "scrndefs.h"#include "gvaldefs.h"#include "fkeydefs.h"#include "icb4b8msgs.h"static char *thisFileName = __FILE__;static void doPeriodic (ICTA_REMOTE_INFO *pRemote);static void doProfile (ICTA_REMOTE_INFO *pRemote);static void doDONewRev (ICTA_REMOTE_INFO *pRemote);static void doDOCancel (ICTA_REMOTE_INFO *pRemote);static void doDOActual (ICTA_REMOTE_INFO *pRemote);static void doPlAvail (ICTA_REMOTE_INFO *pRemote);static void doPlUnavail (ICTA_REMOTE_INFO *pRemote);static void doPlStatusAvail (ICTA_REMOTE_INFO *pRemote);static void doPlStatusUnavail (ICTA_REMOTE_INFO *pRemote);static void doPlForecast (ICTA_REMOTE_INFO *pRemote);static void doPlCurve (ICTA_REMOTE_INFO *pRemote);static void doPlGenDataRpt (ICTA_REMOTE_INFO *pRemote);static void doPlGenDataRsp (ICTA_REMOTE_INFO *pRemote);void doB8Test (icUserData userData, icTimerId timerId);typedef struct tag_TATEST_TBL  {  char *name;  void (*fpSendService) (ICTA_REMOTE_INFO *pRemote);  } TATEST_TBL;static TATEST_TBL sendB8Report[]=  {    {"Periodic",	     doPeriodic	      },    {"Profile",		     doProfile	      },    {"DO New",		     doDONewRev	      },    {"DO Revised",	     doDONewRev	      },    {"DO Cancel",	     doDOCancel	      },    {"DO Actual",	     doDOActual	      },    {"Pl Avail",	     doPlAvail	      },    {"Pl Unavail",	     doPlUnavail      },    {"Pl RT Status Avail",   doPlStatusAvail  },    {"Pl RT Status Unavail", doPlStatusUnavail},    {"Pl Forecast",	     doPlForecast     },    {"Pl Curve",	     doPlCurve	      },    {"Gen Data Report",	     doPlGenDataRpt   },    {"Gen Data Resp",	     doPlGenDataRsp   }  };#define NUM_SEND_SERVICES (sizeof (sendB8Report) / sizeof (TATEST_TBL))/************************************************************************//* startB8Test:								*//************************************************************************/ST_VOID startB8Test (ST_VOID)  {ICTA_REMOTE_INFO *pRemote;ST_BOOLEAN dataEntered;ST_INT	   freq;  printf ("\n\nStart Block 8 Test:");  printf("\nEnter Report Frequency in Seconds (60):  ");    if (!(dataEntered = intget(&freq)))      freq = 60;  pRemote = pstVCC->remoteList;  while (pRemote)    {    pRemote->taTestTimer = icAddTimeOutHandler (freq * 1000, doB8Test, (icUserData) pRemote);    if (!pRemote->taTestTimer)      {      printf ("\nUnable to start B8Test for remote %s", pRemote->remoteName);      ICA_Log_Err1 ("ERROR:  icAddTimeOutHandler failed for remote %s",		    pRemote->remoteName);      }    pRemote = list_get_next (pstVCC->remoteList, pRemote);    }  printf ("\n\n Block 8 Test Started . . .");  }/************************************************************************//* stopB8Test:								*//************************************************************************/ST_VOID stopB8Test (ST_VOID)  {ICTA_REMOTE_INFO *pRemote;  pRemote = pstVCC->remoteList;  while (pRemote)    {    if (pRemote->taTestTimer)      {      icRemoveTimeOutHandler (pRemote->taTestTimer);      pRemote->taTestTimer = NULL;      }    pRemote = list_get_next (pstVCC->remoteList, pRemote);    }  printf ("\n\n Block 8 Test Stopped");  }/************************************************************************//* doB8Test:  called when timer expires - send a TA Report		*//************************************************************************/static int lastAccountSent = 0;void doB8Test (icUserData userData, icTimerId timerId)  {ICTA_REMOTE_INFO *pRemote;  pRemote = (ICTA_REMOTE_INFO *) userData;  if (pRemote->linkList->bLinkUp)    {    (*sendB8Report[lastAccountSent].fpSendService) (pRemote);    lastAccountSent++;    lastAccountSent %= NUM_SEND_SERVICES;    }  }/************************************************************************//* functions to send a Block8 Transer Report				*//************************************************************************//************************************************************************//* doPeriodic:  send Periodic transfer account				*//************************************************************************/#define LOCAL_REF_START	1#define INTEGER_START	1#define FLOAT_START	1.125static void doPeriodic (ICTA_REMOTE_INFO *pRemote)  {icMsgTypePeriodic	*ptkMsg;icTypeIccpHeader	*pstIccpHdr;icTypeNamedPeriodicHeader *pstPeriodicHdr;icInt			msgSize, status;icUChar			*message, *tmpMsg;int i, j, numLocalRef=2, numFloats=2, numInts=2, numPeriods=2;int headerSize, localRefSize, floatMatrixSize, floatArraySize;int intMatrixSize, intArraySize;icReferenceNumType *pLocalRef;icMatrixId *pMatrixId;icIntegerValue *pIntVal;icFloatValue *pFloatVal;  headerSize = sizeof (icMsgTypePeriodic);  localRefSize = numLocalRef * sizeof (icReferenceNumType);  IC_ALIGN_DATA (localRefSize);  floatMatrixSize = numFloats * sizeof (icMatrixId);  IC_ALIGN_DATA (floatMatrixSize);  floatArraySize = numFloats * numPeriods * sizeof (icFloatValue);  IC_ALIGN_DATA (floatArraySize);  intMatrixSize = numInts * sizeof (icMatrixId);  IC_ALIGN_DATA (intMatrixSize);  intArraySize = numInts * numPeriods * sizeof (icIntegerValue);  IC_ALIGN_DATA (intArraySize);  msgSize = headerSize + localRefSize + floatMatrixSize + floatArraySize +  	    intMatrixSize + intArraySize;  /* allocate memory and fill it up			*/  message = chk_malloc (msgSize);  ptkMsg = (icMsgTypePeriodic *) message;  pstIccpHdr = &ptkMsg->MsgHeader;  pstPeriodicHdr = &ptkMsg->MsgTypeHeader;  /* take care of the iccp header	*//*  pstIccpHdr->RemoteId = _hdrRemoteId;*/  pstIccpHdr->RequestId = 0;/*  pstIccpHdr->DestinationId = _hdrDestId; *//*  pstIccpHdr->ReferenceNumber = 100; *//*  pstIccpHdr->MessageType = IC_MSG_TYPE_TA_PERIODIC; *//*  pstIccpHdr->Conditions = pRemote->taConditions; */  /* take care of the periodic header	*/  pstPeriodicHdr->TransferAccountRef = 100;  pstPeriodicHdr->SendUtility = ICTA_UTIL_SEND;  pstPeriodicHdr->RecvUtility = ICTA_UTIL_RECEIVE;  pstPeriodicHdr->SellingUtility = ICTA_UTIL_SELLING;  pstPeriodicHdr->BuyerUtility = ICTA_UTIL_BUYING;  pstPeriodicHdr->TimeStamp = time (NULL);  strcpy (pstPeriodicHdr->Name, "PeriodicTAName");  pstPeriodicHdr->StartTime = time (NULL) + 360;  strcpy (pstPeriodicHdr->PeriodResolution, "PeriodicResolution");  pstPeriodicHdr->NumberLocalRef = (icNumberType) numLocalRef;  pstPeriodicHdr->NumberFloatIds = (icNumberType) numFloats;  pstPeriodicHdr->NumberIntegerIds = (icNumberType) numInts;  pstPeriodicHdr->NumberPeriods = (icNumberType) numPeriods;  /* take care of local references	*/  tmpMsg = message + sizeof (icMsgTypePeriodic);  pLocalRef = (icReferenceNumType *) tmpMsg;  for (i=0; i<numLocalRef; i++, pLocalRef++)    *pLocalRef = LOCAL_REF_START * i;  /* take care of float matrix ids next	*/  tmpMsg += localRefSize;  pMatrixId = (icMatrixId *) tmpMsg;  for (i=1; i<=numFloats; i++, pMatrixId++)    *pMatrixId = i;  /* take care of float values		*/  tmpMsg += floatMatrixSize;  pFloatVal = (icFloatValue *) tmpMsg;  for (i=1; i<=numPeriods; i++)    {    for (j=1; j<=numFloats; j++, pFloatVal++)      {      *pFloatVal = (float) FLOAT_START * i * j;      }    }  /* take care of integer matrix ids 	*/   tmpMsg += floatArraySize;  pMatrixId = (icMatrixId *) tmpMsg;  for (i=1; i<=numInts; i++, pMatrixId++)    *pMatrixId = i;  /* take care of integer values	*/  tmpMsg += intMatrixSize;  pIntVal = (icIntegerValue *) tmpMsg;  for (i=1; i<=numPeriods; i++)    {    for (j=1; j<=numInts; j++, pIntVal++)      *pIntVal = INTEGER_START * i * j;    }  /* send the message	*/  status = icSendTypedMessage (pRemote->linkList->linkId, IC_MSG_TYPE_TA_PERIODIC, 			       NULL, pRemote->taConditions,  			       message, msgSize);  if (status)    {    ICA_Log_Err2 ("ERROR:  icSendTypedMessage status = %d %s",                  status, icPerror(status));    printf ("\n\nSend PeriodicTA Failed -  %d %s", status, icPerror (status));    }  chk_free (message);  }/************************************************************************//* doProfile:  send Profile Transfer Account				*//************************************************************************/static void doProfile (ICTA_REMOTE_INFO *pRemote)  {icMsgTypeProfile	*ptkMsg;icTypeIccpHeader	*pstIccpHdr;icTypeNamedProfileHeader *pstProfileHdr;icInt			msgSize, status;icUChar			*message, *tmpMsg;int i, numLocalRef=4, numProfiles=3;int headerSize, localRefSize, profileSize;icReferenceNumType *pLocalRef;icTypeProfileValue	*pValue;  headerSize = sizeof (icMsgTypeProfile);  localRefSize = numLocalRef * sizeof (icReferenceNumType);  IC_ALIGN_DATA (localRefSize);  profileSize = numProfiles * sizeof (icTypeProfileValue);  IC_ALIGN_DATA (profileSize);  msgSize = headerSize + localRefSize + profileSize;  /* allocate memory and fill it up			*/  message = chk_malloc (msgSize);  ptkMsg = (icMsgTypeProfile *) message;  pstIccpHdr = &ptkMsg->MsgHeader;  pstProfileHdr = &ptkMsg->MsgTypeHeader;  /* take care of the iccp header	*//*  pstIccpHdr->RemoteId = _hdrRemoteId; */  pstIccpHdr->RequestId = 0;/*  pstIccpHdr->DestinationId = _hdrDestId; *//*  pstIccpHdr->ReferenceNumber = _hdrRefNum; *//*  pstIccpHdr->MessageType = msgType; *//*  pstIccpHdr->Conditions = _hdrConditions; */  /* take care of the profile header	*/  pstProfileHdr->TransferAccountRef = 200;   pstProfileHdr->SendUtility = ICTA_UTIL_SEND;  pstProfileHdr->RecvUtility = ICTA_UTIL_RECEIVE;  pstProfileHdr->SellingUtility = ICTA_UTIL_SELLING;  pstProfileHdr->BuyerUtility = ICTA_UTIL_BUYING;  pstProfileHdr->TimeStamp = time (NULL);  strcpy (pstProfileHdr->Name, "ProfileTAName");  pstProfileHdr->NumberLocalRef = (icNumberType) numLocalRef;  pstProfileHdr->NumberProfileVals = (icNumberType) numProfiles;  /* take care of local references	*/  tmpMsg = message + sizeof (icMsgTypeProfile);  pLocalRef = (icReferenceNumType *) tmpMsg;  for (i=0; i<numLocalRef; i++, pLocalRef++)    *pLocalRef = LOCAL_REF_START * i;  /* take care of profile values next	*/  tmpMsg += localRefSize;  pValue = (icTypeProfileValue *) tmpMsg;  for (i=1; i<=numProfiles; i++, pValue++)    {    pValue->RampStartTime = time (NULL) + i;    pValue->RampDuration = pValue->RampStartTime + 120;    pValue->ProfilePrice =  (float) 1.05 * i;    pValue->ProfileTargetClass = i;    pValue->ProfileTarget = (float) .58 * i;    }  /* send the message	*/  status = icSendTypedMessage (pRemote->linkList->linkId, IC_MSG_TYPE_TA_PROFILE,			       NULL, pRemote->taConditions,  			       message, msgSize);  if (status)    {    ICA_Log_Err2 ("ERROR:  icSendTypedMessage status = %d %s",                  status, icPerror(status));    printf ("\n\nSend ProfileTA Failed %d %s", status, icPerror (status));    }  chk_free (message);  }/************************************************************************//* doDONewRev:  send New or Revised Device Outage message		*//************************************************************************/static int DORefId = 0;static void doDONewRev (ICTA_REMOTE_INFO *pRemote)  {icMsgTypeDONewRev	tkMsg;

⌨️ 快捷键说明

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