From f6d4c68c398e25850a4166bf245c790bd1890326 Mon Sep 17 00:00:00 2001 From: Matej Sekoranja Date: Thu, 5 Dec 2013 13:07:10 +0100 Subject: [PATCH] introspectionRegistry: enabled caching of non scalar/scalarArrays --- pvAccessApp/utils/introspectionRegistry.cpp | 7 ++- testApp/remote/channelAccessIFTest.cpp | 7 +++ testApp/utils/introspectionRegistryTest.cpp | 60 +++++++++++++++++++++ 3 files changed, 72 insertions(+), 2 deletions(-) diff --git a/pvAccessApp/utils/introspectionRegistry.cpp b/pvAccessApp/utils/introspectionRegistry.cpp index 7abc636..c91e318 100644 --- a/pvAccessApp/utils/introspectionRegistry.cpp +++ b/pvAccessApp/utils/introspectionRegistry.cpp @@ -107,8 +107,11 @@ void IntrospectionRegistry::serialize(FieldConstPtr const & field, ByteBuffer* b } else { - // only structures registry check - if (field->getType() == structure) + // do not cache scalars, scalarArrays + // ... and (array of) variant unions - not worth the complex condition, + // unless bool Field.cache() would exist + if (field->getType() != scalar && + field->getType() != scalarArray) { bool existing; const int16 key = registerIntrospectionInterface(field, existing); diff --git a/testApp/remote/channelAccessIFTest.cpp b/testApp/remote/channelAccessIFTest.cpp index 7814887..cbee7f3 100755 --- a/testApp/remote/channelAccessIFTest.cpp +++ b/testApp/remote/channelAccessIFTest.cpp @@ -21,6 +21,7 @@ #include "channelAccessIFTest.h" +//#define ENABLE_STRESS_TESTS using namespace std::tr1; @@ -41,7 +42,11 @@ std::string ChannelAccessIFTest::TEST_ARRAY_CHANNEL_NAME = "testArray1"; int ChannelAccessIFTest::runAllTest() { +#ifdef ENABLE_STRESS_TESTS testPlan(157); +#else + testPlan(152); +#endif test_implementation(); test_providerName(); @@ -92,9 +97,11 @@ int ChannelAccessIFTest::runAllTest() { test_channelArray_destroy(); test_channelArrayTestNoConnection(); +#ifdef ENABLE_STRESS_TESTS test_stressConnectDisconnect(); test_stressConnectGetDisconnect(); test_stressMonitorAndProcess(); +#endif return testDone(); } diff --git a/testApp/utils/introspectionRegistryTest.cpp b/testApp/utils/introspectionRegistryTest.cpp index a3fbd33..ed9e2c1 100644 --- a/testApp/utils/introspectionRegistryTest.cpp +++ b/testApp/utils/introspectionRegistryTest.cpp @@ -129,6 +129,39 @@ StructureArrayConstPtr getStructureArray(string name1, string name2) return structureArray; } +UnionConstPtr getUnion(string name) +{ + String properties("alarm"); + FieldConstPtrArray powerSupply = new FieldConstPtr[3]; + powerSupply[0] = standardField->scalar( + String("voltage"),pvDouble,properties); + powerSupply[1] = standardField->scalar( + String("power"),pvDouble,properties); + powerSupply[2] = standardField->scalar( + String("current"),pvDouble,properties); + UnionConstPtr punion = getFieldCreate()->createUnion(name,3,powerSupply); + PVField *pvField = pvDataCreate->createPVField(0,punion); + pvFieldArray.push_back(pvField); + return punion; +} + +UnionArrayConstPtr getUnionArray(string name1, string name2) +{ + String properties("alarm"); + FieldConstPtrArray powerSupply = new FieldConstPtr[3]; + powerSupply[0] = standardField->scalar( + String("voltage"),pvDouble,properties); + powerSupply[1] = standardField->scalar( + String("power"),pvDouble,properties); + powerSupply[2] = standardField->scalar( + String("current"),pvDouble,properties); + UnionConstPtr punion = getFieldCreate()->createUnion(name1,3,powerSupply); + UnionArrayConstPtr unionArray = standardField->unionArray(name2,punion); + PVField *pvField = pvDataCreate->createPVField(0,unionArray); + pvFieldArray.push_back(pvField); + return unionArray; +} + //test methods void testRegistryPutGet() { @@ -324,6 +357,33 @@ void testSerialize() name3 = "structure" + ss.str(); name4 = "structureArray" + ss.str(); testSerializeCommon(static_pointer_cast(getStructureArray(name1,name2)),static_pointer_cast(getStructureArray(name3,name4))); + + name1.clear(); + name2.clear(); + ss.str(""); + ss << j; + name1 = "union" + ss.str(); + ss.str(""); + j++; + ss << j; + name2 = "union" + ss.str(); + testSerializeCommon(static_pointer_cast(getUnion(name1)),static_pointer_cast(getUnion(name2))); + + name1.clear(); + name2.clear(); + name3.clear(); + name4.clear(); + ss.str(""); + ss << j; + name1 = "union" + ss.str(); + name2 = "unionArray" + ss.str(); + ss.str(""); + j++; + ss << j; + name3 = "union" + ss.str(); + name4 = "unionArray" + ss.str(); + testSerializeCommon(static_pointer_cast(getUnionArray(name1,name2)),static_pointer_cast(getUnionArray(name3,name4))); + } //serverRegistry->printKeysAndValues("server");