EPICS Controls Argonne National Laboratory

Experimental Physics and
Industrial Control System

1994  1995  1996  1997  1998  1999  2000  2001  <20022003  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  1997  1998  1999  2000  2001  <20022003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
<== Date ==> <== Thread ==>

Subject: Re: switch clock
From: Maren Purves <[email protected]>
To: Bernd Schoeneburg <[email protected]>
Cc: TECHTALK <[email protected]>
Date: Wed, 24 Jul 2002 08:17:35 -1000
Hi Bernd,

we have such a thing, written by Nick Rees, that in our case runs
at 0 hours UT and makes a date string.

It is a task spawned in the startup file:
taskSpawn ("dhsDailyUpdate", 100, 8, 20000, dhsDailyUpdate)

and the code it runs is as follows:
void dhsDailyUpdate()
{
    time_t    timeNextUpdate = 0;
    time_t    timeNow, timeToday, timeTomorrow;
    struct tm tmNow,   tmToday,   tmTomorrow;
    int secondsDelay;

    do
    {
        /* Find the current time in time_t and struct tm formats */
        timeNow = time(NULL);
        gmtime_r( &timeNow, &tmNow );

        /* Create a tm structure and time_t which is the beginning of
today UTC 
*/
        tmToday = tmNow;
        tmToday.tm_hour = 0;
        tmToday.tm_min  = 0;
        tmToday.tm_sec  = 0;
         timeToday = mktime( &tmToday );

        /* Now create a tm structure and time_t which is the beginning
of tomorr
ow UTC
           Note we rely on the ability of mktime to notice month and
year
           changes to sort these out just from the addition of the day
number */
        tmTomorrow = tmToday;
        tmTomorrow.tm_mday++;
        timeTomorrow = mktime( &tmTomorrow );

        /* Now update the observation number if the next update is
before today
           (the normal occurance) or after tomorrow (indicating that a
time erro
r
           has occurred in the last iteration */
        if (timeNextUpdate <= timeToday || timeNextUpdate > timeTomorrow
)
        {
            DHS_ID pDrv = &dhsDrv;

            dhsObsnum ( pDrv );
            timeNextUpdate = timeTomorrow;
        }

        /* Calculate the number of seconds left in today */
        secondsDelay = 86400 - (tmNow.tm_hour*3600 + tmNow.tm_min*60 +
tmNow.tm_
sec);
        taskDelay( secondsDelay * sysClkRateGet() );
    } while (TRUE);
}


Aloha,

Maren 

Bernd Schoeneburg wrote:
> is there an existing solution or ideas to implement the functionality of
> a switch clock in EPICS? The function, I want is to set one or more
> binary output channels according to the actual time. For example: Output
> 1 should be active every tuesday between 8am and 10am. I think an
> EPICS-record would be a good solution. Is somethink like this existing?

References:
switch clock Bernd Schoeneburg

Navigate by Date:
Prev: Re: buiding GDCT Maren Purves
Next: Re: ISEG VHQ204L Driver J. Frederick Bartlett ([email protected])
Index: 1994  1995  1996  1997  1998  1999  2000  2001  <20022003  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: switch clock Bernd Schoeneburg
Next: Re: switch clock Garrett D. Rinehart
Index: 1994  1995  1996  1997  1998  1999  2000  2001  <20022003  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 ·