EPICS Controls Argonne National Laboratory

Experimental Physics and
Industrial Control System

1994  1995  1996  <19971998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024  Index 1994  1995  1996  <19971998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
<== Date ==> <== Thread ==>

Subject: InitHooks
From: Benjamin Franksen <[email protected]>
To: [email protected]
Date: Mon, 14 Jul 1997 21:02:48 +0200
Hello everybody,

I propose a (minor) change to the next EPICS release. Current problems
with the new lanGpib driver suggest that an entry in the InitHooks
function should be made in that calls the driver at some later point
during IOC init. So far so good. But in our control system there are
already some standard entries in this InitHooks function. And InitHooks
only exists once.

So what one does is to 'ifdef' parts of InitHook depending on what has
to be called on each IOC. In my point of view this is ugly and
contradicts the modular design of EPICS which otherwise allows each IOC
to be configured individually by modifying the startup file while
keeping the common base functionality consistent.

Solution: A function

void registerInitHook(void (*hookFunction)(int))

callable (multiple times) from the startup file before iocInit. It
chains together a series of initHook functions.

A different initHooks.c file could look like

/* includes omitted */

typedef void (*hookFunction)(int);

typedef struct initHookLink {
	hookFunction func;
	struct initHookLink *next;
} initHookLink;

static initHookLink *hooks;

void registerInitHook(hookFunction func)
{
	initHookLink *newHook = (initHookLink *)malloc(sizeof(initHookLink));
	newHook->func = func;
	newHook->next = hooks;
	hooks = newHook;
}

/*
 * called by iocInit at various points during initialization
 */
void initHooks(int callNumber)
{
	initHookLink *hook = hooks;
	while(hook)
	{
		hook->func(callNumber);
		hook = hook->next;
	}
}

An example of an application specific initHook would be (actually the
one I'd to put in there):

void lanGpibHooks(int callNumber)
{
  if (INITHOOKafterFinishDevSup == callNumber)
  {
    hpLink *pHpLink;

    if (ibDebug)
      printf("Driver Support for Gpib (HP E2050A) second call to
init()\n");

    pHpLink = rootHpLink;
    while(pHpLink != NULL)
    {
      ibLinkStart(&(pHpLink->link));
      semTake(pHpLink->initSem, 5*ticksPerSecond); /* wait for task init
*/
      pHpLink = pHpLink->next;
    }
    if (ibDebug)
      printf("Driver Support for Gpib (HP E2050A) initialization
complete\n");
  }
}

and would be registered in the startup file like

registerInitHook(lanGpibHooks)
registerInitHook(someOtherInitHook)

I tried it and it works.

	Ben
-- 
The Notorious Neb Nesknarf
// snail: BESSY II, Rudower Chaussee 5, D-12489 Berlin, Germany
// email: [email protected]
// phone/fax: +49(30)6392-4865 / 6392-4859

Replies:
Building EPICS on HP_UX 10.2 Dave Reid
Re: InitHooks Marty Kraimer

Navigate by Date:
Prev: going mad with Capfast / e2db William Lupton
Next: Building EPICS on HP_UX 10.2 Dave Reid
Index: 1994  1995  1996  <19971998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
Navigate by Thread:
Prev: going mad with Capfast / e2db William Lupton
Next: Building EPICS on HP_UX 10.2 Dave Reid
Index: 1994  1995  1996  <19971998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
ANJ, 10 Aug 2010 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·