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

Subject: RE: save array of floats into HDF5 as attribute
From: <tom.cobb@diamond.ac.uk>
To: <hinkocevar@gmail.com>, <rivers@cars.uchicago.edu>
Cc: tech-talk@aps.anl.gov
Date: Tue, 26 Sep 2017 13:20:51 +0000

If these are static values there is another possible workaround, you can hardcode them in the XML layout file. From the docs at http://cars.uchicago.edu/software/epics/NDFileHDF5.html

 

XML attribute

Required

Description

Value

value

Required only if source="constant"

Constant value to write directly into the HDF5 dataset

String - possibly containing int or float values. Arrays of int and float values can also be represented in a comma-separated string

 

Thanks,

Tom

 

> -----Original Message-----

> From: tech-talk-bounces@aps.anl.gov [mailto:tech-talk-

> bounces@aps.anl.gov] On Behalf Of Hinko Kocevar

> Sent: 26 September 2017 13:42

> To: Mark Rivers

> Cc: tech-talk@aps.anl.gov

> Subject: Re: save array of floats into HDF5 as attribute

>

> 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 <rivers@cars.uchicago.edu>

> 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

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

>

>              Mark

>

>              ________________________________

>              From: Mark Rivers

>              Sent: Tuesday, September 26, 2017 7:12 AM

>              To: Hinko Kocevar; tech-talk@aps.anl.gov

>              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

> <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: tech-talk-bounces@aps.anl.gov [tech-talk-

> bounces@aps.anl.gov] on behalf of Hinko Kocevar [hinkocevar@gmail.com]

>              Sent: Tuesday, September 26, 2017 3:44 AM

>              To: tech-talk@aps.anl.gov

>              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

 

-- 

This e-mail and any attachments may contain confidential, copyright and or privileged material, and are for the use of the intended addressee only. If you are not the intended addressee or an authorised recipient of the addressee please notify us of receipt by returning the e-mail and do not use, copy, retain, distribute or disclose the information in or attached to the e-mail.
Any opinions expressed within this e-mail are those of the individual and not necessarily of Diamond Light Source Ltd.
Diamond Light Source Ltd. cannot guarantee that this e-mail or any attachments are free from viruses and we cannot accept liability for any damage which you may sustain as a result of software viruses which may be transmitted in or with the message.
Diamond Light Source Limited (company no. 4375679). Registered in England and Wales with its registered office at Diamond House, Harwell Science and Innovation Campus, Didcot, Oxfordshire, OX11 0DE, United Kingdom
 


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
Re: save array of floats into HDF5 as attribute Hinko Kocevar

Navigate by Date:
Prev: Question about epics/Labview and Ca Lab -- how to put time to my PV from signal waveform chart in labview. lzf neu
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  <2017
Navigate by Thread:
Prev: Re: save array of floats into HDF5 as attribute Hinko Kocevar
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  <2017
ANJ, 26 Sep 2017 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·