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  <20202021  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  2018  2019  <20202021  2022  2023  2024 
<== Date ==> <== Thread ==>

Subject: Re: Stream device with waveform records
From: "Johnson, Andrew N. via Tech-talk" <tech-talk at aps.anl.gov>
To: "Roehrig, Christian" <roehrig at anl.gov>
Cc: EPICS tech-talk <tech-talk at aps.anl.gov>
Date: Wed, 11 Nov 2020 18:59:39 +0000
@Benjamin Franksen: See below for a possible sequencer bug.

Hi Chris,

On Nov 11, 2020, at 11:45 AM, Roehrig, Christian via Tech-talk <tech-talk at aps.anl.gov> wrote:

    I could use some help formatting an output from a waveform record that uses stream.
 
My IOC is built with:
    Base 7.0.4
    Asyn 4.40
    StreamDevice 2.8.8
    SNCSEQ 2.2.6
 
Here is the record definition.
 
record (waveform, "$(P)$(R):ScanListC")
{
   field(DESC, "Send configuration command.")
   field(DTYP, "stream")
   field(OUT,  "@daq970A.proto set_scan_route $(PORT)")
   field(NELM, "22")
   field(FTVL, "STRING")
}
 
Here is the stream protocol.
 
set_scan_route {
   separator=",";
   out "ROUT:SCAN(@%d)";
}
 
Here is the part of the SNL program that I use to put data into the waveform record.  It may put anywhere from 0 to NUM_CHANNELS (currently 22) integers into the waveform record.
 
int scan_list[NUM_CHANNELS];
assign scan_list to "{P}{R}:ScanListC.VAL";
 
ss set_scan {
 
   state construct_list {
                
      when (set_scan_list == 1) {
 
         set_scan_list = 0;
         counter = 0;
      
         for (channel = 0; channel < NUM_CHANNELS; channel++)
         {
            pvGet(channel_include_in_scan_901A[channel]);
 
            if (channel_include_in_scan_901A[channel] == 1)
            {
               scan_list[counter] = channel + 101;
               counter = counter + 1;
            }
         }
         pvPut(scan_list);
      
      } state construct_list  
   }
}
 
Here is the output on the asyn port when that part of the program runs after I have selected channels 101 and 103 on the MEDM screen and clicked the “Set Scan List” button.
 
ROUT:SCAN(@101,103,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)
 
What I want the output to be is:
 
ROUT:SCAN(@101,103)
 
 
Is there a way to have stream reject the zeros that are not valid data?

Interesting little problem, thanks for including all the elements to describe it.

I’m guessing that StreamDevice uses the current length of the waveform (NORD) as the number of elements it should convert. If that’s true then your problem becomes a sequencer question instead of a Streams question: Is it possible to pvPut() an array value with fewer elements than the array variable (local and remote) is configured to hold?

Unfortunately from the source code it looks like the answer is no; the array length used inside the pvPut() call is always set to the NELM value of the waveform record you’re pointing to.

I suggest you add a subArray record to hold the array that your SNL puts to, and have the SNL code write the channel count to the NELM field before putting the array data to its VAL field. The subArray will strip off the unwanted elements when it processes, and you can then pull the result into a waveform or aao record for StreamDevice to output to your hardware.

Benjamin: There may be a sequencer bug if an SNL array is shorter than the array PV it’s assigned to. The seq_pvPutTmo() routine always uses the max element count from the channel, so it will read data from beyond the end of the local array’s allocated memory. A run under valgrind ought to confirm the problem.

- Andrew

-- 
Complexity comes for free, simplicity you have to work for.


References:
Stream device with waveform records Roehrig, Christian via Tech-talk

Navigate by Date:
Prev: Stream device with waveform records Roehrig, Christian via Tech-talk
Next: RE: LabView-EPICS Integration using SoftIoc Baily, Scott A 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  <20202021  2022  2023  2024 
Navigate by Thread:
Prev: Stream device with waveform records Roehrig, Christian via Tech-talk
Next: read RVB and VAL don't match when moving smarAct motors without encoders Juliane Reinhardt 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  <20202021  2022  2023  2024 
ANJ, 11 Nov 2020 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·