31 #define epicsExportSharedSymbols 41 namespace epics {
namespace pvDatabase {
44 std::string
const & recordName,
double delay)
49 addNestedStructure(
"argument")->
53 addNestedStructure(
"result") ->
57 PVStructurePtr pvStructure = pvDataCreate->createPVStructure(topStructure);
60 if(!pvRecord->init()) pvRecord.reset();
64 void ProcessRecord::startThread()
74 void ProcessRecord::stop()
81 ProcessRecord::ProcessRecord(
82 std::string
const & recordName,
86 pvDatabase(PVDatabase::getMaster())
90 bool ProcessRecord::init()
94 pvCommand = pvStructure->getSubField<
PVString>(
"argument.command");
95 pvRecordName = pvStructure->getSubField<
PVString>(
"argument.recordName");
96 if(!pvRecordName)
return false;
97 pvResult = pvStructure->getSubField<
PVString>(
"result.status");
98 if(!pvResult)
return false;
103 void ProcessRecord::process()
105 string recordName = pvRecordName->get();
106 string command = pvCommand->get();
107 if(command.compare(
"add")==0) {
109 std::map<std::string,PVRecordPtr>::iterator iter = pvRecordMap.find(recordName);
110 if(iter!=pvRecordMap.end()) {
111 pvResult->put(recordName +
" already present");
114 PVRecordPtr pvRecord = pvDatabase->findRecord(recordName);
116 pvResult->put(recordName +
" not in pvDatabase");
119 pvRecordMap.insert(PVRecordMap::value_type(recordName,pvRecord));
120 pvResult->put(
"success");
122 }
else if(command.compare(
"remove")==0) {
124 std::map<std::string,PVRecordPtr>::iterator iter = pvRecordMap.find(recordName);
125 if(iter==pvRecordMap.end()) {
126 pvResult->put(recordName +
" not found");
129 pvRecordMap.erase(iter);
130 pvResult->put(
"success");
133 pvResult->put(command +
" not a valid command: only add and remove are valid");
138 void ProcessRecord::run()
141 if(runStop.tryWait()) {
147 PVRecordMap::iterator iter;
148 for(iter = pvRecordMap.begin(); iter!=pvRecordMap.end(); ++iter) {
151 pvRecord->beginGroupPut();
154 }
catch (std::exception& ex) {
155 std::cout <<
"record " << pvRecord->getRecordName() <<
"exception " << ex.what() <<
"\n";
157 std::cout<<
"record " << pvRecord->getRecordName() <<
" process exception\n";
159 pvRecord->endGroupPut();
shared_ptr< T > static_pointer_cast(shared_ptr< U > const &r) BOOST_NOEXCEPT
TODO only here because of the Lockable.
std::tr1::shared_ptr< const Structure > StructureConstPtr
Mark external symbols and entry points for shared libraries.
LIBCOM_API unsigned int epicsStdCall epicsThreadGetStackSize(epicsThreadStackSizeClass size)
Base interface for a PVRecord.
std::tr1::shared_ptr< PVDataCreate > PVDataCreatePtr
PVString is special case, since it implements SerializableArray.
#define epicsThreadPriorityLow
FORCE_INLINE const FieldCreatePtr & getFieldCreate()
std::tr1::shared_ptr< PVRecord > PVRecordPtr
std::tr1::shared_ptr< PVStructure > PVStructurePtr
Process another record in the same database.
std::tr1::shared_ptr< FieldCreate > FieldCreatePtr
LIBCOM_API void epicsStdCall epicsThreadSleep(double seconds)
Block the calling thread for at least the specified time.
std::tr1::shared_ptr< epicsThread > EpicsThreadPtr
C++ and C descriptions for a thread.
std::tr1::shared_ptr< ProcessRecord > ProcessRecordPtr
FORCE_INLINE const PVDataCreatePtr & getPVDataCreate()