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  <20212022  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  2020  <20212022  2023  2024 
<== Date ==> <== Thread ==>

Subject: Re: changing unit string to scale factor
From: "Zimoch Dirk \(PSI\) via Tech-talk" <tech-talk at aps.anl.gov>
To: "tech-talk at aps.anl.gov" <tech-talk at aps.anl.gov>, "rcayford at lbl.gov" <rcayford at lbl.gov>
Date: Tue, 26 Jan 2021 10:33:18 +0000
On Mon, 2021-01-25 at 12:16 -0800, Randall Cayford via Tech-talk wrote:
> I have a device which returns a value and a string indicating the units of the value.  I’ll get inputs like 0.3nA or
> 3.4mA, etc.  Since I want to report the value in a consistent unit, I want to convert the unit string to a scale
> factor (nA=1, uA=1000, mA=10000) and then use a calc record to scale the value.   CALC records seem to only take
> numbers as input and I don’t see any other appropriate record type.
> 
> In programming I would use a case statement or if-elseif constructs.  How do I do this with EPICS record processing?
> 
> Randall
> LBNL
> 

When using StreamDevice, you can use regular expression preprocessing to modify the unit prefixes.
Assuming the possible units are nA, uA, and mA (not A) and you want everything in nA, you can convert the unit prefix
letters to exponential scaling factors like this:

    in "%#/u/e3n/%#/m/e6n/%fnA";

Then "uA" becomes "3enA" and "mA" becomes "e6nA". Your example "3.4mA" becomes "3.4e6nA" before "%fnA" reads it.

Dirk


References:
changing unit string to scale factor Randall Cayford via Tech-talk

Navigate by Date:
Prev: Re: EPICS Archiver routing issue Ralph Lange via Tech-talk
Next: EPICS Module mrfioc2 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  <20212022  2023  2024 
Navigate by Thread:
Prev: Re: changing unit string to scale factor Jeong Han Lee via Tech-talk
Next: Can I open a CSS Phoebus layout from the command line Phillip A. Sorensen 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  <20212022  2023  2024 
ANJ, 26 Jan 2021 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·