get/setLength capacity removed

This commit is contained in:
Matej Sekoranja
2014-07-22 09:04:08 +02:00
parent c01b928836
commit 16eeeb992b
8 changed files with 37 additions and 62 deletions

View File

@@ -43,9 +43,9 @@ std::string ChannelAccessIFTest::TEST_ARRAY_CHANNEL_NAME = "testArray1";
int ChannelAccessIFTest::runAllTest() {
#ifdef ENABLE_STRESS_TESTS
testPlan(159);
testPlan(158);
#else
testPlan(154);
testPlan(153);
#endif
test_implementation();
@@ -1904,7 +1904,7 @@ void ChannelAccessIFTest::test_channelArray() {
//testOk(data1[2] == 2.2 , "%s: check 2: %f", CURRENT_FUNCTION, data1[2]);
succStatus = arrayReq->syncSetLength(false, 3, 0, getTimeoutSec());
succStatus = arrayReq->syncSetLength(false, 3, getTimeoutSec());
if (!succStatus) {
testFail("%s: an array setLength failed ", CURRENT_FUNCTION);
return;
@@ -1925,9 +1925,8 @@ void ChannelAccessIFTest::test_channelArray() {
testOk(data2[1] == 2.2 , "%s: 2.check 1: %f", CURRENT_FUNCTION, data2[1]);
testOk(data2[2] == 3.3, "%s: 2.check 2: %f", CURRENT_FUNCTION, data2[2]);
size_t currentLength = 3;
size_t newCap = 2;
succStatus = arrayReq->syncSetLength(false, currentLength, newCap, getTimeoutSec());
size_t newLength = 2;
succStatus = arrayReq->syncSetLength(false, newLength, getTimeoutSec());
if (!succStatus) {
testFail("%s: an array setLength failed (2) ", CURRENT_FUNCTION);
return;
@@ -1942,14 +1941,14 @@ void ChannelAccessIFTest::test_channelArray() {
//checking 1.1 2.2
PVDoubleArrayPtr array3 = static_pointer_cast<PVDoubleArray>(arrayReq->getArray());
PVDoubleArray::const_svector data3(array3->view());
testOk(data3.size() == newCap,
"%s: data size after calling setLength should be %zu", CURRENT_FUNCTION, newCap);
testOk(data3.size() == newLength,
"%s: data size after calling setLength should be %zu", CURRENT_FUNCTION, newLength);
testOk(data3[0] == 1.1 , "%s: 3.check 0: %f", CURRENT_FUNCTION, data3[0]);
testOk(data3[1] == 2.2 , "%s: 3.check 1: %f", CURRENT_FUNCTION, data3[1]);
size_t bigCapacity = 10000;
succStatus = arrayReq->syncSetLength(false, bigCapacity, bigCapacity, getTimeoutSec());
succStatus = arrayReq->syncSetLength(false, bigCapacity, getTimeoutSec());
if (!succStatus) {
testFail("%s: an array setLength failed (3) ", CURRENT_FUNCTION);
return;
@@ -1985,9 +1984,8 @@ void ChannelAccessIFTest::test_channelArray() {
}
*/
// test setLength with capacity 0 (no change) and getLength
size_t newLen = bigCapacity/2;
succStatus = arrayReq->syncSetLength(false, newLen, bigCapacity, getTimeoutSec());
succStatus = arrayReq->syncSetLength(false, newLen, getTimeoutSec());
if (!succStatus) {
testFail("%s: an array setLength failed (4) ", CURRENT_FUNCTION);
return;
@@ -1998,7 +1996,6 @@ void ChannelAccessIFTest::test_channelArray() {
return;
}
testOk(arrayReq->getLength() == newLen, "%s: retrieved length should be %zu", CURRENT_FUNCTION, newLen);
testOk(arrayReq->getCapacity() == bigCapacity, "%s: retrieved capacity should be %zu", CURRENT_FUNCTION, bigCapacity);
channel->destroy();
@@ -2045,7 +2042,7 @@ void ChannelAccessIFTest::test_channelArrayTestNoConnection() {
}
succStatus = arrayReq->syncSetLength(false, 1, 2, getTimeoutSec());
succStatus = arrayReq->syncSetLength(false, 1, getTimeoutSec());
if (succStatus) {
testFail("%s: an array syncSetLength should fail after the channel had been destroyed ", CURRENT_FUNCTION);
}

View File

@@ -1261,7 +1261,7 @@ class SyncChannelArrayRequesterImpl : public ChannelArrayRequester, public SyncB
}
bool syncSetLength(bool lastRequest, size_t length, size_t capacity, long timeOut)
bool syncSetLength(bool lastRequest, size_t length, long timeOut)
{
if (!getConnectedStatus()) {
@@ -1271,7 +1271,7 @@ class SyncChannelArrayRequesterImpl : public ChannelArrayRequester, public SyncB
resetEvent();
if (lastRequest)
m_channelArray->lastRequest();
m_channelArray->setLength(length, capacity);
m_channelArray->setLength(length);
return waitUntilSetLengthDone(timeOut);
}
@@ -1390,7 +1390,7 @@ class SyncChannelArrayRequesterImpl : public ChannelArrayRequester, public SyncB
virtual void getLengthDone(const epics::pvData::Status& status,
ChannelArray::shared_pointer const & channelArray,
size_t length, size_t capacity)
size_t length)
{
if (m_debug)
std::cout << getRequesterName() << ".getLengthDone(" << status << ")" << std::endl;
@@ -1399,7 +1399,6 @@ class SyncChannelArrayRequesterImpl : public ChannelArrayRequester, public SyncB
m_channelArray = channelArray;
m_length = length;
m_capacity = capacity;
m_lengthArrayStatus = status.isSuccess();
signalEvent();
@@ -1410,11 +1409,6 @@ class SyncChannelArrayRequesterImpl : public ChannelArrayRequester, public SyncB
return m_length;
}
size_t getCapacity()
{
return m_capacity;
}
private:
bool waitUntilGetArrayDone(double timeOut)
@@ -1478,7 +1472,6 @@ class SyncChannelArrayRequesterImpl : public ChannelArrayRequester, public SyncB
ChannelArray::shared_pointer m_channelArray;
epics::pvData::PVArray::shared_pointer m_pvArray;
size_t m_length;
size_t m_capacity;
};
#endif

View File

@@ -290,9 +290,9 @@ class ChannelArrayRequesterImpl : public ChannelArrayRequester
}
virtual void getLengthDone(const epics::pvData::Status& status, ChannelArray::shared_pointer const &,
size_t length, size_t capacity)
size_t length)
{
std::cout << "getLengthDone(" << status << "," << length << "," << capacity << ")" << std::endl;
std::cout << "getLengthDone(" << status << "," << length << ")" << std::endl;
}
};
@@ -475,7 +475,7 @@ int main()
// TODO !!!
//channelArray->putArray(0,0,1);
//epicsThreadSleep ( SLEEP_TIME );
channelArray->setLength(3,4);
channelArray->setLength(3);
epicsThreadSleep ( SLEEP_TIME );
channelArray->getLength();
epicsThreadSleep ( SLEEP_TIME );

View File

@@ -1812,10 +1812,12 @@ public:
// TODO stride support
if (stride == 1)
{
size_t o = offset;
if (count == 0) count = pvArray->getLength();
size_t len = pvArray->getLength();
size_t o = offset < len ? offset : len;
size_t c = count;
if (c == 0 || ((o + c) > len)) c = len - o;
Field::const_shared_pointer field = pvArray->getField();
Type type = field->getType();
@@ -1916,16 +1918,9 @@ public:
destroy();
}
virtual void setLength(size_t length, size_t capacity)
virtual void setLength(size_t length)
{
if (capacity > 0) {
m_pvStructureArray->setCapacity(capacity);
m_pvStructureArray->setLength(length > capacity ? capacity : length);
}
else
{
m_pvStructureArray->setLength(length);
}
m_pvStructureArray->setLength(length);
m_channelArrayRequester->setLengthDone(Status::Ok, shared_from_this());
@@ -1937,7 +1932,7 @@ public:
{
m_channelArrayRequester->getLengthDone(Status::Ok, shared_from_this(),
m_pvStructureArray->getLength(), m_pvStructureArray->getCapacity());
m_pvStructureArray->getLength());
if (m_lastRequest.get())
destroy();