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

📄 bf_util.h

📁 基于EthernetIP协议的应用程序,可以读取AB公司Controllogix系列Ethernetip协议PLC数据. 此软件代码可用于工业控制.
💻 H
📖 第 1 页 / 共 2 页
字号:
/****************************************************************************
*****************************************************************************
**
** File Name
** ---------
**
** BF_Util.H
**
*****************************************************************************
*****************************************************************************
**
** Description
** -----------
**
** Private definitions for the Buffer Fragment mapper.
**
*****************************************************************************
*****************************************************************************
**
** Source Change Indices
** ---------------------
**
** Porting: <none>0----<major>         Customization: <none>0----<major>
**
*****************************************************************************
*****************************************************************************
**
** Services List
** -------------
**
**    bf_AccessMapping()         - Queue up messaging access request
**    bf_ActivateMapping()       - Activate an mapping entry
**    bf_AddMapping()            - Add a mapping entry but leave deactivated
**    bf_DeactivateMapping()     - Deactivate a mapping entry
**    bf_DeleteMapping()         - Remove a mapping entry
**    bf_InquireMapping()        - Collect info about a pro & a con mapping
**    bf_FindMapping()           - Find a mapping entry
**    bf_MoveActiveEntry()       - Move an active mapping entry
**    bf_RegisterAppDataArea()   - Register a new application data area
**    bf_Task()                  - Main processing task
**
*****************************************************************************
*****************************************************************************
**                                                                         **
** 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
** ----------
**
*****************************************************************************
****************************************************************************/

#ifndef BF_UTIL_H
#define BF_UTIL_H



#ifdef BUFFER_FRAGMENT_MAPPER
/****************************************************************************
*****************************************************************************
**
** Private internal object interface - Constants
**
*****************************************************************************
****************************************************************************/

/*
** Max number of entries in the mapping table.
** Allow one per transport (two per connection).
** Identifier for a non existant entry.
*/

#define BF_NUM_MAPPINGS    ( CD_NUM_TRANSPORTS )
#define BF_NO_MAPPING      0xFFFF



/****************************************************************************
*****************************************************************************
**
** Private internal object interface - Enums
**
*****************************************************************************
****************************************************************************/

/* None defined */



/****************************************************************************
*****************************************************************************
**
** Private internal object interface - Structures
**
*****************************************************************************
****************************************************************************/

/*---------------------------------------------------------------------------
**
** bf_ActiveSubListType
**
** List of active entries assocated with a particular area of app data.
** There may be several of these for each app data area to split the
** amount of time needed to resync the app data area with the
** transport buffers.
**
**---------------------------------------------------------------------------
*/

typedef struct bf_ActiveSubListType
{
   /*
   ** First active entry for this list
   ** Number of active entries in this list
   ** Total copy cpu time for this list.
   */

   UINT16  iActiveEntry1;
   UINT16  iActiveEntries;

   UINT32  lCpuTimeAreaSubList; 
} 
bf_ActiveSubListType;



/*---------------------------------------------------------------------------
**
** bf_AppDataAreaType
**
** Interesting details for each area of application data.
**
**---------------------------------------------------------------------------
*/

typedef struct bf_AppDataAreaType
{
   /*
   ** Base address of app data area (for class 1 connections).
   ** Total size of app data area (for bounds checking).
   */

   UINT8  *pBaseAddress;
   UINT16  iSize;

   /*
   ** Notification method for messaging requests and scheduled data rx.
   */

   GS_MsgQueueType   xMNotifyQueue;
   UINT16            iMNotifyBitMsg;
   GS_SemaphoreType  xMNotifySemaphore;

   GS_MsgQueueType   xSNotifyQueue;
   UINT16            iSNotifyBitMsg;
   GS_SemaphoreType  xSNotifySemaphore;

   /*
   ** Estimated data copy cpu time.
   */

   UINT32  lCpuTimePerMessage;
   UINT32  lCpuTimePerEntry;
   UINT32  lCpuTimePerByte;
   UINT32  lCpuTimeMaxResync;
   UINT32  lCpuTimeMaxPerSecArea;
   UINT32  lCpuTimeMaxPerSecSystem;

   /*
   ** Access request tribble list.
   */

   LL_HEAD_NODE( BF_AccessTrrblType )  sAccessRequestList;

   /*
   ** Active entry sub-list fetching history.
   ** Active entry sub-list details.
   ** First half for producer data, second for consumer.
   */

   UINT16 iNextSubList;
   bf_ActiveSubListType  asActiveSubList[ BF_NUM_SUB_LISTS ];
}
bf_AppDataAreaType;



/*---------------------------------------------------------------------------
**
** bf_MappingEntryType
**
** Entry to map a class/instance to a portion of application data.
**
** Mapping entries are physically held in one large array of structures,
** in no particular order.
**
** There is a separate list sorted by transport Id that points to
** mapping entries in this list.
**
** Selective data from each active mapping entry also appears in one of
** several lists sorted by application data area. These lists only
** contain highlights of the mapping entry and are designed to optimize
** the operation of the code that does the handshake and transfer to/from
** the application data area. This is more work up front, but it minimizes
** the processing time during critical handshake operations.
**
**---------------------------------------------------------------------------
*/

typedef struct bf_MappingEntryType
{
   /*
   ** Class, instance and direction associated with this mapping entry.
   */

   UINT16  iClass;
   UINT16  iInstance;
   BOOL    fCon;

   /*
   ** Which piece of which application data area this entry is mapped to.
   ** Where in the app data piece the entry is mapped to and the
   ** max size of the mapping.
   */

   AD_AppDataAreaIdType  eAppDataAreaId;
   UINT16                iAppDataAreaOffset;
   UINT16                iMaxMappingSize;

   /*
   ** Run/idle status bit # and style.
   */

   UINT16  iStatusBit;
   UINT16  iStatusStyle;

   /*
   ** Number of configured connections using this mapping.
   ** Number of active connections using this mapping.
   ** (This includes connections that have just reserved the mapping
   **  while the connection is opening and connections that are up and
   **  actively usigt the mapping.
   */

   UINT16  iConfiguredUsers;
   UINT16  iActiveUsers;

   /*
   ** Additional information when this entry is active.
   ** Transport associated with this mapping.
   ** (0 if none currently associated, mapping currently inactive).
   ** Index of the corresponging entry in the active entry list.
   ** Which active entry sub-list for the app data area this entry is in.
   */

   UINT16  iTransportId;
   UINT16  iActiveEntry;
   UINT16  iActiveSubList;
}
bf_MappingEntryType;



/*---------------------------------------------------------------------------
**
** bf_DataType
**
** Private data for the buffer fragment manager's use.
** Declared last so we can use the other internal data structures.
**
**---------------------------------------------------------------------------
*/

typedef struct bf_DataType
{
   /*
   ** Number of mapping entries currently in the list.
   ** Number of active entries (in the app data area sorted list).
   */

   UINT16  iMappingEntries;
   UINT16  iActiveEntries;

   /*
   ** Array of mapping entries, unsorted.
   ** Array of active mapping entries, sorted by application data area.
   ** Array of mapping entry numbers, indexed by transport Id.
   */

   bf_MappingEntryType  asMappingEntries    [ BF_NUM_MAPPINGS ];
   BF_ActiveEntryType   asActiveEntries     [ BF_NUM_MAPPINGS ];
   UINT16               aiMappingByTransport[ BF_NUM_MAPPINGS ];

   /*
   ** Details of each application data area.
   */

   bf_AppDataAreaType   asAppDataAreas[ AD_NUM_APP_DATA_AREAS ];

   /*
   ** Max CPU usage allowed across all app data areas.
   */

   UINT32  lCpuTimeMaxPerSecSystem;
}
bf_DataType;

⌨️ 快捷键说明

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