static void testPostPut() { testDiag("== testPostPut =="); StructureConstPtr structure = fieldCreate->createFieldBuilder()-> add("alarm",standardField->alarm()) -> add("timeStamp",standardField->timeStamp()) -> addNestedStructure("power") -> add("value",pvDouble) -> add("alarm",standardField->alarm()) -> endNested()-> addNestedStructure("voltage") -> add("value",pvDouble) -> add("alarm",standardField->alarm()) -> endNested()-> addNestedStructure("current") -> add("value",pvDouble) -> add("alarm",standardField->alarm()) -> endNested()-> createStructure(); PvaClientPutDataPtr pvaData = PvaClientPutData::create(structure); PVStructurePtr pvStructure = pvaData->getPVStructure(); BitSetPtr change = pvaData->getChangedBitSet(); PVDoublePtr powerValue = pvStructure->getSubField<PVDouble>("power.value"); PVDoublePtr voltageValue = pvStructure->getSubField<PVDouble>("voltage.value"); PVDoublePtr currentValue = pvStructure->getSubField<PVDouble>("current.value"); size_t powerOffset = powerValue->getFieldOffset(); size_t voltageOffset = voltageValue->getFieldOffset(); size_t currentOffset = currentValue->getFieldOffset(); change->clear(); powerValue->put(1.0); voltageValue->put(2.0); currentValue->put(.5); testOk(change->cardinality()==3,"3 fields changed"); testOk(change->get(powerOffset),"power changed"); testOk(change->get(voltageOffset),"voltage changed"); testOk(change->get(currentOffset),"current changed"); }
static void testDouble() { testDiag("== testDouble =="); StructureConstPtr structure = fieldCreate->createFieldBuilder() -> add("alarm",standardField->alarm()) -> add("timeStamp",standardField->timeStamp()) -> add("value",pvDouble) -> createStructure(); PvaClientPutDataPtr pvaData = PvaClientPutData::create(structure); PVDoublePtr pvDouble = pvaData->getPVStructure() -> getSubField<PVDouble>("value"); pvDouble->put(5.0); BitSetPtr change = pvaData->getChangedBitSet(); size_t valueOffset = pvDouble->getFieldOffset(); testOk(change->cardinality()==1,"1 field changed"); testOk(change->get(valueOffset),"value changed"); testOk(pvaData->hasValue(),"hasValue"); testOk(pvaData->isValueScalar(),"isValueScalar"); testOk(!pvaData->isValueScalarArray(),"!isValueScalarArray"); try { testOk(!!pvaData->getValue(), "getValue"); } catch (std::runtime_error e) { testFail("getValue exception '%s'", e.what()); } try { testOk(!!pvaData->getScalarValue(), "getScalarValue"); } catch (std::runtime_error e) { testFail("getScalarValue exception '%s'", e.what()); } try { testOk(!pvaData->getArrayValue(), "!getArrayValue"); } catch (std::runtime_error e) { testPass("getArrayValue exception '%s'", e.what()); } try { testOk(!pvaData->getScalarArrayValue(), "!getScalarArrayValue"); } catch (std::runtime_error e) { testPass("getScalarArrayValue exception '%s'", e.what()); } try { testOk(pvaData->getDouble() == 5.0, "getDouble value"); } catch (std::runtime_error e) { testFail("getDouble exception '%s'", e.what()); } try { testOk(pvaData->getString() == "5", "getString value"); } catch (std::runtime_error e) { testFail("getString exception '%s'", e.what()); } try { shared_vector<const double> value = pvaData->getDoubleArray(); testFail("getDoubleArray"); } catch (std::runtime_error e) { testPass("getDoubleArray exception '%s'", e.what()); } try { shared_vector<const string> value = pvaData->getStringArray(); testFail("getStringArray"); } catch (std::runtime_error e) { testPass("getStringArray exception '%s'", e.what()); } try { pvaData->putDouble(5.0); testPass("putDouble"); } catch (std::runtime_error e) { testFail("putDouble exception '%s'", e.what()); } try { pvaData->putString("1e5"); testPass("putString"); } catch (std::runtime_error e) { testFail("putString exception '%s'", e.what()); } try { size_t len = 2; shared_vector<double> val(len); for (size_t i=0; i<len; ++i) val[i] = (i+1) * 10.0; pvaData->putDoubleArray(freeze(val)); testFail("putDoubleArray"); } catch (std::runtime_error e) { testPass("putDoubleArray exception '%s'", e.what()); } try { size_t len = 2; shared_vector<string> val(len); val[0] = "one"; val[1] = "two"; pvaData->putStringArray(freeze(val)); testFail("putStringArray"); } catch (std::runtime_error e) { testPass("putStringArray exception '%s'", e.what()); } }