EPICS Controls Argonne National Laboratory

Experimental Physics and
Industrial Control System

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

Subject: Re: record that processes at a given time of day?
From: "Lang, Keenan C. via Tech-talk" <[email protected]>
To: James Larsson <[email protected]>, Maren Purves <[email protected]>, Michael Westfall <[email protected]>
Cc: "[email protected] Talk" <[email protected]>
Date: Mon, 5 Nov 2018 22:06:46 +0000

The luascript record (https://github.com/epics-modules/lua) makes this pretty simple. Your record would look like:


record(luascript, NAME)

{

  field(SCAN, "1 second")

  field(OOPT, "Transition to Non-zero")

  field(CODE, "@script.lua timecheck()")

  field(OUT, "RECORD_TO_PROCESS.PROC")

}


and then have a file "script.lua" either in the IOC's startup directory or in any directory specified by the environment variable LUA_SCRIPT_PATH. The file would have a function timecheck that looks like so:


function timecheck()

  -- Get the current time as a table of information

  local curr_time = os.date("*t")


  -- Check for your target time (HOURS is in 24-hour format)

  if (curr_time.hour == HOURS and curr_time.min == MINUTES and curr_time.sec == SECONDS) then

    return 1

  end


  return 0

end



Every second the luascript record processes and checks the time, if it's the time you specified, the record's VAL field gets set to 1 and that value gets sent to the PROC field of the record you want to process at that point. If you have multiple fields to process at various times, you can use the same script and just send the time values as parameters like so:


record(luascript, OneThirtyRecord)

{

  field(SCAN, "1 second")

  field(OOPT, "Transition to Non-zero")

  field(CODE, "@script.lua timecheck(1,30,0)")

  field(OUT, "RECORD_TO_PROCESS_1.PROC")

}


record(luascript, TwoThirtyRecord)

{

  field(SCAN, "1 second")

  field(OOPT, "Transition to Non-zero")

  field(CODE, "@script.lua timecheck(2,30,0)")

  field(OUT, "RECORD_TO_PROCESS_2.PROC")

}


function timecheck(hours, minutes, seconds)

  -- Get the current time as a table of information

  local curr_time = os.date("*t")


  -- Check for your target time (HOURS is in 24-hour format)

  if (curr_time.hour == hours and curr_time.min == minutes and curr_time.sec == seconds) then

    return 1

  end


  return 0

end



From: [email protected] <[email protected]> on behalf of James Larsson <[email protected]>
Sent: Monday, November 5, 2018 1:35:47 PM
To: Maren Purves; Michael Westfall
Cc: [email protected] Talk
Subject: Re: record that processes at a given time of day?
 

Good Day,


I tend to avoid cron job on the control system since I don't know that it is *guaranteed* to run, and at specified time - though it usually does.  Even though crontab is a great tool, it isn't a control system tool, so my preference is to avoid it (except for say, booting a control system).


I implemented a calc record that uses inputs from the devIocStats (synapps) to get the second, minute, and hour, and compare them with your desired values and make the Val=1 if equal, which is essentially what you want.  If you connect that to the SDIS of a fanout and process the fanout every 1/2 second then you will get a single process signal output, at the time of day you specify (because usually it's disabled).


You can do the same thing but only use seconds, and minutes for something that happens every hour, and likewise for month and day.  Sometimes I want to process a record, but only once every 10 minutes.


Cheers

James Larsson


From: [email protected] <[email protected]> on behalf of Maren Purves <[email protected]>
Sent: November 5, 2018 10:14:07 AM
To: Michael Westfall
Cc: [email protected] Talk
Subject: Re: record that processes at a given time of day?
 
Hi Michael,

I have a cron job that runs once a day that resets the value of several records by
running cau (with an input file). If you don't find a record that can be made to do
that I'm sure you can adapt the cron job idea.

Maren Purves, EAO/JCMT

On Mon, Nov 5, 2018 at 7:37 AM, Michael Westfall via Tech-talk <[email protected]> wrote:
Hi,

I'm wondering if someone has an EPICS record implemented that processes at a given time of day, like an alarm clock.

I don't see anything like that in EPICS base.

--
Mike Westfall
Control Systems Software Engineer




References:
record that processes at a given time of day? Michael Westfall via Tech-talk
Re: record that processes at a given time of day? Maren Purves
Re: record that processes at a given time of day? James Larsson

Navigate by Date:
Prev: Re: Re: Controlling Eiger 1M with EPICS Jason A . Pattie
Next: Re: record that processes at a given time of day? Johnson, Andrew N. via Tech-talk
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  <20182019  2020  2021  2022  2023  2024 
Navigate by Thread:
Prev: Re: record that processes at a given time of day? Michael Davidsaver
Next: Re: record that processes at a given time of day? Johnson, Andrew N. via Tech-talk
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  <20182019  2020  2021  2022  2023  2024 
ANJ, 05 Nov 2018 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·