本文整理汇总了C++中PVRecordPtr::lock方法的典型用法代码示例。如果您正苦于以下问题:C++ PVRecordPtr::lock方法的具体用法?C++ PVRecordPtr::lock怎么用?C++ PVRecordPtr::lock使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PVRecordPtr
的用法示例。
在下文中一共展示了PVRecordPtr::lock方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: lockOtherRecord
void PVRecord::lockOtherRecord(PVRecordPtr const & otherRecord)
{
if(traceLevel>2) {
cout << "PVRecord::lockOtherRecord() " << recordName << endl;
}
if(this<otherRecord.get()) {
otherRecord->lock();
return;
}
unlock();
otherRecord->lock();
lock();
}
示例2: test
static void test()
{
StandardPVFieldPtr standardPVField = getStandardPVField();
string properties;
ScalarType scalarType;
string recordName;
properties = "alarm,timeStamp";
scalarType = pvDouble;
recordName = "exampleDouble";
PVStructurePtr pvStructure;
pvStructure = standardPVField->scalar(scalarType,properties);
PVRecordPtr exampleRecord = PVRecord::create(recordName,pvStructure);
exampleRecord->setTraceLevel(traceLevel);
RecordClientPtr exampleRecordClient(RecordClient::create(exampleRecord));
ListenerPtr exampleListener(Listener::create(exampleRecord));
{
exampleRecord->lock();
exampleRecord->process();
exampleRecord->unlock();
}
if(debug) {cout << "processed exampleDouble " << endl; }
exampleRecord->destroy();
recordName = "powerSupplyExample";
PowerSupplyPtr psr;
pvStructure = createPowerSupply();
psr = PowerSupply::create("powerSupply",pvStructure);
psr->setTraceLevel(traceLevel);
RecordClientPtr psrRecordClient(RecordClient::create(psr));
ListenerPtr psrListener(Listener::create(psr));
testOk1(psr.get()!=0);
if(!psr) {
if(debug) {cout << "PowerSupplyRecordTest::create failed" << endl;}
return;
}
double voltage,power,current;
{
psr->lock();
voltage = psr->getVoltage();
power = psr->getPower();
current = psr->getCurrent();
psr->unlock();
}
if(debug ) {
cout << "initial ";
cout << " voltage " << voltage ;
cout << " power " << power;
cout << " current " << current;
cout << endl;
}
testOk1(psr->getVoltage()==0.0);
testOk1(psr->getPower()==0.0);
testOk1(psr->getCurrent()==0.0);
voltage = 1.0;
power = 1.0;
if(debug) {
cout << "before put ";
cout << " voltage " << voltage ;
cout << " power " << power;
cout << endl;
}
{
psr->lock();
psr->put(power,voltage);
psr->process();
psr->unlock();
}
{
psr->lock();
if(debug) {
cout << "after put ";
cout << " voltage " << psr->getVoltage() ;
cout << " power " << psr->getPower();
cout << " current " << psr->getCurrent();
cout << endl;
}
psr->unlock();
}
testOk1(psr->getVoltage()==1.0);
testOk1(psr->getPower()==1.0);
testOk1(psr->getCurrent()==1.0);
psr->destroy();
}