added methods to show cache; tests moved to pvaClientTestCPP; doxygen changes

This commit is contained in:
Marty Kraimer
2015-06-26 07:05:41 -04:00
parent b1594e6b78
commit 87d5ca03f7
32 changed files with 605 additions and 1655 deletions
+74 -13
View File
@@ -78,32 +78,67 @@ public:
void destroy() {
pvaClientChannelMap.clear();
}
PvaClientChannelPtr getChannel(string const & channelName);
PvaClientChannelPtr getChannel(
string const & channelName,
string const & providerName);
void addChannel(PvaClientChannelPtr const & pvaClientChannel);
void removeChannel(string const & channelName);
void removeChannel(string const & channelName,string const & providerName);
void showCache();
size_t cacheSize();
private:
map<string,PvaClientChannelPtr> pvaClientChannelMap;
};
PvaClientChannelPtr PvaClientChannelCache::getChannel(string const & channelName)
PvaClientChannelPtr PvaClientChannelCache::getChannel(
string const & channelName,
string const & providerName)
{
map<string,PvaClientChannelPtr>::iterator iter = pvaClientChannelMap.find(channelName);
string name = channelName + providerName;
map<string,PvaClientChannelPtr>::iterator iter = pvaClientChannelMap.find(name);
if(iter!=pvaClientChannelMap.end()) return iter->second;
return PvaClientChannelPtr();
}
void PvaClientChannelCache::addChannel(PvaClientChannelPtr const & pvaClientChannel)
{
Channel::shared_pointer channel = pvaClientChannel->getChannel();
string name = channel->getChannelName()
+ channel->getProvider()->getProviderName();
pvaClientChannelMap.insert(std::pair<string,PvaClientChannelPtr>(
pvaClientChannel->getChannelName(),pvaClientChannel));
name,pvaClientChannel));
}
void PvaClientChannelCache::removeChannel(string const & channelName)
void PvaClientChannelCache::removeChannel(
string const & channelName,
string const & providerName)
{
map<string,PvaClientChannelPtr>::iterator iter = pvaClientChannelMap.find(channelName);
string name = channelName + providerName;
map<string,PvaClientChannelPtr>::iterator iter = pvaClientChannelMap.find(name);
if(iter!=pvaClientChannelMap.end()) pvaClientChannelMap.erase(iter);
}
void PvaClientChannelCache::showCache()
{
map<string,PvaClientChannelPtr>::iterator iter;
for(iter = pvaClientChannelMap.begin(); iter != pvaClientChannelMap.end(); ++iter)
{
PvaClientChannelPtr pvaChannel = iter->second;
Channel::shared_pointer channel = pvaChannel->getChannel();
string channelName = channel->getChannelName();
string providerName = channel->getProvider()->getProviderName();
cout << "channel " << channelName << " provider " << providerName << endl;
cout << " get and put cacheSize " << pvaChannel->cacheSize() << endl;
pvaChannel->showCache();
}
}
size_t PvaClientChannelCache::cacheSize()
{
return pvaClientChannelMap.size();
}
using namespace epics::pvaClient::pvaClientPvt;
PvaClientPtr PvaClient::create()
@@ -149,6 +184,10 @@ void PvaClient::destroy()
string PvaClient:: getRequesterName()
{
static string name("pvaClient");
RequesterPtr req = requester.lock();
if(req) {
return req->getRequesterName();
}
return name;
}
@@ -156,6 +195,11 @@ void PvaClient::message(
string const & message,
MessageType messageType)
{
RequesterPtr req = requester.lock();
if(req) {
req->message(message,messageType);
return;
}
cout << getMessageTypeName(messageType) << " " << message << endl;
}
@@ -164,7 +208,8 @@ PvaClientChannelPtr PvaClient::channel(
std::string const & providerName,
double timeOut)
{
PvaClientChannelPtr pvaClientChannel = pvaClientChannelCache->getChannel(channelName);
PvaClientChannelPtr pvaClientChannel =
pvaClientChannelCache->getChannel(channelName,providerName);
if(pvaClientChannel) return pvaClientChannel;
pvaClientChannel = createChannel(channelName,providerName);
pvaClientChannel->connect(timeOut);
@@ -172,16 +217,32 @@ PvaClientChannelPtr PvaClient::channel(
return pvaClientChannel;
}
PvaClientChannelPtr PvaClient::createChannel(string const & channelName)
{
return PvaClientChannel::create(getPtrSelf(),channelName);
}
PvaClientChannelPtr PvaClient::createChannel(string const & channelName, string const & providerName)
{
return PvaClientChannel::create(getPtrSelf(),channelName,providerName);
}
void PvaClient::setRequester(RequesterPtr const & requester)
{
this->requester = requester;
}
void PvaClient::clearRequester()
{
requester = Requester::weak_pointer();
}
void PvaClient::showCache()
{
pvaClientChannelCache->showCache();
}
size_t PvaClient::cacheSize()
{
return pvaClientChannelCache->cacheSize();
}
PvaClientMultiChannelPtr PvaClient::createMultiChannel(
epics::pvData::PVStringArrayPtr const & channelNames)
{
+216 -380
View File
File diff suppressed because it is too large Load Diff
+46
View File
@@ -36,6 +36,8 @@ public:
}
PvaClientGetPtr getGet(string const & request);
void addGet(string const & request,PvaClientGetPtr const & pvaClientGet);
void showCache();
size_t cacheSize();
private:
map<string,PvaClientGetPtr> pvaClientGetMap;
};
@@ -58,6 +60,20 @@ void PvaClientGetCache::addGet(string const & request,PvaClientGetPtr const & pv
request,pvaClientGet));
}
void PvaClientGetCache::showCache()
{
map<string,PvaClientGetPtr>::iterator iter;
for(iter = pvaClientGetMap.begin(); iter != pvaClientGetMap.end(); ++iter)
{
cout << " " << iter->first << endl;
}
}
size_t PvaClientGetCache::cacheSize()
{
return pvaClientGetMap.size();
}
class PvaClientPutCache
{
@@ -69,6 +85,8 @@ public:
}
PvaClientPutPtr getPut(string const & request);
void addPut(string const & request,PvaClientPutPtr const & pvaClientPut);
void showCache();
size_t cacheSize();
private:
map<string,PvaClientPutPtr> pvaClientPutMap;
};
@@ -91,6 +109,21 @@ void PvaClientPutCache::addPut(string const & request,PvaClientPutPtr const & pv
request,pvaClientPut));
}
void PvaClientPutCache::showCache()
{
map<string,PvaClientPutPtr>::iterator iter;
for(iter = pvaClientPutMap.begin(); iter != pvaClientPutMap.end(); ++iter)
{
cout << " " << iter->first << endl;
}
}
size_t PvaClientPutCache::cacheSize()
{
return pvaClientPutMap.size();
}
class ChannelRequesterImpl : public ChannelRequester
{
PvaClientChannel *pvaClientChannel;
@@ -482,6 +515,19 @@ PvaClientMonitorPtr PvaClientChannel::createMonitor(PVStructurePtr const & pvR
return PvaClientMonitor::create(yyy,getPtrSelf(),channel,pvRequest);
}
void PvaClientChannel::showCache()
{
cout << " pvaClientGet" << endl;
pvaClientGetCache->showCache();
cout << " pvaClientPut" << endl;
pvaClientPutCache->showCache();
}
size_t PvaClientChannel::cacheSize()
{
return pvaClientGetCache->cacheSize() + pvaClientPutCache->cacheSize();
}
PvaClientChannelPtr PvaClientChannel::create(
PvaClientPtr const &pvaClient,
+2 -2
View File
@@ -169,7 +169,7 @@ Status PvaClientGet::waitConnect()
return Status::Ok;
}
connectState = connectIdle;
return Status(Status::STATUSTYPE_ERROR,channelGetConnectStatus.getMessage());
return channelGetConnectStatus;
}
void PvaClientGet::get()
@@ -209,7 +209,7 @@ Status PvaClientGet::waitGet()
if(channelGetStatus.isOK()) {
return Status::Ok;
}
return Status(Status::STATUSTYPE_ERROR,channelGetStatus.getMessage());
return channelGetStatus;
}
PvaClientGetDataPtr PvaClientGet::getData()
{
+36
View File
@@ -38,6 +38,8 @@ static string noArray("value is not an array");
static string noScalarArray("value is not a scalarArray");
static string notDoubleArray("value is not a doubleArray");
static string notStringArray("value is not a stringArray");
static string noAlarm("no alarm");
static string noTimeStamp("no timeStamp");
PvaClientMonitorDataPtr PvaClientMonitorData::create(StructureConstPtr const & structure)
{
@@ -223,4 +225,38 @@ shared_vector<const string> PvaClientMonitorData::getStringArray()
}
Alarm PvaClientMonitorData::getAlarm()
{
if(!pvStructure) {
throw std::runtime_error(messagePrefix + noAlarm);
}
PVStructurePtr pvs = pvStructure->getSubField<PVStructure>("alarm");
if(!pvs) throw std::runtime_error(messagePrefix + noAlarm);
pvAlarm.attach(pvs);
if(pvAlarm.isAttached()) {
Alarm alarm;
pvAlarm.get(alarm);
pvAlarm.detach();
return alarm;
}
throw std::runtime_error(messagePrefix + noAlarm);
}
TimeStamp PvaClientMonitorData::getTimeStamp()
{
if(!pvStructure) {
throw std::runtime_error(messagePrefix + noTimeStamp);
}
PVStructurePtr pvs = pvStructure->getSubField<PVStructure>("timeStamp");
if(!pvs) throw std::runtime_error(messagePrefix + noTimeStamp);
pvTimeStamp.attach(pvs);
if(pvTimeStamp.isAttached()) {
TimeStamp timeStamp;
pvTimeStamp.get(timeStamp);
pvTimeStamp.detach();
return timeStamp;
}
throw std::runtime_error(messagePrefix + noTimeStamp);
}
}}
+6 -12
View File
@@ -23,8 +23,7 @@ namespace epics { namespace pvaClient {
class PvaClientMultiDouble;
typedef std::tr1::shared_ptr<PvaClientMultiDouble> PvaClientMultiDoublePtr;
/**
* @brief Support for multiple channels where each channel has a value field that is a scalar double.
/** Support for multiple channels where each channel has a value field that is a scalar double.
* If any problems arise an exception is thrown.
*
* @author mrk
@@ -33,8 +32,7 @@ class epicsShareClass PvaClientMultiDouble
{
public:
POINTER_DEFINITIONS(PvaClientMultiDouble);
/**
* @brief Create a PvaClientMultiDouble.
/** Create a PvaClientMultiDouble.
* @param &pvaClient Interface to PvaClient
* @param channelName PVStringArray of channelNames.
* @param timeout The timeout in seconds for connecting.
@@ -46,21 +44,17 @@ public:
epics::pvData::PVStringArrayPtr const & channelName,
double timeout = 5.0,
std::string const & providerName = "pva");
/**
* @brief destructor
/** Destructor
*/
~PvaClientMultiDouble();
/**
* @brief destroy any resources used.
/** Destroy all resources used.
*/
void destroy();
/**
* @brief get the value of all the channels.
/** Get the value of all the channels.
* @return The data.
*/
epics::pvData::shared_vector<double> get();
/**
* @brief put a new value to each channel.
/** Put a new value to each channel.
* @param value The data.
*/
void put(epics::pvData::shared_vector<double> const &value);
+7 -14
View File
@@ -23,8 +23,7 @@ namespace epics { namespace pvaClient {
class PvaClientNTMultiChannel;
typedef std::tr1::shared_ptr<PvaClientNTMultiChannel> PvaClientNTMultiChannelPtr;
/**
* @brief Support for multiple channels where each channel has a value field that
/** Support for multiple channels where each channel has a value field that
* is a scalar, scalarArray, or enumerated structure.
* The data is provided via normativeType NTMultiChannel.
* If any problems arise an exception is thrown.
@@ -35,8 +34,7 @@ class epicsShareClass PvaClientNTMultiChannel
{
public:
POINTER_DEFINITIONS(PvaClientNTMultiChannel);
/**
* @brief Create a PvaClientNTMultiChannel.
/** Create a PvaClientNTMultiChannel.
* @param &pvaClient Interface to PvaClient
* @param channelName PVStringArray of channelNames.
* @param structure valid NTMultiChannel structure.
@@ -50,26 +48,21 @@ public:
epics::pvData::StructureConstPtr const & structure,
double timeout = 5.0,
std::string const & providerName = "pva");
/**
* @brief destructor
/** Destructor
*/
~PvaClientNTMultiChannel();
/**
* @brief destroy any resources used.
/** Destroy all resources used.
*/
void destroy();
/**
* @brief get the value of all the channels.
/** Get the value of all the channels.
* @return The data.
*/
epics::nt::NTMultiChannelPtr get();
/**
* @brief put a new value to each channel.
/** Put a new value to each channel.
* @param value The data.
*/
void put(epics::nt::NTMultiChannelPtr const &value);
/**
* @brief Get the PvaClientMultiChannel.
/** Get the PvaClientMultiChannel.
* @return The interface.
*/
PvaClientMultiChannelPtr getPvaClientMultiChannel();