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

📄 ictab4b8.c

📁 ICCP Toolkit 是在 Tru64下开发Tase.2通信协议的开发包
💻 C
📖 第 1 页 / 共 5 页
字号:
  				       block8ConditionsCB,				       (icUserData) pstRemote);  if (status)    {    ICA_Log_Err2("ERROR:  RegisterBlock8CondCallbacks status=%d %s\n",                  status, icPerror (status));    printf ("\nRegisterBlock8CondCallbacks status=%d %s", status, icPerror (status));    }  else    {    ICA_Log_Flow0("RegisterBlock8CondCallbacks OK");    printf ("\nRegisterBlock8CondCallbacks successful for %s", pstRemote->remoteName);    }  pause_msg("\nPress a key to continue!");  showCurrMenu();  }/************************************************************************//* b4b8SendMsg:  Send block 4 or block 8 message			*//************************************************************************/void b4b8SendMsg (void)  {ST_BOOLEAN dataEntered;ST_CHAR    buffer[100], messageName[100];ICTA_REMOTE_INFO *pstRemote;ICTA_LINK_INFO *pstLink;int i;  printf("\n\nSend Block 4 or Block 8 message . . .\n");  for (i=0; i < NUM_SEND_SERVICES; i++)    printf ("\n\t\t%s", ictaB4B8SendTbl[i].name);  printf("\nEnter Type of Message (see the list above):  ");    dataEntered = strget(messageName);  if (!dataEntered)    {    pause_msg("\nPress a key to continue!");    showCurrMenu();    return;    }  printf ("\nEnter Remote Name:  ");    dataEntered = strget(buffer);  if (!dataEntered)    {    pause_msg("\nPress a key to continue!");    showCurrMenu();    return;    }  pstRemote = findRemote(ICTA_NOONE, buffer);  if (!pstRemote)    {    printf("\nInvalid Remote Name!!!!!\n\n");    pause_msg("\nPress a key to continue!");    showCurrMenu();    return;    }  pstLink = findOutWhichLink(&pstRemote);  if (!pstLink)    {    printf("\nInvalid Link Name!!!!!\n\n");    pause_msg("\nPress a key to continue!");    showCurrMenu();    return;    }  for (i=0; i < NUM_SEND_SERVICES; i++)    {    if (stricmp (messageName, ictaB4B8SendTbl[i].name) == 0)      {      (*ictaB4B8SendTbl[i].fpSendService) (ictaB4B8SendTbl[i].constant, pstLink->linkId);      break;      }    }  pause_msg("\nPress a key to continue!");  showCurrMenu();  }/************************************************************************//* Block 4 and Block 8 callback functions				*//************************************************************************//************************************************************************//* receiveMessageCB:  see icRegisterMessageCallbacks			*//************************************************************************/static void receiveMessageCB (icMessageStatus status,			      icLinkId        linkId,			      icInt           variableType,			      icMessageId     messageId,			      icBoolean       referIdValid,			      icReferenceId   referenceId,			      icUChar         *message,			      icInt           messageSize,			      icUserData      userData)  {RECV_MSG stRecvMsg;ICTA_REMOTE_INFO *pstRemote;ICTA_LINK_INFO   *pstLink;icBoolean bFound = icFalse;  pstRemote = (ICTA_REMOTE_INFO *) userData;  pstLink = pstRemote->linkList;  while (pstLink && !bFound)    {    if (pstLink->linkId == linkId)      {      printf ("\nReceived Message Callback for %s for remote %s",               pstLink->linkName, pstRemote->remoteName);      bFound = icTrue;      }    else      pstLink = list_get_next (pstRemote->linkList, pstLink);    }  if (!bFound)     {     printf ("\n Received Message Callback for UNKNOWN link on remote %s",              pstRemote->remoteName);     }  stRecvMsg.status = status;  stRecvMsg.variableType = variableType;  stRecvMsg.messageId = messageId;  stRecvMsg.referIdValid = referIdValid;  stRecvMsg.referenceId = referenceId;  stRecvMsg.message = message;  stRecvMsg.messageSize = messageSize;  stRecvMsg.userData = userData;		/*ICTA_REMOTE_INFO * */  switch (variableType)    {    case IC_MSG_TYPE_B4_DATA:      recvB4Data (&stRecvMsg);      break;    case IC_MSG_TYPE_TA_SEG_PRD:      recvSegPrd (&stRecvMsg);      break;    case IC_MSG_TYPE_TA_PERIODIC:      recvPeriodic (&stRecvMsg);      break;    case IC_MSG_TYPE_TA_SEG_PRF:      recvSegPrf (&stRecvMsg);      break;    case IC_MSG_TYPE_TA_PROFILE:      recvProfile (&stRecvMsg);      break;    case IC_MSG_TYPE_B8_REQUEST:      recvB8Request (&stRecvMsg);      break;    case IC_MSG_TYPE_DO_NEW:      recvDONew (&stRecvMsg);      break;    case IC_MSG_TYPE_DO_REVISED:      recvDORevised (&stRecvMsg);      break;    case IC_MSG_TYPE_DO_CANCEL:      recvDOCancel (&stRecvMsg);      break;    case IC_MSG_TYPE_DO_ACTUAL:      recvDOActual (&stRecvMsg);      break;    case IC_MSG_TYPE_PL_AVAILABLE:      recvPlAvail (&stRecvMsg);      break;    case IC_MSG_TYPE_PL_UNAVAILABLE:      recvPlUnavail (&stRecvMsg);      break;    case IC_MSG_TYPE_PL_RT_STATUS_AVAIL:      recvPlStatusAvail (&stRecvMsg);      break;    case IC_MSG_TYPE_PL_RT_STATUS_UNAVAIL:      recvPlStatusUnavail (&stRecvMsg);      break;    case IC_MSG_TYPE_PL_FORECAST:      recvPlForecast (&stRecvMsg);      break;    case IC_MSG_TYPE_PL_CURVE:      recvPlCurve (&stRecvMsg);      break;    case IC_MSG_TYPE_GEN_DATA_REPORT:      recvGenDataRpt (&stRecvMsg);      break;    case IC_MSG_TYPE_GEN_DATA_RESPONSE:      recvGenDataRsp (&stRecvMsg);      break;    default:      printf ("\n\n An Unknown Message type was received!");      break;    }  }/************************************************************************//* block4ConditionsCB:  see icRegisterBlock4Conditions			*//************************************************************************/static void block4ConditionsCB (icLinkId   linkId,			        icBoolean  condition,				icUserData userData)  {ICTA_REMOTE_INFO *pstRemote;  pstRemote = (ICTA_REMOTE_INFO *) userData;  printf ("\n\nBlock 4 Conditions Callback:");  printf ("\n\tRemote %s Block 4 Conditions %s", pstRemote->remoteName,  	  condition ? "Enabled" : "Disabled");  if (!bAutoResponse)    {    pause_msg("\nPress a key to continue!");    showCurrMenu();    }  }/************************************************************************//* block8ConditionsCB:  see icRegisterBlock8Conditions			*/ /************************************************************************/static void block8ConditionsCB (icLinkId   linkId,				icChar     condition,				icUserData userData)  {ICTA_REMOTE_INFO *pstRemote;  pstRemote = (ICTA_REMOTE_INFO *) userData;  pstRemote->taConditions = condition;  printf ("\n\nBlock 8 Conditions Callback:");  printf ("\n\tRemote %s Block 8 Conditions:  ", pstRemote->remoteName);  printf ("\n\tCondition = '%d'", condition);  if (condition == TAC_ALL)    printf ("\n\tAll Conditions enabled");  else if (condition == TAC_NONE)    printf ("\n\tNO Conditions enabled");  else    {    if (condition & TAC_BEFORE_HOUR)      printf ("\n\tBeforeTheHour Enabled");    if (condition & TAC_DISPATCH_UPDATE)      printf ("\n\tDispatchUpdate Enabled");    if (condition & TAC_DURING_HOUR)      printf ("\n\tDuringTheHour Enabled");    if (condition & TAC_AFTER_HOUR)      printf ("\n\tAfterTheHour Enabled");    if (condition & TAC_ACTUAL_UPDATE)      printf ("\n\tActualUpdate Enabled");    if (condition & TAC_PAST_HOURS)      printf ("\n\tPastHours Enabled");    if (condition & TAC_OBJECT_CHANGE)      printf ("\n\tObjectChange Enabled");    if (condition & TAC_OPERATOR_REQUEST)      printf ("\n\tOperatorRequest Enabled");    }  if (!bAutoResponse)    {    pause_msg("\nPress a key to continue!");    showCurrMenu();    }  }/************************************************************************//* Support functions to send a typed message:				*//************************************************************************//* sendB4Data:  send a Block 4 Information Message			*//************************************************************************/static void sendB4Data (int msgType, icLinkId linkId)  {icMsgTypeBlock4Data	*ptkMsg;icTypeInfoBufferHeader	*pstMsgPtr;icTypeIccpHeader	*pstHeader;icInt			msgSize, status, infoSize=0;icUChar			*message, *temp;char			*msgBuf;ST_CHAR textFileName[128];ST_BOOLEAN dataEntered;  printf ("\nEnter InfoBuf Size:  ");  intget (&infoSize);  if (!infoSize)    {    printf ("\nEnter FileName:  ");    dataEntered = strget(textFileName);    if (dataEntered)      sendB4TextFile (msgType, linkId, textFileName);    showCurrMenu();    return;    }  /* determine message size 	*/  msgSize = sizeof (icMsgTypeBlock4Data) + infoSize + 1;  ptkMsg = chk_malloc (msgSize);  msgBuf = chk_malloc (infoSize + 1);  pstMsgPtr = &ptkMsg->MsgTypeHeader;  pstHeader = &ptkMsg->MsgHeader;  message = (icUChar *) ptkMsg;  /* take care of the header	*/  getHdrData ();  pstHeader->RemoteId = _hdrRemoteId;  pstHeader->RequestId = _hdrRequestId;  pstHeader->DestinationId = _hdrDestId;  pstHeader->ReferenceNumber = _hdrRefNum;  pstHeader->MessageType = msgType;  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;  printf ("\nEnter the Message (text):  ");  strget (msgBuf);  temp = message + sizeof (icMsgTypeBlock4Data);  memset (temp, 0, infoSize);  strcpy ((char *) temp, msgBuf);  /* 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);  chk_free (msgBuf);  }/************************************************************************//* sendB4TextFile: send block 4 message read from a text file		*//************************************************************************/static void sendB4TextFile (int msgType, icLinkId linkId, ST_CHAR *textFilename)  {icMsgTypeBlock4Data	*ptkMsg;icTypeInfoBufferHeader	*pstMsgPtr;icTypeIccpHeader	*pstHeader;icInt			msgSize, status, infoSize;icUChar			*message;char			*msgBuf;int maxBuf = 10000, ch;FILE *fPtr;  /* first read the text file and stash it in a buffer			*/  if ((fPtr  = fopen( textFilename, "r" )) == NULL )    {    printf ("\n Unable to open text file %s", textFilename);    return;    }  ptkMsg = chk_calloc (1, maxBuf + sizeof (icMsgTypeBlock4Data) + 1);  infoSize = 0;  message = (icUChar *) ptkMsg;  msgBuf = (char *) (message + sizeof (icMsgTypeBlock4Data));  ch = fgetc (fPtr);  while (!feof (fPtr) && (infoSize < maxBuf))    {    msgBuf[infoSize++] = (char) ch;    ch = fgetc (fPtr);    }  fclose (fPtr);  infoSize++;	    /* determine message size 	*/  msgSize = sizeof (icMsgTypeBlock4Data) + infoSize;  pstMsgPtr = &ptkMsg->MsgTypeHeader;  pstHeader = &ptkMsg->MsgHeader;  /* take care of the header	*/  getHdrData ();  pstHeader->RemoteId = _hdrRemoteId;  pstHeader->RequestId = _hdrRequestId;  pstHeader->DestinationId = _hdrDestId;  pstHeader->ReferenceNumber = _hdrRefNum;  pstHeader->MessageType = msgType;

⌨️ 快捷键说明

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