EPICS Home

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  <20172018  2019  2020  2021  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  <20172018  2019  2020  2021  2022  2023  2024 
<== Date ==> <== Thread ==>

Subject: Re: save array of floats into HDF5 as attribute
From: Hinko Kocevar <[email protected]>
To: Mark Rivers <[email protected]>
Cc: "[email protected]" <[email protected]>
Date: Tue, 26 Sep 2017 14:42:11 +0200
Hi Mark,

thanks for explaining! I managed to get the FTVL=CHAR waveforms to appear as strings in the HDF5 file, on another occasion.

What I want to save now are coefficients that need to be floats, chars (FTVL=CHAR) will not cut it.
I'll resort to defining 10 ai records instead of one waveform for now, since I need this in the coming days/weeks.

Will keep an eye on the #2 issue, though!

Thanks,
Hinko


On Tue, Sep 26, 2017 at 2:19 PM, Mark Rivers <[email protected]> wrote:
I have updated the Github issue to raise the possibility of supporting arrays in NDAttributes by storing them as strings.

https://github.com/areaDetector/ADCore/issues/2

Mark

________________________________
From: Mark Rivers
Sent: Tuesday, September 26, 2017 7:12 AM
To: Hinko Kocevar; [email protected]
Subject: RE: save array of floats into HDF5 as attribute

Hi Hinko,

> can I save an array of floats into HDF5 file through areaDetector Attribute?

No, unfortunately that is not possible.  There is a 4 year old issue in ADCore about this:
https://github.com/areaDetector/ADCore/issues/2

This is from NDAttribute.h

******************************************
/** Union defining the values in an NDAttribute object */
typedef union {
    epicsInt8    i8;    /**< Signed 8-bit integer */
    epicsUInt8   ui8;   /**< Unsigned 8-bit integer */
    epicsInt16   i16;   /**< Signed 16-bit integer */
    epicsUInt16  ui16;  /**< Unsigned 16-bit integer */
    epicsInt32   i32;   /**< Signed 32-bit integer */
    epicsUInt32  ui32;  /**< Unsigned 32-bit integer */
    epicsFloat32 f32;   /**< 32-bit float */
    epicsFloat64 f64;   /**< 64-bit float */
} NDAttrValue;

/** Structure used by the EPICS ellLib library for linked lists of C++ objects.
  * This is needed for ellLists of C++ objects, for which making the first data element the ELLNODE
  * does not work if the class has virtual functions or derived classes. */
typedef struct NDAttributeListNode {
    ELLNODE node;
    class NDAttribute *pNDAttribute;
} NDAttributeListNode;

/** NDAttribute class; an attribute has a name, description, source type, source string,
  * data type, and value.
  */
class epicsShareClass NDAttribute {
public:
    /* Methods */
    NDAttribute(const char *pName, const char *pDescription,
                NDAttrSource_t sourceType, const char *pSource, NDAttrDataType_t dataType, void *pValue);
    NDAttribute(NDAttribute& attribute);
    static const char *attrSourceString(NDAttrSource_t type);
    virtual ~NDAttribute();
    virtual NDAttribute* copy(NDAttribute *pAttribute);
    virtual const char *getName();
    virtual const char *getDescription();
    virtual const char *getSource();
    virtual const char *getSourceInfo(NDAttrSource_t *pSourceType);
    virtual NDAttrDataType_t getDataType();
    virtual int getValueInfo(NDAttrDataType_t *pDataType, size_t *pDataSize);
    virtual int getValue(NDAttrDataType_t dataType, void *pValue, size_t dataSize=0);
    virtual int getValue(std::string& value);
    virtual int setDataType(NDAttrDataType_t dataType);
    virtual int setValue(const void *pValue);
    virtual int setValue(const std::string&);
    virtual int updateValue();
    virtual int report(FILE *fp, int details);
    friend class NDArray;
    friend class NDAttributeList;


private:
    template <typename epicsType> int getValueT(void *pValue, size_t dataSize);
    std::string name_;              /**< Name string */
    std::string description_;       /**< Description string */
    NDAttrDataType_t dataType_;     /**< Data type of attribute */
    NDAttrValue value_;             /**< Value of attribute except for strings */
    std::string string_;            /**< Value of attribute for strings */
    std::string source_;            /**< Source string - EPICS PV name or DRV_INFO string */
    NDAttrSource_t sourceType_;     /**< Source type */
    std::string sourceTypeString_;  /**< Source type string */
    NDAttributeListNode listNode_;  /**< Used for NDAttributeList */
******************************************

So the value_ member is a union of the numeric data types, and it can store only a single value.

The exception is for strings, where the value is stored in the std::string string_ member.  There is effectively no length limit on strings.

If you change from DBR_NATIVE to DBR_STRING it will read the entire array as a string if the waveform record FTVL is CHAR.  So I was hoping this would work to read your array:

<Attribute name="GaussParams"  type="EPICS_PV" source="DTU:GaussParams"   dbrtype="DBR_STRING"  description="Gauss params"/>

However, I just tested this with a waveform record whose FTVL is DOUBLE and it only reads the first element, not the entire array.  I think that is something that would not be too hard to fix:  if the requested dbrtype=DBR_STRING then subscribe for callbacks on the entire array, not just the first element.

Would that be useful for you, i.e. having the array as a string rather than 10 numbers?

Mark

________________________________
From: [email protected] [[email protected]] on behalf of Hinko Kocevar [[email protected]]
Sent: Tuesday, September 26, 2017 3:44 AM
To: [email protected]
Subject: AD: save array of floats into HDF5 as attribute

Hi,

can I save an array of floats into HDF5 file through areaDetector Attribute?

XML definition:

<Attribute name="GaussParams"         type="EPICS_PV" source="DTU:GaussParams"                dbrtype="DBR_NATIVE"  description="Gauss params"/>

where PV is:

record(waveform, "$(P)$(R)GaussParams")
{
field(FTVL, "DOUBLE")
field(NELM, "10")
}


With the above, I only a single (first) value saved in the HDF5 file as opposed to all 10.

Thanks,
Hinko

--
.. the more I see the less I believe.., AE AoR



--
.. the more I see the less I believe.., AE AoR

Replies:
RE: save array of floats into HDF5 as attribute tom.cobb
References:
AD: save array of floats into HDF5 as attribute Hinko Kocevar
RE: save array of floats into HDF5 as attribute Mark Rivers
RE: save array of floats into HDF5 as attribute Mark Rivers

Navigate by Date:
Prev: RE: save array of floats into HDF5 as attribute Mark Rivers
Next: Question about epics/Labview and Ca Lab -- how to put time to my PV from signal waveform chart in labview. lzf neu
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  <20172018  2019  2020  2021  2022  2023  2024 
Navigate by Thread:
Prev: RE: save array of floats into HDF5 as attribute Mark Rivers
Next: RE: save array of floats into HDF5 as attribute tom.cobb
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  <20172018  2019  2020  2021  2022  2023  2024