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

📄 icta_dev.c

📁 ICCP Toolkit 是在 Tru64下开发Tase.2通信协议的开发包
💻 C
📖 第 1 页 / 共 2 页
字号:
        theErrCode=0;      }    else      theErrCode = 0;    }  ICA_Log_CFlow1 ("  Returning Status=%d", theErrCode);  status = icOperateResponse(pstDevice->deviceId, theErrCode);  printf ("\n\nOperate Response Sent with Status = %d", theErrCode);  if (status)    {    printf("\nOperate Device Response Failed - see log file for details");    ICA_Log_Err3("ERROR:  operate device response%s status =%d %s",                 pstDevice->name, status, icPerror(status));    }  if (!bAutoResponse)    {    pause_msg("\nPress a key to continue!");    showCurrMenu();    }  }/************************************************************************//* selectDevConf:  the client received a select device confirmation	*//************************************************************************/void selectDevConf (icSelectStatus status, icCheckbackID checkbackID,                    icUserData ud)  {ICTA_DEVICE *pstDevice;  pstDevice = (ICTA_DEVICE *)ud;  printf("\nThe selection of device %s has been confirmed!", pstDevice->name);  printf("\nThe checkback ID = %d", checkbackID);  switch (status)    {    case icssSelectOk:      printf("\nThe status = SelectOk");      break;    case icssNoSuchDevice:      printf("\nThe status = NoSuchDevice");      break;    case icssAccessDenied:      printf("\nThe status = AccessDenied");      break;    case icssDeviceInoperable:      printf("\nThe status = DeviceInoperable");      break;    case icssDeviceTempUnavail:      printf("\nThe status = DeviceTemporaryilyUnavailable");      break;    case icssOtherError:      printf("\nThe status = OtherError");      break;    default:      printf("\nINVALID MMSOP_STATUS!");      break;    }  ICA_Log_Flow1 ("Client SELECT Device Confirmation for Device %s",                 pstDevice->name);  ICA_Log_CFlow2 (" Received CheckBackID %d, Status %d", checkbackID, status);  pstDevice->checkBackId = checkbackID;  if (!bAutoResponse)    {    pause_msg("\nPress a key to continue!");    showCurrMenu();    }  }/************************************************************************//* operateDevConf:  the client receive an operate device confirmation	*//************************************************************************/void operateDevConf (icOperStatus status, icUserData ud)  {ICTA_DEVICE *pstDevice;  pstDevice = (ICTA_DEVICE *)ud;  printf("\nOperate Device %s Confirmation", pstDevice->name);  printf("\nThe returned status = %d", status);    switch (status)    {    case icosOperateOk:      printf("\nThe Status = OperateOk");      break;    case icosNoSuchDevice:      printf("\nThe Status = NoSuchDevice");      break;    case icosAccessDenied:      printf("\nThe Status = AccessDenied");      break;    case icosDeviceInoperable:      printf("\nThe Status = Device Inoperable");      break;    case icosDeviceTempUnavail:      printf("\nThe Status = DeviceTemporarilyUnavailable");      break;    case icosOtherError:      printf("\nThe Status = Other Error!!!");      break;    default:      printf("\nINVALID STATUS");      break;    }  ICA_Log_Flow2("Client OPERATE Device Confirmation for Device %s, status %d",                 pstDevice->name, status);  if (!bAutoResponse)    {    pause_msg("\nPress a key to continue!");    showCurrMenu();    }  }      /************************************************************************//* getDeviceTag:  local client option to get a remote device tag	*//************************************************************************/void getDeviceTag (void)  {ICTA_REMOTE_INFO *pstRemote;ICTA_LINK_INFO   *pstLink;ICTA_DEVICE	 *pstDevice;ST_BOOLEAN	 dataEntered;ST_CHAR		 buffer[100];icInt		 status;ST_BOOLEAN	 bIsClient = SD_FALSE;  printf("\n\nGet Device Tag. . .\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("\nGet Device Tag is a CLIENT ONLY Operation!");    pause_msg("\nPress a key to continue!");    showCurrMenu();    return;    }  pstRemote = pstVCC->remoteList;  pstLink = findOutWhichLink(&pstRemote);  if (!pstLink)    {    printf("\nInvalid Link!!!");    pause_msg("\nPress a key to continue!");    showCurrMenu();    return;    }   printf("\nEnter Device Name:  ");  dataEntered = strget(buffer);  pstDevice = findClientDevice(buffer, pstRemote);  if (!pstDevice)    {    printf("\nInvalid Device Name!!!");    pause_msg("\nPress a key to continue!");    showCurrMenu();    return;    }   status = icGetTag (pstDevice->deviceId,   		     pstLink->linkId,		     getDevTagConf,		     (icUserData) pstDevice);  if (status)    {    printf ("\nGet Device Tag Failed ");    printf ("\nStatus=%d %s", status, icPerror (status));    ICA_Log_Err3("ERROR:  get device tag %s status =%d %s",                 pstDevice->name, status, icPerror(status));    }  else    {    printf ("\nGetTag Device %s Request Issued", pstDevice->name);    ICA_Log_Flow1 ("GetTag Device Request Issued for Device %s", pstDevice->name);    }  pause_msg("\nPress a key to continue!");  showCurrMenu();  }/************************************************************************//* setDeviceTag:  local client option to set a remote device tag	*//************************************************************************/void setDeviceTag (void)  {ICTA_REMOTE_INFO *pstRemote;ICTA_LINK_INFO   *pstLink;ICTA_DEVICE	 *pstDevice;ST_BOOLEAN	 dataEntered;ST_CHAR		 buffer[100];icInt		 status;ST_BOOLEAN	 bIsClient = SD_FALSE;ST_INT	   	 tagValue;  printf("\n\nSet Device Tag. . .\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("\nSet Device Tag is a CLIENT ONLY Operation!");    pause_msg("\nPress a key to continue!");    showCurrMenu();    return;    }  pstRemote = pstVCC->remoteList;  pstLink = findOutWhichLink(&pstRemote);  if (!pstLink)    {    printf("\nInvalid Link!!!");    pause_msg("\nPress a key to continue!");    showCurrMenu();    return;    }   printf("\nEnter Device Name:  ");  dataEntered = strget(buffer);  pstDevice = findClientDevice(buffer, pstRemote);  if (!pstDevice)    {    printf("\nInvalid Device Name!!!");    pause_msg("\nPress a key to continue!");    showCurrMenu();    return;    }   printf("\nEnter tag value (0 to 2):  ");  if (!(dataEntered = intget(&tagValue)))      tagValue=0;			  buffer[0] = '\0';  printf ("\nEnter tag reason:  ");  dataEntered = strget (buffer);  status = icSetTag (pstDevice->deviceId,   		     pstLink->linkId,		     tagValue,		     buffer,		     setDevTagConf,		     (icUserData) pstDevice);  if (status)    {    printf ("\nSet Device Tag Failed ");    printf ("\nStatus=%d %s", status, icPerror (status));    ICA_Log_Err3("ERROR:  set device tag %s status =%d %s",                 pstDevice->name, status, icPerror(status));    }  else    {    printf ("\nSetTag Device %s Request Issued", pstDevice->name);    ICA_Log_Flow1 ("SetTag Device Request Issued for Device %s", pstDevice->name);    }  pause_msg("\nPress a key to continue!");  showCurrMenu();  }/************************************************************************//* getDevTagInd:  remote client request to get a local device tag has	*//*		  been received.					*//************************************************************************/static int reasonCount = 0;void getDevTagInd (icRemoteId remoteId, icUserData userData)  {ICTA_DEVICE *pstDevice;icInt status;ST_BOOLEAN dataEntered;ST_CHAR	buffer[100];static ST_INT getTagErrCode = -1;ST_INT theTagErrCode;ST_INT theTagValue;  pstDevice = (ICTA_DEVICE *)userData;  printf("\n*** Received a Get Tag indication for device %s.",          pstDevice->name);  ICA_Log_Flow1("Server GETTAG Indication for Device %s", pstDevice->name);  if (bAutoResponse)    sprintf (buffer, "reason #%d", reasonCount++);  else    {    printf("\nEnter Get Tag Reason for Device %s:  ", pstDevice->name);    dataEntered = strget(buffer);    }  if (bSendErrorResp)    theTagErrCode = (++getTagErrCode) % 4;  else    {    theTagErrCode = 0;    ++getTagErrCode;    }  theTagValue = getTagErrCode % 3;  if (!bAutoResponse)    {    if (ask ("\n Send Error Response (N)? ",SD_FALSE))      {      printf("\nEnter Error Code (1 to 3):  ");      if (!(dataEntered = intget(&theTagErrCode)))        theTagErrCode=0;      }    else      theTagErrCode = 0;    }  ICA_Log_CFlow3 ("  Returning TagValue %d, Reason %s, Status %d",  		     tv_close_only_inhibit, buffer, theTagErrCode);  status = icGetTagResponse(pstDevice->deviceId,  			    theTagValue,			    buffer,			    theTagErrCode);  printf ("\n\nGetTagResponse sent with status =%d, TagValue=%d, Reason=%s",  		     theTagErrCode, theTagValue, buffer);  if (status)    {    printf("\nGet Device Tag Response Failed - see log file for details");    ICA_Log_Err3("ERROR:  Get Device Tag response%s status =%d %s",                 pstDevice->name, status, icPerror(status));    }  if (!bAutoResponse)    {    pause_msg("\nPress a key to continue!");    showCurrMenu();    }  }/************************************************************************//* setDevTagInd:  remote client request to set a local device tag has	*//*		  been received.					*//************************************************************************/void setDevTagInd (icRemoteId remoteId, icTagValue tagValue,		   char *reason, icUserData userData)  {ICTA_DEVICE *pstDevice;icInt status;ST_BOOLEAN dataEntered;static ST_INT setTagErrCode = -1;ST_INT theTagErrCode;  pstDevice = (ICTA_DEVICE *)userData;  printf ("\n*** Received a Set Tag indication for device %s.",          pstDevice->name);  printf ("\n\tTagValue = %d, Reason=%s", tagValue, reason);  ICA_Log_Flow1 ("Server SETAG Indication for Device %s", pstDevice->name);  ICA_Log_CFlow2 ("  Received TagValue %d, Reason %s", tagValue, reason);  if (bSendErrorResp)    theTagErrCode = (++setTagErrCode) % 4;  else    theTagErrCode = 0;  if (!bAutoResponse)    {    if (ask ("\n Send Error Response (N)? ",SD_FALSE))      {      printf("\nEnter Error Code (1 to 3):  ");      if (!(dataEntered = intget(&theTagErrCode)))        theTagErrCode=0;      }    else      theTagErrCode = 0;    }  ICA_Log_CFlow1 ("  Returning Status %d", theTagErrCode);  status = icSetTagResponse(pstDevice->deviceId,			    theTagErrCode);  printf ("\n\nSetTagResponse sent with status = %d", theTagErrCode);  if (status)    {    printf("\nSet Device Tag Response Failed - see log file for details");    ICA_Log_Err3("ERROR:  Set Device Tag response%s status =%d %s",                 pstDevice->name, status, icPerror(status));    }  if (!bAutoResponse)    {    pause_msg("\nPress a key to continue!");    showCurrMenu();    }  }/************************************************************************//* getDevTagConf:  local clients request to get a remote device tag has	*//*		   been completed - here is the data			*//************************************************************************/void getDevTagConf (icGetTagStatus status, icTagValue tagValue,		    char *reason, icBoolean bArmed, 		    icUserData userData)  {ICTA_DEVICE *pstDevice;  pstDevice = (ICTA_DEVICE *)userData;  printf ("\nGet Device Tag %s Confirmation", pstDevice->name);  printf ("\n\tTagValue  = %d", tagValue);  printf ("\n\tTagReason = %s", reason);  printf ("\n\tArmed     = %d", bArmed);  printf ("\n\tTagStatus = %d", status);    switch (status)    {    case icgtGetTagOk:      printf("\tGetTagOk");      break;    case icgtNoTagAttribute:      printf("\tNoTagAttribute");      break;    case icgtAccessDenied:      printf("\tAccessDenied");      break;    case icgtDeviceTempUnavail:      printf("\tDeviceTemporarilyUnavailable");      break;    case icgtOtherError:      printf("\tOther Error!!!");    default:      printf("\tINVALID STATUS");      break;    }  ICA_Log_Flow2("Client GETTAG Confirmation for Device %s, status %d",                 pstDevice->name, status);  ICA_Log_CFlow3 ("  Received TagValue %d; TagReason %s; Armed %d",  		   tagValue, reason, bArmed);  if (!bAutoResponse)    {    pause_msg("\nPress a key to continue!");    showCurrMenu();    }  }/************************************************************************//* setDevTagConf:  localclients request to set a remote device tag has	*//*		   been completed - here is the result			*//************************************************************************/void setDevTagConf (icSetTagStatus status, icUserData userData)  {ICTA_DEVICE *pstDevice;  pstDevice = (ICTA_DEVICE *)userData;  printf ("\nSet Device Tag %s Confirmation", pstDevice->name);  printf("\nThe Tag status = %d", status);    switch (status)    {    case icstSetTagOk:      printf("\tSetTagOk");      break;    case icstNoTagAttribute:      printf("\tNoTagAttribute");      break;    case icstAccessDenied:      printf("\tAccessDenied");      break;    case icstDeviceTempUnavail:      printf("\tDeviceTemporarilyUnavailable");      break;    case icstOtherError:      printf("\tOther Error!!!");    default:      printf("\nINVALID STATUS");      break;    }  ICA_Log_Flow2("Client SETTAG Confirmation for Device %s, status %d",                 pstDevice->name, status);  if (!bAutoResponse)    {    pause_msg("\nPress a key to continue!");    showCurrMenu();    }  }

⌨️ 快捷键说明

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