ClientFactory added
This commit is contained in:
@@ -7,7 +7,9 @@ PVACCESS = $(TOP)/pvAccessApp/
|
||||
SRC_DIRS += $(PVACCESS)/ca
|
||||
INC += caConstants.h
|
||||
INC += version.h
|
||||
INC += clientFactory.h
|
||||
LIBSRCS += version.cpp
|
||||
LIBSRCS += clientFactory.cpp
|
||||
|
||||
|
||||
SRC_DIRS += $(PVACCESS)/utils
|
||||
|
||||
37
pvAccessApp/ca/clientFactory.cpp
Normal file
37
pvAccessApp/ca/clientFactory.cpp
Normal file
@@ -0,0 +1,37 @@
|
||||
/* clientFactory.cpp */
|
||||
/* Author: Matej Sekoranja Date: 2011.2.1 */
|
||||
|
||||
#include <clientFactory.h>
|
||||
#include <errlog.h>
|
||||
|
||||
using namespace epics::pvData;
|
||||
using namespace epics::pvAccess;
|
||||
|
||||
Mutex ClientFactory::m_mutex;
|
||||
ClientContextImpl* ClientFactory::m_context = 0;
|
||||
|
||||
void ClientFactory::start()
|
||||
{
|
||||
Lock guard(&m_mutex);
|
||||
|
||||
if (m_context) return;
|
||||
|
||||
try {
|
||||
m_context = createClientContextImpl();
|
||||
m_context->initialize();
|
||||
registerChannelProvider(m_context->getProvider());
|
||||
} catch (std::exception &e) {
|
||||
errlogSevPrintf(errlogMajor, "Unhandled exception caught at %s:%d: %s", __FILE__, __LINE__, e.what());
|
||||
} catch (...) {
|
||||
errlogSevPrintf(errlogMajor, "Unhandled exception caught at %s:%d.", __FILE__, __LINE__);
|
||||
}
|
||||
}
|
||||
|
||||
void ClientFactory::stop()
|
||||
{
|
||||
Lock guard(&m_mutex);
|
||||
|
||||
unregisterChannelProvider(m_context->getProvider());
|
||||
m_context->dispose();
|
||||
m_context = 0;
|
||||
}
|
||||
22
pvAccessApp/ca/clientFactory.h
Normal file
22
pvAccessApp/ca/clientFactory.h
Normal file
@@ -0,0 +1,22 @@
|
||||
/* clientFactory.h */
|
||||
#ifndef CLIENTFACTORY_H
|
||||
#define CLIENTFACTORY_H
|
||||
|
||||
#include <clientContextImpl.h>
|
||||
#include <lock.h>
|
||||
|
||||
namespace epics { namespace pvAccess {
|
||||
|
||||
class ClientFactory {
|
||||
public:
|
||||
static void start();
|
||||
static void stop();
|
||||
|
||||
private:
|
||||
static epics::pvData::Mutex m_mutex;
|
||||
static ClientContextImpl* m_context;
|
||||
};
|
||||
|
||||
}}
|
||||
|
||||
#endif /* CLIENTFACTORY_H */
|
||||
@@ -2967,7 +2967,7 @@ namespace epics {
|
||||
|
||||
virtual epics::pvData::String getProviderName()
|
||||
{
|
||||
return "ChannelProviderImpl";
|
||||
return "pvAccess";
|
||||
}
|
||||
|
||||
virtual void destroy()
|
||||
@@ -3139,6 +3139,7 @@ TODO
|
||||
|
||||
virtual void dispose()
|
||||
{
|
||||
// TODO try catch
|
||||
destroy();
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include <CDRMonitor.h>
|
||||
#include <epicsExit.h>
|
||||
#include <clientContextImpl.h>
|
||||
#include <clientFactory.h>
|
||||
|
||||
using namespace epics::pvData;
|
||||
using namespace epics::pvAccess;
|
||||
@@ -438,6 +439,7 @@ class ChannelProcessRequesterImpl : public ChannelProcessRequester
|
||||
|
||||
int main(int argc,char *argv[])
|
||||
{
|
||||
/*
|
||||
ClientContextImpl* context = createClientContextImpl();
|
||||
context->printInfo();
|
||||
|
||||
@@ -445,14 +447,21 @@ int main(int argc,char *argv[])
|
||||
context->printInfo();
|
||||
|
||||
epicsThreadSleep ( 1.0 );
|
||||
|
||||
ChannelProvider* provider = context->getProvider();
|
||||
*/
|
||||
|
||||
ClientFactory::start();
|
||||
ChannelProvider* provider = getChannelAccess()->getProvider("pvAccess");
|
||||
|
||||
/*
|
||||
ChannelFindRequesterImpl findRequester;
|
||||
ChannelFind* channelFind = context->getProvider()->channelFind("something", &findRequester);
|
||||
ChannelFind* channelFind = provider->channelFind("something", &findRequester);
|
||||
epicsThreadSleep ( 1.0 );
|
||||
channelFind->destroy();
|
||||
*/
|
||||
ChannelRequesterImpl channelRequester;
|
||||
Channel* channel = context->getProvider()->createChannel("structureArrayTest", &channelRequester);
|
||||
Channel* channel = provider->createChannel("structureArrayTest", &channelRequester);
|
||||
|
||||
epicsThreadSleep ( 1.0 );
|
||||
|
||||
@@ -473,7 +482,7 @@ int main(int argc,char *argv[])
|
||||
epicsThreadSleep ( 1.0 );
|
||||
*/
|
||||
ChannelGetRequesterImpl channelGetRequesterImpl;
|
||||
pvRequest = 0;//getCreateRequest()->createRequest("field(kiki)",&channelGetRequesterImpl);
|
||||
pvRequest = getCreateRequest()->createRequest("field()",&channelGetRequesterImpl);
|
||||
ChannelGet* channelGet = channel->createChannelGet(&channelGetRequesterImpl, pvRequest);
|
||||
epicsThreadSleep ( 3.0 );
|
||||
channelGet->get(false);
|
||||
@@ -556,10 +565,13 @@ int main(int argc,char *argv[])
|
||||
|
||||
epicsThreadSleep ( 3.0 );
|
||||
|
||||
ClientFactory::start();
|
||||
/*
|
||||
printf("Destroying context... \n");
|
||||
context->destroy();
|
||||
printf("done.\n");
|
||||
|
||||
*/
|
||||
|
||||
std::cout << "-----------------------------------------------------------------------" << std::endl;
|
||||
epicsExitCallAtExits();
|
||||
CDRMonitor::get().show(stdout);
|
||||
|
||||
Reference in New Issue
Block a user