EPICS Controls Argonne National Laboratory

Experimental Physics and
Industrial Control System

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

Subject: RE: ? initHookRegister()
From: Ralph Lange <[email protected]>
To: "Liyu, Andrei" <[email protected]>
Cc: Marty Kraimer <[email protected]>, [email protected]
Date: Wed, 21 Jan 2004 17:37:58 +0100
>>>>> "Andrei" == Andrei Liyu <Liyu> writes:

  > Thank you very much.
  > I have small question according 2. Why should static object be?
  > I tried in Windows:

  > //Server.h
  > class CServer{
  > 	...
  > };
  > extern CServer * pCServer;

  > //Server.cpp
  > .....
  > CServer oCServer;
  > CServer * pCServer = & oCServer;

  > It works too.

I don't understand your question - if the declaration of oCServer is
file global in Server.cpp, it _is_ a static object.

The reason for using a static object (as you did) is that the compiler /
runtime system makes sure the object is created (and its constructor
called) at init time. This makes sure myHookFunction is registered
before iocInit() runs.

Ralph


  > -----Original Message-----
  > From: Marty Kraimer [mailto:[email protected]] 
  > Sent: Monday, January 19, 2004 8:50 AM
  > To: Liyu, Andrei
  > Cc: [email protected]
  > Subject: Re: ? initHookRegister()

  > Liyu, Andrei wrote:
  >> Hi,
  >> 
  >> If I like to do some job during IOC initialization I should call
  >> initHookRegister(). But I couldn't understand where (how) can I call
  >> this function before iocInit()?

  > I can think of three ways.

  > 1) Call your routine from the st.cmd file

  >      Assume you have a function

  >      int initMyHook(void)
  >      {
  >          return(initHookFunction(myHookFunction));
  >      }


  >     the st.cmd file contains
  >     initMyHook
  >     iocInit

  > 2) Use a C++ static object.

  >     class initMyHook {
  >         public:
  >            initMyHook() {initHookFunction(myHookFunction);}
  >     }
  >     static initMyHook initMyHookObj;

  >     The constructor initMyHook will get called for initMyHookObj at load
  > time.

  > 3) For 3.14.4 or later use the registrar facility

  >     In your xxxInclude.dbd file the following must appear

  >     registrar(myHook)

  >     Your source file contains

  >     static void myHook(void)
  >     {
  >         static int firstTime = 1;
  >         if(!firstTime) return;
  >         firstTime=0;
  >         initHookFunction(myHookFunction);
  >     }
  >     epicsExportRegistrar(myHook);


  > For 3.14.4 and later method 3) is the recommended method.

  >> Can anybody write couple words about IOC deinitialization? Has
  >> Epics similar hook here?
  >> 

  > Sorry but iocCore is currently written to run forever. There is no
  > deinitialization.

  >> Thanks, Andrei.
  >> 



-- 
      __  Ralph Lange                               [email protected]
     /\ \                                            http://www.bessy.de
    /  \ \  BESSY II                           
   / /\ \ \  Berliner Elektronenspeicherring-    Albert-Einstein-Str. 15
  / / /\ \ \  Gesellschaft fuer Synchrotron-       12489 Berlin, Germany
 / / /__\_\ \  strahlung m.b.H.
/ / /________\                                Phone:    +49 30 6392-2117
\/___________/ Control System Group           Fax:           ...   -4859

References:
RE: ? initHookRegister() Liyu, Andrei

Navigate by Date:
Prev: RE: ? initHookRegister() Liyu, Andrei
Next: RE: ? initHookRegister() Liyu, Andrei
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  <20042005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
Navigate by Thread:
Prev: RE: ? initHookRegister() Liyu, Andrei
Next: RE: ? initHookRegister() Liyu, Andrei
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  <20042005  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 ·