From 45216ff0f0ed85b464b81680b17fc446c77d769a Mon Sep 17 00:00:00 2001 From: Matej Sekoranja Date: Tue, 23 Sep 2014 13:47:33 +0200 Subject: [PATCH] testServer: loading of RGB image --- pvtoolsSrc/eget.cpp | 4 ++-- testApp/remote/testNTImage.cpp | 35 +++++++++++++++++++++++++++++----- testApp/remote/testServer.cpp | 3 ++- 3 files changed, 34 insertions(+), 8 deletions(-) diff --git a/pvtoolsSrc/eget.cpp b/pvtoolsSrc/eget.cpp index 40ecf78..7c684db 100644 --- a/pvtoolsSrc/eget.cpp +++ b/pvtoolsSrc/eget.cpp @@ -757,8 +757,8 @@ void formatNTNDArray(std::ostream& /*o*/, PVStructurePtr const & pvStruct) } else if (cm == 2 && dims == 3) { - cols = data[0]->getSubField("size")->get(); - rows = data[1]->getSubField("size")->get(); + cols = data[1]->getSubField("size")->get(); + rows = data[2]->getSubField("size")->get(); imageSize = cols * rows * 3; } else diff --git a/testApp/remote/testNTImage.cpp b/testApp/remote/testNTImage.cpp index bd93d0b..600edfe 100644 --- a/testApp/remote/testNTImage.cpp +++ b/testApp/remote/testNTImage.cpp @@ -117,21 +117,46 @@ void setNTNDArrayData( imagePV->getSubField("uniqueId")->put(0); PVStructureArray::shared_pointer pvAttributes = imagePV->getSubField("attribute"); + PVStructureArray::svector attributes(pvAttributes->reuse()); - PVStructure::shared_pointer attribute = - getPVDataCreate()->createPVStructure(pvAttributes->getStructureArray()->getStructure()); + bool addNew = false; + + PVStructure::shared_pointer attribute; + + // find ColorMode + for (PVStructureArray::const_svector::const_iterator iter = attributes.begin(); + iter != attributes.end(); + iter++) + { + PVStructure::shared_pointer fattribute = *iter; + PVString::shared_pointer pvName = fattribute->getSubField("name"); + if (pvName && pvName->get() == "ColorMode") + { + attribute = fattribute; + break; + } + } + + if (!attribute) + { + attribute = getPVDataCreate()->createPVStructure(pvAttributes->getStructureArray()->getStructure()); + addNew = true; + } + attribute->getSubField("name")->put("ColorMode"); PVInt::shared_pointer pvColorMode = getPVDataCreate()->createPVScalar(); pvColorMode->put(colorMode); - attributes.push_back(attribute); - pvAttributes->replace(freeze(attributes)); + + if (addNew) + attributes.push_back(attribute); + attribute->getSubField("value")->set(pvColorMode); attribute->getSubField("descriptor")->put("Color mode"); attribute->getSubField("sourceType")->put(0); attribute->getSubField("source")->put(""); - + pvAttributes->replace(freeze(attributes)); } void initImage( diff --git a/testApp/remote/testServer.cpp b/testApp/remote/testServer.cpp index 0151372..7b0d359 100644 --- a/testApp/remote/testServer.cpp +++ b/testApp/remote/testServer.cpp @@ -1475,7 +1475,8 @@ public: initImage(m_pvStructure, "", 0 /* NDColorModeMono=0 */, 2, dim, fileSize, 0); } - PVByteArrayPtr value = std::tr1::dynamic_pointer_cast(m_pvStructure->getSubField("value")); + PVUnionPtr unionValue = m_pvStructure->getSubField("value"); + PVByteArrayPtr value = unionValue->select("byteValue"); PVByteArray::svector temp(value->reuse()); temp.resize(fileSize); in.readsome((char*)temp.data(), fileSize);