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  <20222023  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  2021  <20222023  2024 
<== Date ==> <== Thread ==>

Subject: Re: NTNDArray with attributes using QSRV group Pas
From: "Veseli, Sinisa via Tech-talk" <tech-talk at aps.anl.gov>
To: "tech-talk at aps.anl.gov" <tech-talk at aps.anl.gov>, Joao Paulo Martins <JoaoPaulo.Martins at ess.eu>, "Kasemir, Kay" <kasemirk at ornl.gov>
Date: Wed, 2 Nov 2022 15:40:50 +0000
Hi,

Although this does not help with your problem, perhaps it is worth looking into as possible alternative approach for serving images:

>>> import time
>>> import pvaccess as pva
>>> attr = pva.NtAttribute('x', pva.PvInt(3))
>>> attr['timeStamp'] = pva.PvTimeStamp(time.time())
>>> nda = pva.NtNdArray()
>>> nda['attribute'] = [attr]
>>> nda['timeStamp'] = pva.PvTimeStamp(time.time())
>>> s = pva.PvaServer('image', pva.NtNdArray())
>>> s.update('image', nda)
>>>

$ pvget image
image epics:nt/NTNDArray:1.0
    union value
        (none)
    codec_t codec
        string name
        any parameters
            (none)
    long compressedSize 0
    long uncompressedSize 0
    dimension_t[] dimension
    int uniqueId 0
    time_t dataTimeStamp <undefined>              
        long secondsPastEpoch 0
        int nanoseconds 0
        int userTag 0
    epics:nt/NTAttribute:1.0[] attribute
        epics:nt/NTAttribute:1.0
            string name x
            any value
                int  3
            string[] tags []
            string descriptor
            structure alarm
                int severity 0
                int status 0
                string message
            structure timeStamp
                long secondsPastEpoch 1667401566
                int nanoseconds 915819406
                int userTag -1
            int sourceType 0
            string source
    string descriptor
    alarm_t alarm
        int severity 0
        int status 0
        string message
    time_t timeStamp 2022-11-02 10:06:28.768  -1
        long secondsPastEpoch 1667401588
        int nanoseconds 768045902
        int userTag -1
    display_t display
        double limitLow 0
        double limitHigh 0
        string description
        string format
        string units

Also note that pvapy has some useful utilities available for this:

>>> from pvapy.utility.adImageUtility import AdImageUtility
>>> image = AdImageUtility.generateNtNdArray2D(imageId=1, image=np.array([[1,2,3,4,5],[11,12,13,14,15]], dtype=np.uint8))
>>> print(image)
epics:nt/NTNDArray:1.0
    union value
        ubyte[] ubyteValue [1,2,3,4,5,11,12,13,14,15]
    codec_t codec
        string name
...

Best Regards,

Sinisa

--
Siniša Veseli
Scientific Software Engineering & Data Management
Advanced Photon Source
Argonne National Laboratory
sveseli at anl.gov
(630)252-9182

From: Tech-talk <tech-talk-bounces at aps.anl.gov> on behalf of Kasemir, Kay via Tech-talk <tech-talk at aps.anl.gov>
Sent: Wednesday, November 2, 2022 9:28 AM
To: tech-talk at aps.anl.gov <tech-talk at aps.anl.gov>; Joao Paulo Martins <JoaoPaulo.Martins at ess.eu>
Subject: Re: NTNDArray with attributes using QSRV group Pas
 
I think this shows that the "info(Q:group, ..." approach may not be the one, only and final way to assemble information from records into custom PV Access data structures.

Info tags can be useful to configure a simple aggregation of records into a combined data type. But if we then want to control the exact naming and layout of the resulting structure, add details about the order of timing, time stamps, .. we're starting to invent a new programming syntax. At that point, maybe it's better to fall back to an existing programming syntax like python or lua. We can already create custom PVA data structures from python, maybe tying that into the IOC's record processing is a better approach for creating fully custom data structures?

From: Tech-talk <tech-talk-bounces at aps.anl.gov> on behalf of Joao Paulo Martins via Tech-talk <tech-talk at aps.anl.gov>
Sent: Wednesday, November 2, 2022 10:04 AM
To: tech-talk at aps.anl.gov <tech-talk at aps.anl.gov>
Subject: [EXTERNAL] NTNDArray with attributes using QSRV group Pas
 

Hello,

 

I’m trying to instantiate a NTNDArray with some NTAttributes in my IOC using QSRV group PV definitions, as the example in pva2pva (https://github.com/epics-base/pva2pva/blob/master/iocBoot/iocimagedemo/image.db ).

 

If I set the database as the following:

 

record(waveform, "$(P)ArrayData") {

    field(FTVL, "USHORT")

    field(NELM, "262144")

    info(Q:group, {

        "$(N):Array":{

            +id:"epics:nt/NTNDArray:1.0",

            "value":{+type:"any",

                     +channel:"VAL",

                     +trigger:"*"},

            "":{+type:"meta", +channel:"SEVR"}

        }

    })

}

 

record(mbbi, "$(P)FOO") {

    info(Q:group, {

        "$(N):Array":{

            "attribute[0].value":{+type:"any", +channel:"VAL"},

            "attribute[0].timeStamp":{+type:"meta", +channel:"TIME"}

 

        }

    })

}

 

the resulting NTNDArray PV will have the following structure in its attribute[0] field:

 

structure

            structure timeStamp

                alarm_t alarm

                    int severity 0

                    int status 0

                    string message NO_ALARM

                time_t timeStamp

                    long secondsPastEpoch 1667394506

                    int nanoseconds 335496073

                    int userTag 0

            any value

                double  0

 

The timeStamp values of the top structure are correctly taken from the “ArrayData” record. However, for the “attribute[0]” field, the timestamp values are taken from the “FOO” record, but the structure of the NTAttribute contains two other structures (alarm and timeStamp) inside the “top” timeStamp structure.

 

The question is: how one can set the “timeStamp” structure of the attribute[] taking the TIME information from a different record than the one used to get the array value?

 

Thanks in advance!

 

João Paulo Martins

European Spallation Source ERIC


Replies:
Re: NTNDArray with attributes using QSRV group Pas Kasemir, Kay via Tech-talk
Re: NTNDArray with attributes using QSRV group Pas Michael Davidsaver via Tech-talk
References:
NTNDArray with attributes using QSRV group Pas Joao Paulo Martins via Tech-talk
Re: NTNDArray with attributes using QSRV group Pas Kasemir, Kay via Tech-talk

Navigate by Date:
Prev: Open position at Diamond: Head of Beamline Controls Pedersen, Ulrik (DLSLtd, RAL, LSCI) via Tech-talk
Next: Re: NTNDArray with attributes using QSRV group Pas Kasemir, Kay 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  <20222023  2024 
Navigate by Thread:
Prev: Re: NTNDArray with attributes using QSRV group Pas Kasemir, Kay via Tech-talk
Next: Re: NTNDArray with attributes using QSRV group Pas Kasemir, Kay 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  <20222023  2024 
ANJ, 02 Nov 2022 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·