diff --git a/src/pva/pvaVersion.cpp b/src/pva/pvaVersion.cpp index f3d008e..036e8ea 100644 --- a/src/pva/pvaVersion.cpp +++ b/src/pva/pvaVersion.cpp @@ -54,7 +54,7 @@ bool Version::isDevelopmentVersion() const { const string Version::getVersionString() const { stringstream ret; - ret< +#endif + +#include + #include #include #include @@ -13,6 +19,7 @@ #include #include +#include #include #include @@ -454,6 +461,7 @@ private: static Structure::const_shared_pointer helpStructure; static Structure::const_shared_pointer channelListStructure; + static Structure::const_shared_pointer infoStructure; static std::string helpString; @@ -511,6 +519,44 @@ public: PVStringArray::shared_pointer pvArray = result->getSubField("value"); pvArray->replace(listListener->channelNames); + return result; + } + else if (op == "info") + { + PVStructure::shared_pointer result = + getPVDataCreate()->createPVStructure(infoStructure); + + // TODO cache hostname in InetAddressUtil + char buffer[256]; + std::string hostName("localhost"); + if (gethostname(buffer, sizeof(buffer)) == 0) + hostName = buffer; + + std::stringstream ret; + ret << EPICS_PVA_MAJOR_VERSION << '.' << + EPICS_PVA_MINOR_VERSION << '.' << + EPICS_PVA_MAINTENANCE_VERSION; + if (EPICS_PVA_DEVELOPMENT_FLAG) + ret << "-SNAPSHOT"; + + result->getSubField("version")->put(ret.str()); + result->getSubField("implLang")->put("cpp"); + result->getSubField("host")->put(hostName); + + std::stringstream sspid; +#ifdef __vxworks + sspid << taskIdSelf(); +#else + sspid << getpid(); +#endif + result->getSubField("process")->put(sspid.str()); + + char timeText[64]; + epicsTimeToStrftime(timeText, 64, "%Y-%m-%dT%H:%M:%S.%03f", &m_serverContext->getStartTime()); + + result->getSubField("startTime")->put(timeText); + + return result; } else @@ -531,14 +577,28 @@ Structure::const_shared_pointer ServerRPCService::channelListStructure = addArray("value", pvString)-> createStructure(); +Structure::const_shared_pointer ServerRPCService::infoStructure = + getFieldCreate()->createFieldBuilder()-> + add("process", pvString)-> + add("startTime", pvString)-> + add("version", pvString)-> + add("implLang", pvString)-> + add("host", pvString)-> +// add("os", pvString)-> +// add("arch", pvString)-> +// add("CPUs", pvInt)-> + createStructure(); + + std::string ServerRPCService::helpString = "pvAccess server RPC service.\n" "arguments:\n" "\tstring op\toperation to execute\n" "\n" "\toperations:\n" + "\t\tinfo\t\treturns some information about the server\n" "\t\tchannels\treturns a list of 'static' channels the server can provide\n" - "\t\t\t (no arguments)\n" +// "\t\t\t (no arguments)\n" "\n"; std::string ServerCreateChannelHandler::SERVER_CHANNEL_NAME = "server"; diff --git a/src/server/serverContext.cpp b/src/server/serverContext.cpp index a95e1be..fc3b453 100644 --- a/src/server/serverContext.cpp +++ b/src/server/serverContext.cpp @@ -40,9 +40,12 @@ ServerContextImpl::ServerContextImpl(): _channelProviderRegistry(), _channelProviderNames(PVACCESS_DEFAULT_PROVIDER), _channelProviders(), - _beaconServerStatusProvider() + _beaconServerStatusProvider(), + _startTime() { + epicsTimeGetCurrent(&_startTime); + // TODO maybe there is a better place for this (when there will be some factory) epicsSignalInstallSigAlarmIgnore (); epicsSignalInstallSigPipeIgnore (); @@ -674,6 +677,12 @@ void ServerContextImpl::newServerDetected() // not used } +epicsTimeStamp& ServerContextImpl::getStartTime() +{ + return _startTime; +} + + std::map >& ServerContextImpl::getSecurityPlugins() { return SecurityPluginRegistry::instance().getServerSecurityPlugins(); diff --git a/src/server/serverContext.h b/src/server/serverContext.h index 0cf6116..7336bdb 100644 --- a/src/server/serverContext.h +++ b/src/server/serverContext.h @@ -92,6 +92,8 @@ public: */ virtual void dispose() = 0; + virtual epicsTimeStamp& getStartTime() = 0; + // ************************************************************************** // // **************************** [ Plugins ] ********************************* // // ************************************************************************** // @@ -146,6 +148,9 @@ public: BlockingUDPTransport::shared_pointer getLocalMulticastTransport(); + epicsTimeStamp& getStartTime(); + + /** * Version. */ @@ -440,6 +445,9 @@ private: void destroyAllTransports(); Configuration::shared_pointer configuration; + + epicsTimeStamp _startTime; + }; epicsShareExtern ServerContext::shared_pointer startPVAServer(