void MonitorRequesterImpl::ParseScalarArray(PVScalarArray::shared_pointer const & pvArray, knobData* kPtr) { size_t length = pvArray->getLength(); qDebug() << "lenght of array " << length; PVDoubleArrayPtr ArrayData = static_pointer_cast<epics::pvData::PVDoubleArray> (pvArray); DoubleArrayData valuesArrayData; int valuesLength = ArrayData->get(0, ArrayData->getLength(), valuesArrayData); if((double) (valuesLength * sizeof(double)) != kPtr->edata.dataSize) { free(kPtr->edata.dataB); kPtr->edata.dataB = (void*) malloc(valuesLength * sizeof(double)); kPtr->edata.dataSize = valuesLength * sizeof(double); } kPtr->edata.valueCount = valuesLength; kPtr->edata.precision = 3; // for the time beeing, set to 3 kPtr->edata.fieldtype = caDOUBLE; memcpy(kPtr->edata.dataB, &valuesArrayData.data[0], valuesLength * sizeof(double)); }
static void test() { NTScalarMultiChannelBuilderPtr builder = NTScalarMultiChannel::createBuilder(); testOk(builder.get() != 0, "Got builder"); NTScalarMultiChannelPtr multiChannel = builder-> addDescriptor()-> addAlarm()-> addTimeStamp()-> addSeverity() -> add("extra1",fieldCreate->createScalar(pvString)) -> add("extra2",fieldCreate->createScalarArray(pvString)) -> create(); testOk1(multiChannel.get() != 0); PVStructurePtr pvStructure = multiChannel->getPVStructure(); testOk1(pvStructure.get()!=NULL); testOk1(NTScalarMultiChannel::is_a(pvStructure->getStructure())); size_t nchan = 3; shared_vector<string> names(nchan); names[0] = "channel 0"; names[1] = "channel 1"; names[2] = "channel 2"; shared_vector<const string> channelNames(freeze(names)); PVStringArrayPtr pvChannelName = multiChannel->getChannelName(); pvChannelName->replace(channelNames); if(debug) {cout << *pvStructure << endl;} multiChannel = builder-> value(pvDouble) -> addDescriptor()-> addAlarm()-> addTimeStamp()-> addSeverity() -> addIsConnected() -> create(); testOk1(multiChannel.get() != 0); pvStructure = multiChannel->getPVStructure(); if(debug) {cout << *pvStructure << endl;} pvChannelName = multiChannel->getChannelName(); pvChannelName->replace(channelNames); PVDoubleArrayPtr pvValue = multiChannel->getValue<PVDoubleArray>(); PVDoubleArray::svector doubles(nchan); doubles.resize(nchan); doubles[0] = 3.14159; doubles[1] = 2.71828; doubles[2] = 137.036; pvValue->replace(freeze(doubles)); shared_vector<int32> severities(nchan); severities[0] = 0; severities[1] = 1; severities[2] = 2; PVIntArrayPtr pvSeverity = multiChannel->getSeverity(); pvSeverity->replace(freeze(severities)); if(debug) {cout << *pvStructure << endl;} PVBooleanArrayPtr pvIsConnected = multiChannel->getIsConnected(); shared_vector<const epics::pvData::boolean> isConnected = pvIsConnected->view(); multiChannel = builder-> value(pvDouble) -> addDescriptor()-> addAlarm()-> addTimeStamp()-> addSeverity() -> addStatus() -> addMessage() -> addSecondsPastEpoch() -> addNanoseconds() -> addUserTag() -> addIsConnected() -> create(); testOk1(multiChannel.get() != 0); pvStructure = multiChannel->getPVStructure(); if(debug) {cout << *pvStructure << endl;} testOk1(NTScalarMultiChannel::isCompatible(pvStructure)==true); PVStructurePtr pvTimeStamp = multiChannel->getTimeStamp(); testOk1(pvTimeStamp.get() !=0); PVStructurePtr pvAlarm = multiChannel->getAlarm(); testOk1(pvAlarm.get() !=0); pvValue = multiChannel->getValue<PVDoubleArray>(); testOk1(pvValue.get() !=0); pvChannelName = multiChannel->getChannelName(); testOk1(pvChannelName.get() !=0); pvIsConnected = multiChannel->getIsConnected(); testOk1(pvIsConnected.get() !=0); pvSeverity = multiChannel->getSeverity(); testOk1(pvSeverity.get() !=0); PVIntArrayPtr pvStatus = multiChannel->getStatus(); testOk1(pvStatus.get() !=0); PVStringArrayPtr pvMessage = multiChannel->getMessage(); testOk1(pvMessage.get() !=0); PVLongArrayPtr pvSecondsPastEpoch = multiChannel->getSecondsPastEpoch(); testOk1(pvSecondsPastEpoch.get() !=0); PVIntArrayPtr pvNanoseconds = multiChannel->getNanoseconds(); testOk1(pvNanoseconds.get() !=0); PVIntArrayPtr pvUserTag = multiChannel->getUserTag(); testOk1(pvUserTag.get() !=0); PVStringPtr pvDescriptor = multiChannel->getDescriptor(); testOk1(pvDescriptor.get() !=0); }