void NTNDArrayRecord::setAttributes() { // Get the attribute field PVStructureArrayPtr attributeField = ndarray->getAttribute(); // Create a shared vector or reuse PVStructureArray::svector attributes(attributeField->reuse()); attributes.reserve(1); // Create an attribute for the Color Mode // name: ColorMode // value: variant union stores a PVInt with value 0 // descriptor: "Color mode" // source: "" // sourceType = 0 PVStructurePtr attribute = getPVDataCreate()->createPVStructure(attributeField->getStructureArray()->getStructure()); NTNDArrayAttributePtr ntattribute = NTNDArrayAttribute::wrap(attribute); ntattribute->getName()->put("ColorMode"); PVInt::shared_pointer pvColorMode = getPVDataCreate()->createPVScalar<PVInt>(); pvColorMode->put(0); ntattribute->getValue()->set(pvColorMode); ntattribute->getDescriptor()->put("Color mode"); ntattribute->getSourceType()->put(0); ntattribute->getSource()->put(""); attributes.push_back(attribute); // Replace the attribute fields stored attributeField->replace(freeze(attributes)); }
void NTNDArrayRecord::setDimension(const int32_t * dims, size_t ndims) { // Get the dimension field PVStructureArrayPtr dimField = ndarray->getDimension(); // create a shared_vector or try to reuse the dimension field's one PVStructureArray::svector dimVector(dimField->reuse()); // resize/reserve the number of elements dimVector.resize(ndims); // Iterate over the number of dimensions, creating and adding the // appropriate dimension structures. for (size_t i = 0; i < ndims; i++) { PVStructurePtr d = dimVector[i]; if (!d || !d.unique()) d = dimVector[i] = getPVDataCreate()->createPVStructure(dimField->getStructureArray()->getStructure()); d->getSubField<PVInt>("size")->put(dims[i]); d->getSubField<PVInt>("offset")->put(0); d->getSubField<PVInt>("fullSize")->put(dims[i]); d->getSubField<PVInt>("binning")->put(1); d->getSubField<PVBoolean>("reverse")->put(false); } // replace the dimensions field's shared_vector // (Remember to freeze first) dimField->replace(freeze(dimVector)); }