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

Subject: Re: 答复: Get a time difference in EPICS database
From: Tim Mooney <[email protected]>
To: 洪春霞 <[email protected]>
Cc: [email protected]
Date: Sat, 24 Nov 2012 09:36:59 -0600 (CST)
Hi hongchunxia,
 

----- Original Message -----
> From: "洪春霞" <[email protected]>
> To: "Tim Mooney" <[email protected]>
> Cc: [email protected]
> Sent: Saturday, November 24, 2012 5:52:34 AM
> Subject: 答复: Get a time difference in EPICS database
> Hi,
> 
> Thank you for your reply.
> 
> What I want to do is as follows:
> 1) First I want to have a judgement on the value of A and B in
> record(calcout,"h:time_difference"), if A=B, I will get the time2
> (h:Systemtime2).
> so I want to cause h:Systemtime2 to process just in the time of
> A=B,and if A is not equal to B, the h:Systemtime2 should not be
> processed.
> so in record(stringin,"h:Systemtime2"), I use field(DISV,"0") and
> field(SDIS,"***"),because If DISV=DISA, the record will be disabled,
> so I
> think if I set DISV!=DISA, the record will be enabled, but I do not
> know whether is it right?

By setting SDIS, you've made sure that h:Systemtime2 will not be processed
if A!=B, but there is nothing that makes h:Systemtime2 process if A==B.

How about this:

record(calcout,"h:check_status")
{
    field(DESC,"if status==3, get time2 and calc time diff")
    field(CALC,"A=B")
    field(INPA,"h:status PP NMS")
    field(INPB,"3")
    field(OUT,"h:calc_time_diff.PROC PP NMS")
    field(OOPT,"Transition To Non-zero")
}
record(calcout,"h:calc_time_diff")
{
    field(DESC,"get time2 and calc time diff")
    field(CALC,"C-D")
    field(INPC,"h:Systemtime1 NPP NMS")
    field(INPD,"h:Systemtime2 PP NMS")
}

If h:Systemtime1 gets processed once when the ioc boots and never again, then
h:calc_time_diff.VAL will be the number of seconds after boot that h:status was
found equal to 3.  It won't be the time that the h:status /changed/ to 3, but
instead the time h:status was checked and found equal to 3.  If you want to
check h:status whenever it changes, you could replace
    field(INPA,"h:status PP NMS")
with
    field(INPA,"h:status CP NMS")

This will cause h:check_status to process whenever a new value of h:status is posted.

> 2) I want to cause a recond to process just when some requirements
> were met in the EPICS database, for example, in field
> (CALC,"A=B?(C-D):0"),
> I want to cause some reconds to process according to the different
> results of CALC, that is, a record is processed when A=B, and another
> record is processed when A!=B,
> Now I do not know how to do?

You can do this with a fanout or seq record.

record(calcout,"choose") {
    field(INPA,"status")
    field(INPB,"3")
    field(CALC,"a=b?1:2")
    field(OUT,"switch.SELN PP")
}
record(fanout,"switch") {
    field(SELM,"Specified")
    field(LNK1,"process_me_when_a_is_b")
    field(LNK2,"process_me_when_a_is_not_b")
}

> Thank you so much. Best Wishes.
> 
> ------------------------------------------
> hongchunxia
> 
> 
> 
> -----Original Message-----
> From: Tim Mooney [ mailto:[email protected] ]
> Sent: 2012-11-24 (星期六) 12:46
> To: 洪春霞
> Cc: [email protected]
> Subject: Re: Get a time difference in EPICS database
> 
> hongchunxia,
> Two things:
> 
> 1) If you are using the soft time device support in EPICS base, and
> you want to use a calc record to calculate the time difference, you
> should not get the time as a formatted string, but instead get it as
> the raw number of seconds since the fixed "epoch" (which I think is
> some time back in 1990 or something):
> 
> record(ai,"time1") {
> field(DTYP, "Soft Timestamp")
> }
> record(ai,"time2") {
> field(DTYP, "Soft Timestamp")
> }
> record(calcout,"timeDiff") {
> field(DESC,"time2-time1 (seconds)")
> field(INPA,"time1 NPP")
> field(INPB,"time2" NPP)
> field(CALC,"b-a")
> }
> 
> 2) I don't see anything in your database that would cause
> h:Systemtime2 to process. I think your job might be easier if you
> separate the job of deciding whether h:Systemtime2 should process,
> from the job of calculating the difference between h:Systemtime1 and
> h:Systemtime2.
> 
> Tim Mooney
> 
> ----- Original Message -----
> From: "洪春霞" <[email protected]>
> To: [email protected]
> Sent: Friday, November 23, 2012 2:07:26 AM
> Subject: Get a time difference in EPICS database
> 
> 
> 
> 
> Hi,
> I want to get a time difference in EPICS database, the record of
> h:Systemtime1 is run when ioc is start, that is, it is the realtime
> time.
> The record of h:Systemtime2 is get when A=3 in the
> record(calcout,"h:monitor_time"), and it should be executed once, but
> now I can not get the time of h:Systemtime2.
> When I input “camonitor h:Systemtime2” in another Terminal, I always
> get “h:Systemtime2 <underfined> UDF INVALID”,and I input “camonitor
> h:time_plus” in another Terminal, I get the time is the value of C.
> That is to say, the record of h:Systemtime2 is not executed.
> 
> Can you give me some advice? Thank you very much.
> Best Wishes.
> 
> The database which I use is as follows:
> 
> record(ai, "h:status")
> {
> }
> record(stringin,"h:Systemtime1")
> {
> field(DESC,"Systemtime1")
> field(DTYP,"Soft Timestamp")
> field(SCAN,"1 second")
> field(PINI,"YES")
> field(INP,"@%s")
> }
> record(stringin,"h:Systemtime2")
> {
> field(DESC,"Systemtime2")
> field(DTYP,"Soft Timestamp")
> field(INP,"@%s")
> field(DISV,"0")#If DISV=DISA, then the record will be disabled
> field(SDIS,"h:monitor_time PP MS")#
> }
> #This is the value that is compared with DISV to determine if the
> record is
> #disabled. Its value is obtained via SDIS if SDIS is a database or
> channel access
> #link.
> record(calcout,"h:time_difference")
> {
> field(CALC,"A=B?(C-D):0")
> field(INPA,"h:status PP NMS")
> field(INPB,"3")
> field(INPC,"h:Systemtime1 PP NMS")
> field(INPD,"h:Systemtime2 NPP NMS")
> field(OUT,"h:time_plus PP NMS")
> field(OOPT,"Transition To Non-zero")
> }
> ------------------------------------------
> hongchunxia
> 
> --
> Tim Mooney ([email protected]) (630)252-5417
> Software Services Group (www.aps.anl.gov)
> Advanced Photon Source, Argonne National Lab

-- 
Tim Mooney ([email protected]) (630)252-5417
Software Services Group (www.aps.anl.gov)
Advanced Photon Source, Argonne National Lab


References:
答复: Get a time difference in EPICS database 洪春霞

Navigate by Date:
Prev: 答复: Get a time difference in EPICS database 洪春霞
Next: Re: caRepeater object code not cross-compiled in R3.14.12.2 Rod Nussbaumer
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  <20122013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
Navigate by Thread:
Prev: 答复: Get a time difference in EPICS database 洪春霞
Next: Utilities for EPICS on Multi-Core Linux Ralph Lange
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  <20122013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
ANJ, 18 Nov 2013 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·