11 #include <pv/standardField.h> 12 #include <pv/standardPVField.h> 13 #include <pv/timeStamp.h> 14 #include <pv/pvTimeStamp.h> 16 #include <pv/pvAlarm.h> 17 #include <pv/pvAccess.h> 18 #include <pv/serverContext.h> 19 #include <pv/rpcService.h> 22 #include <epicsExport.h> 23 #define epicsExportSharedSymbols 29 namespace epics {
namespace pvDatabase {
32 std::string
const & recordName,
33 int asLevel,std::string
const & asGroup)
35 FieldCreatePtr fieldCreate = getFieldCreate();
36 PVDataCreatePtr pvDataCreate = getPVDataCreate();
37 StructureConstPtr topStructure = fieldCreate->createFieldBuilder()->
38 addNestedStructure(
"argument")->
39 add(
"recordName",pvString)->
42 addNestedStructure(
"result") ->
43 add(
"status",pvString) ->
46 PVStructurePtr pvStructure = pvDataCreate->createPVStructure(topStructure);
49 if(!pvRecord->init()) pvRecord.reset();
53 PvdbcrTraceRecord::PvdbcrTraceRecord(
54 std::string
const & recordName,
55 epics::pvData::PVStructurePtr
const & pvStructure,
56 int asLevel,std::string
const & asGroup)
57 :
PVRecord(recordName,pvStructure,asLevel,asGroup)
62 bool PvdbcrTraceRecord::init()
65 PVStructurePtr pvStructure = getPVStructure();
66 pvRecordName = pvStructure->getSubField<PVString>(
"argument.recordName");
67 if(!pvRecordName)
return false;
68 pvLevel = pvStructure->getSubField<PVInt>(
"argument.level");
69 if(!pvLevel)
return false;
70 pvResult = pvStructure->getSubField<PVString>(
"result.status");
71 if(!pvResult)
return false;
75 void PvdbcrTraceRecord::process()
77 string name = pvRecordName->get();
78 PVRecordPtr pvRecord = PVDatabase::getMaster()->findRecord(name);
80 pvResult->put(name +
" not found");
83 pvRecord->setTraceLevel(pvLevel->get());
84 pvResult->put(
"success");
88 static const iocshArg arg0 = {
"recordName", iocshArgString };
89 static const iocshArg arg1 = {
"asLevel", iocshArgInt };
90 static const iocshArg arg2 = {
"asGroup", iocshArgString };
91 static const iocshArg *args[] = {&arg0,&arg1,&arg2};
93 static const iocshFuncDef pvdbcrTraceRecordFuncDef = {
"pvdbcrTraceRecord", 3,args};
95 static void pvdbcrTraceRecordCallFunc(
const iocshArgBuf *args)
97 char *sval = args[0].sval;
99 throw std::runtime_error(
"pvdbcrTraceRecord recordName not specified");
101 string recordName = string(sval);
102 int asLevel = args[1].ival;
103 string asGroup(
"DEFAULT");
106 asGroup = string(sval);
110 record->setAsLevel(asLevel);
111 record->setAsGroup(asGroup);
113 bool result = master->addRecord(record);
114 if(!result) cout <<
"recordname " << recordName <<
" not added" << endl;
117 static void pvdbcrTraceRecord(
void)
119 static int firstTime = 1;
122 iocshRegister(&pvdbcrTraceRecordFuncDef, pvdbcrTraceRecordCallFunc);
static PvdbcrTraceRecordPtr create(std::string const &recordName, int asLevel=0, std::string const &asGroup=std::string("DEFAULT"))
Create a record.
Base interface for a PVRecord.
std::tr1::shared_ptr< PVDatabase > PVDatabasePtr
std::tr1::shared_ptr< PvdbcrTraceRecord > PvdbcrTraceRecordPtr
static PVDatabasePtr getMaster()
Get the master database.
std::tr1::shared_ptr< PVRecord > PVRecordPtr
epicsExportRegistrar(pvdbcrTraceRecord)
PvdbcrTraceRecord A record sets trace level for a record in the master database.