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

📄 ab_stat.c

📁 基于EthernetIP协议的应用程序,可以读取AB公司Controllogix系列Ethernetip协议PLC数据. 此软件代码可用于工业控制.
💻 C
字号:
/****************************************************************************
*****************************************************************************
**
** File Name
** ---------
**
** AB_STAT.C
**
*****************************************************************************
*****************************************************************************
**
** Description
** -----------
**
** Status code to text string conversion.
**
*****************************************************************************
*****************************************************************************
**
** Source Change Indices
** ---------------------
**
** Porting: <none>0----<major>         Customization: <none>0----<major>
**
*****************************************************************************
*****************************************************************************
**                                                                         **
** ETHERNET/IP EXAMPLE CODE                                                **
** COPYRIGHT (c) 2000-2005 ODVA (Open DeviceNet Vendor Association)		   **
**						   & ControlNet International Ltd.                 **
**                                                                         **
** All rights reserved, except as specifically licensed in writing.        **
** Use of the Ethernet/IP Example Protocol Software is subject to          **
** ODVA's and ControlNet International's Terms of Use Agreement.           **
** The following work constitutes example program code and is intended     **
** merely to illustrate useful programming techniques.  The user is        **
** responsible for applying the code correctly.  The code is provided      **
** AS IS without warranty and is in no way guaranteed to be error-free.    **
**                                                                         **
*****************************************************************************
*****************************************************************************
*/

/****************************************************************************
*****************************************************************************
**
** Change Log
** ----------
**
**
*****************************************************************************
*****************************************************************************
*/

/*
** See if this code is to be included.
*/

#include "ab.h"
#ifdef STATUS_STRINGS



/****************************************************************************
**
** Private typedef
**
*****************************************************************************
*/

/*---------------------------------------------------------------------------
**
** ab_StatusStringType
**
** Structure to map a status code to a text string describing it.
** Done this way since the status codes are scattered through the available
** values of an int.
**
**---------------------------------------------------------------------------
*/

typedef struct ab_StatusStringType
{
   StatusType eStatus;
   char *pachText;
}
ab_StatusStringType;



/****************************************************************************
**
** Private data
**
*****************************************************************************
*/

/*---------------------------------------------------------------------------
**
** ab_asStatusStrings[]
**
** Status code to string translation table.
**
** Built from the information contained in the status code macro files:
**    ab_stat.h  --- Contains the basic example code status codes
**    abu_stat.h --- Contains the user specified status codes
** These macro files contain lists of status code names, status code numbers,
** and status text strings.
**
**---------------------------------------------------------------------------
*/

/*
** Define the status definition macros to extract the information needed
** to fill the status code to string translation table.
**
** STATUS_S defines a status code with a specific number.
*/

#undef  STATUS_S
#define STATUS_S( name, code, string )  { name, string },

/*
** Now declare and initialize the translation table from the
** common and user specified status codes.
** Add a final entry to mark the end of the table.
*/

ab_StatusStringType ab_asStatusStrings[] =
{
#include "ab_stat.h"
#include "abu_stat.h"
   { 0x7FFF, "Undefined status code" }

}; /* end of ab_asStatusStrings[] */



/****************************************************************************
**
** Public Services
**
*****************************************************************************
*/

/*---------------------------------------------------------------------------
** AB_GetStatusTextString()
**---------------------------------------------------------------------------
*/

char *AB_GetStatusTextString( StatusType eStatus )
{
   ab_StatusStringType *psStatus;


   /*
   ** Scan through the status code / text table for a match.
   ** There is a special end of table marker that catches
   ** status codes not in the list.
   */

   psStatus = &ab_asStatusStrings[ 0 ];

   while ( ( psStatus->eStatus != 0x7FFF ) &&
      ( psStatus->eStatus != eStatus ) )
   {
      psStatus++;
   }

   /*
   ** Return a pointer to the character string for the status code.
   */

   return( psStatus->pachText );

} /* end of AB_GetStatusTextString() */



#endif /* STATUS_STRINGS */

/****************************************************************************
**
** End of AB_STAT.C
**
*****************************************************************************
*/

⌨️ 快捷键说明

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