On 06/19/2018 10:49 AM, Heinz Junkes wrote:
> HI,
>
> try to create NTTable :
>
> NTTableBuilderPtr builder = NTTable::createBuilder();
>
> PVStructurePtr pvStructure = builder->
> addColumn("ts", pvInt)->
> addColumn("X", pvDouble)->
> addColumn("Y", pvDouble)->
> addColumn("Z", pvDouble)->
> addDescriptor()->
> addAlarm()->
> addTimeStamp()->
> createPVStructure();
>
> Unfortunately, I always end up with "core-dump” on the RTEMS-system.
Are you able to test on another OS as well?
> I have not understood yet how to specify the length for the four arrays (pvInt, pvDouble [X,Y,Z] ) connected to the 4 columns.
> I thought I had to add an array structure to the 4 columns. But I found nothing in the nttable.h file how to do that.
> Every note is welcome as always.
As the reluctant maintainer of normativeTypesCPP I'm recommending not to use class NTTable.
I've not found it so helpful since, as you've found, it doesn't help with handling column data.
A more complete example, which should compile and not crash (it's late).
> #include <pv/pvData.h>
> #include <pv/standardField.h>
> namespace pvd = epics::pvData;
>
> static
> pvd::StructureConstPtr typedesc(pvd::getFieldCreate()->createFieldBuilder()
> ->setId("epics:nt/NTTable:1.0")
> ->addArray("labels", pvd::pvString)
> ->addNestedStructure("value")
> ->addArray("ts", pvd::pvInt)
> ->addArray("X", pvd::pvDouble)
> ->addArray("Y", pvd::pvDouble)
> ->addArray("Z", pvd::pvDouble)
> ->endNested()
> //->add("timeStamp", pvd::getStandardField()->timeStamp()) // unused in this example
> //->add("alarm", pvd::getStandardField()->alarm())
> ->createStructure());
>
> pvd::PVStructure::shared_pointer buildTable(){
> pvd::shared_vector<std::string> labels;
> labels.push_back("The TS");
> labels.push_back("The X");
> labels.push_back("The Y");
> labels.push_back("The Z");
>
> pvd::shared_vector<pvd::int32> ts;
> pvd::shared_vector<double> X, Y, Z;
>
> for(size_t i=0; i<10; i++) { // some fake data
> ts.push_back(i*10);
> X.push_back(i);
> Y.push_back(i+1);
> Z.push_back(i+2);
> }
>
> pvd::PVStructure::shared_pointer value(pvd::getPVDataCreate()->createPVStructure(typedesc));
>
> value->getSubFieldT<pvd::PVScalarArray>("labels")->putFrom(freeze(labels));
> value->getSubFieldT<pvd::PVScalarArray>("value.ts")->putFrom(freeze(ts));
> value->getSubFieldT<pvd::PVScalarArray>("value.X")->putFrom(freeze(X));
> value->getSubFieldT<pvd::PVScalarArray>("value.Y")->putFrom(freeze(Y));
> value->getSubFieldT<pvd::PVScalarArray>("value.Z")->putFrom(freeze(Z));
>
> return value;
> }
- Replies:
- Re: CPP example NTTable builder Heinz Junkes
- References:
- CPP example NTTable builder Heinz Junkes
- Navigate by Date:
- Prev:
Re: EPICS Meeting Talk files Ricardo Cardenes
- Next:
AW: EPICS Meeting Talk files Mexner, Wolfgang (IBPT)
- 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
- Navigate by Thread:
- Prev:
CPP example NTTable builder Heinz Junkes
- Next:
Re: CPP example NTTable builder Heinz Junkes
- 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
|