EPICS Base  7.0.7.0
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Typedefs | Enumerations | Functions
initHooks.h File Reference

Facility to call functions during iocInit() More...

#include "libComAPI.h"
Include dependency graph for initHooks.h:

Go to the source code of this file.

Typedefs

typedef void(* initHookFunction )(initHookState state)
 Type for application callback functions. More...
 

Enumerations

enum  initHookState {
  initHookAtIocBuild = 0, initHookAtBeginning, initHookAfterCallbackInit, initHookAfterCaLinkInit,
  initHookAfterInitDrvSup, initHookAfterInitRecSup, initHookAfterInitDevSup, initHookAfterInitDatabase,
  initHookAfterFinishDevSup, initHookAfterScanInit, initHookAfterInitialProcess, initHookAfterCaServerInit,
  initHookAfterIocBuilt, initHookAtIocRun, initHookAfterDatabaseRunning, initHookAfterCaServerRunning,
  initHookAfterIocRunning, initHookAtIocPause, initHookAfterCaServerPaused, initHookAfterDatabasePaused,
  initHookAfterIocPaused, initHookAtShutdown, initHookAfterCloseLinks, initHookAfterStopScan,
  initHookAfterStopCallback, initHookAfterStopLinks, initHookBeforeFree, initHookAfterShutdown,
  initHookAfterInterruptAccept, initHookAtEnd
}
 Initialization stages. More...
 

Functions

LIBCOM_API int initHookRegister (initHookFunction func)
 Register a function for initHook notifications. More...
 
LIBCOM_API void initHookAnnounce (initHookState state)
 Routine called by iocInit() to trigger notifications. More...
 
LIBCOM_API const char * initHookName (int state)
 Returns printable representation of state. More...
 
LIBCOM_API void initHookFree (void)
 Forget all registered application functions. More...
 

Detailed Description

Author
Benjamin Franksen (BESSY)
Marty Kraimer (ANL)

The initHooks facility allows application functions to be called at various stages/states during IOC initialization, pausing, restart and shutdown.

All registered application functions will be called whenever the IOC initialization, pause/resume or shutdown process reaches a new state.

The following C++ example shows how to use this facility:

static void myHookFunction(initHookState state)
{
switch (state) {
...
break;
...
break;
default:
break;
}
}
// A static constructor registers hook function at startup:
static int myHookStatus = initHookRegister(myHookFunction);

An arbitrary number of functions can be registered.

Definition in file initHooks.h.

Typedef Documentation

typedef void(* initHookFunction)(initHookState state)

Application callback functions must match this typdef.

Parameters
stateinitHook enumeration value

Definition at line 114 of file initHooks.h.

Enumeration Type Documentation

The enum states must agree with the names in the initHookName() function. New states may be added in the future if extra facilities get incorporated into the IOC. The numerical value of any state enum may change between EPICS releases; states are not guaranteed to appear in numerical order.

Some states were deprecated when iocPause() and iocRun() were added, but are still provided for backwards compatibility. These deprecated states are announced at the same point they were before, but will not be repeated if the IOC is later paused and restarted.

Enumerator
initHookAtIocBuild 

Start of iocBuild() / iocInit()

initHookAtBeginning 

Database sanity checks passed

initHookAfterCallbackInit 

Callbacks, generalTime & taskwd init

initHookAfterCaLinkInit 

CA links init

initHookAfterInitDrvSup 

Driver support init

initHookAfterInitRecSup 

Record support init

initHookAfterInitDevSup 

Device support init pass 0

initHookAfterInitDatabase 

Records and locksets init

initHookAfterFinishDevSup 

Device support init pass 1

initHookAfterScanInit 

Scan, AS, ProcessNotify init

initHookAfterInitialProcess 

Records with PINI = YES processsed

initHookAfterCaServerInit 

RSRV init

initHookAfterIocBuilt 

End of iocBuild()

initHookAtIocRun 

Start of iocRun()

initHookAfterDatabaseRunning 

Scan tasks and CA links running

initHookAfterCaServerRunning 

RSRV running

initHookAfterIocRunning 

End of iocRun() / iocInit()

initHookAtIocPause 

Start of iocPause()

initHookAfterCaServerPaused 

RSRV paused

initHookAfterDatabasePaused 

CA links and scan tasks paused

initHookAfterIocPaused 

End of iocPause()

initHookAtShutdown 

Start of iocShutdown() (unit tests only)

initHookAfterCloseLinks 

Links disabled/deleted

initHookAfterStopScan 

Scan tasks stopped

initHookAfterStopCallback 

Callback tasks stopped

initHookAfterStopLinks 

CA links stopped

initHookBeforeFree 

Resource cleanup about to happen

initHookAfterShutdown 

End of iocShutdown()

initHookAfterInterruptAccept 

After initHookAfterDatabaseRunning

initHookAtEnd 

Before initHookAfterIocRunning

Definition at line 71 of file initHooks.h.

Function Documentation

LIBCOM_API int initHookRegister ( initHookFunction  func)

Registers func for initHook notifications

Parameters
funcPointer to application's notification function.
Returns
0 if Ok, -1 on error (memory allocation failure).
LIBCOM_API void initHookAnnounce ( initHookState  state)

Calls registered callbacks announcing state

Parameters
stateinitHook enumeration value
LIBCOM_API const char* initHookName ( int  state)

Static string representation of state for printing

Parameters
stateenum value of an initHook
Returns
Pointer to name string
LIBCOM_API void initHookFree ( void  )

This cleanup routine is called by unit test programs between IOC runs.