2) In the epics:nt/NTTable:1.0"
object all the columns should have the same number of elements/rows. Is it possible to have different number elements/rows in different columns. Presently I am filling the empty ones
with null string.
Yes, something like this will work:
>>> nt2.setColumn(1, [1,2,3])
>>> nt2.setColumn(2, [1,2,3,4,5,6])
>>> print(nt2)
epics:nt/NTTable:1.0
string[] labels []
structure value
int[] column0 []
int[] column1 [1,2,3]
int[] column2 [1,2,3,4,5,6]
int[] column3 []
int[] column4 []
If you prefer the dot notation, this also works:
>>> nt2['value.column0'] = [1,2,3,5,6,7]
>>> nt2['value.column1'] = [1,2,3,5,6,7,8,9]
>>> print(nt2)
epics:nt/NTTable:1.0
string[] labels []
structure value
int[] column0 [1,2,3,5,6,7]
int[] column1 [1,2,3,5,6,7,8,9]
...
--
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 Veseli, Sinisa via Tech-talk <tech-talk at aps.anl.gov>
Sent: Thursday, August 11, 2022 8:57 AM
To: tech-talk at aps.anl.gov <tech-talk at aps.anl.gov>; Kuldeep Joshi <kuldeep.joshi at gmail.com>
Subject: Re: pypva, PvObject and NTTable
Hi,
I want to use a different number of columns depending upon the user configuration.
I have the following queries
1) Can I change the structDict to another
struct2Dict and update the PV. The API
getIntrospectionDict or getStructureDict can only get the existing structure. Is there any API to modify/update the structure of the pv object at runtime?
You cannot change record structure definition at runtime, but you can easily remove old record and add new one:
>>> from pvapy import *
>>> nt = NtTable(3, DOUBLE)
>>> print(nt)
epics:nt/NTTable:1.0
string[] labels []
structure value
double[] column0 []
double[] column1 []
double[] column2 []
string descriptor
alarm_t alarm
int severity 0
int status 0
string message
time_t timeStamp
long secondsPastEpoch 0
int nanoseconds 0
int userTag 0
>>> s = PvaServer()
>>> s.addRecord('t', nt)
>>> c = Channel('t')
>>> pv = c.get()
>>> print(pv)
structure
structure value
double[] column0 []
double[] column1 []
double[] column2 []
>>> nt2 = NtTable(5, INT)
>>> s.update('t', nt2)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: structure definitions do not match
>>> s.removeRecord('t')
>>> s.addRecord('t', nt2)
>>> pv = c.get()
>>> print(pv)
structure
structure value
int[] column0 []
int[] column1 []
int[] column2 []
int[] column3 []
int[] column4 []
2) In the epics:nt/NTTable:1.0"
object all the columns should have the same number of elements/rows. Is it possible to have different number elements/rows in different columns. Presently I am filling
the empty ones with null string.
Yes, something like this will work:
>>> nt2.setColumn(1, [1,2,3])
>>> nt2.setColumn(2, [1,2,3,4,5,6])
>>> print(nt2)
epics:nt/NTTable:1.0
string[] labels []
structure value
int[] column0 []
int[] column1 [1,2,3]
int[] column2 [1,2,3,4,5,6]
int[] column3 []
int[] column4 []
3) Is it possible to have the number of columns of the NTTable PvObject to be programmable at run time. similar to as in C functions printf(char*, ...)
Yes, you can add/remove records at runtime, and hence you can change it however you like.
I hope this helps,
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 Kuldeep Joshi via Tech-talk <tech-talk at aps.anl.gov>
Sent: Thursday, August 11, 2022 6:35 AM
To: tech-talk at aps.anl.gov <tech-talk at aps.anl.gov>
Subject: Re: pypva, PvObject and NTTable
2) In the epics:nt/NTTable:1.0" object all the columns should have the same number of elements/rows. Is it possible to have different number elements/rows in different columns. Presently I am filling the empty ones with null string.
Regarding this point, it seems the limitation is due to the Phoebus table widget.
Hello,
I am using a pypva server and publishing a NTTable object. This object is being displayed using the table widget of phoebus
tablePV = PvObject(structDict, "epics:nt/NTTable:1.0")
I want to use a different number of columns depending upon the user configuration.
I have the following queries
1) Can I change the structDict to another struct2Dict and update the PV. The API
getIntrospectionDict or getStructureDict can only get the existing structure. Is there any API to modify/update the structure of the pv object at runtime?
2) In the epics:nt/NTTable:1.0" object all the columns should have the same number of elements/rows. Is it possible to have different number elements/rows in different columns. Presently I am filling the empty ones with null string.
3) Is it possible to have the number of columns of the NTTable PvObject to be programmable at run time. similar to as in C functions printf(char*, ...)
Presently I am deleting the PvObject and adding one with modified the structure Dictionary.
Thank you in advance.
Regards,
Kuldeep
|