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  <2026 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  <2026
<== Date ==> <== Thread ==>

Subject: Re: Issues with PVXS
From: Michael Davidsaver via Tech-talk <tech-talk at aps.anl.gov>
To: Mark Rivers <rivers at cars.uchicago.edu>
Cc: EPICS Tech Talk <tech-talk at aps.anl.gov>
Date: Mon, 19 Jan 2026 19:54:12 -0800
Hi Mark,

On 1/19/26 3:18 PM, Mark Rivers via Tech-talk wrote:
Hi Ralph,


I'm sure you are correct.  I believe the issue is that PVXS is promoting the datatype during an assignment in the plugin code.  This is not obvious.

This is the line that sets the codec.parameters field in ntndArrayConverterPvxs.cpp:

    m_value["codec.parameters"] = (int32_t) NDDataTypeToScalar[src->dataType];

m_value is of type pvxs::Value.  It is doing its best to define codec.parameters as being of type int32_t.

However, as far as I can tell PXVS use the StoreType enum to define the datatypes that can be stored.

StoreType is relevant for the in-memory representation, and does store scalar integers as (u)int64.  (wasting up to 7 bytes!)  The wire representation is determined by the TypeCode enum, which includes the full range of PVA supported scalar integer types.  As does the in-memory representation for arrays (see also the ArrayType enum).


StoreType and ArrayType mostly do not cross over.  The exception is when assigning a variant union (aka ANY).  Which is how "codec.parameters" is defined.  Using the "Value::operator=()" will automatically promote integers, as you have found.  Arrays are not promoted.


PVXS does provide a way to assign an ANY with an explicit type.


Value paramval = TypeDef(TypeCode::Int32).create();
paramval = NDDataTypeToScalar[src->dataType];
m_value["codec.parameters"].from(paramval);

To make this slightly more efficient, avoid re-creating the type each time.  (TypeDef is relatively expensive)


// once
this->paramval = TypeDef(TypeCode::Int32).create();

// each time
Value paramval(this->paramval.cloneEmpty());
paramval = NDDataTypeToScalar[src->dataType];
m_value["codec.parameters"].from(paramval);


..
So the issue is that PVXS is not allowing the creation of the same data structures that PVA does, at least not with the Value class.

PVXS supports the full range of scalar integer field types.



There is a further issue.  NTNDArrays can be compressed.  For compressed arrays the datatype is effectively uint8_t, but the actual datatype of the original array must be conveyed.  By convention this is stored in codec.parameters as an int.  The int is one of the values in the ScalarType enum.

I completely agree with Ralph that robust client code interpreting PVA structures should be written to implicitly convert between numeric types when accessing scalar fields.  pvDataCPP/Java made it complex for API users to do this, leading to breakages like you are seeing.  PVXS makes it complex for users not to do this.  (I can't speak directly for Kay's core.pva library, but I suspect the same is true)


The ScalarType enum is defined here in PVA:

For Java it is defined here:

However, I cannot find an equivalent enum in PVXS.  So ntndArrayConverterPvxs.cpp currently has to include pv/pvIntrospect.h from PVA to get the required definition.  This is ugly since it is mixing code from PVA and PVXS.


In PVXS, the ScalarType enum, along with its cousins, are collapsed down into the single TypeCode enum.


https ://github.com/epics-base/pvxs/blob/48b260d008bd1d65c5f132c54523e27b41d0f4c3/src/pvxs/data.h#L154-L190



Replies:
Re: Issues with PVXS Michael Davidsaver via Tech-talk
Re: Issues with PVXS Mark Rivers via Tech-talk
References:
Issues with PVXS Mark Rivers via Tech-talk
Re: Issues with PVXS Ralph Lange via Tech-talk
Re: Issues with PVXS Mark Rivers via Tech-talk

Navigate by Date:
Prev: Re: Issues with PVXS Mark Rivers via Tech-talk
Next: Re: Issues with PVXS Michael Davidsaver 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  <2026
Navigate by Thread:
Prev: Re: Issues with PVXS Mark Rivers via Tech-talk
Next: Re: Issues with PVXS Michael Davidsaver 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  <2026
ANJ, 19 Mar 2026 · Home · News · About · Talk · Base · Modules · Extensions ·
· Distributions · Download · Documents · Links · Licensing ·