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: How can I collect data values
From: Benjamin Franksen <[email protected]>
To: <[email protected]>
Date: Thu, 27 Sep 2012 21:20:39 +0200
Am Donnerstag, 27. September 2012, 16:43:59 schrieb Kai Stein:
> I'm working on an automatic data analysis of electron beam (emittance
> measurement with a wire scanner and a magnetic lens) with EPICS.
> I get values from the hardware (self build measurement cards). The
> device support put the values into a longin records (this part is fixed,
> because it is already used for other applications).
> I need to gather the values (will be a position and a corresponding
> current) for a certain amount of time (approximately 1000 to 10000
> values)  and then hand it over to a subroutine, to perform the analysis
> (like fitting a curve onto the data). It should all run on a debian
> machine.
>
> My problem is to collect the data with EPICS. I thought about collecting
> them somehow in a waveform record, but i have no idea, how to do this by
> using other records instead of the device support.

I must admit that I have not tried it for data analysis, but I see no reason
not to use a state machine, a.k.a. an SNL program.

Let's say you wrote a C function

        double do_analysis(int *meas, int count);

that actually performs the analysis. For simplicity I assume here that the
result is a single scalar, but it should be obvious how to adapt the following
to more complex results.

A little SNL program that calls the C procedure follows:

        program data_analysis

We define an array of integers for the measurement data

        #define N_MEAS 10000;

        int measurements[N_MEAS];
        assign measurements to {};

and some variables for the results; for simplicity I assume here that the
result is a single scalar

        double result;
        assign result to "RESULT";

Then use dynamic assign for the inputs; this is easy if your records follow a
systematic naming convention, I am assuming the most simple case here, i.e.
they are called "MEAS_0", "MEAS_1",...:

        entry {
                int i;
                for (i=0; i<N_MEAS; i++) {
                        char name[10];
                        snprintf(name, "MEAS_%d", i);
                        pvAssign(measurements[i], name);
                }
        }

We create a state set

        ss analysis {
                state analyse {
                        when(delay(0.01)) { /*assuming 100Hz rate*/
                                result = do_analysis(measurements, N_MEAS);
                                pvPut(result);
                        } state analyse
                }
        }

Voila, that's it.

Of course this is only a rough sketch; you might want to trigger the analysis
whenever new data arrives, you may have an extra record for the actual number
of measurements, you might have more than one result (maybe an array or more
than one array) etc.pp. but I think SNL supports all this quite nicely. For
details, see  http://tinyurl.com/epics-seq/

Cheers
--
Ben Franksen
()  ascii ribbon campaign - against html e-mail
/\  www.asciiribbon.org   - against proprietary attachments

________________________________

Helmholtz-Zentrum Berlin für Materialien und Energie GmbH

Mitglied der Hermann von Helmholtz-Gemeinschaft Deutscher Forschungszentren e.V.

Aufsichtsrat: Vorsitzender Prof. Dr. Dr. h.c. mult. Joachim Treusch, stv. Vorsitzende Dr. Beatrix Vierkorn-Rudolph
Geschäftsführung: Prof. Dr. Anke Rita Kaysser-Pyzalla, Thomas Frederking

Sitz Berlin, AG Charlottenburg, 89 HRB 5583

Postadresse:
Hahn-Meitner-Platz 1
D-14109 Berlin

http://www.helmholtz-berlin.de


Replies:
RE: How can I collect data values Mark Rivers
References:
How can I collect data values Kai Stein

Navigate by Date:
Prev: RE: How can I collect data values Hu, Yong
Next: RE: How can I collect data values Mark Rivers
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: RE: How can I collect data values Hu, Yong
Next: RE: How can I collect data values Mark Rivers
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 ·