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

📄 ab.h

📁 基于EthernetIP协议的应用程序,可以读取AB公司Controllogix系列Ethernetip协议PLC数据. 此软件代码可用于工业控制.
💻 H
字号:
/****************************************************************************
*****************************************************************************
**
** File Name
** ---------
**
** AB.H
**
*****************************************************************************
*****************************************************************************
**
** Description
** -----------
**
** This module contains the public interfaces of the basic services API.
**
*****************************************************************************
*****************************************************************************
**
** Source Change Indices
** ---------------------
**
** Porting: <none>0----<major>         Customization: <none>0----<major>
**
*****************************************************************************
*****************************************************************************
**
** Services List
** -------------
**    AB_Exit                    General cleanup prior to exiting.
**    AB_GetStatusTextString()   Get a text string for a given status code.
**    AB_Init()                  General initialization.
**    AB_PreInit()               General pre-initialization.
**
** Private services
** ----------------
**    ab_Init()                  Internal initialization.
**    ab_Verify()                Initialization error checking shorthand.
**
** User provided private services
** ------------------------------
**    abu_AcquireInterrupts()    User defined hooking of interrupts.
**    abu_Exit()                 User defined exit cleanup.
**    abu_Init()                 User defined initialization.
**    abu_PreInit()              User defined pre-initialization.
**    abu_RelinquishInterrupts() User defined releasing of interrupts.
**
*****************************************************************************
*****************************************************************************
**                                                                         **
** 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.    **
**                                                                         **
*****************************************************************************
*****************************************************************************
*/


#ifndef AB_H
#define AB_H

#include <stddef.h>     /* need for NULL and other ANSI standard things    */

#include "ab_env.h"     /* overall environment selections (coarse tuning)  */
#include "ab_cfg.h"     /* overall configuration selections (fine tuning)  */
#include "ab_rev.h"     /* example code revision numbers                   */

#include "fd.h"         /* fundamental defs - generic stuff                */
#include "fd_comp.h"    /* fundamental defs - compiler specific stuff      */



/****************************************************************************
*****************************************************************************
**
** Public internal object interface - Constants
**
*****************************************************************************
*****************************************************************************
*/

/*---------------------------------------------------------------------------
**
** Number of connection status bits and an invalid bit number identifier.
**
**---------------------------------------------------------------------------
*/

#define AB_NUM_CONN_STATUS_BITS  256

#define AB_NO_CONN_STATUS_BIT    ( AB_NUM_CONN_STATUS_BITS - 2 )

/*---------------------------------------------------------------------------
**
** AB_DataType
**
** Global data supplied by the user for configuring various pieces
** of the example code.
**
** The values in this structure are filled in during pre-initialization.
**
**---------------------------------------------------------------------------
*/

typedef struct AB_DataType
{
   /*
   ** Our initial MAC Id.
   ** Set to 0 to stay offline until an online tribble toss to CD.
   */

   UINT8  bMacId;

   /*
   ** Base address and sizes for the heap.
   */

   void *pHeapBase;
   UINT32           lHeapSize;

   /*
   ** Pointer to the connection status bit array.
   */

   UINT8           *pabConnectionStatus;

} AB_DataType;



/*---------------------------------------------------------------------------
**
** StatusType
**
** Status code enumeration.
** 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 build the status enum.
**
** STATUS_S defines a status code with a specific number.
*/

#undef  STATUS_S
#define STATUS_S( name, code, string )  name = code,

/*
** Now build the enum from the common and user specified status codes.
** Add a final code to mark the end of the list.
*/

typedef enum StatusType
{
#include "ab_stat.h"
#include "abu_stat.h"
   LAST_STATUS_CODE = 0x7FFF
}
StatusType;



/*---------------------------------------------------------------------------
**
** Initialization flags.
** These are common bit mask parameters for component initialization
** functions (like CM_Init()...)
**
**---------------------------------------------------------------------------
*/

#define AB_CREATE_RESOURCE       0x0001
#define AB_INIT_RESOURCE         0x0002
#define AB_CREATE_TASK           0x0004
#define AB_INIT_TASK             0x0008
#define AB_PREPARE_FOR_RESTART   0x0010

#define AB_COLD_START_RESOURCE   AB_CREATE_RESOURCE+AB_INIT_RESOURCE
#define AB_COLD_START_TASK       AB_CREATE_TASK+AB_INIT_TASK
#define AB_PREP_WARM_START       AB_PREPARE_FOR_RESTART
#define AB_WARM_START            AB_INIT_RESOURCE+AB_INIT_TASK



/****************************************************************************
**
** Public Data
**
*****************************************************************************
*/

/*---------------------------------------------------------------------------
**
** AB_s
**
** Global configuration data.  Filled in by the user.
**
**---------------------------------------------------------------------------
*/

extern AB_DataType  AB_s;



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

/*---------------------------------------------------------------------------
**
** AB_Exit()
**
** Cleanup prior to exiting the example code.
**
**---------------------------------------------------------------------------
**
** Inputs:
**    None
**
** Outputs:
**    None
**
** Usage:
**    AB_Exit();
**
**---------------------------------------------------------------------------
*/

EXTFUNC void AB_Exit( void );



/*---------------------------------------------------------------------------
**
** AB_GetStatusTextString( )
**
** Return a text string that describes a given status code.
** Undefined status codes will return an appropriate string.
**
**---------------------------------------------------------------------------
**
** Inputs:
**    eStatus           - Status code to look up
**
** Outputs:
**    Return            - Pointer to text string
**
** Usage:
**    pach = AB_GetStatusTextString(  eStatus );
**
**---------------------------------------------------------------------------
*/

#ifdef STATUS_STRINGS
	EXTFUNC char* AB_GetStatusTextString(  StatusType eStatus );
#endif



/*---------------------------------------------------------------------------
**
** AB_Init()
**
** Primary initialization of the example code.
**
**---------------------------------------------------------------------------
**
** Inputs:
**    None
**
** Outputs:
**    Status                  - Completion status (SUCCESS or error code).
**
** Usage:
**    eStatus = AB_Init();
**
**---------------------------------------------------------------------------
*/

EXTFUNC StatusType AB_Init( void );



/*---------------------------------------------------------------------------
**
** AB_PreInit()
**
** Initialization that must be done prior to the main initialization.
** This sets up defaults that may then be overridden prior to the
** main initialization in AB_Init().
**
**---------------------------------------------------------------------------
**
** Inputs:
**    None
**
** Outputs:
**    Status                  - Completion status (SUCCESS or error code).
**
** Usage:
**    eStatus = AB_PreInit();
**
**---------------------------------------------------------------------------
*/

EXTFUNC StatusType AB_PreInit( void );



/****************************************************************************
**
** Private Services
**
*****************************************************************************
*/




/*---------------------------------------------------------------------------
**
** ab_Init()
**
** Internal shortcut for initialization of all example code components.
**
**---------------------------------------------------------------------------
**
** Inputs:
**    iOptions                - Portions of intiializaion to be performed
**
** Outputs:
**    None
**
** Usage:
**    eStatus = ab_Init( AB_COLD_START_RESOURCE );
**
**---------------------------------------------------------------------------
*/

EXTFUNC StatusType ab_Init( UINT16 iOptions );



/*---------------------------------------------------------------------------
**
** ab_Verify()
**
** Verify that one piece of initialization succeeded & return error if not.
**
**---------------------------------------------------------------------------
**
** Inputs:
**    pFunction               - Initialization function to call
**
** Outputs:
**    None
**
** Usage:
**    ab_Verify( GS_Init( AB_COLD_START_RESOURCE ) );
**
**---------------------------------------------------------------------------
*/

#define ab_Verify( pFunction ) \
   {                           \
      StatusType eStatus;      \
      eStatus = pFunction;     \
      if( eStatus != SUCCESS ) \
      {                        \
         return( eStatus );    \
      }                        \
   }



/*---------------------------------------------------------------------------
**
** abu_AcquireInterrupts()
**
** Acquire the interrupts need to support the example code before calling
** example code initialization functions.
** Called from within AB_Init();
**
**---------------------------------------------------------------------------
**
** Inputs:
**    None
**
** Outputs:
**    None
**
** Usage:
**    abu_AcquireInterrupts();
**
**---------------------------------------------------------------------------
*/

EXTFUNC void abu_AcquireInterrupts( void );



/*---------------------------------------------------------------------------
**
** abu_Exit()
**
** Cleanup of the user portion of an application prior to shutdown.
** Called from within AB_Exit().
**
**---------------------------------------------------------------------------
**
** Inputs:
**    None
**
** Outputs:
**    None
**
** Usage:
**    abu_Exit();
**
**---------------------------------------------------------------------------
*/

EXTFUNC void abu_Exit( void );



/*---------------------------------------------------------------------------
**
** abu_Init()
**
** Initialization of the user portion of an application.
** Called with some combination of the initialization option bits
** defined above.
** Called from within AB_Init().
**
**---------------------------------------------------------------------------
**
** Inputs:
**    iOptions                - Portions of intiializaion to be performed
**
** Outputs:
**    Status                  - Completion status (SUCCESS or error code).
**
** Usage:
**    eStatus = abu_Init( AB_COLD_START_RESOURCE );
**
**---------------------------------------------------------------------------
*/

EXTFUNC StatusType abu_Init( UINT16 iOptions );



/*---------------------------------------------------------------------------
**
** abu_PreInit()
**
** Initialization of various user configurable items that must be set up
** prior to running the main initialization code.
** Called from within AB_Init().
**
**---------------------------------------------------------------------------
**
** Inputs:
**    None
**
** Outputs:
**    Status                  - Completion status (SUCCESS or error code).
**
** Usage:
**    eStatus = abu_PreInit();
**
**---------------------------------------------------------------------------
*/

EXTFUNC StatusType abu_PreInit( void );



/*---------------------------------------------------------------------------
**
** abu_RelinquishInterrupts()
**
** Restore the interrupts used by the example code after exiting the
** code completely.
** Called from within AB_Exit().
**
**---------------------------------------------------------------------------
**
** Inputs:
**    None
**
** Outputs:
**    None
**
** Usage:
**    abu_RelinquishInterrupts();
**
**---------------------------------------------------------------------------
*/

EXTFUNC void abu_RelinquishInterrupts( void );



#endif  /* inclusion lock */

/****************************************************************************
**
** End of AB.H
**
*****************************************************************************
*/

⌨️ 快捷键说明

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