merge feature/changesAfter3_0_2; resolve conflicts

This commit is contained in:
Marty Kraimer
2014-06-10 15:53:37 -04:00
parent 35429bf4df
commit 92be294bbf
87 changed files with 561 additions and 445 deletions

View File

@@ -14,13 +14,10 @@
#include <epicsThread.h>
#include <pv/timeStamp.h>
#include <pv/channelProviderLocal.h>
#include <pv/convert.h>
#include <pv/pvSubArrayCopy.h>
#define epicsExportSharedSymbols
#include <pv/channelProviderLocal.h>
namespace epics { namespace pvDatabase {
using namespace epics::pvData;
using namespace epics::pvAccess;
@@ -30,6 +27,26 @@ using std::cout;
using std::endl;
static ConvertPtr convert = getConvert();
static StructureConstPtr nullStructure;
static PVStructurePtr nullPVStructure;
static BitSetPtr nullBitSet;
static Status channelDestroyedStatus(
Status::Status::STATUSTYPE_ERROR,
"was destroyed"
);
static Status illegalOffsetStatus(
Status::Status::STATUSTYPE_ERROR,
"count must be >0"
);
static Status illegalCountStatus(
Status::Status::STATUSTYPE_ERROR,
"count must be >0"
);
static Status illegalStrideStatus(
Status::Status::STATUSTYPE_ERROR,
"stride must be >0"
);
class ChannelProcessLocal;
typedef std::tr1::shared_ptr<ChannelProcessLocal> ChannelProcessLocalPtr;
@@ -49,7 +66,7 @@ typedef std::tr1::shared_ptr<ChannelArrayLocal> ChannelArrayLocalPtr;
static bool getProcess(PVStructurePtr pvRequest,bool processDefault)
{
PVFieldPtr pvField = pvRequest->getSubField("record._options.process");
if(pvField.get()==NULL || pvField->getField()->getType()!=scalar) {
if(pvField==NULL || pvField->getField()->getType()!=scalar) {
return processDefault;
}
ScalarConstPtr scalar = static_pointer_cast<const Scalar>(
@@ -82,8 +99,12 @@ public:
ChannelProcessRequester::shared_pointer const & channelProcessRequester,
PVStructurePtr const & pvRequest,
PVRecordPtr const &pvRecord);
virtual void process(bool lastRequest);
virtual void process();
virtual void destroy();
virtual std::tr1::shared_ptr<Channel> getChannel()
{return channelLocal;}
virtual void cancel(){}
virtual void lastRequest() {}
virtual void lock() {mutex.lock();}
virtual void unlock() {mutex.unlock();}
private:
@@ -105,7 +126,6 @@ private:
{
}
bool isDestroyed;
bool callProcess;
ChannelLocalPtr channelLocal;
ChannelProcessRequester::shared_pointer channelProcessRequester;
PVRecordPtr pvRecord;
@@ -167,13 +187,11 @@ void ChannelProcessLocal::destroy()
channelLocal.reset();
}
void ChannelProcessLocal::process(bool lastRequest)
void ChannelProcessLocal::process()
{
if(isDestroyed) {
Status status(
Status::STATUSTYPE_ERROR,
"was destroyed");
channelProcessRequester->processDone(status);
channelProcessRequester->processDone(channelDestroyedStatus,getPtrSelf());
return;
}
if(pvRecord->getTraceLevel()>1)
@@ -193,8 +211,7 @@ void ChannelProcessLocal::process(bool lastRequest)
}
pvRecord->unlock();
}
channelProcessRequester->processDone(Status::Ok);
if(lastRequest) destroy();
channelProcessRequester->processDone(Status::Ok,getPtrSelf());
}
class ChannelGetLocal :
@@ -215,8 +232,12 @@ public:
ChannelGetRequester::shared_pointer const & channelGetRequester,
PVStructurePtr const & pvRequest,
PVRecordPtr const &pvRecord);
virtual void get(bool lastRequest);
virtual void get();
virtual void destroy();
virtual std::tr1::shared_ptr<Channel> getChannel()
{return channelLocal;}
virtual void cancel(){}
virtual void lastRequest() {}
virtual void lock() {mutex.lock();}
virtual void unlock() {mutex.unlock();}
private:
@@ -263,21 +284,18 @@ ChannelGetLocalPtr ChannelGetLocal::create(
PVRecordPtr const &pvRecord)
{
PVCopyPtr pvCopy = PVCopy::create(
pvRecord,
pvRecord->getPVRecordStructure()->getPVStructure(),
pvRequest,
"");
if(pvCopy.get()==NULL) {
if(pvCopy==NULL) {
Status status(
Status::STATUSTYPE_ERROR,
Status::Status::STATUSTYPE_ERROR,
"invalid pvRequest");
ChannelGet::shared_pointer channelGet;
PVStructurePtr pvStructure;
BitSetPtr bitSet;
channelGetRequester->channelGetConnect(
status,
channelGet,
pvStructure,
bitSet);
nullStructure);
ChannelGetLocalPtr localGet;
return localGet;
}
@@ -296,7 +314,8 @@ ChannelGetLocalPtr ChannelGetLocal::create(
cout << "ChannelGetLocal::create";
cout << " recordName " << pvRecord->getRecordName() << endl;
}
channelGetRequester->channelGetConnect(Status::Ok, get, pvStructure,bitSet);
channelGetRequester->channelGetConnect(
Status::Ok,get,pvStructure->getStructure());
return get;
}
@@ -316,13 +335,11 @@ void ChannelGetLocal::destroy()
channelLocal.reset();
}
void ChannelGetLocal::get(bool lastRequest)
void ChannelGetLocal::get()
{
if(isDestroyed) {
Status status(
Status::STATUSTYPE_ERROR,
"was destroyed");
channelGetRequester->getDone(status);
channelGetRequester->getDone(
channelDestroyedStatus,getPtrSelf(),nullPVStructure,nullBitSet);
return;
}
bitSet->clear();
@@ -344,12 +361,15 @@ void ChannelGetLocal::get(bool lastRequest)
bitSet->set(0);
firstTime = false;
}
channelGetRequester->getDone(Status::Ok);
channelGetRequester->getDone(
Status::Ok,
getPtrSelf(),
pvStructure,
bitSet);
if(pvRecord->getTraceLevel()>1)
{
cout << "ChannelGetLocal::get" << endl;
}
if(lastRequest) destroy();
}
class ChannelPutLocal :
@@ -370,9 +390,13 @@ public:
ChannelPutRequester::shared_pointer const & channelPutRequester,
PVStructurePtr const & pvRequest,
PVRecordPtr const &pvRecord);
virtual void put(bool lastRequest);
virtual void put(PVStructurePtr const &pvStructure,BitSetPtr const &bitSet);
virtual void get();
virtual void destroy();
virtual std::tr1::shared_ptr<Channel> getChannel()
{return channelLocal;}
virtual void cancel(){}
virtual void lastRequest() {}
virtual void lock() {mutex.lock();}
virtual void unlock() {mutex.unlock();}
private:
@@ -385,8 +409,6 @@ private:
ChannelLocalPtr const &channelLocal,
ChannelPutRequester::shared_pointer const & channelPutRequester,
PVCopyPtr const &pvCopy,
PVStructurePtr const&pvStructure,
BitSetPtr const & bitSet,
PVRecordPtr const &pvRecord)
:
isDestroyed(false),
@@ -394,8 +416,6 @@ private:
channelLocal(channelLocal),
channelPutRequester(channelPutRequester),
pvCopy(pvCopy),
pvStructure(pvStructure),
bitSet(bitSet),
pvRecord(pvRecord)
{
}
@@ -404,8 +424,6 @@ private:
ChannelLocalPtr channelLocal;
ChannelPutRequester::shared_pointer channelPutRequester;
PVCopyPtr pvCopy;
PVStructurePtr pvStructure;
BitSetPtr bitSet;
PVRecordPtr pvRecord;
Mutex mutex;
};
@@ -417,12 +435,12 @@ ChannelPutLocalPtr ChannelPutLocal::create(
PVRecordPtr const &pvRecord)
{
PVCopyPtr pvCopy = PVCopy::create(
pvRecord,
pvRecord->getPVRecordStructure()->getPVStructure(),
pvRequest,
"");
if(pvCopy.get()==NULL) {
if(pvCopy==NULL) {
Status status(
Status::STATUSTYPE_ERROR,
Status::Status::STATUSTYPE_ERROR,
"invalid pvRequest");
ChannelPut::shared_pointer channelPut;
PVStructurePtr pvStructure;
@@ -430,22 +448,18 @@ ChannelPutLocalPtr ChannelPutLocal::create(
channelPutRequester->channelPutConnect(
status,
channelPut,
pvStructure,
bitSet);
nullStructure);
ChannelPutLocalPtr localPut;
return localPut;
}
PVStructurePtr pvStructure = pvCopy->createPVStructure();
BitSetPtr bitSet(new BitSet(pvStructure->getNumberFields()));
ChannelPutLocalPtr put(new ChannelPutLocal(
getProcess(pvRequest,true),
channelLocal,
channelPutRequester,
pvCopy,
pvStructure,
bitSet,
pvRecord));
channelPutRequester->channelPutConnect(Status::Ok, put, pvStructure,bitSet);
channelPutRequester->channelPutConnect(
Status::Ok, put, pvCopy->getStructure());
if(pvRecord->getTraceLevel()>0)
{
cout << "ChannelPutLocal::create";
@@ -472,12 +486,12 @@ void ChannelPutLocal::destroy()
void ChannelPutLocal::get()
{
if(isDestroyed) {
Status status(
Status::STATUSTYPE_ERROR,
"was destroyed");
channelPutRequester->getDone(status);
channelPutRequester->getDone(
channelDestroyedStatus,getPtrSelf(),nullPVStructure,nullBitSet);
return;
}
PVStructurePtr pvStructure = pvCopy->createPVStructure();
BitSetPtr bitSet(new BitSet(pvStructure->getNumberFields()));
bitSet->clear();
bitSet->set(0);
pvRecord->lock();
@@ -488,26 +502,25 @@ void ChannelPutLocal::get()
throw;
}
pvRecord->unlock();
channelPutRequester->getDone(Status::Ok);
channelPutRequester->getDone(
Status::Ok,getPtrSelf(),pvStructure,bitSet);
if(pvRecord->getTraceLevel()>1)
{
cout << "ChannelPutLocal::get" << endl;
}
}
void ChannelPutLocal::put(bool lastRequest)
void ChannelPutLocal::put(
PVStructurePtr const &pvStructure,BitSetPtr const &bitSet)
{
if(isDestroyed) {
Status status(
Status::STATUSTYPE_ERROR,
"was destroyed");
channelPutRequester->getDone(status);
channelPutRequester->putDone(channelDestroyedStatus,getPtrSelf());
return;
}
pvRecord->lock();
try {
pvRecord->beginGroupPut();
pvCopy->updateRecord(pvStructure, bitSet);
pvCopy->updateMaster(pvStructure, bitSet);
if(callProcess) {
pvRecord->process();
}
@@ -517,12 +530,11 @@ void ChannelPutLocal::put(bool lastRequest)
throw;
}
pvRecord->unlock();
channelPutRequester->putDone(Status::Ok);
channelPutRequester->putDone(Status::Ok,getPtrSelf());
if(pvRecord->getTraceLevel()>1)
{
cout << "ChannelPutLocal::put" << endl;
}
if(lastRequest) destroy();
}
@@ -544,10 +556,16 @@ public:
ChannelPutGetRequester::shared_pointer const & channelPutGetRequester,
PVStructurePtr const & pvRequest,
PVRecordPtr const &pvRecord);
virtual void putGet(bool lastRequest);
virtual void putGet(
PVStructurePtr const &pvPutStructure,
BitSetPtr const &putBitSet);
virtual void getPut();
virtual void getGet();
virtual void destroy();
virtual std::tr1::shared_ptr<Channel> getChannel()
{return channelLocal;}
virtual void cancel(){}
virtual void lastRequest() {}
virtual void lock() {mutex.lock();}
virtual void unlock() {mutex.unlock();}
private:
@@ -561,9 +579,7 @@ private:
ChannelPutGetRequester::shared_pointer const & channelPutGetRequester,
PVCopyPtr const &pvPutCopy,
PVCopyPtr const &pvGetCopy,
PVStructurePtr const&pvPutStructure,
PVStructurePtr const&pvGetStructure,
BitSetPtr const & putBitSet,
BitSetPtr const & getBitSet,
PVRecordPtr const &pvRecord)
:
@@ -573,9 +589,7 @@ private:
channelPutGetRequester(channelPutGetRequester),
pvPutCopy(pvPutCopy),
pvGetCopy(pvGetCopy),
pvPutStructure(pvPutStructure),
pvGetStructure(pvGetStructure),
putBitSet(putBitSet),
getBitSet(getBitSet),
pvRecord(pvRecord)
{
@@ -586,9 +600,7 @@ private:
ChannelPutGetRequester::shared_pointer channelPutGetRequester;
PVCopyPtr pvPutCopy;
PVCopyPtr pvGetCopy;
PVStructurePtr pvPutStructure;
PVStructurePtr pvGetStructure;
BitSetPtr putBitSet;
BitSetPtr getBitSet;
PVRecordPtr pvRecord;
Mutex mutex;
@@ -601,50 +613,35 @@ ChannelPutGetLocalPtr ChannelPutGetLocal::create(
PVRecordPtr const &pvRecord)
{
PVCopyPtr pvPutCopy = PVCopy::create(
pvRecord,
pvRecord->getPVRecordStructure()->getPVStructure(),
pvRequest,
"putField");
PVCopyPtr pvGetCopy = PVCopy::create(
pvRecord,
pvRecord->getPVRecordStructure()->getPVStructure(),
pvRequest,
"getField");
if(pvPutCopy.get()==NULL || pvGetCopy.get()==NULL) {
if(pvPutCopy==NULL || pvGetCopy==NULL) {
Status status(
Status::STATUSTYPE_ERROR,
Status::Status::STATUSTYPE_ERROR,
"invalid pvRequest");
ChannelPutGet::shared_pointer channelPutGet;
PVStructurePtr pvStructure;
BitSetPtr bitSet;
channelPutGetRequester->channelPutGetConnect(
status,
channelPutGet,
pvStructure,
pvStructure);
nullStructure,
nullStructure);
ChannelPutGetLocalPtr localPutGet;
return localPutGet;
}
PVStructurePtr pvPutStructure = pvPutCopy->createPVStructure();
PVStructurePtr pvGetStructure = pvGetCopy->createPVStructure();
BitSetPtr putBitSet(new BitSet(pvPutStructure->getNumberFields()));
BitSetPtr getBitSet(new BitSet(pvGetStructure->getNumberFields()));
pvRecord->lock();
try {
pvPutCopy->initCopy(pvPutStructure,putBitSet);
pvGetCopy->initCopy(pvGetStructure,getBitSet);
} catch(...) {
pvRecord->unlock();
throw;
}
pvRecord->unlock();
ChannelPutGetLocalPtr putGet(new ChannelPutGetLocal(
getProcess(pvRequest,true),
channelLocal,
channelPutGetRequester,
pvPutCopy,
pvGetCopy,
pvPutStructure,
pvGetStructure,
putBitSet,
getBitSet,
pvRecord));
if(pvRecord->getTraceLevel()>0)
@@ -653,7 +650,7 @@ ChannelPutGetLocalPtr ChannelPutGetLocal::create(
cout << " recordName " << pvRecord->getRecordName() << endl;
}
channelPutGetRequester->channelPutGetConnect(
Status::Ok, putGet, pvPutStructure,pvGetStructure);
Status::Ok, putGet, pvPutCopy->getStructure(),pvGetCopy->getStructure());
return putGet;
}
@@ -673,22 +670,20 @@ void ChannelPutGetLocal::destroy()
channelLocal.reset();
}
void ChannelPutGetLocal::putGet(bool lastRequest)
void ChannelPutGetLocal::putGet(
PVStructurePtr const &pvPutStructure,BitSetPtr const &putBitSet)
{
if(isDestroyed) {
Status status(
Status::STATUSTYPE_ERROR,
"was destroyed");
channelPutGetRequester->putGetDone(status);
channelPutGetRequester->putGetDone(
channelDestroyedStatus,getPtrSelf(),nullPVStructure,nullBitSet);
return;
}
putBitSet->clear();
putBitSet->set(0);
pvRecord->lock();
try {
pvRecord->beginGroupPut();
pvPutCopy->updateRecord(pvPutStructure, putBitSet);
pvPutCopy->updateMaster(pvPutStructure, putBitSet);
if(callProcess) pvRecord->process();
getBitSet->clear();
pvGetCopy->updateCopySetBitSet(pvGetStructure, getBitSet);
pvRecord->endGroupPut();
} catch(...) {
@@ -696,36 +691,33 @@ void ChannelPutGetLocal::putGet(bool lastRequest)
throw;
}
pvRecord->unlock();
getBitSet->clear();
getBitSet->set(0);
channelPutGetRequester->putGetDone(Status::Ok);
channelPutGetRequester->putGetDone(
Status::Ok,getPtrSelf(),pvGetStructure,getBitSet);
if(pvRecord->getTraceLevel()>1)
{
cout << "ChannelPutGetLocal::putGet" << endl;
}
if(lastRequest) destroy();
}
void ChannelPutGetLocal::getPut()
{
if(isDestroyed) {
Status status(
Status::STATUSTYPE_ERROR,
"was destroyed");
channelPutGetRequester->getPutDone(status);
channelPutGetRequester->getPutDone(
channelDestroyedStatus,getPtrSelf(),nullPVStructure,nullBitSet);
return;
}
PVStructurePtr pvPutStructure = pvPutCopy->createPVStructure();
BitSetPtr putBitSet(new BitSet(pvPutStructure->getNumberFields()));
pvRecord->lock();
try {
pvPutCopy->updateCopySetBitSet(pvPutStructure, putBitSet);
pvPutCopy->initCopy(pvPutStructure, putBitSet);
} catch(...) {
pvRecord->unlock();
throw;
}
pvRecord->unlock();
putBitSet->clear();
putBitSet->set(0);
channelPutGetRequester->getPutDone(Status::Ok);
channelPutGetRequester->getPutDone(
Status::Ok,getPtrSelf(),pvPutStructure,putBitSet);
if(pvRecord->getTraceLevel()>1)
{
cout << "ChannelPutGetLocal::getPut" << endl;
@@ -735,12 +727,11 @@ void ChannelPutGetLocal::getPut()
void ChannelPutGetLocal::getGet()
{
if(isDestroyed) {
Status status(
Status::STATUSTYPE_ERROR,
"was destroyed");
channelPutGetRequester->getGetDone(status);
channelPutGetRequester->getGetDone(
channelDestroyedStatus,getPtrSelf(),nullPVStructure,nullBitSet);
return;
}
getBitSet->clear();
pvRecord->lock();
try {
pvGetCopy->updateCopySetBitSet(pvGetStructure, getBitSet);
@@ -749,9 +740,8 @@ void ChannelPutGetLocal::getGet()
throw;
}
pvRecord->unlock();
getBitSet->clear();
getBitSet->set(0);
channelPutGetRequester->getGetDone(Status::Ok);
channelPutGetRequester->getGetDone(
Status::Ok,getPtrSelf(),pvGetStructure,getBitSet);
if(pvRecord->getTraceLevel()>1)
{
cout << "ChannelPutGetLocal::getGet" << endl;
@@ -778,10 +768,17 @@ public:
ChannelArrayRequester::shared_pointer const & channelArrayRequester,
PVStructurePtr const & pvRequest,
PVRecordPtr const &pvRecord);
virtual void getArray(bool lastRequest,int offset, int count);
virtual void putArray(bool lastRequest,int offset, int count);
virtual void setLength(bool lastRequest,int length, int capacity);
virtual void getArray(size_t offset, size_t count, size_t stride);
virtual void putArray(
PVArrayPtr const &putArray,
size_t offset, size_t count, size_t stride);
virtual void getLength();
virtual void setLength(size_t length, size_t capacity);
virtual void destroy();
virtual std::tr1::shared_ptr<Channel> getChannel()
{return channelLocal;}
virtual void cancel(){}
virtual void lastRequest() {}
virtual void lock() {mutex.lock();}
virtual void unlock() {mutex.unlock();}
private:
@@ -797,7 +794,6 @@ private:
PVRecordPtr const &pvRecord)
:
isDestroyed(false),
callProcess(callProcess),
channelLocal(channelLocal),
channelArrayRequester(channelArrayRequester),
pvArray(pvArray),
@@ -806,7 +802,6 @@ private:
{
}
bool isDestroyed;
bool callProcess;
ChannelLocalPtr channelLocal;
ChannelArrayRequester::shared_pointer channelArrayRequester;
PVArrayPtr pvArray;
@@ -825,10 +820,10 @@ ChannelArrayLocalPtr ChannelArrayLocal::create(
PVFieldPtrArray const & pvFields = pvRequest->getPVFields();
if(pvFields.size()!=1) {
Status status(
Status::STATUSTYPE_ERROR,"invalid pvRequest");
Status::Status::STATUSTYPE_ERROR,"invalid pvRequest");
ChannelArrayLocalPtr channelArray;
PVScalarArrayPtr pvArray;
channelArrayRequester->channelArrayConnect(status,channelArray,pvArray);
ArrayConstPtr array;
channelArrayRequester->channelArrayConnect(status,channelArray,array);
return channelArray;
}
PVFieldPtr pvField = pvFields[0];
@@ -845,19 +840,21 @@ ChannelArrayLocalPtr ChannelArrayLocal::create(
pvField = pvRecord->getPVRecordStructure()->getPVStructure()->getSubField(fieldName);
if(pvField==NULL) {
Status status(
Status::STATUSTYPE_ERROR,fieldName +" not found");
Status::Status::STATUSTYPE_ERROR,fieldName +" not found");
ChannelArrayLocalPtr channelArray;
PVScalarArrayPtr pvArray;
channelArrayRequester->channelArrayConnect(status,channelArray,pvArray);
ArrayConstPtr array;
channelArrayRequester->channelArrayConnect(
status,channelArray,array);
return channelArray;
}
if(pvField->getField()->getType()!=scalarArray && pvField->getField()->getType()!=structureArray)
{
Status status(
Status::STATUSTYPE_ERROR,fieldName +" not array");
Status::Status::STATUSTYPE_ERROR,fieldName +" not array");
ChannelArrayLocalPtr channelArray;
PVArrayPtr pvArray;
channelArrayRequester->channelArrayConnect(status,channelArray,pvArray);
ArrayConstPtr array;
channelArrayRequester->channelArrayConnect(
status,channelArray,array);
return channelArray;
}
PVArrayPtr pvArray = static_pointer_cast<PVArray>(pvField);
@@ -866,26 +863,47 @@ ChannelArrayLocalPtr ChannelArrayLocal::create(
PVScalarArrayPtr xxx = static_pointer_cast<PVScalarArray>(pvField);
pvCopy = getPVDataCreate()->createPVScalarArray(
xxx->getScalarArray()->getElementType());
} else {
ChannelArrayLocalPtr array(new ChannelArrayLocal(
channelLocal,
channelArrayRequester,
pvArray,
pvCopy,
pvRecord));
if(pvRecord->getTraceLevel()>0)
{
cout << "ChannelArrayLocal::create";
cout << " recordName " << pvRecord->getRecordName() << endl;
}
channelArrayRequester->channelArrayConnect(
Status::Ok, array, pvCopy->getArray());
return array;
}
if(pvField->getField()->getType()==structureArray) {
PVStructureArrayPtr xxx = static_pointer_cast<PVStructureArray>(pvField);
pvCopy = getPVDataCreate()->createPVStructureArray(
xxx->getStructureArray());
xxx->getStructureArray()->getStructure());
ChannelArrayLocalPtr array(new ChannelArrayLocal(
channelLocal,
channelArrayRequester,
pvArray,
pvCopy,
pvRecord));
if(pvRecord->getTraceLevel()>0)
{
cout << "ChannelArrayLocal::create";
cout << " recordName " << pvRecord->getRecordName() << endl;
}
channelArrayRequester->channelArrayConnect(
Status::Ok, array, pvCopy->getArray());
return array;
}
ChannelArrayLocalPtr array(new ChannelArrayLocal(
channelLocal,
channelArrayRequester,
pvArray,
pvCopy,
pvRecord));
if(pvRecord->getTraceLevel()>0)
{
cout << "ChannelArrayLocal::create";
cout << " recordName " << pvRecord->getRecordName() << endl;
}
channelArrayRequester->channelArrayConnect(
Status::Ok, array, pvCopy);
return array;
Status status(Status::Status::STATUSTYPE_ERROR,
"Sorry only ScalarArray and Structure Array are supported");
ChannelArrayLocalPtr channelArray;
ArrayConstPtr array;
channelArrayRequester->channelArrayConnect(status,channelArray,array);
return channelArray;
}
@@ -904,72 +922,120 @@ void ChannelArrayLocal::destroy()
channelLocal.reset();
}
void ChannelArrayLocal::getArray(bool lastRequest,int offset, int count)
void ChannelArrayLocal::getArray(size_t offset, size_t count, size_t stride)
{
if(isDestroyed) {
Status status(
Status::STATUSTYPE_ERROR,
"was destroyed");
channelArrayRequester->getArrayDone(status);
channelArrayRequester->getArrayDone(channelDestroyedStatus,getPtrSelf(),pvCopy);
return;
}
if(pvRecord->getTraceLevel()>1)
{
cout << "ChannelArrayLocal::getArray" << endl;
}
if(offset<0) {
channelArrayRequester->getArrayDone(illegalOffsetStatus,getPtrSelf(),pvCopy);
return;
}
if(stride<0) {
channelArrayRequester->getArrayDone(illegalStrideStatus,getPtrSelf(),pvCopy);
return;
}
const char *exceptionMessage = NULL;
pvRecord->lock();
try {
if(count<0) count = pvArray->getLength();
size_t capacity = pvArray->getCapacity();
if(capacity!=0) {
pvCopy->setCapacity(capacity);
pvCopy->setLength(count);
copy(*pvArray.get(),offset,*pvCopy.get(),0,count);
bool ok = false;
while(true) {
size_t length = pvArray->getLength();
if(length<=0) break;
if(count<=0) {
count = -offset + length/stride;
if(count>0) ok = true;
break;
}
size_t maxcount = -offset + length/stride;
if(count>maxcount) count = maxcount;
ok = true;
break;
}
} catch(...) {
pvRecord->unlock();
throw;
if(ok) {
pvCopy->setLength(count);
copy(pvArray,offset,stride,pvCopy,0,1,count);
}
} catch(std::exception e) {
exceptionMessage = e.what();
}
pvRecord->unlock();
channelArrayRequester->getArrayDone(Status::Ok);
if(lastRequest) destroy();
Status status = Status::Ok;
if(exceptionMessage!=NULL) {
status = Status(Status::Status::STATUSTYPE_ERROR,exceptionMessage);
}
channelArrayRequester->getArrayDone(status,getPtrSelf(),pvCopy);
}
void ChannelArrayLocal::putArray(bool lastRequest,int offset, int count)
void ChannelArrayLocal::putArray(
PVArrayPtr const & pvArray, size_t offset, size_t count, size_t stride)
{
if(isDestroyed) {
Status status(
Status::STATUSTYPE_ERROR,
"was destroyed");
channelArrayRequester->putArrayDone(status);
channelArrayRequester->putArrayDone(channelDestroyedStatus,getPtrSelf());
return;
}
if(pvRecord->getTraceLevel()>1)
{
cout << "ChannelArrayLocal::putArray" << endl;
}
if(offset<0) {
channelArrayRequester->putArrayDone(illegalOffsetStatus,getPtrSelf());
return;
}
if(count<0) {
channelArrayRequester->putArrayDone(illegalCountStatus,getPtrSelf());
return;
}
if(stride<0) {
channelArrayRequester->putArrayDone(illegalStrideStatus,getPtrSelf());
return;
}
size_t newLength = offset + count*stride;
pvArray->setLength(newLength);
const char *exceptionMessage = NULL;
pvRecord->lock();
try {
if(count<=0) count = pvCopy->getLength();
if(pvArray->getCapacity()<count) pvArray->setCapacity(count);
if(pvArray->getLength()<count) pvArray->setLength(count);
copy(*pvCopy.get(),0,*pvArray.get(),offset,count);
} catch(...) {
pvRecord->unlock();
throw;
copy(pvArray,0,1,this->pvArray,offset,stride,count);
} catch(std::exception e) {
exceptionMessage = e.what();
}
pvRecord->unlock();
channelArrayRequester->putArrayDone(Status::Ok);
if(lastRequest) destroy();
Status status = Status::Ok;
if(exceptionMessage!=NULL) {
status = Status(Status::Status::STATUSTYPE_ERROR,exceptionMessage);
}
channelArrayRequester->putArrayDone(status,getPtrSelf());
}
void ChannelArrayLocal::setLength(bool lastRequest,int length, int capacity)
void ChannelArrayLocal::getLength()
{
size_t length = 0;
size_t capacity = 0;
const char *exceptionMessage = NULL;
pvRecord->lock();
try {
length = pvArray->getLength();
capacity = pvArray->getCapacity();
} catch(std::exception e) {
exceptionMessage = e.what();
}
pvRecord->unlock();
Status status = Status::Ok;
if(exceptionMessage!=NULL) {
status = Status(Status::Status::STATUSTYPE_ERROR,exceptionMessage);
}
channelArrayRequester->getLengthDone(status,getPtrSelf(),length,capacity);
}
void ChannelArrayLocal::setLength(size_t length, size_t capacity)
{
if(isDestroyed) {
Status status(
Status::STATUSTYPE_ERROR,
"was destroyed");
channelArrayRequester->setLengthDone(status);
channelArrayRequester->setLengthDone(channelDestroyedStatus,getPtrSelf());
return;
}
if(pvRecord->getTraceLevel()>1)
@@ -980,16 +1046,16 @@ void ChannelArrayLocal::setLength(bool lastRequest,int length, int capacity)
try {
if(capacity>=0 && !pvArray->isCapacityMutable()) {
Status status(
Status::STATUSTYPE_ERROR,
Status::Status::STATUSTYPE_ERROR,
"capacityImnutable");
channelArrayRequester->setLengthDone(status);
channelArrayRequester->setLengthDone(status,getPtrSelf());
pvRecord->unlock();
return;
}
if(capacity>0) {
if(capacity>=0) {
if(pvArray->getCapacity()!=capacity) pvArray->setCapacity(capacity);
}
if(length>0) {
if(length>=0) {
if(pvArray->getLength()!=length) pvArray->setLength(length);
}
} catch(...) {
@@ -997,7 +1063,7 @@ void ChannelArrayLocal::setLength(bool lastRequest,int length, int capacity)
throw;
}
pvRecord->unlock();
channelArrayRequester->setLengthDone(Status::Ok);
channelArrayRequester->setLengthDone(Status::Ok,getPtrSelf());
}