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  2018  2019  2020  2021  2022  <20232024  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  2018  2019  2020  2021  2022  <20232024 
<== Date ==> <== Thread ==>

Subject: Re: Parse multiple waveforms in stream device
From: Zimoch Dirk via Tech-talk <tech-talk at aps.anl.gov>
To: "tech-talk at aps.anl.gov" <tech-talk at aps.anl.gov>, "Abdalla.Ahmad at sesame.org.jo" <Abdalla.Ahmad at sesame.org.jo>
Date: Wed, 6 Sep 2023 09:51:19 +0000
Hi Abdalla,

Unfortunately, StreamDevice currently cannot read "tables", i.e. vertical
columns of multiple arrays. Sorry.

There are ways to work around this problem but they are not easy and involve a
compress record for each array. The trick is to read one line at a time in "I/O
Intr" mode and use redirections to write the 4 values to 4 records (e.g. ai or
longin) which then trigger 4 compress records to add one value to their buffer.
This happens then 10 times for each readout and after that the compress records
should be "full". But many things may go wrong with this approach causing the
records to go out of sync with the input data, e.g. other commands that result
in lines like "  1        2        3        4". Tricky stuff.

Also a custom format converter will not help, because those are always bound to
1 record, not 4 as you need it here.

You can write your own custom client connecting to the same asyn port.
StreamDevice will lock the port before sending a command until the end of the
protocol. This guarantees clean serialization among StreamDevice records
connecting to the same port but also with any other client connecting to the
same port. You must lock the port between sending the command and reading the
table as well.

But maybe the easier solution is to read the whole table into one big waveform
and then let an asubRecord do the sorting and splitting. To allow this, the
whole table must appear to StreamDevice as one input. That means the newline
must NOT be an InTerminator. However, it would be nice to have an "end of table"
terminator which is different from the "end of line" (two newlines?). If you
don't have that, you can try MaxInput if your input has always the same number
of bytes (i.e. digits+signs+spaces+newlines). Otherwise the only table
terminator left is ReadTimeout which will lead to some latency. You will not
need a Separator, as all your data is separated by either space or newline,
which is all whitespace and thus ignored by %d. Thus, your protocol will look
something like this:

readADC {
  InTerminator="";
  MaxInput=360; # My guess: 9*4*10, if possible
#  ReadTimeout=....; # You have to test what works
  out "ADC 10";
  in "%d";
}

Yours
Dirk

On Wed, 2023-09-06 at 09:22 +0000, Abdalla Ahmad via Tech-talk wrote:
> Hi
>  
> We have a device that performs data read-out as follows:
>  
> We send the command “ADC 10” that collects 10 ADC samples for each of the 4 channels, the response is as follows:
>  
>        1        2        3        4
>       -5       -8       0        1
>  
> And so on until the 10th sample. The target is to read each channel individually in its own waveform record. Here are my questions:
> 1.       Is it possible to parse such output in stream device? I tried the “Separator” command as explained here https://paulscherrerinstitute.github.io/StreamDevice/tipsandtricks.html along with this input command (in “%d%*d%*d%*d”) but it always read one sample. This input command should choose the channel and then with the separator command should convert the output into the waveform but that is not what happening. I also tried using PCRE to skip or substitute parts of the input but it is still the same.
> 2.       Is it possible to use the stream device format converter API to create a custom parser for this case? If yes, is there a tutorial on how to do it?
> 3.       Can I write an asynPortDriver class that uses the same asyn port as the stream device?
>  
> Thanks!
> Abdalla
>  

Replies:
RE: Parse multiple waveforms in stream device Abdalla Ahmad via Tech-talk
Re: Parse multiple waveforms in stream device Maren Purves via Tech-talk
References:
Parse multiple waveforms in stream device Abdalla Ahmad via Tech-talk

Navigate by Date:
Prev: RE: Parse multiple waveforms in stream device Abdalla Ahmad via Tech-talk
Next: RE: Parse multiple waveforms in stream device Abdalla Ahmad 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  2018  2019  2020  2021  2022  <20232024 
Navigate by Thread:
Prev: RE: Parse multiple waveforms in stream device Abdalla Ahmad via Tech-talk
Next: RE: Parse multiple waveforms in stream device Abdalla Ahmad 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  2018  2019  2020  2021  2022  <20232024 
ANJ, 06 Sep 2023 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·