本文整理汇总了C++中channel::shared_pointer::createChannelGet方法的典型用法代码示例。如果您正苦于以下问题:C++ shared_pointer::createChannelGet方法的具体用法?C++ shared_pointer::createChannelGet怎么用?C++ shared_pointer::createChannelGet使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类channel::shared_pointer
的用法示例。
在下文中一共展示了shared_pointer::createChannelGet方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: channelCreated
void PvValue::channelCreated(
const Status& status,
Channel::shared_pointer const & channel)
{
if(!status.isOK()) {
this->status = status;
requester->message(status.getMessage(),errorMessage);
isConnected = false;
event.signal();
}
this->channel = channel;
isConnected = true;
channelGet = channel->createChannelGet(getPtrSelf(),getRequest);
}
示例2: runTest
void runTest()
{
reset();
if (verbose)
printf("%d channel(s) of double array size of %d element(s) (0==scalar), %d iteration(s) per run, %d run(s) (0==forever)\n", channels, arraySize, iterations, runs);
/*
StringArray fieldNames;
fieldNames.push_back("strategy");
FieldConstPtrArray fields;
fields.push_back(getFieldCreate()->createScalar(pvInt));
PVStructure::shared_pointer configuration =
getPVDataCreate()->createPVStructure(getFieldCreate()->createStructure(fieldNames, fields));
configuration->getIntField("strategy")->put(bulkMode ? USER_CONTROLED : DELAYED);
provider->configure(configuration);
*/
vector<string> channelNames;
char buf[64];
for (int i = 0; i < channels; i++)
{
if (arraySize > 0)
sprintf(buf, "testArray%d_%d", arraySize, i);
else
sprintf(buf, "test%d", i);
channelNames.push_back(buf);
}
vector<Channel::shared_pointer> channels;
for (vector<string>::const_iterator i = channelNames.begin();
i != channelNames.end();
i++)
{
shared_ptr<ChannelRequesterImpl> channelRequesterImpl(
new ChannelRequesterImpl()
);
Channel::shared_pointer channel = provider->createChannel(*i, channelRequesterImpl);
channels.push_back(channel);
}
if (bulkMode) provider->flush();
bool differentConnectionsWarningIssued = false;
string theRemoteAddress;
for (vector<Channel::shared_pointer>::iterator i = channels.begin();
i != channels.end();
i++)
{
Channel::shared_pointer channel = *i;
shared_ptr<ChannelRequesterImpl> channelRequesterImpl =
dynamic_pointer_cast<ChannelRequesterImpl>(channel->getChannelRequester());
if (channelRequesterImpl->waitUntilConnected(5.0))
{
string remoteAddress = channel->getRemoteAddress();
if (theRemoteAddress.empty())
{
theRemoteAddress = remoteAddress;
}
else if (theRemoteAddress != remoteAddress)
{
if (!differentConnectionsWarningIssued)
{
std::cout << "not all channels are hosted by the same connection: " <<
theRemoteAddress << " != " << remoteAddress << std::endl;
differentConnectionsWarningIssued = true;
// we assumes same connection (thread-safety)
exit(2);
}
}
shared_ptr<ChannelGetRequesterImpl> getRequesterImpl(
new ChannelGetRequesterImpl(channel->getChannelName())
);
ChannelGet::shared_pointer channelGet = channel->createChannelGet(getRequesterImpl, pvRequest);
if (bulkMode) provider->flush();
bool allOK = getRequesterImpl->waitUntilConnected(timeOut);
if (!allOK)
{
std::cout << "[" << channel->getChannelName() << "] failed to get all the gets" << std::endl;
exit(1);
}
channelGetList.push_back(channelGet);
}
else
{
std::cout << "[" << channel->getChannelName() << "] connection timeout" << std::endl;
exit(1);
}
}
if (verbose)
std::cout << "all connected" << std::endl;
{
Lock guard(waitLoopPtrMutex);
waitLoopEvent.reset(new Event());
}
//.........这里部分代码省略.........
示例3: main
int main()
{
for (int i = 0; i < 10; i++) {
{
/*
ClientContextImpl::shared_pointer context = createClientContextImpl();
context->printInfo();
context->initialize();
context->printInfo();
epicsThreadSleep ( SLEEP_TIME );
ChannelProvider::shared_pointer provider = context->getProvider();
*/
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)));
//.........这里部分代码省略.........