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

📄 ictab4b8.c

📁 ICCP Toolkit 是在 Tru64下开发Tase.2通信协议的开发包
💻 C
📖 第 1 页 / 共 5 页
字号:
  pstHeader->Conditions = _hdrConditions;  /* take care of the message	*/  printf ("\nEnter Info Reference (an integer):  ");  intget ((ST_INT *)&pstMsgPtr->InfoReference);  printf ("\nEnter Local Reference (an integer):  ");  intget ((ST_INT *)&pstMsgPtr->LocalReference);  printf ("\nEnter Message ID (an integer):  ");  intget ((ST_INT *)&pstMsgPtr->MessageId);  pstMsgPtr->Size = (icLong) infoSize;  /* send the message	*/   status = icSendTypedMessage (linkId, msgType, NULL, (char) TAC_ALL,  			       message, msgSize);  if (status)    {    ICA_Log_Err2 ("ERROR:  icSendTypedMessage status = %d %s",                  status, icPerror(status));    printf ("\n\nSend Message Failed %d %s", status, icPerror (status));    }  else    {    ICA_Log_Flow0 ("icSendTypedMessage OK!");    printf ("icSendTypedMessage OK!");    }  chk_free (ptkMsg);  }/************************************************************************//* sendSegPrd: send Periodic Transfer Account with segments		*//************************************************************************/static void sendSegPrd (int msgType, icLinkId linkId)  {  printf ("\nSend Segment Periodic TA Account:");  printf ("\nThe new API icSendTypedMesssage does not support segments.");  printf ("\nUse the old API icSendSimpleAccount.");  }/************************************************************************//* sendPeriodic:  send Periodic transfer account			*//************************************************************************/#define LOCAL_REF_START	1#define INTEGER_START	1#define FLOAT_START	1.125static void sendPeriodic (int msgType, icLinkId linkId)  {icMsgTypePeriodic	*ptkMsg;icTypeIccpHeader	*pstIccpHdr;icTypeNamedPeriodicHeader *pstPeriodicHdr;icInt			msgSize, status;icUChar			*message, *tmpMsg;int i, j, numLocalRef=0, numFloats=0, numInts=0, numPeriods=0;int headerSize, localRefSize, floatMatrixSize, floatArraySize;int intMatrixSize, intArraySize;icReferenceNumType *pLocalRef;icMatrixId *pMatrixId;icIntegerValue *pIntVal;icFloatValue *pFloatVal;  /* see how much to send				*/  printf ("\nEnter Number of Local References to send:  ");  intget (&numLocalRef);  printf ("\nEnter Number of Floats to send:  ");  intget (&numFloats);  printf ("\nEnter Number of Integers to send:  ");  intget (&numInts);  printf ("\nEnter Number of Periods to send:  ");  intget (&numPeriods);  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	*/  getHdrData ();  pstIccpHdr->RemoteId = _hdrRemoteId;  pstIccpHdr->RequestId = _hdrRequestId;  pstIccpHdr->DestinationId = _hdrDestId;  pstIccpHdr->ReferenceNumber = _hdrRefNum;  pstIccpHdr->MessageType = msgType;  pstIccpHdr->Conditions = _hdrConditions;  /* take care of the periodic header	*/  printf ("\nEnter TranfserAccountReference (an integer):  ");  intget ((ST_INT *)&pstPeriodicHdr->TransferAccountRef);   pstPeriodicHdr->SendUtility = ICTA_UTIL_SEND;  pstPeriodicHdr->RecvUtility = ICTA_UTIL_RECEIVE;  pstPeriodicHdr->SellingUtility = ICTA_UTIL_SELLING;  pstPeriodicHdr->BuyerUtility = ICTA_UTIL_BUYING;  pstPeriodicHdr->TimeStamp = time (NULL);  printf ("\nEnter Name (a string):  ");  strget (pstPeriodicHdr->Name);  pstPeriodicHdr->StartTime = time (NULL) + 3600;  printf ("\nEnter Periodic Resolution (a string):  ");  strget (pstPeriodicHdr->PeriodResolution);  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 (linkId, msgType, NULL, (char) TAC_ALL,  			       message, msgSize);  if (status)    {    ICA_Log_Err2 ("ERROR:  icSendTypedMessage status = %d %s",                  status, icPerror(status));    printf ("\n\nSend Message Failed %d %s", status, icPerror (status));    }  else    {    ICA_Log_Flow0 ("icSendTypedMessage OK!");    printf ("icSendTypedMessage OK!");    }  chk_free (message);  }/************************************************************************//* sendSegPrf:  send Profile transfer account with segments		*//************************************************************************/static void sendSegPrf (int msgType, icLinkId linkId)  {  printf ("\nSend Segment Profile TA Account:");  printf ("\nThe new API icSendTypedMesssage does not support segments.");  printf ("\nUse the old API icSendSimpleAccount.");  }/************************************************************************//* sendProfile:  send Profile Transfer Account				*//************************************************************************/static void sendProfile (int msgType, icLinkId linkId)  {icMsgTypeProfile	*ptkMsg;icTypeIccpHeader	*pstIccpHdr;icTypeNamedProfileHeader *pstProfileHdr;icInt			msgSize, status;icUChar			*message, *tmpMsg;int i, numLocalRef=0, numProfiles=0;int headerSize, localRefSize, profileSize;icReferenceNumType *pLocalRef;icTypeProfileValue	*pValue;  /* see how much to send				*/  printf ("\nEnter Number of Local References to send:  ");  intget (&numLocalRef);  printf ("\nEnter Number of Profiles to send:  ");  intget (&numProfiles);  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	*/  getHdrData ();  pstIccpHdr->RemoteId = _hdrRemoteId;  pstIccpHdr->RequestId = _hdrRequestId;  pstIccpHdr->DestinationId = _hdrDestId;  pstIccpHdr->ReferenceNumber = _hdrRefNum;  pstIccpHdr->MessageType = msgType;  pstIccpHdr->Conditions = _hdrConditions;  /* take care of the profile header	*/  printf ("\nEnter TranfserAccountReference (an integer):  ");  intget ((ST_INT *)&pstProfileHdr->TransferAccountRef);   pstProfileHdr->SendUtility = ICTA_UTIL_SEND;  pstProfileHdr->RecvUtility = ICTA_UTIL_RECEIVE;  pstProfileHdr->SellingUtility = ICTA_UTIL_SELLING;  pstProfileHdr->BuyerUtility = ICTA_UTIL_BUYING;  pstProfileHdr->TimeStamp = time (NULL);  printf ("\nEnter Name (a string):  ");  strget (pstProfileHdr->Name);  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 (linkId, msgType, NULL, (char) TAC_ALL,  			       message, msgSize);  if (status)    {    ICA_Log_Err2 ("ERROR:  icSendTypedMessage status = %d %s",                  status, icPerror(status));    printf ("\n\nSend Message Failed %d %s", status, icPerror (status));    }  else    {    ICA_Log_Flow0 ("icSendTypedMessage OK!");    printf ("icSendTypedMessage OK!");    }  chk_free (message);  }/************************************************************************//* sendB8Request:  send Block 8 request for transfer account		*//************************************************************************/static void sendB8Request (int msgType, icLinkId linkId)  {icMsgTypeBlock8Request	tkMsg;icTypeAccountReq	*pstMsgPtr;icInt			msgSize, status;icUChar			*message;unsigned char 		hexBuffer[100];  /* determine message size 	*/  msgSize = sizeof (icTypeIccpHeader) + sizeof (icTypeAccountReq);  pstMsgPtr = &tkMsg.MsgTypeHeader;  message = (icUChar *) &tkMsg;  /* fill up the message struct */  printf ("\nEnter Transfer Account Reference (an integer):  ");  intget ((ST_INT *)&pstMsgPtr->ReferenceTar);  pstMsgPtr->StartTime = time (NULL);  printf ("\nEnter Duration in seconds:  ");  intget ((ST_INT *)&pstMsgPtr->Duration);  printf ("\nEnter Request ID (an integer):  ");  intget ((ST_INT *)&pstMsgPtr->RequestId);  printf ("\nEnter Condition in HEX:  ");  input_hex (hexBuffer, 1);  pstMsgPtr->TAConditionsRequested = hexBuffer[0];  /* send the message	*/  status = icSendTypedMessage (linkId, msgType, NULL, (char) TAC_ALL,  			       message, msgSize);  if (status)    {    ICA_Log_Err2 ("ERROR:  icSendTypedMessage status = %d %s",                  status, icPerror(status));    printf ("\n\nSend Message Failed %d %s", status, icPerror (status));    }  else    {    ICA_Log_Flow0 ("icSendTypedMessage OK!");    printf ("icSendTypedMessage OK!");    }  }/************************************************************************//* sendDONewRev:  send New or Revised Device Outage message		*//************************************************************************/static void sendDONewRev (int msgType, icLinkId linkId)  {icMsgTypeDONewRev	tkMsg;icTypeDONewRevSched	*doMsgPtr;icInt			msgSize, status, anInt;icUChar			*message;  /* determine message size 	*/  msgSize = sizeof (icTypeIccpHeader) + sizeof (icTypeDONewRevSched);  doMsgPtr = &tkMsg.MsgTypeHeader;  message = (icUChar *) &tkMsg;  /* fill up the message struct */  doMsgPtr->OutageRefId = msgType;  printf ("\nEnter OutageUtility ID (an integer): ");  intget ((ST_INT *)&doMsgPtr->OutageUtilityId);  doMsgPtr->TimeStamp = time (NULL);    printf ("\nEnter Station Name (a string):  ");  strget(doMsgPtr->StationName);  printf ("\nEnter Device Name (a string):  ");  strget (doMsgPtr->DeviceName);  printf ("\nEnter Device Type (0 thru 6):  ");  intget (&doMsgPtr->DeviceType);  printf ("\nEnter Device Number (an integer):  ");  intget (&anInt);  doMsgPtr->DeviceNumber = (icNumberType) anInt;  printf ("\nEnter Device Rating (a real):  ");  floatget (&doMsgPtr->DeviceRating);  doMsgPtr->ActivityDateAndTime = time (NULL) + 3600;  printf ("\nEnter Plan Type (0 or 1):  ");  intget (&anInt);  doMsgPtr->PlanType = (icPlanTypeIdType) anInt;  doMsgPtr->PlanOpenOOSDateTime = time (NULL) + 36000;  doMsgPtr->PlanCloseISDateTime = time (NULL) + 72000;    printf ("\nEnter Outage Period  (0 thru 3):  ");  intget (&anInt);  doMsgPtr->OutagePeriod = (icOutagePeriodIdType) anInt;  printf ("\nEnter Outage Type (0 thru 6):  ");  intget (&anInt);  doMsgPtr->OutageType = (icOutageTypeIdType) anInt;  printf ("\nEnter Amount (a real):  ");  floatget (&doMsgPtr->Amount);  printf ("\nEnter Upper Operating Limit (a real):  ");  floatget (&doMsgPtr->UpperOperLimit);  printf ("\nEnter Lower Operating Limit (a real):  ");  floatget (&doMsgPtr->LowerOperLimit);  printf ("\nEnter Class (0 or 1):  ");  intget (&anInt);  doMsgPtr->Class = (icClassIdType) anInt;  printf ("\nEnter Comments (a string):  ");  strget (doMsgPtr->Comments);		     printf ("\nEnter Outage Effect (a string):  ");  strget (doMsgPtr->OutageEffect);  /* send the message	*/

⌨️ 快捷键说明

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