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

📄 ab_init.c

📁 基于EthernetIP协议的应用程序,可以读取AB公司Controllogix系列Ethernetip协议PLC数据. 此软件代码可用于工业控制.
💻 C
字号:
/****************************************************************************
*****************************************************************************
**
** File Name
** ---------
**
** AB_INIT.C
**
*****************************************************************************
*****************************************************************************
**
** Description
** -----------
**
** Basic Services API Initialization Module.
**
** This source file contains the complete (constructor) type initialization
** for the combined APIs.
**
*****************************************************************************
*****************************************************************************
**
** 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
** ----------
**
**
*****************************************************************************
*****************************************************************************
*/

#include "cd.h"         /* communications device public interfaces         */

#ifdef BD_COMPONENT
#include "bd.h"         /* background diagnostics public interfaces        */
#endif

#ifdef CORE_OBJECTS
#include "mr.h"         /* message router component public interfaces      */
#include "um.h"         /* unconnected message manager public interfaces   */
#include "id.h"         /* Identity Object public interfaces               */
#include "cm.h"         /* Connection Manager public interfaces            */
#endif

#ifdef BUFFER_FRAGMENT_MAPPER
#include "ad.h"         /* App Data Area handler public interfaces         */
#include "bf.h"         /* Buffer Fragment Mapper public interfaces        */
#endif

#ifdef ASSEMBLY_OBJECT
#include "sy.h"         /* Assembly Object component public interfaces     */
#endif

#ifdef PCCC_OBJECT
#include "p3.h"         /* PCCC messaging component public interfaces      */
#endif

#ifdef DEBUG_OBJECT
#include "db.h"         /* Debug Object public interfaces                  */
#endif

#ifdef NV_STORAGE_UTIL
#include "ns.h"         /* Non-volatile storage services                   */
#endif

#ifdef NVS_OBJECT
#include "nv.h"         /* Non-volatile storage object public interfaces   */
#endif

#ifdef TCPIP_INTERFACE_OBJECT
#include "ei.h"         /* Tcp/Ip Interface public interfaces              */
#endif

#ifdef ETHERNET_LINK_OBJECT
#include "el.h"         /* Ethernet link public interfaces                 */
#endif

#ifdef CD_EN_OBJECTS
#include "en.h"         /* Communications Device public interfaces         */
#endif

#include "ECUserDefined_obj.h"

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

/*
** Global configuration data.
*/

AB_DataType AB_s;


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

/*---------------------------------------------------------------------------
** AB_Exit()
**---------------------------------------------------------------------------
*/

void AB_Exit( void )
{
   /*
   ** Do any additional user cleanup prior to exiting.
   ** Restore all interrupt vectors.
   */

   abu_Exit();
   abu_RelinquishInterrupts();

} /* end of AB_Exit() */



/*---------------------------------------------------------------------------
** AB_Init()
**---------------------------------------------------------------------------
*/

EXTFUNC StatusType AB_Init( void )
{
   /*
   ** Allocate and initialize all resources for the various tasks.
   ** This include message queues, events, timers, memory and the like.
   **
   ** Task creation and startup happens later in the code
   ** after all resources are in place.
   **
   ** Note that tribble tosses of any kind are not yet allowed
   ** because the message queue the tribble is being tossed to
   ** may not have been created yet...  Tribble tosses can occur
   ** during the task creation phase of startup.
   */

   ab_Verify( ab_Init(  AB_COLD_START_RESOURCE ) );

   ab_Verify( abu_Init( AB_COLD_START_RESOURCE ) );

   /*
   ** Now that all resources have been allocated and initialized,
   ** grab all required interrupts, then create and start up the tasks.
   ** Tribble tosses are now allowed.
   */

   abu_AcquireInterrupts();
   ab_Verify( ab_Init(  AB_COLD_START_TASK ) );
   ab_Verify( abu_Init( AB_COLD_START_TASK ) );

   return( SUCCESS );


} /* end of AB_Init() */



/*---------------------------------------------------------------------------
** AB_PreInit()
**---------------------------------------------------------------------------
*/

StatusType AB_PreInit( void )
{
   INT16 i;

   /*
   ** Make certain all the UCMM Qids are invalid
   ** before initialization.  This is done so that
   ** we can check for a valid port by checking
   ** for a non-NULL Qid.
   */

   for( i = 1; i <= CD_NPORTS; i++ )
        CD_s[i].xUMQid = NULL;


   /*
   ** Do any user specific initialization that must be done prior
   ** to the main block of initialization.
   */

   ab_Verify( abu_PreInit() );

   return( SUCCESS );

} /* end of AB_PreInit() */



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

/*---------------------------------------------------------------------------
** ab_Init()
**---------------------------------------------------------------------------
*/

EXTFUNC StatusType ab_Init( UINT16 iOptions )
{
   /*
   ** Initialize all required components.
   **
   ** GS must be initialized first.
   ** The remaining components may be initialized in any order.
   */
   ab_Verify( GS_Init( iOptions ) );   /* General Services                 */

#ifdef BD_COMPONENT
   ab_Verify( BD_Init( iOptions ) );   /* Background Debug task            */
#endif /* BD_COMPONENT */
#ifdef CD_EN_OBJECTS
/*jjw */
   ab_Verify( EN_CD_Init( iOptions ) );   /* Communication Device             */
   ab_Verify( EN_Init( iOptions ) );   /* Communication Device             */
#endif
   ab_Verify( CD_Init( iOptions ) );   /* Communication Device             */
   ab_Verify( CM_Init( iOptions ) );   /* Connection Manager object        */
   ab_Verify( ID_Init( iOptions ) );   /* Identity object                  */
   ab_Verify( MR_Init( iOptions ) );   /* Message Router task              */
   ab_Verify( UM_Init( iOptions ) );   /* Unconnected Message Manager      */

   /*
   ** Initialize optional components per the compile switches.
   */

#ifdef BUFFER_FRAGMENT_MAPPER
   ab_Verify( AD_Init( iOptions ) );   /* App Data Area Handler            */
   ab_Verify( BF_Init( iOptions ) );   /* Buffer Fragment Mapper           */
#endif

#ifdef DEBUG_OBJECT
   ab_Verify( DB_Init( iOptions ) );   /* Debug object                     */
#endif

#ifdef TCPIP_INTERFACE_OBJECT
   ab_Verify( EI_Init( iOptions ) );   /* Tcp/Ip Interface Object          */
#endif

#ifdef ETHERNET_LINK_OBJECT
   ab_Verify( EL_Init( iOptions ) );   /* Ethernet Link Object             */
#endif

#ifdef NVS_OBJECT
   ab_Verify( NV_Init( iOptions ) );   /* Non-volatile storage object      */
#endif

#ifdef NV_STORAGE_UTIL
   ab_Verify( NS_Init( iOptions ) );
#endif

#ifdef PCCC_OBJECT
   ab_Verify( P3_Init( iOptions ) );   /* PCCC object                      */
#endif

#ifdef ASSEMBLY_OBJECT
   ab_Verify( SY_Init( iOptions ) );   /* Assembly object                  */
#endif

	ab_Verify( UserDefined_Init( iOptions ) );

   return( SUCCESS );

} /* end of ab_Init() */



/****************************************************************************
**
** End of AB_INIT.C
**
*****************************************************************************
*/

⌨️ 快捷键说明

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