general indent beautification

This commit is contained in:
Matej Sekoranja
2016-03-10 23:36:16 +01:00
parent d139c42d17
commit 5279d247ca
110 changed files with 21778 additions and 21525 deletions

3388
testApp/remote/channelAccessIFTest.cpp Executable file → Normal file

File diff suppressed because it is too large Load Diff

46
testApp/remote/channelAccessIFTest.h Executable file → Normal file
View File

@@ -1,41 +1,41 @@
#ifndef CHANNELACCESSIFTEST_HPP
#define CHANNELACCESSIFTEST_HPP
#define CHANNELACCESSIFTEST_HPP
#include <pv/pvAccess.h>
#include "syncTestRequesters.h"
class ChannelAccessIFTest {
public:
public:
int runAllTest();
virtual ~ChannelAccessIFTest() {}
protected:
virtual ~ChannelAccessIFTest() {}
protected:
static std::string TEST_COUNTER_CHANNEL_NAME;
static std::string TEST_SIMPLECOUNTER_CHANNEL_NAME;
static std::string TEST_CHANNEL_NAME;
static std::string TEST_VALUEONLY_CHANNEL_NAME;
static std::string TEST_SUMRPC_CHANNEL_NAME;
static std::string TEST_ARRAY_CHANNEL_NAME;
virtual ChannelProvider::shared_pointer getChannelProvider() = 0;
virtual long getTimeoutSec() = 0;
virtual bool isLocal() = 0;
Channel::shared_pointer createChannel(std::string channelName, bool debug = false );
Channel::shared_pointer createChannel(std::string channelName, bool debug = false );
Channel::shared_pointer syncCreateChannel(std::string channelName, bool debug = false );
SyncChannelGetRequesterImpl::shared_pointer syncCreateChannelGet(
Channel::shared_pointer const & channel, std::string const & request, bool debug = false );
Channel::shared_pointer const & channel, std::string const & request, bool debug = false );
SyncChannelPutRequesterImpl::shared_pointer syncCreateChannelPut(
@@ -43,33 +43,33 @@ class ChannelAccessIFTest {
SyncChannelPutGetRequesterImpl::shared_pointer syncCreateChannelPutGet(
Channel::shared_pointer const & channel, std::string const & request, bool debug = false );
Channel::shared_pointer const & channel, std::string const & request, bool debug = false );
SyncChannelRPCRequesterImpl::shared_pointer syncCreateChannelRPC(
Channel::shared_pointer const & channel, bool debug = false);
Channel::shared_pointer const & channel, bool debug = false);
SyncMonitorRequesterImpl::shared_pointer syncCreateChannelMonitor(
Channel::shared_pointer const & channel, std::string const & request, bool debug = false);
SyncChannelArrayRequesterImpl::shared_pointer syncCreateChannelArray(
Channel::shared_pointer const & channel, PVStructure::shared_pointer pvRequest, bool debug = false);
Channel::shared_pointer const & channel, PVStructure::shared_pointer pvRequest, bool debug = false);
private:
private:
void test_implementation();
void test_providerName();
void test_createEmptyChannel();
void test_createEmptyChannel();
void test_createChannelWithInvalidPriority();
void test_createChannel();
void test_recreateChannelOnDestroyedProvider();
void test_recreateChannelOnDestroyedProvider();
void test_findEmptyChannel();
@@ -77,7 +77,7 @@ class ChannelAccessIFTest {
void test_channel();
void test_channelGetWithInvalidChannelAndRequester();
void test_channelGetWithInvalidChannelAndRequester();
void test_channelGetNoProcess();
@@ -85,14 +85,14 @@ class ChannelAccessIFTest {
void test_channelGetNotYetConnected();
void test_channelGetIntProcessInternal(Channel::shared_pointer channel, std::string const & testMethodName);
void test_channelGetIntProcessInternal(Channel::shared_pointer channel, std::string const & testMethodName);
void test_channelGetTestNoConnection();
void test_channelPutWithInvalidChannelAndRequester();
void test_channelPutNoProcess();
void test_channelPutIntProcess();
void test_channelPutNotYetConnected();
@@ -148,8 +148,8 @@ class ChannelAccessIFTest {
void test_stressConnectGetDisconnect();
void test_stressMonitorAndProcess();
PVStructure::shared_pointer createSumArgumentStructure(int a, int b);
PVStructure::shared_pointer createSumArgumentStructure(int a, int b);
PVStructure::shared_pointer createArrayPvRequest();
};

View File

@@ -11,18 +11,18 @@ using namespace epics::pvData;
using namespace epics::pvAccess;
static Structure::const_shared_pointer dataStructure =
getFieldCreate()->createFieldBuilder()->
add("count", pvInt)->
createStructure();
getFieldCreate()->createFieldBuilder()->
add("count", pvInt)->
createStructure();
class PipelineSessionImpl :
public PipelineSession
public PipelineSession
{
public:
PipelineSessionImpl(
epics::pvData::PVStructure::shared_pointer const & pvRequest
) :
epics::pvData::PVStructure::shared_pointer const & pvRequest
) :
m_counter(0),
m_max(0)
{
@@ -76,11 +76,11 @@ private:
};
class PipelineServiceImpl :
public PipelineService
public PipelineService
{
PipelineSession::shared_pointer createPipeline(
epics::pvData::PVStructure::shared_pointer const & pvRequest
)
epics::pvData::PVStructure::shared_pointer const & pvRequest
)
{
return PipelineSession::shared_pointer(new PipelineSessionImpl(pvRequest));
}

View File

@@ -10,11 +10,11 @@
using namespace epics::pvData;
using namespace epics::pvAccess;
static StructureConstPtr requestStructure =
static StructureConstPtr requestStructure =
getFieldCreate()->createFieldBuilder()->
add("a", pvString)->
add("b", pvString)->
createStructure();
add("a", pvString)->
add("b", pvString)->
createStructure();
#define TIMEOUT 3.0
@@ -47,7 +47,7 @@ int main()
std::cout << e.what() << std::endl;
return 1;
}
// async way, allows multiple RPC calls on the clinet instance
try
{

View File

@@ -11,9 +11,9 @@ using namespace epics::pvData;
using namespace epics::pvAccess;
static Structure::const_shared_pointer resultStructure =
getFieldCreate()->createFieldBuilder()->
add("c", pvDouble)->
createStructure();
getFieldCreate()->createFieldBuilder()->
add("c", pvDouble)->
createStructure();
// s1 starts with s2 check
static bool starts_with(const std::string& s1, const std::string& s2) {
@@ -23,15 +23,15 @@ static bool starts_with(const std::string& s1, const std::string& s2) {
class SumServiceImpl :
public RPCServiceAsync
{
void request(PVStructure::shared_pointer const & pvArguments,
RPCResponseCallback::shared_pointer const & callback)
void request(PVStructure::shared_pointer const & pvArguments,
RPCResponseCallback::shared_pointer const & callback)
{
// NTURI support
PVStructure::shared_pointer args(
(starts_with(pvArguments->getStructure()->getID(), "epics:nt/NTURI:1.")) ?
pvArguments->getSubField<PVStructure>("query") :
pvArguments
);
(starts_with(pvArguments->getStructure()->getID(), "epics:nt/NTURI:1.")) ?
pvArguments->getSubField<PVStructure>("query") :
pvArguments
);
// get fields and check their existence
PVScalar::shared_pointer af = args->getSubField<PVScalar>("a");
@@ -39,11 +39,11 @@ class SumServiceImpl :
if (!af || !bf)
{
callback->requestDone(
Status(
Status::STATUSTYPE_ERROR,
"scalar 'a' and 'b' fields are required"
),
PVStructure::shared_pointer());
Status(
Status::STATUSTYPE_ERROR,
"scalar 'a' and 'b' fields are required"
),
PVStructure::shared_pointer());
return;
}
@@ -57,14 +57,14 @@ class SumServiceImpl :
catch (std::exception &e)
{
callback->requestDone(
Status(
Status::STATUSTYPE_ERROR,
std::string("failed to convert arguments to double: ") + e.what()
),
PVStructure::shared_pointer());
Status(
Status::STATUSTYPE_ERROR,
std::string("failed to convert arguments to double: ") + e.what()
),
PVStructure::shared_pointer());
return;
}
// create return structure and set data
PVStructure::shared_pointer result = getPVDataCreate()->createPVStructure(resultStructure);
result->getSubField<PVDouble>("c")->put(a+b);

View File

@@ -11,9 +11,9 @@ using namespace epics::pvData;
using namespace epics::pvAccess;
static Structure::const_shared_pointer resultStructure =
getFieldCreate()->createFieldBuilder()->
add("c", pvDouble)->
createStructure();
getFieldCreate()->createFieldBuilder()->
add("c", pvDouble)->
createStructure();
// s1 starts with s2 check
static bool starts_with(const std::string& s1, const std::string& s2) {
@@ -27,17 +27,17 @@ class SumServiceImpl :
{
// NTURI support
PVStructure::shared_pointer args(
(starts_with(pvArguments->getStructure()->getID(), "epics:nt/NTURI:1.")) ?
pvArguments->getSubField<PVStructure>("query") :
pvArguments
);
(starts_with(pvArguments->getStructure()->getID(), "epics:nt/NTURI:1.")) ?
pvArguments->getSubField<PVStructure>("query") :
pvArguments
);
// get fields and check their existence
PVScalar::shared_pointer af = args->getSubField<PVScalar>("a");
PVScalar::shared_pointer bf = args->getSubField<PVScalar>("b");
if (!af || !bf)
throw RPCRequestException(Status::STATUSTYPE_ERROR, "scalar 'a' and 'b' fields are required");
// get the numbers (and convert if neccessary)
double a, b;
try
@@ -48,9 +48,9 @@ class SumServiceImpl :
catch (std::exception &e)
{
throw RPCRequestException(Status::STATUSTYPE_ERROR,
std::string("failed to convert arguments to double: ") + e.what());
std::string("failed to convert arguments to double: ") + e.what());
}
// create return structure and set data
PVStructure::shared_pointer result = getPVDataCreate()->createPVStructure(resultStructure);
result->getSubField<PVDouble>("c")->put(a+b);

View File

@@ -11,9 +11,9 @@ using namespace epics::pvData;
using namespace epics::pvAccess;
static Structure::const_shared_pointer resultStructure =
getFieldCreate()->createFieldBuilder()->
add("channelName", pvString)->
createStructure();
getFieldCreate()->createFieldBuilder()->
add("channelName", pvString)->
createStructure();
class WildServiceImpl :
public RPCService
@@ -25,7 +25,7 @@ class WildServiceImpl :
throw RPCRequestException(Status::STATUSTYPE_ERROR, "RPC argument must be a NTURI normative type");
std::string channelName = pvArguments->getSubField<PVString>("path")->get();
// create return structure and set data
PVStructure::shared_pointer result = getPVDataCreate()->createPVStructure(resultStructure);
result->getSubField<PVString>("channelName")->put(channelName);

1448
testApp/remote/syncTestRequesters.h Executable file → Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -120,7 +120,7 @@ baseValue::baseValue()
#include <epicsEvent.h>
struct SimADC : public std::tr1::enable_shared_from_this<SimADC>,
public epicsThreadRunable
public epicsThreadRunable
{
typedef std::tr1::shared_ptr<SimADC> smart_pointer_type;
@@ -247,10 +247,12 @@ SimADC::~SimADC()
}
namespace {
template<typename T>
struct Freeme {
void operator()(T* p) {free(p);}
};
template<typename T>
struct Freeme {
void operator()(T* p) {
free(p);
}
};
}
void SimADC::cycle()

View File

@@ -30,7 +30,7 @@ private:
size_t total;
int count;
Event& g_event;
virtual string getRequesterName()
{
return "ChannelRequesterImpl";
@@ -66,7 +66,7 @@ private:
}
else
cout << c->getChannelName() << " " << Channel::ConnectionStateNames[connectionState] << endl;
}
};
@@ -102,7 +102,7 @@ int main (int argc, char *argv[])
int tmp = atoi(optarg);
if (tmp < 0) tmp = 1;
// note: possible overflow (size_t is not always unsigned int)
nChannels = static_cast<size_t>(tmp);
nChannels = static_cast<size_t>(tmp);
break;
}
case '?':
@@ -120,37 +120,37 @@ int main (int argc, char *argv[])
return 1;
}
}
{
Event g_event;
ClientFactory::start();
ChannelProvider::shared_pointer provider = getChannelProviderRegistry()->getProvider("pva");
int run = 0;
while (runs < 0 || run++ < runs)
{
vector<Channel::shared_pointer> channels(nChannels);
ChannelRequester::shared_pointer channelRequester(new ChannelRequesterImpl(nChannels, g_event));
char buf[16];
for (size_t i = 0; i < nChannels; i++)
{
sprintf(buf, "test%zu", (i+1));
channels.push_back(provider->createChannel(buf, channelRequester));
}
g_event.wait();
cout << "connected to all" << endl;
}
}
ClientFactory::stop();
}
epicsThreadSleep ( 2.0 );
epicsThreadSleep ( 2.0 );
//std::cout << "-----------------------------------------------------------------------" << std::endl;
//epicsExitCallAtExits();
return(0);

View File

@@ -7,9 +7,9 @@ int main()
epics::pvAccess::ClientFactory::start();
epics::pvAccess::getChannelProviderRegistry()->getProvider("pva");
epics::pvAccess::ClientFactory::stop();
//epicsThreadSleep ( 3.0 );
//epicsThreadSleep ( 3.0 );
//epicsExitCallAtExits();
return 0;
}

File diff suppressed because it is too large Load Diff

View File

@@ -53,7 +53,7 @@ string request(DEFAULT_REQUEST);
PVStructure::shared_pointer pvRequest;
class RequesterImpl : public Requester,
public std::tr1::enable_shared_from_this<RequesterImpl>
public std::tr1::enable_shared_from_this<RequesterImpl>
{
public:
@@ -109,8 +109,8 @@ epicsTimeStamp startTime;
void get_all()
{
for (vector<ChannelGet::shared_pointer>::const_iterator i = channelGetList.begin();
i != channelGetList.end();
i++)
i != channelGetList.end();
i++)
(*i)->get();
// we assume all channels are from the same provider
@@ -205,7 +205,7 @@ public:
else
{
printf("%d %d %d %d %.3f\n", channels, arraySize, iterations, runs, sum/runs);
Lock guard(waitLoopPtrMutex);
waitLoopEvent->signal(); // all done
}
@@ -312,12 +312,12 @@ void runTest()
vector<Channel::shared_pointer> channels;
for (vector<string>::const_iterator i = channelNames.begin();
i != channelNames.end();
i++)
i != channelNames.end();
i++)
{
shared_ptr<ChannelRequesterImpl> channelRequesterImpl(
new ChannelRequesterImpl()
);
new ChannelRequesterImpl()
);
Channel::shared_pointer channel = provider->createChannel(*i, channelRequesterImpl);
channels.push_back(channel);
}
@@ -326,12 +326,12 @@ void runTest()
bool differentConnectionsWarningIssued = false;
string theRemoteAddress;
for (vector<Channel::shared_pointer>::iterator i = channels.begin();
i != channels.end();
i++)
i != channels.end();
i++)
{
Channel::shared_pointer channel = *i;
shared_ptr<ChannelRequesterImpl> channelRequesterImpl =
dynamic_pointer_cast<ChannelRequesterImpl>(channel->getChannelRequester());
dynamic_pointer_cast<ChannelRequesterImpl>(channel->getChannelRequester());
if (channelRequesterImpl->waitUntilConnected(5.0))
{
string remoteAddress = channel->getRemoteAddress();
@@ -344,7 +344,7 @@ void runTest()
if (!differentConnectionsWarningIssued)
{
std::cout << "not all channels are hosted by the same connection: " <<
theRemoteAddress << " != " << remoteAddress << std::endl;
theRemoteAddress << " != " << remoteAddress << std::endl;
differentConnectionsWarningIssued = true;
// we assumes same connection (thread-safety)
exit(2);
@@ -352,8 +352,8 @@ void runTest()
}
shared_ptr<ChannelGetRequesterImpl> getRequesterImpl(
new ChannelGetRequesterImpl(channel->getChannelName())
);
new ChannelGetRequesterImpl(channel->getChannelName())
);
ChannelGet::shared_pointer channelGet = channel->createChannelGet(getRequesterImpl, pvRequest);
if (bulkMode) provider->flush();
@@ -383,7 +383,7 @@ void runTest()
}
epicsTimeGetCurrent(&startTime);
get_all();
waitLoopEvent->wait();
}
@@ -478,7 +478,7 @@ int main (int argc, char *argv[])
{
//printf("%d %d %d %d\n", channels, arraySize, iterations, runs);
runTest();
// wait a bit for a next test
epicsThreadSleep(1.0);
}

View File

@@ -51,7 +51,7 @@ string request(DEFAULT_REQUEST);
PVStructure::shared_pointer pvRequest;
class RequesterImpl : public Requester,
public std::tr1::enable_shared_from_this<RequesterImpl>
public std::tr1::enable_shared_from_this<RequesterImpl>
{
public:
@@ -106,8 +106,8 @@ epicsTimeStamp startTime;
void monitor_all()
{
for (vector<Monitor::shared_pointer>::const_iterator i = channelMonitorList.begin();
i != channelMonitorList.end();
i++)
i != channelMonitorList.end();
i++)
(*i)->start();
}
@@ -138,8 +138,8 @@ public:
}
virtual void monitorConnect(const epics::pvData::Status& status,
Monitor::shared_pointer const & /*monitor*/,
epics::pvData::Structure::const_shared_pointer const & /*structure*/)
Monitor::shared_pointer const & /*monitor*/,
epics::pvData::Structure::const_shared_pointer const & /*structure*/)
{
if (status.isSuccess())
{
@@ -294,12 +294,12 @@ void runTest()
vector<Channel::shared_pointer> channels;
for (vector<string>::const_iterator i = channelNames.begin();
i != channelNames.end();
i++)
i != channelNames.end();
i++)
{
shared_ptr<ChannelRequesterImpl> channelRequesterImpl(
new ChannelRequesterImpl()
);
new ChannelRequesterImpl()
);
Channel::shared_pointer channel = provider->createChannel(*i, channelRequesterImpl);
channels.push_back(channel);
}
@@ -307,12 +307,12 @@ void runTest()
bool differentConnectionsWarningIssued = false;
string theRemoteAddress;
for (vector<Channel::shared_pointer>::iterator i = channels.begin();
i != channels.end();
i++)
i != channels.end();
i++)
{
Channel::shared_pointer channel = *i;
shared_ptr<ChannelRequesterImpl> channelRequesterImpl =
dynamic_pointer_cast<ChannelRequesterImpl>(channel->getChannelRequester());
dynamic_pointer_cast<ChannelRequesterImpl>(channel->getChannelRequester());
if (channelRequesterImpl->waitUntilConnected(5.0))
{
string remoteAddress = channel->getRemoteAddress();
@@ -325,7 +325,7 @@ void runTest()
if (!differentConnectionsWarningIssued)
{
std::cout << "not all channels are hosted by the same connection: " <<
theRemoteAddress << " != " << remoteAddress << std::endl;
theRemoteAddress << " != " << remoteAddress << std::endl;
differentConnectionsWarningIssued = true;
// we assumes same connection (thread-safety)
exit(2);
@@ -333,8 +333,8 @@ void runTest()
}
shared_ptr<ChannelMonitorRequesterImpl> getRequesterImpl(
new ChannelMonitorRequesterImpl(channel->getChannelName())
);
new ChannelMonitorRequesterImpl(channel->getChannelName())
);
Monitor::shared_pointer monitor = channel->createMonitor(getRequesterImpl, pvRequest);
bool allOK = getRequesterImpl->waitUntilConnected(timeOut);
@@ -363,7 +363,7 @@ void runTest()
}
epicsTimeGetCurrent(&startTime);
monitor_all();
waitLoopEvent->wait();
}
@@ -455,7 +455,7 @@ int main (int argc, char *argv[])
{
//printf("%d %d %d %d\n", channels, arraySize, iterations, runs);
runTest();
// wait a bit for a next test
epicsThreadSleep(1.0);
}

View File

@@ -17,53 +17,53 @@ epics::pvData::StructureConstPtr createNTNDArrayStructure()
UnionConstPtr valueType = fb->createUnion();
StructureConstPtr codecStruc = fb->setId("codec_t")->
add("name", pvString)->
add("parameters", getFieldCreate()->createVariantUnion())->
createStructure();
add("name", pvString)->
add("parameters", getFieldCreate()->createVariantUnion())->
createStructure();
StructureConstPtr dimensionStruc = fb->setId("dimension_t")->
add("size", pvInt)->
add("offset", pvInt)->
add("fullSize", pvInt)->
add("binning", pvInt)->
add("reverse", pvBoolean)->
createStructure();
add("size", pvInt)->
add("offset", pvInt)->
add("fullSize", pvInt)->
add("binning", pvInt)->
add("reverse", pvBoolean)->
createStructure();
StructureConstPtr attributeStruc = fb->setId("epics:nt/NTAttribute:1.0")->
add("name", pvString)->
add("value", getFieldCreate()->createVariantUnion())->
add("descriptor", pvString)->
add("sourceType", pvInt)->
add("source", pvString)->
createStructure();
add("name", pvString)->
add("value", getFieldCreate()->createVariantUnion())->
add("descriptor", pvString)->
add("sourceType", pvInt)->
add("source", pvString)->
createStructure();
ntndArrayStructure = fb->setId("epics:nt/NTNDArray:1.0")->
add("value", valueType)->
add("codec", codecStruc)->
add("compressedSize", pvLong)->
add("uncompressedSize", pvLong)->
addArray("dimension", dimensionStruc)->
add("uniqueId", pvInt)->
add("dataTimeStamp", standardField->timeStamp())->
addArray("attribute", attributeStruc)->
//add("descriptor", pvString)->
//add("timeStamp", standardField->timeStamp())->
//add("alarm", standardField->alarm())->
//add("display", standardField->display())->
createStructure();
add("value", valueType)->
add("codec", codecStruc)->
add("compressedSize", pvLong)->
add("uncompressedSize", pvLong)->
addArray("dimension", dimensionStruc)->
add("uniqueId", pvInt)->
add("dataTimeStamp", standardField->timeStamp())->
addArray("attribute", attributeStruc)->
//add("descriptor", pvString)->
//add("timeStamp", standardField->timeStamp())->
//add("alarm", standardField->alarm())->
//add("display", standardField->display())->
createStructure();
}
return ntndArrayStructure;
}
void setNTNDArrayValue(
PVStructure::shared_pointer const & imagePV,
const size_t raw_dim_size,
const int32_t* raw_dim,
const size_t raw_size,
const int8_t* raw
)
PVStructure::shared_pointer const & imagePV,
const size_t raw_dim_size,
const int32_t* raw_dim,
const size_t raw_size,
const int8_t* raw
)
{
PVUnionPtr unionValue = imagePV->getSubField<PVUnion>("value");
// assumes byteArray
@@ -109,10 +109,10 @@ void setNTNDArrayValue(
void setNTNDArrayData(
PVStructure::shared_pointer const & imagePV,
const string & codec,
int32 colorMode
)
PVStructure::shared_pointer const & imagePV,
const string & codec,
int32 colorMode
)
{
imagePV->getSubField<PVString>("codec.name")->put(codec);
@@ -128,8 +128,8 @@ void setNTNDArrayData(
// find ColorMode
for (PVStructureArray::const_svector::const_iterator iter = attributes.begin();
iter != attributes.end();
iter++)
iter != attributes.end();
iter++)
{
PVStructure::shared_pointer fattribute = *iter;
PVString::shared_pointer pvName = fattribute->getSubField<PVString>("name");
@@ -162,14 +162,14 @@ void setNTNDArrayData(
}
void initImage(
PVStructure::shared_pointer const & imagePV,
const string & codec,
int32 colorMode,
const size_t raw_dim_size,
const int32_t* raw_dim,
const size_t raw_size,
const int8_t* raw
)
PVStructure::shared_pointer const & imagePV,
const string & codec,
int32 colorMode,
const size_t raw_dim_size,
const int32_t* raw_dim,
const size_t raw_size,
const int8_t* raw
)
{
setNTNDArrayValue(imagePV, raw_dim_size, raw_dim, raw_size, raw);
setNTNDArrayData(imagePV, codec, colorMode);

View File

@@ -18,8 +18,8 @@ using std::string;
class ChannelFindRequesterImpl : public ChannelFindRequester
{
virtual void channelFindResult(const epics::pvData::Status& status,
ChannelFind::shared_pointer const & /*channelFind*/,
bool wasFound)
ChannelFind::shared_pointer const & /*channelFind*/,
bool wasFound)
{
std::cout << "[ChannelFindRequesterImpl] channelFindResult("
<< status << ", ..., " << wasFound << ")" << std::endl;
@@ -77,8 +77,8 @@ class GetFieldRequesterImpl : public GetFieldRequester
class ChannelGetRequesterImpl : public ChannelGetRequester
{
public:
public:
virtual string getRequesterName()
{
return "ChannelGetRequesterImpl";
@@ -100,7 +100,7 @@ class ChannelGetRequesterImpl : public ChannelGetRequester
}
virtual void getDone(const epics::pvData::Status& status, ChannelGet::shared_pointer const &,
PVStructure::shared_pointer const & getData, BitSet::shared_pointer const & /*bitSet*/)
PVStructure::shared_pointer const & getData, BitSet::shared_pointer const & /*bitSet*/)
{
std::cout << "getDone(" << status << ")" << std::endl;
@@ -113,8 +113,8 @@ class ChannelGetRequesterImpl : public ChannelGetRequester
class ChannelPutRequesterImpl : public ChannelPutRequester
{
public:
public:
virtual string getRequesterName()
{
return "ChannelPutRequesterImpl";
@@ -136,7 +136,7 @@ class ChannelPutRequesterImpl : public ChannelPutRequester
}
virtual void getDone(const epics::pvData::Status& status, ChannelPut::shared_pointer const &,
PVStructure::shared_pointer const & getData, BitSet::shared_pointer const & /*bitSet*/)
PVStructure::shared_pointer const & getData, BitSet::shared_pointer const & /*bitSet*/)
{
std::cout << "getDone(" << status << ")" << std::endl;
if (status.isSuccess())
@@ -154,7 +154,7 @@ class ChannelPutRequesterImpl : public ChannelPutRequester
class ChannelPutGetRequesterImpl : public ChannelPutGetRequester
{
public:
public:
virtual string getRequesterName()
{
@@ -183,7 +183,7 @@ class ChannelPutGetRequesterImpl : public ChannelPutGetRequester
}
virtual void getGetDone(const epics::pvData::Status& status, ChannelPutGet::shared_pointer const &,
PVStructure::shared_pointer const & getData, BitSet::shared_pointer const & /*bitSet*/)
PVStructure::shared_pointer const & getData, BitSet::shared_pointer const & /*bitSet*/)
{
std::cout << "getGetDone(" << status << ")" << std::endl;
if (status.isSuccess())
@@ -193,7 +193,7 @@ class ChannelPutGetRequesterImpl : public ChannelPutGetRequester
}
virtual void getPutDone(const epics::pvData::Status& status, ChannelPutGet::shared_pointer const &,
PVStructure::shared_pointer const & putData, BitSet::shared_pointer const & /*bitSet*/)
PVStructure::shared_pointer const & putData, BitSet::shared_pointer const & /*bitSet*/)
{
std::cout << "getPutDone(" << status << ")" << std::endl;
if (status.isSuccess())
@@ -203,7 +203,7 @@ class ChannelPutGetRequesterImpl : public ChannelPutGetRequester
}
virtual void putGetDone(const epics::pvData::Status& status, ChannelPutGet::shared_pointer const &,
PVStructure::shared_pointer const & putData, BitSet::shared_pointer const & /*bitSet*/)
PVStructure::shared_pointer const & putData, BitSet::shared_pointer const & /*bitSet*/)
{
std::cout << "putGetDone(" << status << ")" << std::endl;
if (status.isSuccess())
@@ -228,13 +228,13 @@ class ChannelRPCRequesterImpl : public ChannelRPCRequester
}
virtual void channelRPCConnect(const epics::pvData::Status& status,
ChannelRPC::shared_pointer const & /*channelRPC*/)
ChannelRPC::shared_pointer const & /*channelRPC*/)
{
std::cout << "channelRPCConnect(" << status << ")" << std::endl;
}
virtual void requestDone(const epics::pvData::Status& status, ChannelRPC::shared_pointer const &,
epics::pvData::PVStructure::shared_pointer const & pvResponse)
epics::pvData::PVStructure::shared_pointer const & pvResponse)
{
std::cout << "requestDone(" << status << ")" << std::endl;
if (status.isSuccess())
@@ -246,8 +246,8 @@ class ChannelRPCRequesterImpl : public ChannelRPCRequester
class ChannelArrayRequesterImpl : public ChannelArrayRequester
{
public:
public:
virtual string getRequesterName()
{
return "ChannelArrayRequesterImpl";
@@ -266,11 +266,11 @@ class ChannelArrayRequesterImpl : public ChannelArrayRequester
{
std::cout << array << std::endl;
}
}
virtual void getArrayDone(const epics::pvData::Status& status, ChannelArray::shared_pointer const &,
PVArray::shared_pointer const & pvArray)
PVArray::shared_pointer const & pvArray)
{
std::cout << "getArrayDone(" << status << ")" << std::endl;
if (status.isSuccess())
@@ -290,7 +290,7 @@ class ChannelArrayRequesterImpl : public ChannelArrayRequester
}
virtual void getLengthDone(const epics::pvData::Status& status, ChannelArray::shared_pointer const &,
size_t length)
size_t length)
{
std::cout << "getLengthDone(" << status << "," << length << ")" << std::endl;
}
@@ -309,7 +309,7 @@ class MonitorRequesterImpl : public MonitorRequester
}
virtual void monitorConnect(const epics::pvData::Status& status,
Monitor::shared_pointer const & /*monitor*/, StructureConstPtr const & structure)
Monitor::shared_pointer const & /*monitor*/, StructureConstPtr const & structure)
{
std::cout << "monitorConnect(" << status << ")" << std::endl;
if (status.isSuccess() && structure)
@@ -325,7 +325,7 @@ class MonitorRequesterImpl : public MonitorRequester
MonitorElement::shared_pointer element = monitor->poll();
std::cout << "changed/overrun " << *element->changedBitSet << '/' <<
*element->overrunBitSet << std::endl << *element->pvStructurePtr << std::endl;
*element->overrunBitSet << std::endl << *element->pvStructurePtr << std::endl;
monitor->release(element);
}
@@ -352,7 +352,7 @@ class ChannelProcessRequesterImpl : public ChannelProcessRequester
}
virtual void channelProcessConnect(const epics::pvData::Status& status,
ChannelProcess::shared_pointer const & /*channelProcess*/)
ChannelProcess::shared_pointer const & /*channelProcess*/)
{
std::cout << "channelProcessConnect(" << status << ")" << std::endl;
@@ -370,144 +370,147 @@ class ChannelProcessRequesterImpl : public ChannelProcessRequester
int main()
{
for (int i = 0; i < 10; i++) {
{
ClientFactory::start();
ChannelProvider::shared_pointer provider = getChannelProviderRegistry()->getProvider("pva");
{
ChannelFindRequester::shared_pointer findRequester(new ChannelFindRequesterImpl());
ChannelFind::shared_pointer channelFind = provider->channelFind("testSomething", findRequester);
epicsThreadSleep ( SLEEP_TIME );
//channelFind->destroy();
ClientFactory::start();
ChannelProvider::shared_pointer provider = getChannelProviderRegistry()->getProvider("pva");
ChannelFindRequester::shared_pointer findRequester(new ChannelFindRequesterImpl());
ChannelFind::shared_pointer channelFind = provider->channelFind("testSomething", findRequester);
epicsThreadSleep ( SLEEP_TIME );
//channelFind->destroy();
ChannelRequester::shared_pointer channelRequester(new ChannelRequesterImpl());
Channel::shared_pointer channel = provider->createChannel("testStructureArrayTest", channelRequester);
epicsThreadSleep ( SLEEP_TIME );
channel->printInfo();
{
GetFieldRequester::shared_pointer getFieldRequesterImpl(new GetFieldRequesterImpl());
channel->getField(getFieldRequesterImpl, "");
epicsThreadSleep ( SLEEP_TIME );
}
{
ChannelProcessRequester::shared_pointer channelProcessRequester(new ChannelProcessRequesterImpl());
PVStructure::shared_pointer pvRequest;
ChannelProcess::shared_pointer channelProcess = channel->createChannelProcess(channelProcessRequester, pvRequest);
epicsThreadSleep ( SLEEP_TIME );
channelProcess->process();
epicsThreadSleep ( SLEEP_TIME );
channelProcess->destroy();
epicsThreadSleep ( SLEEP_TIME );
}
{
ChannelGetRequester::shared_pointer channelGetRequesterImpl(new ChannelGetRequesterImpl());
PVStructure::shared_pointer pvRequest = CreateRequest::create()->createRequest("field()");
ChannelGet::shared_pointer channelGet = channel->createChannelGet(channelGetRequesterImpl, pvRequest);
epicsThreadSleep ( 3.0 );
channelGet->get();
epicsThreadSleep ( 3.0 );
channelGet->destroy();
}
{
ChannelPutRequester::shared_pointer channelPutRequesterImpl(new ChannelPutRequesterImpl());
PVStructure::shared_pointer pvRequest = CreateRequest::create()->createRequest("field(value,timeStamp)");
ChannelPut::shared_pointer channelPut = channel->createChannelPut(channelPutRequesterImpl, pvRequest);
epicsThreadSleep ( SLEEP_TIME );
channelPut->get();
epicsThreadSleep ( SLEEP_TIME );
// TODO !!!
//channelPut->put();
//epicsThreadSleep ( SLEEP_TIME );
channelPut->destroy();
}
{
ChannelPutGetRequester::shared_pointer channelPutGetRequesterImpl(new ChannelPutGetRequesterImpl());
PVStructure::shared_pointer pvRequest = CreateRequest::create()->createRequest("putField(value,timeStamp)getField(timeStamp)");
ChannelPutGet::shared_pointer channelPutGet = channel->createChannelPutGet(channelPutGetRequesterImpl, pvRequest);
epicsThreadSleep ( SLEEP_TIME );
channelPutGet->getGet();
epicsThreadSleep ( SLEEP_TIME );
channelPutGet->getPut();
epicsThreadSleep ( SLEEP_TIME );
// TODO !!!
//channelPutGet->putGet();
//epicsThreadSleep ( SLEEP_TIME );
channelPutGet->destroy();
}
{
ChannelRPCRequester::shared_pointer channelRPCRequesterImpl(new ChannelRPCRequesterImpl());
PVStructure::shared_pointer pvRequest = CreateRequest::create()->createRequest("record[]field(arguments)");
ChannelRPC::shared_pointer channelRPC = channel->createChannelRPC(channelRPCRequesterImpl, pvRequest);
epicsThreadSleep ( SLEEP_TIME );
// for test simply use pvRequest as arguments
channelRPC->request(pvRequest);
epicsThreadSleep ( SLEEP_TIME );
channelRPC->destroy();
}
{
ChannelArrayRequester::shared_pointer channelArrayRequesterImpl(new ChannelArrayRequesterImpl());
StringArray fieldNames;
fieldNames.push_back("field");
FieldConstPtrArray fields;
fields.push_back(getFieldCreate()->createScalar(pvString));
PVStructure::shared_pointer pvRequest(getPVDataCreate()->createPVStructure(getFieldCreate()->createStructure(fieldNames, fields)));
ChannelArray::shared_pointer channelArray = channel->createChannelArray(channelArrayRequesterImpl, pvRequest);
epicsThreadSleep ( SLEEP_TIME );
channelArray->getArray(0,0,1);
epicsThreadSleep ( SLEEP_TIME );
// TODO !!!
//channelArray->putArray(0,0,1);
//epicsThreadSleep ( SLEEP_TIME );
channelArray->setLength(3);
epicsThreadSleep ( SLEEP_TIME );
channelArray->getLength();
epicsThreadSleep ( SLEEP_TIME );
channelArray->destroy();
}
{
MonitorRequester::shared_pointer monitorRequesterImpl(new MonitorRequesterImpl());
PVStructure::shared_pointer pvRequest = CreateRequest::create()->createRequest("field()");
Monitor::shared_pointer monitor = channel->createMonitor(monitorRequesterImpl, pvRequest);
epicsThreadSleep( SLEEP_TIME );
Status status = monitor->start();
std::cout << "monitor->start() = " << status << std::endl;
epicsThreadSleep( 3*SLEEP_TIME );
status = monitor->stop();
std::cout << "monitor->stop() = " << status << std::endl;
monitor->destroy();
}
epicsThreadSleep ( 3*SLEEP_TIME );
printf("Destroying channel... \n");
channel->destroy();
printf("done.\n");
epicsThreadSleep ( 3*SLEEP_TIME );
ChannelRequester::shared_pointer channelRequester(new ChannelRequesterImpl());
Channel::shared_pointer channel = provider->createChannel("testStructureArrayTest", channelRequester);
epicsThreadSleep ( SLEEP_TIME );
channel->printInfo();
{
GetFieldRequester::shared_pointer getFieldRequesterImpl(new GetFieldRequesterImpl());
channel->getField(getFieldRequesterImpl, "");
epicsThreadSleep ( SLEEP_TIME );
}
{
ChannelProcessRequester::shared_pointer channelProcessRequester(new ChannelProcessRequesterImpl());
PVStructure::shared_pointer pvRequest;
ChannelProcess::shared_pointer channelProcess = channel->createChannelProcess(channelProcessRequester, pvRequest);
epicsThreadSleep ( SLEEP_TIME );
channelProcess->process();
epicsThreadSleep ( SLEEP_TIME );
channelProcess->destroy();
epicsThreadSleep ( SLEEP_TIME );
}
{
ChannelGetRequester::shared_pointer channelGetRequesterImpl(new ChannelGetRequesterImpl());
PVStructure::shared_pointer pvRequest = CreateRequest::create()->createRequest("field()");
ChannelGet::shared_pointer channelGet = channel->createChannelGet(channelGetRequesterImpl, pvRequest);
epicsThreadSleep ( 3.0 );
channelGet->get();
epicsThreadSleep ( 3.0 );
channelGet->destroy();
}
{
ChannelPutRequester::shared_pointer channelPutRequesterImpl(new ChannelPutRequesterImpl());
PVStructure::shared_pointer pvRequest = CreateRequest::create()->createRequest("field(value,timeStamp)");
ChannelPut::shared_pointer channelPut = channel->createChannelPut(channelPutRequesterImpl, pvRequest);
epicsThreadSleep ( SLEEP_TIME );
channelPut->get();
epicsThreadSleep ( SLEEP_TIME );
// TODO !!!
//channelPut->put();
//epicsThreadSleep ( SLEEP_TIME );
channelPut->destroy();
}
{
ChannelPutGetRequester::shared_pointer channelPutGetRequesterImpl(new ChannelPutGetRequesterImpl());
PVStructure::shared_pointer pvRequest = CreateRequest::create()->createRequest("putField(value,timeStamp)getField(timeStamp)");
ChannelPutGet::shared_pointer channelPutGet = channel->createChannelPutGet(channelPutGetRequesterImpl, pvRequest);
epicsThreadSleep ( SLEEP_TIME );
channelPutGet->getGet();
epicsThreadSleep ( SLEEP_TIME );
channelPutGet->getPut();
epicsThreadSleep ( SLEEP_TIME );
// TODO !!!
//channelPutGet->putGet();
//epicsThreadSleep ( SLEEP_TIME );
channelPutGet->destroy();
}
ClientFactory::stop();
{
ChannelRPCRequester::shared_pointer channelRPCRequesterImpl(new ChannelRPCRequesterImpl());
PVStructure::shared_pointer pvRequest = CreateRequest::create()->createRequest("record[]field(arguments)");
ChannelRPC::shared_pointer channelRPC = channel->createChannelRPC(channelRPCRequesterImpl, pvRequest);
epicsThreadSleep ( SLEEP_TIME );
// for test simply use pvRequest as arguments
channelRPC->request(pvRequest);
epicsThreadSleep ( SLEEP_TIME );
channelRPC->destroy();
}
{
ChannelArrayRequester::shared_pointer channelArrayRequesterImpl(new ChannelArrayRequesterImpl());
StringArray fieldNames; fieldNames.push_back("field");
FieldConstPtrArray fields; fields.push_back(getFieldCreate()->createScalar(pvString));
PVStructure::shared_pointer pvRequest(getPVDataCreate()->createPVStructure(getFieldCreate()->createStructure(fieldNames, fields)));
/*
printf("Destroying context... \n");
context->destroy();
printf("done.\n");
*/
ChannelArray::shared_pointer channelArray = channel->createChannelArray(channelArrayRequesterImpl, pvRequest);
epicsThreadSleep ( SLEEP_TIME );
channelArray->getArray(0,0,1);
epicsThreadSleep ( SLEEP_TIME );
// TODO !!!
//channelArray->putArray(0,0,1);
//epicsThreadSleep ( SLEEP_TIME );
channelArray->setLength(3);
epicsThreadSleep ( SLEEP_TIME );
channelArray->getLength();
epicsThreadSleep ( SLEEP_TIME );
channelArray->destroy();
}
{
MonitorRequester::shared_pointer monitorRequesterImpl(new MonitorRequesterImpl());
PVStructure::shared_pointer pvRequest = CreateRequest::create()->createRequest("field()");
Monitor::shared_pointer monitor = channel->createMonitor(monitorRequesterImpl, pvRequest);
epicsThreadSleep( SLEEP_TIME );
Status status = monitor->start();
std::cout << "monitor->start() = " << status << std::endl;
epicsThreadSleep( 3*SLEEP_TIME );
status = monitor->stop();
std::cout << "monitor->stop() = " << status << std::endl;
monitor->destroy();
}
epicsThreadSleep ( 3*SLEEP_TIME );
printf("Destroying channel... \n");
channel->destroy();
printf("done.\n");
epicsThreadSleep ( 3*SLEEP_TIME );
epicsThreadSleep ( SLEEP_TIME );
}
ClientFactory::stop();
/*
printf("Destroying context... \n");
context->destroy();
printf("done.\n");
*/
epicsThreadSleep ( SLEEP_TIME ); }
//std::cout << "-----------------------------------------------------------------------" << std::endl;
//epicsExitCallAtExits();
return(0);

File diff suppressed because it is too large Load Diff

View File

@@ -12,16 +12,18 @@ using namespace std;
class TestChannelProvider : public ChannelProvider
{
public:
std::string getProviderName() { return "local"; };
std::string getProviderName() {
return "local";
};
ChannelFind::shared_pointer channelFind(std::string const & /*channelName*/,
ChannelFindRequester::shared_pointer const & channelFindRequester)
{
ChannelFind::shared_pointer nullCF;
channelFindRequester->channelFindResult(Status::Ok, nullCF, false);
return nullCF;
channelFindRequester->channelFindResult(Status::Ok, nullCF, false);
return nullCF;
}
ChannelFind::shared_pointer channelList(ChannelListRequester::shared_pointer const & channelListRequester)
@@ -33,23 +35,23 @@ public:
}
Channel::shared_pointer createChannel(
std::string const & channelName,
ChannelRequester::shared_pointer const & channelRequester,
short priority = PRIORITY_DEFAULT)
std::string const & channelName,
ChannelRequester::shared_pointer const & channelRequester,
short priority = PRIORITY_DEFAULT)
{
return createChannel(channelName, channelRequester, priority, "");
}
Channel::shared_pointer createChannel(
std::string const & /*channelName*/,
ChannelRequester::shared_pointer const & channelRequester,
short /*priority*/, std::string const & /*address*/)
std::string const & /*channelName*/,
ChannelRequester::shared_pointer const & channelRequester,
short /*priority*/, std::string const & /*address*/)
{
Channel::shared_pointer nullC;
channelRequester->channelCreated(Status::Ok, nullC);
return nullC;
return nullC;
}
void destroy()
{
}
@@ -58,19 +60,19 @@ public:
class TestChannelProviderRegistry : public ChannelProviderRegistry {
public:
virtual ~TestChannelProviderRegistry() {};
ChannelProvider::shared_pointer getProvider(std::string const & providerName)
{
if (providerName == "local")
{
return ChannelProvider::shared_pointer(new TestChannelProvider());
return ChannelProvider::shared_pointer(new TestChannelProvider());
}
else
return ChannelProvider::shared_pointer();
return ChannelProvider::shared_pointer();
}
ChannelProvider::shared_pointer createProvider(std::string const & providerName)
{
return getProvider(providerName);
@@ -87,24 +89,24 @@ public:
void testServerContext()
{
ServerContextImpl::shared_pointer ctx = ServerContextImpl::create();
ServerContextImpl::shared_pointer ctx = ServerContextImpl::create();
ChannelProviderRegistry::shared_pointer ca(new TestChannelProviderRegistry());
ctx->initialize(ca);
ChannelProviderRegistry::shared_pointer ca(new TestChannelProviderRegistry());
ctx->initialize(ca);
ctx->printInfo();
ctx->printInfo();
ctx->run(1);
ctx->run(1);
ctx->destroy();
ctx->destroy();
}
int main()
{
testServerContext();
testServerContext();
cout << "Done" << endl;
cout << "Done" << endl;
//epicsExitCallAtExits();
//epicsExitCallAtExits();
return (0);
}

View File

@@ -1,9 +1,9 @@
/*
* Network configuration -- QEMU NOT using DHCP
*
*
************************************************************
* EDIT THIS FILE TO REFLECT YOUR NETWORK CONFIGURATION *
* BEFORE RUNNING ANY RTEMS PROGRAMS WHICH USE THE NETWORK! *
* BEFORE RUNNING ANY RTEMS PROGRAMS WHICH USE THE NETWORK! *
************************************************************
*
* The dynamic probing is based upon the EPICS network
@@ -19,8 +19,8 @@
/* #define USE_LIBBSDPORT */
#if defined(USE_LIBBSDPORT)
#include <bsp/libbsdport_api.h>
#define CONFIGURE_MAXIMUM_TIMERS 10
#include <bsp/libbsdport_api.h>
#define CONFIGURE_MAXIMUM_TIMERS 10
#endif
/*
* For TFTP test application
@@ -35,7 +35,7 @@
/*
* For NFS test application
*
*
* NFS mount and a directory to ls once mounted
*/
#define RTEMS_NFS_SERVER "192.168.1.210"
@@ -128,9 +128,9 @@ const int gesysNetworkTaskPriority = NETWORK_TASK_PRIORITY;
#ifdef MULTI_NETDRIVER
#if 0
#if RTEMS_VERSION_ATLEAST(4,6,99)
#define pcib_init pci_initialize
#endif
#if RTEMS_VERSION_ATLEAST(4,6,99)
#define pcib_init pci_initialize
#endif
#endif
extern int rtems_3c509_driver_attach (struct rtems_bsdnet_ifconfig *, int);
@@ -143,60 +143,60 @@ extern int rtems_ne_driver_attach (struct rtems_bsdnet_ifconfig *, int);
extern int rtems_wd_driver_attach (struct rtems_bsdnet_ifconfig *, int);
static struct rtems_bsdnet_ifconfig isa_netdriver_config[] = {
{
"ep0", rtems_3c509_driver_attach, isa_netdriver_config + 1,
},
{
"ne1", rtems_ne_driver_attach, 0, irno: 9 /* qemu cannot configure irq-no :-(; has it hardwired to 9 */
},
{
"ep0", rtems_3c509_driver_attach, isa_netdriver_config + 1,
},
{
"ne1", rtems_ne_driver_attach, 0, irno: 9 /* qemu cannot configure irq-no :-(; has it hardwired to 9 */
},
};
static struct rtems_bsdnet_ifconfig pci_netdriver_config[]={
{
"dc1", rtems_dec21140_driver_attach, pci_netdriver_config+1,
},
#if !defined(USE_LIBBSDPORT)
static struct rtems_bsdnet_ifconfig pci_netdriver_config[]= {
{
"fxp1", rtems_fxp_attach, pci_netdriver_config+2,
"dc1", rtems_dec21140_driver_attach, pci_netdriver_config+1,
},
#else
#if !defined(USE_LIBBSDPORT)
{
"", libbsdport_netdriver_attach, pci_netdriver_config+2,
"fxp1", rtems_fxp_attach, pci_netdriver_config+2,
},
#else
{
"", libbsdport_netdriver_attach, pci_netdriver_config+2,
},
#endif
{
"elnk1", rtems_elnk_driver_attach, isa_netdriver_config,
},
#endif
{
"elnk1", rtems_elnk_driver_attach, isa_netdriver_config,
},
};
static int pci_check(struct rtems_bsdnet_ifconfig *ocfg, int attaching)
{
struct rtems_bsdnet_ifconfig *cfg;
int if_index_pre;
extern int if_index;
if ( attaching ) {
cfg = pci_initialize() ?
isa_netdriver_config : pci_netdriver_config;
}
while ( cfg ) {
printk("Probing '%s'", cfg->name);
/* unfortunately, the return value is unreliable - some drivers report
* success even if they fail.
* Check if they chained an interface (ifnet) structure instead
*/
if_index_pre = if_index;
cfg->attach(cfg, attaching);
if ( if_index > if_index_pre ) {
/* assume success */
printk(" .. seemed to work\n");
ocfg->name = cfg->name;
ocfg->attach = cfg->attach;
return 0;
}
printk(" .. failed\n");
cfg = cfg->next;
}
return -1;
struct rtems_bsdnet_ifconfig *cfg;
int if_index_pre;
extern int if_index;
if ( attaching ) {
cfg = pci_initialize() ?
isa_netdriver_config : pci_netdriver_config;
}
while ( cfg ) {
printk("Probing '%s'", cfg->name);
/* unfortunately, the return value is unreliable - some drivers report
* success even if they fail.
* Check if they chained an interface (ifnet) structure instead
*/
if_index_pre = if_index;
cfg->attach(cfg, attaching);
if ( if_index > if_index_pre ) {
/* assume success */
printk(" .. seemed to work\n");
ocfg->name = cfg->name;
ocfg->attach = cfg->attach;
return 0;
}
printk(" .. failed\n");
cfg = cfg->next;
}
return -1;
}
@@ -233,18 +233,19 @@ static char ethernet_address[6] = { 0x00, 0xab, 0xcd, 0xef, 0x12, 0x34 };
#endif
static struct rtems_bsdnet_ifconfig netdriver_config[1] = {{
NIC_NAME, /* name */
(int (*)(struct rtems_bsdnet_ifconfig*,int))NIC_ATTACH, /* attach function */
0, /* link to next interface */
FIXED_IP_ADDR,
FIXED_NETMASK
NIC_NAME, /* name */
(int (*)(struct rtems_bsdnet_ifconfig*,int))NIC_ATTACH, /* attach function */
0, /* link to next interface */
FIXED_IP_ADDR,
FIXED_NETMASK
#if RTEMS_BSP_NETWORK_DRIVER_ATTACH == BSP_NE2000_NETWORK_DRIVER_ATTACH
,
ethernet_address,
irno:9,
port:0xc100
,
ethernet_address,
irno:9,
port:0xc100
#endif
}};
}
};
#else
#warning "NO KNOWN NETWORK DRIVER FOR THIS BSP -- YOU MAY HAVE TO EDIT networkconfig.h"
#endif

View File

@@ -23,8 +23,8 @@
#ifdef _WIN32
void setenv(char * a, char * b, int c)
{
char buf[1024];
sprintf(buf, "%s=%s", a, b);
char buf[1024];
sprintf(buf, "%s=%s", a, b);
_putenv(buf);
}
#endif
@@ -33,18 +33,18 @@ using namespace epics::pvAccess;
using namespace epics::pvData;
static const char indata[] =
"hello = world \n"
" # oops\n"
" #dd=da\n"
" empty = \n"
" this = is a test\n\n"
;
"hello = world \n"
" # oops\n"
" #dd=da\n"
" empty = \n"
" this = is a test\n\n"
;
static const char expectdata[] =
"empty = \n"
"hello = world\n"
"this = is a test\n"
;
"empty = \n"
"hello = world\n"
"this = is a test\n"
;
static
void showEscaped(const char *msg, const std::string& s)

View File

@@ -19,44 +19,44 @@ using std::tr1::static_pointer_cast;
using namespace epics::pvData;
namespace epics {
namespace pvAccess {
class SerializableControlImpl : public SerializableControl,
public NoDefaultMethods {
public:
virtual void flushSerializeBuffer() {
}
virtual void ensureBuffer(int size) {
}
virtual void alignBuffer(int alignment) {
}
SerializableControlImpl() {
}
virtual ~SerializableControlImpl() {
}
};
class DeserializableControlImpl : public DeserializableControl,
public NoDefaultMethods {
public:
virtual void ensureData(int size) {
}
virtual void alignData(int alignment) {
}
DeserializableControlImpl() {
}
virtual ~DeserializableControlImpl() {
}
};
namespace pvAccess {
class SerializableControlImpl : public SerializableControl,
public NoDefaultMethods {
public:
virtual void flushSerializeBuffer() {
}
virtual void ensureBuffer(int size) {
}
virtual void alignBuffer(int alignment) {
}
SerializableControlImpl() {
}
virtual ~SerializableControlImpl() {
}
};
class DeserializableControlImpl : public DeserializableControl,
public NoDefaultMethods {
public:
virtual void ensureData(int size) {
}
virtual void alignData(int alignment) {
}
DeserializableControlImpl() {
}
virtual ~DeserializableControlImpl() {
}
};
}
}
using namespace epics::pvAccess;
@@ -81,440 +81,440 @@ static string builder;
//helper methods
ScalarConstPtr getScalar(string name)
{
ScalarConstPtr scalar = standardField->scalar(name,pvFloat);
PVField *pvField = pvDataCreate->createPVField(0,scalar);
pvFieldArray.push_back(pvField);
return scalar;
ScalarConstPtr scalar = standardField->scalar(name,pvFloat);
PVField *pvField = pvDataCreate->createPVField(0,scalar);
pvFieldArray.push_back(pvField);
return scalar;
}
ScalarArrayConstPtr getScalarArray(string name)
{
ScalarArrayConstPtr scalarArray = standardField->scalarArray(name,pvFloat);
PVField *pvField = pvDataCreate->createPVField(0,scalarArray);
pvFieldArray.push_back(pvField);
return scalarArray;
ScalarArrayConstPtr scalarArray = standardField->scalarArray(name,pvFloat);
PVField *pvField = pvDataCreate->createPVField(0,scalarArray);
pvFieldArray.push_back(pvField);
return scalarArray;
}
StructureConstPtr getStructure(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);
StructureConstPtr structure = standardField->structure(name,3,powerSupply);
PVField *pvField = pvDataCreate->createPVField(0,structure);
pvFieldArray.push_back(pvField);
return structure;
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);
StructureConstPtr structure = standardField->structure(name,3,powerSupply);
PVField *pvField = pvDataCreate->createPVField(0,structure);
pvFieldArray.push_back(pvField);
return structure;
}
StructureArrayConstPtr getStructureArray(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);
StructureConstPtr structure = standardField->structure(name1,3,powerSupply);
StructureArrayConstPtr structureArray = standardField->structureArray(name2,structure);
PVField *pvField = pvDataCreate->createPVField(0,structureArray);
pvFieldArray.push_back(pvField);
return structureArray;
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);
StructureConstPtr structure = standardField->structure(name1,3,powerSupply);
StructureArrayConstPtr structureArray = standardField->structureArray(name2,structure);
PVField *pvField = pvDataCreate->createPVField(0,structureArray);
pvFieldArray.push_back(pvField);
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;
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;
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()
{
short id = 0;
ScalarConstPtr scalarIn = getScalar("field1");
registry->registerIntrospectionInterface(id,scalarIn);
short id = 0;
ScalarConstPtr scalarIn = getScalar("field1");
registry->registerIntrospectionInterface(id,scalarIn);
id++;
ScalarArrayConstPtr scalarArrayIn = getScalarArray("fieldArray1");
registry->registerIntrospectionInterface(id,scalarArrayIn);
id++;
ScalarArrayConstPtr scalarArrayIn = getScalarArray("fieldArray1");
registry->registerIntrospectionInterface(id,scalarArrayIn);
id++;
StructureConstPtr structureIn = getStructure("struct1");
registry->registerIntrospectionInterface(id,structureIn);
id++;
StructureConstPtr structureIn = getStructure("struct1");
registry->registerIntrospectionInterface(id,structureIn);
id++;
StructureArrayConstPtr structureArrayIn = getStructureArray("struct1","structArray1");
registry->registerIntrospectionInterface(id,structureArrayIn);
id++;
StructureArrayConstPtr structureArrayIn = getStructureArray("struct1","structArray1");
registry->registerIntrospectionInterface(id,structureArrayIn);
id = 0;
ScalarConstPtr scalarOut = static_pointer_cast<const Scalar>(registry->getIntrospectionInterface(id));
assert(scalarIn == scalarOut);
id = 0;
ScalarConstPtr scalarOut = static_pointer_cast<const Scalar>(registry->getIntrospectionInterface(id));
assert(scalarIn == scalarOut);
id++;
ScalarArrayConstPtr scalarArrayOut = static_pointer_cast<const ScalarArray>(registry->getIntrospectionInterface(id));
assert(scalarArrayIn == scalarArrayOut);
id++;
ScalarArrayConstPtr scalarArrayOut = static_pointer_cast<const ScalarArray>(registry->getIntrospectionInterface(id));
assert(scalarArrayIn == scalarArrayOut);
id++;
StructureConstPtr structureOut = static_pointer_cast<const Structure>(registry->getIntrospectionInterface(id));
assert(structureIn == structureOut);
id++;
StructureConstPtr structureOut = static_pointer_cast<const Structure>(registry->getIntrospectionInterface(id));
assert(structureIn == structureOut);
id++;
StructureArrayConstPtr structureArrayOut = static_pointer_cast<const StructureArray>(registry->getIntrospectionInterface(id));
assert(structureArrayIn == structureArrayOut);
id++;
StructureArrayConstPtr structureArrayOut = static_pointer_cast<const StructureArray>(registry->getIntrospectionInterface(id));
assert(structureArrayIn == structureArrayOut);
bool existing;
id = registry->registerIntrospectionInterface(static_pointer_cast<const Field>(scalarIn),existing);
assert(existing == true);
assert(id == 0);
bool existing;
id = registry->registerIntrospectionInterface(static_pointer_cast<const Field>(scalarIn),existing);
assert(existing == true);
assert(id == 0);
id = registry->registerIntrospectionInterface(static_pointer_cast<const Field>(scalarArrayIn),existing);
assert(existing == true);
assert(id == 1);
id = registry->registerIntrospectionInterface(static_pointer_cast<const Field>(scalarArrayIn),existing);
assert(existing == true);
assert(id == 1);
id = registry->registerIntrospectionInterface(static_pointer_cast<const Field>(structureIn),existing);
assert(existing == true);
assert(id == 2);
id = registry->registerIntrospectionInterface(static_pointer_cast<const Field>(structureIn),existing);
assert(existing == true);
assert(id == 2);
id = registry->registerIntrospectionInterface(static_pointer_cast<const Field>(structureArrayIn),existing);
assert(existing == true);
assert(id == 3);
id = registry->registerIntrospectionInterface(static_pointer_cast<const Field>(structureArrayIn),existing);
assert(existing == true);
assert(id == 3);
//should exist
ScalarConstPtr scalarInNew = getScalar("field1");
id = registry->registerIntrospectionInterface(static_pointer_cast<const Field>(scalarInNew),existing);
assert(existing == true);
assert(id == 0);
//should exist
ScalarConstPtr scalarInNew = getScalar("field1");
id = registry->registerIntrospectionInterface(static_pointer_cast<const Field>(scalarInNew),existing);
assert(existing == true);
assert(id == 0);
scalarOut = static_pointer_cast<const Scalar>(registry->getIntrospectionInterface(id));
assert(scalarIn == scalarOut);
scalarOut = static_pointer_cast<const Scalar>(registry->getIntrospectionInterface(id));
assert(scalarIn == scalarOut);
}
void testRegistryReset()
{
registry->reset();
registry->reset();
short id = 0;
short id = 0;
assert(static_pointer_cast<const Scalar>(registry->getIntrospectionInterface(id)) == 0);
}
void serialize(FieldConstPtr field, IntrospectionRegistry* registry)
{
buffer->clear();
registry->serialize(field,buffer,flusher);
//should be in registry
bool existing;
registry->registerIntrospectionInterface(field,existing);
assert(existing == true);
buffer->clear();
registry->serialize(field,buffer,flusher);
//should be in registry
bool existing;
registry->registerIntrospectionInterface(field,existing);
assert(existing == true);
}
FieldConstPtr deserialize(IntrospectionRegistry* registry)
{
FieldConstPtr field = registry->deserialize(buffer,control);
PVField *pvField = pvDataCreate->createPVField(0,field);
pvFieldArray.push_back(pvField);
//should be in registry
bool existing;
registry->registerIntrospectionInterface(field,existing);
assert(existing == true);
return field;
FieldConstPtr field = registry->deserialize(buffer,control);
PVField *pvField = pvDataCreate->createPVField(0,field);
pvFieldArray.push_back(pvField);
//should be in registry
bool existing;
registry->registerIntrospectionInterface(field,existing);
assert(existing == true);
return field;
}
void checkTypeCode(int8 typeCodeIn)
{
int8 typeCode = buffer->getByte();
int8 typeCode = buffer->getByte();
//printf("%d == %d\n", typeCode, typeCodeIn);
assert(typeCode == typeCodeIn);
buffer->rewind();
assert(typeCode == typeCodeIn);
buffer->rewind();
}
void testSerializeCommon(FieldConstPtr serverField1, FieldConstPtr clientField2)
{
//server serializes field 1
serialize(serverField1,serverRegistry);
//server serializes field 1
serialize(serverField1,serverRegistry);
//full should be serialized
buffer->flip();
checkTypeCode(IntrospectionRegistry::FULL_WITH_ID_TYPE_CODE);
//full should be serialized
buffer->flip();
checkTypeCode(IntrospectionRegistry::FULL_WITH_ID_TYPE_CODE);
//client deserializes 1
FieldConstPtr clientField1 = deserialize(clientRegistry);
assert(serverField1->getFieldName() == clientField1->getFieldName());
assert(serverField1->getType() == clientField1->getType());
//client deserializes 1
FieldConstPtr clientField1 = deserialize(clientRegistry);
assert(serverField1->getFieldName() == clientField1->getFieldName());
assert(serverField1->getType() == clientField1->getType());
//client serializes the same field
serialize(serverField1,clientRegistry);
//client serializes the same field
serialize(serverField1,clientRegistry);
//only id should be serialized
buffer->flip();
checkTypeCode(IntrospectionRegistry::ONLY_ID_TYPE_CODE);
//only id should be serialized
buffer->flip();
checkTypeCode(IntrospectionRegistry::ONLY_ID_TYPE_CODE);
//server deserializes the same field
serverField1 = deserialize(serverRegistry);
assert(serverField1->getFieldName() == clientField1->getFieldName());
assert(serverField1->getType() == clientField1->getType());
//server deserializes the same field
serverField1 = deserialize(serverRegistry);
assert(serverField1->getFieldName() == clientField1->getFieldName());
assert(serverField1->getType() == clientField1->getType());
//client requests new field
serialize(clientField2,clientRegistry);
//client requests new field
serialize(clientField2,clientRegistry);
//full should be serialized
buffer->flip();
checkTypeCode(IntrospectionRegistry::FULL_WITH_ID_TYPE_CODE);
//full should be serialized
buffer->flip();
checkTypeCode(IntrospectionRegistry::FULL_WITH_ID_TYPE_CODE);
//server deserializes new field
FieldConstPtr serverField2 = deserialize(serverRegistry);
assert(serverField2->getFieldName() == clientField2->getFieldName());
assert(serverField2->getType() == clientField2->getType());
//server deserializes new field
FieldConstPtr serverField2 = deserialize(serverRegistry);
assert(serverField2->getFieldName() == clientField2->getFieldName());
assert(serverField2->getType() == clientField2->getType());
}
void testSerialize()
{
clientRegistry->reset();
serverRegistry->reset();
stringstream ss;
string name1,name2,name3,name4;
clientRegistry->reset();
serverRegistry->reset();
stringstream ss;
string name1,name2,name3,name4;
for(int i = 0, j = 0; i < 10 ; i++, j++)
{
name1.clear();
name2.clear();
ss.str("");
ss << j;
name1 = "field" + ss.str();
ss.str("");
j++;
ss << j;
name2 = "field" + ss.str();
testSerializeCommon(static_pointer_cast<const Field>(getScalar(name1)),static_pointer_cast<const Field>(getScalar(name2)));
for(int i = 0, j = 0; i < 10 ; i++, j++)
{
name1.clear();
name2.clear();
ss.str("");
ss << j;
name1 = "field" + ss.str();
ss.str("");
j++;
ss << j;
name2 = "field" + ss.str();
testSerializeCommon(static_pointer_cast<const Field>(getScalar(name1)),static_pointer_cast<const Field>(getScalar(name2)));
name1.clear();
name2.clear();
ss.str("");
ss << j;
name1 = "fieldArray" + ss.str();
ss.str("");
j++;
ss << j;
name2 = "fieldArray" + ss.str();
testSerializeCommon(static_pointer_cast<const Field>(getScalarArray(name1)),static_pointer_cast<const Field>(getScalarArray(name2)));
name1.clear();
name2.clear();
ss.str("");
ss << j;
name1 = "fieldArray" + ss.str();
ss.str("");
j++;
ss << j;
name2 = "fieldArray" + ss.str();
testSerializeCommon(static_pointer_cast<const Field>(getScalarArray(name1)),static_pointer_cast<const Field>(getScalarArray(name2)));
name1.clear();
name2.clear();
ss.str("");
ss << j;
name1 = "structure" + ss.str();
ss.str("");
j++;
ss << j;
name2 = "structure" + ss.str();
testSerializeCommon(static_pointer_cast<const Field>(getStructure(name1)),static_pointer_cast<const Field>(getStructure(name2)));
name1.clear();
name2.clear();
ss.str("");
ss << j;
name1 = "structure" + ss.str();
ss.str("");
j++;
ss << j;
name2 = "structure" + ss.str();
testSerializeCommon(static_pointer_cast<const Field>(getStructure(name1)),static_pointer_cast<const Field>(getStructure(name2)));
name1.clear();
name2.clear();
name3.clear();
name4.clear();
ss.str("");
ss << j;
name1 = "structure" + ss.str();
name2 = "structureArray" + ss.str();
ss.str("");
j++;
ss << j;
name3 = "structure" + ss.str();
name4 = "structureArray" + ss.str();
testSerializeCommon(static_pointer_cast<const Field>(getStructureArray(name1,name2)),static_pointer_cast<const Field>(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<const Field>(getUnion(name1)),static_pointer_cast<const Field>(getUnion(name2)));
name1.clear();
name2.clear();
name3.clear();
name4.clear();
ss.str("");
ss << j;
name1 = "structure" + ss.str();
name2 = "structureArray" + ss.str();
ss.str("");
j++;
ss << j;
name3 = "structure" + ss.str();
name4 = "structureArray" + ss.str();
testSerializeCommon(static_pointer_cast<const Field>(getStructureArray(name1,name2)),static_pointer_cast<const Field>(getStructureArray(name3,name4)));
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<const Field>(getUnionArray(name1,name2)),static_pointer_cast<const Field>(getUnionArray(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<const Field>(getUnion(name1)),static_pointer_cast<const Field>(getUnion(name2)));
//serverRegistry->printKeysAndValues("server");
//clientRegistry->printKeysAndValues("client");
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<const Field>(getUnionArray(name1,name2)),static_pointer_cast<const Field>(getUnionArray(name3,name4)));
}
//serverRegistry->printKeysAndValues("server");
//clientRegistry->printKeysAndValues("client");
}
void testSerializeFull()
{
buffer->clear();
ScalarConstPtr scalarIn = getScalar("field1");
IntrospectionRegistry::serializeFull(static_pointer_cast<const Field>(scalarIn),buffer,flusher);
buffer->flip();
ScalarConstPtr scalarOut = static_pointer_cast<const Scalar>(IntrospectionRegistry::deserializeFull(buffer,control));
PVField *pvField = pvDataCreate->createPVField(0,scalarOut);
pvFieldArray.push_back(pvField);
assert(scalarIn->getFieldName() == scalarOut->getFieldName());
assert(scalarIn->getType() == scalarOut->getType());
buffer->clear();
ScalarConstPtr scalarIn = getScalar("field1");
IntrospectionRegistry::serializeFull(static_pointer_cast<const Field>(scalarIn),buffer,flusher);
buffer->flip();
ScalarConstPtr scalarOut = static_pointer_cast<const Scalar>(IntrospectionRegistry::deserializeFull(buffer,control));
PVField *pvField = pvDataCreate->createPVField(0,scalarOut);
pvFieldArray.push_back(pvField);
assert(scalarIn->getFieldName() == scalarOut->getFieldName());
assert(scalarIn->getType() == scalarOut->getType());
buffer->clear();
ScalarArrayConstPtr scalarArrayIn = getScalarArray("fieldArray1");
IntrospectionRegistry::serializeFull(static_pointer_cast<const Field>(scalarArrayIn),buffer,flusher);
buffer->flip();
ScalarArrayConstPtr scalarArrayOut = static_pointer_cast<const ScalarArray>(IntrospectionRegistry::deserializeFull(buffer,control));
pvField = pvDataCreate->createPVField(0,scalarArrayOut);
pvFieldArray.push_back(pvField);
assert(scalarArrayIn->getFieldName() == scalarArrayOut->getFieldName());
assert(scalarArrayIn->getType() == scalarArrayOut->getType());
buffer->clear();
ScalarArrayConstPtr scalarArrayIn = getScalarArray("fieldArray1");
IntrospectionRegistry::serializeFull(static_pointer_cast<const Field>(scalarArrayIn),buffer,flusher);
buffer->flip();
ScalarArrayConstPtr scalarArrayOut = static_pointer_cast<const ScalarArray>(IntrospectionRegistry::deserializeFull(buffer,control));
pvField = pvDataCreate->createPVField(0,scalarArrayOut);
pvFieldArray.push_back(pvField);
assert(scalarArrayIn->getFieldName() == scalarArrayOut->getFieldName());
assert(scalarArrayIn->getType() == scalarArrayOut->getType());
buffer->clear();
StructureConstPtr structureIn = getStructure("struct1");
IntrospectionRegistry::serializeFull(static_pointer_cast<const Field>(structureIn),buffer,flusher);
buffer->flip();
StructureConstPtr structureOut = static_pointer_cast<const Structure>(IntrospectionRegistry::deserializeFull(buffer,control));
pvField = pvDataCreate->createPVField(0,structureOut);
pvFieldArray.push_back(pvField);
assert(structureIn->getFieldName() == structureOut->getFieldName());
assert(structureIn->getType() == structureOut->getType());
buffer->clear();
StructureConstPtr structureIn = getStructure("struct1");
IntrospectionRegistry::serializeFull(static_pointer_cast<const Field>(structureIn),buffer,flusher);
buffer->flip();
StructureConstPtr structureOut = static_pointer_cast<const Structure>(IntrospectionRegistry::deserializeFull(buffer,control));
pvField = pvDataCreate->createPVField(0,structureOut);
pvFieldArray.push_back(pvField);
assert(structureIn->getFieldName() == structureOut->getFieldName());
assert(structureIn->getType() == structureOut->getType());
buffer->clear();
StructureArrayConstPtr structureArrayIn = getStructureArray("struct1","structArray1");
IntrospectionRegistry::serializeFull(static_pointer_cast<const Field>(structureArrayIn),buffer,flusher);
buffer->flip();
StructureArrayConstPtr structureArrayOut = static_pointer_cast<const StructureArray>(IntrospectionRegistry::deserializeFull(buffer,control));
pvField = pvDataCreate->createPVField(0,structureArrayOut);
pvFieldArray.push_back(pvField);
assert(structureArrayIn->getFieldName() == structureArrayOut->getFieldName());
assert(structureArrayIn->getType() == structureArrayOut->getType());
buffer->clear();
StructureArrayConstPtr structureArrayIn = getStructureArray("struct1","structArray1");
IntrospectionRegistry::serializeFull(static_pointer_cast<const Field>(structureArrayIn),buffer,flusher);
buffer->flip();
StructureArrayConstPtr structureArrayOut = static_pointer_cast<const StructureArray>(IntrospectionRegistry::deserializeFull(buffer,control));
pvField = pvDataCreate->createPVField(0,structureArrayOut);
pvFieldArray.push_back(pvField);
assert(structureArrayIn->getFieldName() == structureArrayOut->getFieldName());
assert(structureArrayIn->getType() == structureArrayOut->getType());
}
void testSerializePVRequest()
{
buffer->clear();
registry->reset();
PVStructurePtr pvStructureIn = pvDataCreate->createPVStructure(NULL,getStructure("structure1"));
registry->serializePVRequest(buffer,flusher,pvStructureIn);
buffer->clear();
registry->reset();
PVStructurePtr pvStructureIn = pvDataCreate->createPVStructure(NULL,getStructure("structure1"));
registry->serializePVRequest(buffer,flusher,pvStructureIn);
buffer->flip();
PVStructurePtr pvStructureOut = registry->deserializePVRequest(buffer,control);
assert(*pvStructureIn == *pvStructureOut);
delete pvStructureIn;
delete pvStructureOut;
buffer->flip();
PVStructurePtr pvStructureOut = registry->deserializePVRequest(buffer,control);
assert(*pvStructureIn == *pvStructureOut);
delete pvStructureIn;
delete pvStructureOut;
}
void testDeserializeStructureAndCreatePVStructure()
{
buffer->clear();
registry->reset();
StructureConstPtr structureIn = getStructure("structure1");
serialize(structureIn,registry);
buffer->clear();
registry->reset();
StructureConstPtr structureIn = getStructure("structure1");
serialize(structureIn,registry);
buffer->flip();
PVStructurePtr pvStructureOut = registry->deserializeStructureAndCreatePVStructure(buffer,control);
StructureConstPtr structureOut = pvStructureOut->getStructure();
assert(structureIn->getFieldName() == structureOut->getFieldName());
assert(structureIn->getType() == structureOut->getType());
delete pvStructureOut;
buffer->flip();
PVStructurePtr pvStructureOut = registry->deserializeStructureAndCreatePVStructure(buffer,control);
StructureConstPtr structureOut = pvStructureOut->getStructure();
assert(structureIn->getFieldName() == structureOut->getFieldName());
assert(structureIn->getType() == structureOut->getType());
delete pvStructureOut;
}
void testSerializeStatus()
{
buffer->clear();
registry->reset();
Status statusIn(Status::STATUSTYPE_WARNING, "msg", "dumpy");
registry->serializeStatus(buffer,flusher,statusIn);
buffer->clear();
registry->reset();
Status statusIn(Status::STATUSTYPE_WARNING, "msg", "dumpy");
registry->serializeStatus(buffer,flusher,statusIn);
buffer->flip();
Status statusOut;
registry->deserializeStatus(statusOut, buffer,control);
assert(statusIn.getType() == statusOut.getType());
assert(statusIn.getMessage() == statusOut.getMessage());
assert(statusIn.getStackDump() == statusOut.getStackDump());
buffer->flip();
Status statusOut;
registry->deserializeStatus(statusOut, buffer,control);
assert(statusIn.getType() == statusOut.getType());
assert(statusIn.getMessage() == statusOut.getMessage());
assert(statusIn.getStackDump() == statusOut.getStackDump());
}
int main(int argc, char *argv[])
{
pvDataCreate = getPVDataCreate();
fieldCreate = getFieldCreate();
standardField = getStandardField();
pvDataCreate = getPVDataCreate();
fieldCreate = getFieldCreate();
standardField = getStandardField();
flusher = new SerializableControlImpl();
control = new DeserializableControlImpl();
buffer = new ByteBuffer(1<<16);
registry = new IntrospectionRegistry(true);
clientRegistry = new IntrospectionRegistry(false);
serverRegistry = new IntrospectionRegistry(true);
registry = new IntrospectionRegistry(true);
clientRegistry = new IntrospectionRegistry(false);
serverRegistry = new IntrospectionRegistry(true);
testRegistryPutGet();
testRegistryReset();
testSerialize();
testSerializeFull();
testDeserializeStructureAndCreatePVStructure();
testSerializeStatus();
testRegistryPutGet();
testRegistryReset();
testSerialize();
testSerializeFull();
testDeserializeStructureAndCreatePVStructure();
testSerializeStatus();
registry->reset();
clientRegistry->reset();
serverRegistry->reset();
for (unsigned int i=0; i < pvFieldArray.size(); i++)
{
delete pvFieldArray[i];
}
pvFieldArray.clear();
registry->reset();
clientRegistry->reset();
serverRegistry->reset();
for (unsigned int i=0; i < pvFieldArray.size(); i++)
{
delete pvFieldArray[i];
}
pvFieldArray.clear();
if(flusher) delete flusher;
if(control) delete control;
if(buffer) delete buffer;
if(registry) delete registry;
if(clientRegistry) delete clientRegistry;
if(serverRegistry) delete serverRegistry;
if(registry) delete registry;
if(clientRegistry) delete clientRegistry;
if(serverRegistry) delete serverRegistry;
epicsExitCallAtExits();
CDRMonitor::get().show(stdout, true);
cout << "DONE" << endl;
return 0;
epicsExitCallAtExits();
CDRMonitor::get().show(stdout, true);
cout << "DONE" << endl;
return 0;
}

View File

@@ -27,201 +27,201 @@ epicsMessageQueueId join2;
void testIntLockPattern()
{
int64 timeout = 100;
NamedLockPattern<int> namedLockPattern;
int name1 = 1;
assert(namedLockPattern.acquireSynchronizationObject(name1,timeout));
assert(namedLockPattern.acquireSynchronizationObject(name1,timeout));
namedLockPattern.releaseSynchronizationObject(name1);
namedLockPattern.releaseSynchronizationObject(name1);
int name2 = 2;
assert(namedLockPattern.acquireSynchronizationObject(name2,timeout));
namedLockPattern.releaseSynchronizationObject(name2);
int64 timeout = 100;
NamedLockPattern<int> namedLockPattern;
int name1 = 1;
assert(namedLockPattern.acquireSynchronizationObject(name1,timeout));
assert(namedLockPattern.acquireSynchronizationObject(name1,timeout));
namedLockPattern.releaseSynchronizationObject(name1);
namedLockPattern.releaseSynchronizationObject(name1);
int name2 = 2;
assert(namedLockPattern.acquireSynchronizationObject(name2,timeout));
namedLockPattern.releaseSynchronizationObject(name2);
}
void testIntPtrLockPattern()
{
int64 timeout = 100;
NamedLockPattern<int*> namedLockPattern;
int name1 = 1;
assert(namedLockPattern.acquireSynchronizationObject(&name1,timeout));
assert(namedLockPattern.acquireSynchronizationObject(&name1,timeout));
namedLockPattern.releaseSynchronizationObject(&name1);
namedLockPattern.releaseSynchronizationObject(&name1);
int name2 = 2;
assert(namedLockPattern.acquireSynchronizationObject(&name2,timeout));
namedLockPattern.releaseSynchronizationObject(&name2);
int64 timeout = 100;
NamedLockPattern<int*> namedLockPattern;
int name1 = 1;
assert(namedLockPattern.acquireSynchronizationObject(&name1,timeout));
assert(namedLockPattern.acquireSynchronizationObject(&name1,timeout));
namedLockPattern.releaseSynchronizationObject(&name1);
namedLockPattern.releaseSynchronizationObject(&name1);
int name2 = 2;
assert(namedLockPattern.acquireSynchronizationObject(&name2,timeout));
namedLockPattern.releaseSynchronizationObject(&name2);
}
struct cmp_str
{
bool operator()(char const *a, char const *b)
{
return strcmp(a, b) < 0;
}
bool operator()(char const *a, char const *b)
{
return strcmp(a, b) < 0;
}
};
void testCharPtrLockPattern()
{
int64 timeout = 100;
NamedLockPattern<const char*,cmp_str> namedLockPattern;
string name1 = "lojze";
assert(namedLockPattern.acquireSynchronizationObject(name1.c_str(),timeout));
assert(namedLockPattern.acquireSynchronizationObject(name1.c_str(),timeout));
namedLockPattern.releaseSynchronizationObject(name1.c_str());
namedLockPattern.releaseSynchronizationObject(name1.c_str());
string name2 = "francka";
assert(namedLockPattern.acquireSynchronizationObject(name2.c_str(),timeout));
namedLockPattern.releaseSynchronizationObject(name2.c_str());
int64 timeout = 100;
NamedLockPattern<const char*,cmp_str> namedLockPattern;
string name1 = "lojze";
assert(namedLockPattern.acquireSynchronizationObject(name1.c_str(),timeout));
assert(namedLockPattern.acquireSynchronizationObject(name1.c_str(),timeout));
namedLockPattern.releaseSynchronizationObject(name1.c_str());
namedLockPattern.releaseSynchronizationObject(name1.c_str());
string name2 = "francka";
assert(namedLockPattern.acquireSynchronizationObject(name2.c_str(),timeout));
namedLockPattern.releaseSynchronizationObject(name2.c_str());
}
void testOsiSockAddrLockPattern()
{
int64 timeout = 10000;
NamedLockPattern<const osiSockAddr*,comp_osiSockAddrPtr> namedLockPattern;
osiSockAddr name1;
name1.ia.sin_addr.s_addr = 1;
name1.ia.sin_port = 1;
name1.ia.sin_family = AF_INET;
int64 timeout = 10000;
NamedLockPattern<const osiSockAddr*,comp_osiSockAddrPtr> namedLockPattern;
osiSockAddr name1;
name1.ia.sin_addr.s_addr = 1;
name1.ia.sin_port = 1;
name1.ia.sin_family = AF_INET;
assert(namedLockPattern.acquireSynchronizationObject(&name1,timeout));
assert(namedLockPattern.acquireSynchronizationObject(&name1,timeout));
assert(namedLockPattern.acquireSynchronizationObject(&name1,timeout));
assert(namedLockPattern.acquireSynchronizationObject(&name1,timeout));
osiSockAddr name2;
name2.ia.sin_addr.s_addr = 1;
name2.ia.sin_port = 1;
name2.ia.sin_family = AF_INET;
assert(namedLockPattern.acquireSynchronizationObject(&name2,timeout));
assert(namedLockPattern.acquireSynchronizationObject(&name2,timeout));
osiSockAddr name2;
name2.ia.sin_addr.s_addr = 1;
name2.ia.sin_port = 1;
name2.ia.sin_family = AF_INET;
assert(namedLockPattern.acquireSynchronizationObject(&name2,timeout));
assert(namedLockPattern.acquireSynchronizationObject(&name2,timeout));
namedLockPattern.releaseSynchronizationObject(&name1);
namedLockPattern.releaseSynchronizationObject(&name1);
namedLockPattern.releaseSynchronizationObject(&name2);
namedLockPattern.releaseSynchronizationObject(&name2);
namedLockPattern.releaseSynchronizationObject(&name1);
namedLockPattern.releaseSynchronizationObject(&name1);
namedLockPattern.releaseSynchronizationObject(&name2);
namedLockPattern.releaseSynchronizationObject(&name2);
osiSockAddr name3;
name3.ia.sin_addr.s_addr = 1;
name3.ia.sin_port = 1;
name3.ia.sin_family = AF_INET;
NamedLock<const osiSockAddr*,comp_osiSockAddrPtr> namedGuard(&namedLockPattern);
assert(namedGuard.acquireSynchronizationObject(&name3,timeout));
osiSockAddr name3;
name3.ia.sin_addr.s_addr = 1;
name3.ia.sin_port = 1;
name3.ia.sin_family = AF_INET;
NamedLock<const osiSockAddr*,comp_osiSockAddrPtr> namedGuard(&namedLockPattern);
assert(namedGuard.acquireSynchronizationObject(&name3,timeout));
}
void testOsiSockAddrWithPtrKeyLockPattern()
{
int64 timeout = 10000;
NamedLockPattern<const osiSockAddr*,comp_osiSockAddrPtr> namedLockPattern;
osiSockAddr* name1 = new osiSockAddr;
name1->ia.sin_addr.s_addr = 1;
name1->ia.sin_port = 1;
name1->ia.sin_family = AF_INET;
assert(namedLockPattern.acquireSynchronizationObject(name1,timeout));
assert(namedLockPattern.acquireSynchronizationObject(name1,timeout));
namedLockPattern.releaseSynchronizationObject(name1);
namedLockPattern.releaseSynchronizationObject(name1);
delete name1;
int64 timeout = 10000;
NamedLockPattern<const osiSockAddr*,comp_osiSockAddrPtr> namedLockPattern;
osiSockAddr* name1 = new osiSockAddr;
name1->ia.sin_addr.s_addr = 1;
name1->ia.sin_port = 1;
name1->ia.sin_family = AF_INET;
assert(namedLockPattern.acquireSynchronizationObject(name1,timeout));
assert(namedLockPattern.acquireSynchronizationObject(name1,timeout));
namedLockPattern.releaseSynchronizationObject(name1);
namedLockPattern.releaseSynchronizationObject(name1);
delete name1;
}
void testWorker1(void* p)
{
int32 timeout = 1000;
const int32 max = 1000;
NamedLockPattern<osiSockAddr,comp_osiSockAddr>* namedLockPattern = (NamedLockPattern<osiSockAddr,comp_osiSockAddr>*)p;
int32 timeout = 1000;
const int32 max = 1000;
NamedLockPattern<osiSockAddr,comp_osiSockAddr>* namedLockPattern = (NamedLockPattern<osiSockAddr,comp_osiSockAddr>*)p;
for(int32 i = 0 ; i < max; i = i +2)
{
osiSockAddr addr;
addr.ia.sin_addr.s_addr = i;
addr.ia.sin_port = i;
addr.ia.sin_family = AF_INET;
NamedLock<osiSockAddr,comp_osiSockAddr> namedGuard(namedLockPattern);
assert(namedGuard.acquireSynchronizationObject(addr,timeout));
epicsThreadSleep(1e-6);
}
for(int32 i = 0 ; i < max; i = i +2)
{
osiSockAddr addr;
addr.ia.sin_addr.s_addr = i;
addr.ia.sin_port = i;
addr.ia.sin_family = AF_INET;
NamedLock<osiSockAddr,comp_osiSockAddr> namedGuard(namedLockPattern);
assert(namedGuard.acquireSynchronizationObject(addr,timeout));
epicsThreadSleep(1e-6);
}
//this one takes a lock, thread 2 will be slower and will get timeout
{ //due to namedGuard
osiSockAddr addr;
addr.ia.sin_addr.s_addr = 1;
addr.ia.sin_port = 1;
addr.ia.sin_family = AF_INET;
NamedLock<osiSockAddr,comp_osiSockAddr> namedGuard(namedLockPattern);
assert(namedGuard.acquireSynchronizationObject(addr,timeout));
epicsThreadSleep(5.0);
}
int dummy = 1;
epicsMessageQueueSend(join1, &dummy, 1);
//this one takes a lock, thread 2 will be slower and will get timeout
{ //due to namedGuard
osiSockAddr addr;
addr.ia.sin_addr.s_addr = 1;
addr.ia.sin_port = 1;
addr.ia.sin_family = AF_INET;
NamedLock<osiSockAddr,comp_osiSockAddr> namedGuard(namedLockPattern);
assert(namedGuard.acquireSynchronizationObject(addr,timeout));
epicsThreadSleep(5.0);
}
int dummy = 1;
epicsMessageQueueSend(join1, &dummy, 1);
}
void testWorker2(void* p)
{
int32 timeout = 1000;
const int32 max = 1000;
NamedLockPattern<osiSockAddr,comp_osiSockAddr>* namedLockPattern = (NamedLockPattern<osiSockAddr,comp_osiSockAddr>*)p;
int32 timeout = 1000;
const int32 max = 1000;
NamedLockPattern<osiSockAddr,comp_osiSockAddr>* namedLockPattern = (NamedLockPattern<osiSockAddr,comp_osiSockAddr>*)p;
for(int32 i = 1 ; i < max; i = i + 2)
{
osiSockAddr addr;
addr.ia.sin_addr.s_addr = i;
addr.ia.sin_port = i;
addr.ia.sin_family = AF_INET;
NamedLock<osiSockAddr,comp_osiSockAddr> namedGuard(namedLockPattern);
assert(namedGuard.acquireSynchronizationObject(addr,timeout));
epicsThreadSleep(1e-6);
}
for(int32 i = 1 ; i < max; i = i + 2)
{
osiSockAddr addr;
addr.ia.sin_addr.s_addr = i;
addr.ia.sin_port = i;
addr.ia.sin_family = AF_INET;
NamedLock<osiSockAddr,comp_osiSockAddr> namedGuard(namedLockPattern);
assert(namedGuard.acquireSynchronizationObject(addr,timeout));
epicsThreadSleep(1e-6);
}
//this thread sleeps a while and gets timeout on lock
{
epicsThreadSleep(1.0);
osiSockAddr addr;
addr.ia.sin_addr.s_addr = 1;
addr.ia.sin_port = 1;
addr.ia.sin_family = AF_INET;
NamedLock<osiSockAddr,comp_osiSockAddr> namedGuard(namedLockPattern);
//TODO swap next two lines if timed lock used
//assert(!namedGuard.acquireSynchronizationObject(addr,timeout));
assert(namedGuard.acquireSynchronizationObject(addr,timeout));
}
//this thread sleeps a while and gets timeout on lock
{
epicsThreadSleep(1.0);
osiSockAddr addr;
addr.ia.sin_addr.s_addr = 1;
addr.ia.sin_port = 1;
addr.ia.sin_family = AF_INET;
NamedLock<osiSockAddr,comp_osiSockAddr> namedGuard(namedLockPattern);
//TODO swap next two lines if timed lock used
//assert(!namedGuard.acquireSynchronizationObject(addr,timeout));
assert(namedGuard.acquireSynchronizationObject(addr,timeout));
}
int dummy = 2;
epicsMessageQueueSend(join2, &dummy, 1);
int dummy = 2;
epicsMessageQueueSend(join2, &dummy, 1);
}
int main(int argc, char *argv[])
{
testIntLockPattern();
testIntPtrLockPattern();
testCharPtrLockPattern();
testOsiSockAddrLockPattern();
testOsiSockAddrWithPtrKeyLockPattern();
testIntLockPattern();
testIntPtrLockPattern();
testCharPtrLockPattern();
testOsiSockAddrLockPattern();
testOsiSockAddrWithPtrKeyLockPattern();
NamedLockPattern<osiSockAddr,comp_osiSockAddr> namedLockPattern;
NamedLockPattern<osiSockAddr,comp_osiSockAddr> namedLockPattern;
join1 = epicsMessageQueueCreate(1, 1);
join2 = epicsMessageQueueCreate(1, 1);
join1 = epicsMessageQueueCreate(1, 1);
join2 = epicsMessageQueueCreate(1, 1);
//create two threads
epicsThreadId t1 = epicsThreadCreate("worker1", epicsThreadPriorityMedium, epicsThreadGetStackSize(epicsThreadStackMedium),
testWorker1, &namedLockPattern);
assert(t1);
epicsThreadId t2 = epicsThreadCreate("worker2", epicsThreadPriorityMedium, epicsThreadGetStackSize(epicsThreadStackMedium),
testWorker2, &namedLockPattern);
assert(t2);
//create two threads
epicsThreadId t1 = epicsThreadCreate("worker1", epicsThreadPriorityMedium, epicsThreadGetStackSize(epicsThreadStackMedium),
testWorker1, &namedLockPattern);
assert(t1);
int dummy;
epicsMessageQueueReceive(join1, &dummy, 1);
epicsMessageQueueReceive(join2, &dummy, 1);
epicsThreadId t2 = epicsThreadCreate("worker2", epicsThreadPriorityMedium, epicsThreadGetStackSize(epicsThreadStackMedium),
testWorker2, &namedLockPattern);
assert(t2);
epicsExitCallAtExits();
CDRMonitor::get().show(stdout, true);
int dummy;
epicsMessageQueueReceive(join1, &dummy, 1);
epicsMessageQueueReceive(join2, &dummy, 1);
return 0;
epicsExitCallAtExits();
CDRMonitor::get().show(stdout, true);
return 0;
}

View File

@@ -12,7 +12,7 @@ MAIN(testHexDump)
testDiag("Tests for hexDump");
char TO_DUMP[] = "pvAccess dump test\0\1\2\3\4\5\6\254\255\256";
hexDump("test", (int8*)TO_DUMP, 18+9);
testPass("Entire array");

View File

@@ -43,12 +43,12 @@ void test_getSocketAddressList()
testOk1(htons(555) == addr.ia.sin_port);
testOk1(htonl(0xC0A80304) == addr.ia.sin_addr.s_addr);
testOk1("192.168.3.4:555" == inetAddressToString(addr));
auto_ptr<InetAddrVector> vec1(getSocketAddressList("172.16.55.160", 6789, vec.get()));
testOk1(static_cast<size_t>(4) == vec1->size());
addr = vec1->at(0);
@@ -143,16 +143,17 @@ void test_encodeAsIPv6Address()
auto_ptr<ByteBuffer> buff(new ByteBuffer(32, EPICS_ENDIAN_LITTLE));
char src[] = { (char)0, (char)0, (char)0, (char)0, (char)0, (char)0,
(char)0, (char)0, (char)0, (char)0, (char)0xFF, (char)0xFF,
(char)0x0A, (char)0x0A, (char)0x0C, (char)0x0B };
(char)0, (char)0, (char)0, (char)0, (char)0xFF, (char)0xFF,
(char)0x0A, (char)0x0A, (char)0x0C, (char)0x0B
};
auto_ptr<osiSockAddr> paddr(intToIPv4Address(0x0A0A0C0B));
testOk1((uintptr_t)0 != (uintptr_t)paddr.get());
osiSockAddr addr = *paddr;
encodeAsIPv6Address(buff.get(), &addr);
testOk1(static_cast<size_t>(16) == buff->getPosition());
testOk1(strncmp(buff->getArray(), src, 16) == 0);
}
@@ -262,9 +263,9 @@ void test_multicastLoopback()
imreq.imr_multiaddr.s_addr = mcastAddr.ia.sin_addr.s_addr;
imreq.imr_interface.s_addr = loAddr.ia.sin_addr.s_addr;
// join multicast group on default interface
// join multicast group on default interface
status = ::setsockopt(socket, IPPROTO_IP, IP_ADD_MEMBERSHIP,
(char*)&imreq, sizeof(struct ip_mreq));
(char*)&imreq, sizeof(struct ip_mreq));
if (status)
{
char errStr[64];
@@ -294,7 +295,7 @@ void test_multicastLoopback()
// send multicast traffic to myself too
unsigned char mcast_loop = 1;
status = ::setsockopt(sendSocket, IPPROTO_IP, IP_MULTICAST_LOOP,
(char*)&mcast_loop, sizeof(unsigned char));
(char*)&mcast_loop, sizeof(unsigned char));
if (status)
{
char errStr[64];

View File

@@ -13,44 +13,68 @@
#include <string>
namespace epics {
namespace pvAccess {
namespace pvAccess {
class TestTransport : public Transport{
public:
typedef std::tr1::shared_ptr<TestTransport> shared_pointer;
typedef std::tr1::shared_ptr<const TestTransport> const_shared_pointer;
class TestTransport : public Transport {
public:
typedef std::tr1::shared_ptr<TestTransport> shared_pointer;
typedef std::tr1::shared_ptr<const TestTransport> const_shared_pointer;
TestTransport(string type, int16 priority, osiSockAddr* address): _type(type), _priority(priority), _address(address) {/*cout << "Transport::Transport" << endl;*/};
~TestTransport(){/*cout << "Transport::~Transport" << endl;*/};
virtual const string getType() const {return _type;};
virtual int16 getPriority() const { return _priority;};
virtual const osiSockAddr* getRemoteAddress() const {return _address;};
TestTransport(string type, int16 priority, osiSockAddr* address): _type(type), _priority(priority), _address(address) {
/*cout << "Transport::Transport" << endl;*/
};
~TestTransport() {
/*cout << "Transport::~Transport" << endl;*/
};
virtual const string getType() const {
return _type;
};
virtual int16 getPriority() const {
return _priority;
};
virtual const osiSockAddr* getRemoteAddress() const {
return _address;
};
virtual int8 getMajorRevision() const {return 0;};
virtual int8 getMinorRevision() const {return 0;};
virtual int getReceiveBufferSize() const {return 0;};
virtual int getSocketReceiveBufferSize() const {return 0;};
virtual void setRemoteMinorRevision(int8 minor) {};
virtual void setRemoteTransportReceiveBufferSize(
int receiveBufferSize) {};
virtual void setRemoteTransportSocketReceiveBufferSize(
int socketReceiveBufferSize){};
virtual void aliveNotification(){};
virtual void changedTransport(){};
virtual void close(bool force){};
virtual bool isClosed() {return false;};
virtual bool isVerified() {return false;};
virtual void verified(){};
virtual void enqueueSendRequest(TransportSender::shared_pointer const & sender){};
virtual void ensureData(int) {};
virtual void alignData(int) {};
virtual IntrospectionRegistry* getIntrospectionRegistry() {return NULL;};
private:
string _type;
int16 _priority;
osiSockAddr* _address;
};
virtual int8 getMajorRevision() const {
return 0;
};
virtual int8 getMinorRevision() const {
return 0;
};
virtual int getReceiveBufferSize() const {
return 0;
};
virtual int getSocketReceiveBufferSize() const {
return 0;
};
virtual void setRemoteMinorRevision(int8 minor) {};
virtual void setRemoteTransportReceiveBufferSize(
int receiveBufferSize) {};
virtual void setRemoteTransportSocketReceiveBufferSize(
int socketReceiveBufferSize) {};
virtual void aliveNotification() {};
virtual void changedTransport() {};
virtual void close(bool force) {};
virtual bool isClosed() {
return false;
};
virtual bool isVerified() {
return false;
};
virtual void verified() {};
virtual void enqueueSendRequest(TransportSender::shared_pointer const & sender) {};
virtual void ensureData(int) {};
virtual void alignData(int) {};
virtual IntrospectionRegistry* getIntrospectionRegistry() {
return NULL;
};
private:
string _type;
int16 _priority;
osiSockAddr* _address;
};
}
}
@@ -65,97 +89,97 @@ typedef std::vector<osiSockAddr*> osiSockAddrVector_t;
int main(int argc, char *argv[])
{
registry = new TransportRegistry();
auto_ptr<TransportRegistry::transportVector_t> transportArrayOut;
std::vector<Transport::shared_pointer> transportArrayIn (address_max * priority_max);
osiSockAddrVector_t addrArray (address_max);
//address
for(int32 i = 0; i < address_max; i++)
{
osiSockAddr* addr = new osiSockAddr;
addr->ia.sin_addr.s_addr = i;
addr->ia.sin_port = i;
addr->ia.sin_family = AF_INET;
addrArray.at(i) = addr;
registry = new TransportRegistry();
auto_ptr<TransportRegistry::transportVector_t> transportArrayOut;
std::vector<Transport::shared_pointer> transportArrayIn (address_max * priority_max);
osiSockAddrVector_t addrArray (address_max);
//address
for(int32 i = 0; i < address_max; i++)
{
osiSockAddr* addr = new osiSockAddr;
addr->ia.sin_addr.s_addr = i;
addr->ia.sin_port = i;
addr->ia.sin_family = AF_INET;
addrArray.at(i) = addr;
//priority
for(int16 j = 0; j < priority_max; j++)
{
Transport::shared_pointer testTransportIn(new TestTransport("tcp", j, addr));
transportArrayIn.at(i * priority_max + j) = testTransportIn;
registry->put(testTransportIn);
//priority
for(int16 j = 0; j < priority_max; j++)
{
Transport::shared_pointer testTransportIn(new TestTransport("tcp", j, addr));
transportArrayIn.at(i * priority_max + j) = testTransportIn;
registry->put(testTransportIn);
Transport::shared_pointer testTransportOut(registry->get("tcp",addr,(const int16)j));
assert(testTransportIn.get() == testTransportOut.get());
}
Transport::shared_pointer testTransportOut(registry->get("tcp",addr,(const int16)j));
assert(testTransportIn.get() == testTransportOut.get());
}
transportArrayOut = registry->get("tcp",addr);
assert((int16)transportArrayOut->size() == priority_max);
for(int32 k = 0; k < priority_max; k++)
{
assert(transportArrayIn.at(i * priority_max + k).get() == transportArrayOut->at(k).get());
}
}
transportArrayOut = registry->get("tcp",addr);
assert((int16)transportArrayOut->size() == priority_max);
for(int32 k = 0; k < priority_max; k++)
{
assert(transportArrayIn.at(i * priority_max + k).get() == transportArrayOut->at(k).get());
}
}
//add one transport which has same addr and priority as last one and check that the size does not increase
osiSockAddr* addr = new osiSockAddr;
addr->ia.sin_addr.s_addr = address_max - 1;
addr->ia.sin_port = address_max - 1;
addr->ia.sin_family = AF_INET;
Transport::shared_pointer testTransportIn(new TestTransport("tcp", priority_max - 1, addr));
registry->put(testTransportIn);
Transport::shared_pointer testTransportOut(registry->get("tcp",addr,(const int16)priority_max - 1));
assert(testTransportIn.get() == testTransportOut.get());
delete addr;
//put back the old one
registry->put(transportArrayIn.at((address_max - 1) * priority_max + priority_max - 1));
//add one transport which has same addr and priority as last one and check that the size does not increase
osiSockAddr* addr = new osiSockAddr;
addr->ia.sin_addr.s_addr = address_max - 1;
addr->ia.sin_port = address_max - 1;
addr->ia.sin_family = AF_INET;
Transport::shared_pointer testTransportIn(new TestTransport("tcp", priority_max - 1, addr));
registry->put(testTransportIn);
Transport::shared_pointer testTransportOut(registry->get("tcp",addr,(const int16)priority_max - 1));
assert(testTransportIn.get() == testTransportOut.get());
delete addr;
//put back the old one
registry->put(transportArrayIn.at((address_max - 1) * priority_max + priority_max - 1));
assert(registry->numberOfActiveTransports() == (address_max * priority_max));
assert(registry->numberOfActiveTransports() == (address_max * priority_max));
transportArrayOut = registry->toArray("tcp");
assert((int16)transportArrayOut->size() == (address_max * priority_max));
for(int32 i = 0; i < address_max * priority_max; i++)
{
assert(transportArrayIn.at(i).get() == transportArrayOut->at(i).get());
}
transportArrayOut = registry->toArray("tcp");
assert((int16)transportArrayOut->size() == (address_max * priority_max));
for(int32 i = 0; i < address_max * priority_max; i++)
{
assert(transportArrayIn.at(i).get() == transportArrayOut->at(i).get());
}
transportArrayOut = registry->toArray();
assert((int16)transportArrayOut->size() == (address_max * priority_max));
for(int32 i = 0; i < address_max * priority_max; i++)
{
assert(transportArrayIn.at(i).get() == transportArrayOut->at(i).get());
}
transportArrayOut = registry->toArray();
assert((int16)transportArrayOut->size() == (address_max * priority_max));
for(int32 i = 0; i < address_max * priority_max; i++)
{
assert(transportArrayIn.at(i).get() == transportArrayOut->at(i).get());
}
for(int32 i = 0; i < address_max; i++)
{
for(int16 j = 0; j < priority_max; j++)
{
assert(transportArrayIn.at(i * priority_max + j) == registry->remove(transportArrayIn.at(i * priority_max + j)));
}
}
assert(registry->numberOfActiveTransports() == 0);
for(int32 i = 0; i < address_max; i++)
{
for(int16 j = 0; j < priority_max; j++)
{
assert(transportArrayIn.at(i * priority_max + j) == registry->remove(transportArrayIn.at(i * priority_max + j)));
}
}
assert(registry->numberOfActiveTransports() == 0);
for(int32 i = 0; i < address_max; i++)
{
for(int16 j = 0; j < priority_max; j++)
{
registry->put(transportArrayIn.at(i * priority_max + j));
}
}
assert(registry->numberOfActiveTransports() == (priority_max * address_max));
registry->clear();
assert(registry->numberOfActiveTransports() == 0);
for(int32 i = 0; i < address_max; i++)
{
for(int16 j = 0; j < priority_max; j++)
{
registry->put(transportArrayIn.at(i * priority_max + j));
}
}
assert(registry->numberOfActiveTransports() == (priority_max * address_max));
registry->clear();
assert(registry->numberOfActiveTransports() == 0);
for(osiSockAddrVector_t::iterator iter = addrArray.begin(); iter != addrArray.end(); iter++)
{
delete *iter;
}
addrArray.clear();
if(registry) delete registry;
epicsExitCallAtExits();
epics::pvData::CDRMonitor::get().show(stdout, true);
return 0;
for(osiSockAddrVector_t::iterator iter = addrArray.begin(); iter != addrArray.end(); iter++)
{
delete *iter;
}
addrArray.clear();
if(registry) delete registry;
epicsExitCallAtExits();
epics::pvData::CDRMonitor::get().show(stdout, true);
return 0;
}