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

Subject: RE: Streams format converters question ( how to convert 10100 to 1.0E+00, 10011 to 1.0E-11)
From: Zimoch Dirk via Tech-talk <tech-talk at aps.anl.gov>
To: Peter Sx <xinss0017 at gmail.com>, "tech-talk at aps.anl.gov" <tech-talk at aps.anl.gov>
Cc: "sxin at bnl.gov" <sxin at bnl.gov>
Date: Thu, 27 Mar 2025 15:24:31 +0000

Hi Susheng

 

Nice format. People always invent something new.

 

I would try to pre-process the format with regular _expression_ substitution (%#/regex/subs/) so that it fits the normal %f format.

 

We need to keep one digit, then insert a period dot, then take the next digit, insert an “e”, convert a 0 to a – and a 1 to a + and then copy the next two digits. The sign magic is the nasty part.

 

This may do the trick: (I have not tested it yet)

 

in "%#/([0-9])([0-9])0([0-9][0-9])/\1.\2e-\3/%#/([0-9])([0-9])1([0-9][0-9])/\1.\2e+\3/%f";

 

Output too?

 

 

From: Tech-talk <tech-talk-bounces at aps.anl.gov> On Behalf Of Peter Sx via Tech-talk
Sent: Donnerstag, 27. März 2025 14:54
To: tech-talk at aps.anl.gov
Cc: sxin at bnl.gov
Subject: Streams format converters question ( how to convert 10100 to 1.0E+00, 10011 to 1.0E-11)

 

Hi EPICS Specialists:

 

I've run into a problem converting data to exponential readings. I have a device that outputs messages and data in the same channel. I have separated the readings from messages with data by using the following records and protocol. 
I am wondering whether I can add some arguments in the protocol and convert the data through calcout, but I am new to Streams and can't figure out the details.
 
Data format:  ppsee (p.p * 10see):
Symbols   Description
pp        Mantissa of the reading (1.0 to 9.9)
s         Sign of the exponent (0 = negative, 1 = positive)
ee        Exponent (00 to 11)
 

record(ai, "$(Sys)$(Dev)Ch1_Reading")
{
    field(DESC, "Ch1 Reading")
    field(DTYP, "stream")
    field(INP, "@Televac.proto get_Ch1_reading($(Sys)$(Dev)Ch1message) $(PORT)")
    field(SCAN, ".1 second")
}
record(stringin, "$(Sys)$(Dev)Ch1message")
{
}

 

get_Ch1_reading {
    out "S101";
    in "%f";
    @mismatch {in "%(\$1)39c";}
}

 
Current channel readback examples:
[sxin@eic-905-pc01 ~]$ caget 905-HC1-Televac:Ch5_Reading    device panel reading 1.0E-11
905-HC1-Televac:Ch5_Reading    10011
[sxin@eic-905-pc01 ~]$ caget 905-HC1-Televac:Ch6message  
905-HC1-Televac:Ch6message     OFF
 
Thank you!
Susheng

References:
Streams format converters question ( how to convert 10100 to 1.0E+00, 10011 to 1.0E-11) Peter Sx via Tech-talk

Navigate by Date:
Prev: Streams format converters question ( how to convert 10100 to 1.0E+00, 10011 to 1.0E-11) Peter Sx via Tech-talk
Next: Re: Structured PVs archiving and archived data retrieval problem Aleš Kete 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  2023  2024  <2025
Navigate by Thread:
Prev: Streams format converters question ( how to convert 10100 to 1.0E+00, 10011 to 1.0E-11) Peter Sx via Tech-talk
Next: Connect to IOC in container from another host in different network, via CA Gateway Gonzalez, Jose Carlos 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  2023  2024  <2025
ANJ, 28 Mar 2025 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions ·
· Download · Search · IRMIS · Talk · Documents · Links · Licensing ·