本文整理汇总了C++中PVFieldPtr类的典型用法代码示例。如果您正苦于以下问题:C++ PVFieldPtr类的具体用法?C++ PVFieldPtr怎么用?C++ PVFieldPtr使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PVFieldPtr类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _getColumn
static PyObject * _getColumn(PyObject *willbenull, PyObject *args)
{
PyObject *pcapsule = 0;
const char *name = 0;
if(!PyArg_ParseTuple(args,"Os:nttablePy",
&pcapsule,
&name))
{
PyErr_SetString(PyExc_SyntaxError,
"Bad argument. Expected (pvt,index)");
return NULL;
}
void *pvoid = PyCapsule_GetPointer(pcapsule,"nttablePvt");
if(pvoid==0) {
PyErr_SetString(PyExc_SyntaxError,
"first arg must be return from _init");
return NULL;
}
NTTablePvt *pvt = static_cast<NTTablePvt *>(pvoid);
PVFieldPtr pvField = pvt->nttable->getColumn(name);
Type type = pvField->getField()->getType();
if(type!=scalarArray) {
PyErr_SetString(PyExc_SyntaxError,
"logic error. Why is a column not a scalarArray?");
return NULL;
}
PVScalarArrayPtr pvScalarArray = static_pointer_cast<PVScalarArray>(pvField);
return getScalarArrayValue(pvScalarArray);
}
示例2: getStructure
std::ostream& PVStructure::dumpValue(std::ostream& o) const
{
o << format::indent() << getStructure()->getID() << ' ' << getFieldName();
String extendsName = getExtendsStructureName();
if(extendsName.length()>0) {
o << " extends " << extendsName;
}
o << std::endl;
{
format::indent_scope s(o);
PVFieldPtrArray const & fieldsData = getPVFields();
if (fieldsData.size() != 0) {
size_t length = getStructure()->getNumberFields();
for(size_t i=0; i<length; i++) {
PVFieldPtr fieldField = fieldsData[i];
Type type = fieldField->getField()->getType();
if (type == scalar || type == scalarArray)
o << format::indent() << fieldField->getField()->getID() << ' ' << fieldField->getFieldName() << ' ' << *(fieldField.get()) << std::endl;
else
o << *(fieldField.get());
}
}
}
return o;
}
示例3: getFieldOffset
void PVStructure::deserialize(ByteBuffer *pbuffer,
DeserializableControl *pcontrol, BitSet *pbitSet) {
size_t offset = getFieldOffset();
size_t numberFields = getNumberFields();
int32 next = pbitSet->nextSetBit(offset);
// no more changes or no changes in this structure
if(next<0||next>=static_cast<int32>(offset+numberFields)) return;
// entire structure
if(static_cast<int32>(offset)==next) {
deserialize(pbuffer, pcontrol);
return;
}
size_t fieldsSize = pvFields.size();
for(size_t i = 0; i<fieldsSize; i++) {
PVFieldPtr pvField = pvFields[i];
offset = pvField->getFieldOffset();
int32 inumberFields = pvField->getNumberFields();
next = pbitSet->nextSetBit(offset);
// no more changes
if(next<0) return;
// no change in this pvField
if(next>=static_cast<int32>(offset+inumberFields)) continue;
// deserialize field or fields
if(inumberFields==1) {
pvField->deserialize(pbuffer, pcontrol);
} else {
PVStructurePtr pvStructure = std::tr1::static_pointer_cast<PVStructure>(pvField);
pvStructure->deserialize(pbuffer, pcontrol, pbitSet);
}
}
}
示例4: findSubField
static PVFieldPtr findSubField(
String const & fieldName,
PVStructure const *pvStructure)
{
if( fieldName.length()<1) return PVFieldPtr();
String::size_type index = fieldName.find('.');
String name = fieldName;
String restOfName = String();
if(index>0) {
name = fieldName.substr(0, index);
if(fieldName.length()>index) {
restOfName = fieldName.substr(index+1);
}
}
PVFieldPtrArray pvFields = pvStructure->getPVFields();
PVFieldPtr pvField;
size_t numFields = pvStructure->getStructure()->getNumberFields();
for(size_t i=0; i<numFields; i++) {
pvField = pvFields[i];
size_t result = pvField->getFieldName().compare(name);
if(result==0) {
if(restOfName.length()==0) return pvFields[i];
if(pvField->getField()->getType()!=structure) return PVFieldPtr();
PVStructurePtr pvStructure =
std::tr1::static_pointer_cast<PVStructure>(pvField);
return findSubField(restOfName,pvStructure.get());
}
}
return PVFieldPtr();
}
示例5: isCompatible
bool NTMultiChannel::isCompatible(PVStructurePtr const &pvStructure)
{
if(!pvStructure) return false;
PVUnionArrayPtr pvValue = pvStructure->getSubField<PVUnionArray>("value");
if(!pvValue) return false;
PVFieldPtr pvField = pvStructure->getSubField("descriptor");
if(pvField && !pvStructure->getSubField<PVString>("descriptor")) return false;
pvField = pvStructure->getSubField("alarm");
if(pvField && !ntField->isAlarm(pvField->getField())) return false;
pvField = pvStructure->getSubField("timeStamp");
if(pvField && !ntField->isTimeStamp(pvField->getField())) return false;
pvField = pvStructure->getSubField("severity");
if(pvField && !pvStructure->getSubField<PVIntArray>("severity")) return false;
pvField = pvStructure->getSubField("status");
if(pvField && !pvStructure->getSubField<PVIntArray>("status")) return false;
pvField = pvStructure->getSubField("message");
if(pvField && !pvStructure->getSubField<PVStringArray>("message")) return false;
pvField = pvStructure->getSubField("secondsPastEpoch");
if(pvField && !pvStructure->getSubField<PVLongArray>("secondsPastEpoch")) return false;
pvField = pvStructure->getSubField("nanoseconds");
if(pvField && !pvStructure->getSubField<PVIntArray>("nanoseconds")) return false;
pvField = pvStructure->getSubField("userTag");
if(pvField && !pvStructure->getSubField<PVIntArray>("userTag")) return false;
return true;
}
示例6: getPVRecord
void PVRecordStructure::init()
{
PVRecordField::init();
const PVFieldPtrArray & pvFields = pvStructure.lock()->getPVFields();
size_t numFields = pvFields.size();
pvRecordFields->reserve( numFields);
PVRecordStructurePtr self =
static_pointer_cast<PVRecordStructure>(shared_from_this());
PVRecordPtr pvRecord = getPVRecord();
for(size_t i=0; i<numFields; i++) {
PVFieldPtr pvField = pvFields[i];
if(pvField->getField()->getType()==structure) {
PVStructurePtr xxx = static_pointer_cast<PVStructure>(pvField);
PVRecordStructurePtr pvRecordStructure(
new PVRecordStructure(xxx,self,pvRecord));
pvRecordFields->push_back(pvRecordStructure);
pvRecordStructure->init();
} else {
PVRecordFieldPtr pvRecordField(
new PVRecordField(pvField,self,pvRecord));
pvRecordFields->push_back(pvRecordField);
pvRecordField->init();
}
}
}
示例7: getPVStructure
string PvaClientData::getString()
{
if(PvaClient::getDebug()) cout << "PvaClientData::getString\n";
PVScalarPtr pvScalar;
PVStructurePtr pvStructure = getPVStructure();
PVFieldPtr pvValue = pvStructure->getSubField("value");
if(pvValue) {
Type type = pvValue->getField()->getType();
if(type==scalar) pvScalar = static_pointer_cast<PVScalar>(pvValue);
}
if(!pvScalar) {
while(true) {
const PVFieldPtrArray fieldPtrArray(pvStructure->getPVFields());
if(fieldPtrArray.size()!=1) {
throw std::logic_error(
"PvaClientData::getString() pvRequest for multiple fields");
}
PVFieldPtr pvField(fieldPtrArray[0]);
Type type = pvField->getField()->getType();
if(type==scalar) {
pvScalar = static_pointer_cast<PVScalar>(pvField);
break;
}
if(pvField->getField()->getType()!=epics::pvData::structure) break;
pvStructure = static_pointer_cast<PVStructure>(pvField);
}
}
if(!pvScalar) {
throw std::logic_error(
"PvaClientData::getString() did not find a scalar field");
}
return convert->toString(pvScalar);
}
示例8: setImmutable
void PVStructure::setImmutable()
{
size_t numFields = pvFields.size();
for(size_t i=0; i<numFields; i++) {
PVFieldPtr pvField = pvFields[i];
pvField->setImmutable();
}
PVField::setImmutable();
}
示例9: isCompatible
bool NTTable::isCompatible(PVStructurePtr const & pvStructure)
{
if(!pvStructure) return false;
PVFieldPtr pvField = pvStructure->getSubField("alarm");
if(pvField && !ntField->isAlarm(pvField->getField())) return false;
pvField = pvStructure->getSubField("timeStamp");
if(pvField && !ntField->isTimeStamp(pvField->getField())) return false;
PVStringArrayPtr pvLabel = pvStructure->getSubField<PVStringArray>("labels");
if(!pvLabel) return false;
return true;
}
示例10: checkBitSetPVField
static bool checkBitSetPVField(
PVFieldPtr const &pvField,BitSetPtr const &bitSet,int32 initialOffset)
{
int32 offset = initialOffset;
int32 nbits = static_cast<int32>(pvField->getNumberFields());
if(nbits==1) return bitSet->get(offset);
int32 nextSetBit = bitSet->nextSetBit(offset);
if(nextSetBit>=(offset+nbits)) return false;
if(nextSetBit<0) return false;
if(bitSet->get(offset)) {
if(nbits>1) {
for(int32 i=offset+1; i<offset+nbits; i++) bitSet->clear(i);
}
return true;
}
bool atLeastOneBitSet = false;
bool allBitsSet = true;
PVStructurePtr pvStructure = static_pointer_cast<PVStructure>(pvField);
offset = static_cast<int32>(pvStructure->getFieldOffset()) + 1;
while(offset<initialOffset + nbits) {
PVFieldPtr pvSubField = pvStructure->getSubField(offset);
int32 nbitsNow = static_cast<int32>(pvSubField->getNumberFields());
if(nbitsNow==1) {
if(bitSet->get(offset)) {
atLeastOneBitSet = true;
} else {
allBitsSet = false;
}
offset++;
} else {
bool result = checkBitSetPVField(pvSubField,bitSet,offset);
if(result) {
atLeastOneBitSet = true;
if(!bitSet->get(offset)) {
allBitsSet = false;
}
} else {
allBitsSet = false;
}
offset += static_cast<int32>(pvSubField->getNumberFields());
}
}
if(allBitsSet) {
if(nbits>1) {
for(int32 i=initialOffset+1; i<initialOffset+nbits; i++) {
bitSet->clear(i);
}
}
bitSet->set(initialOffset);
}
return atLeastOneBitSet;
}
示例11: testRequest
static void testRequest()
{
StringArray nullNames;
FieldConstPtrArray nullFields;
StringArray optionNames(1);
FieldConstPtrArray optionFields(1);
optionNames[0] = "process";
optionFields[0] = fieldCreate->createScalar(pvString);
StringArray recordNames(1);
FieldConstPtrArray recordFields(1);
recordNames[0] = "_options";
recordFields[0] = fieldCreate->createStructure(optionNames,optionFields);
StringArray fieldNames(2);
FieldConstPtrArray fieldFields(2);
fieldNames[0] = "alarm";
fieldFields[0] = fieldCreate->createStructure(nullNames,nullFields);
fieldNames[1] = "timeStamp";
fieldFields[1] = fieldCreate->createStructure(nullNames,nullFields);
StringArray topNames(2);
FieldConstPtrArray topFields(2);
topNames[0] = "record";
topFields[0] = fieldCreate->createStructure(recordNames,recordFields);
topNames[1] = "field";
topFields[1] = fieldCreate->createStructure(fieldNames,fieldFields);
StructureConstPtr topStructure = fieldCreate->createStructure(
topNames,topFields);
cout << *topStructure << endl;
PVStructurePtr pvTop = pvDataCreate->createPVStructure(topStructure);
cout << *pvTop << endl;
cout << *pvTop->getStructure() << endl;
PVStructurePtr xxx = pvTop->getSubField<PVStructure>("record");
cout << *xxx << endl;
xxx = pvTop->getSubField<PVStructure>("field");
cout << *xxx << endl;
PVStringPtr pvString = pvTop->getSubField<PVString>("record._options.process");
pvString->put("true");
cout << *pvTop << endl;
string subName("record._options.process");
PVFieldPtr pvField = pvTop->getSubField<PVString>(subName);
string fieldName = pvField->getFieldName();
string fullName = pvField->getFullName();
cout << "fieldName " << fieldName << " fullName " << fullName << endl;
testOk1(fieldName.compare("process")==0);
testOk1(fullName.compare(subName)==0);
}
示例12: Status
Status PvValue::getAlarm(Alarm &alarm)
{
if(pvGetStructure.get()==NULL) {
return Status(Status::STATUSTYPE_ERROR, "no alarm field");
}
PVAlarm pvAlarm;
PVFieldPtr pvField = pvGetStructure->getSubField("alarm");
if(pvField.get()==NULL) {
return Status(Status::STATUSTYPE_ERROR, "no alarm field");
}
if(!pvAlarm.attach(pvField)) {
return Status(Status::STATUSTYPE_ERROR, "no alarm field");
}
pvAlarm.get(alarm);
return Status::Ok;
}
示例13: while
std::ostream & PvaClientPutData::showChanged(std::ostream & out)
{
size_t nextSet = bitSet->nextSetBit(0);
PVFieldPtr pvField;
while(nextSet!=string::npos) {
if(nextSet==0) {
pvField = pvStructure;
} else {
pvField = pvStructure->getSubField(nextSet);
}
string name = pvField->getFullName();
out << name << " = " << pvField << endl;
nextSet = bitSet->nextSetBit(nextSet+1);
}
return out;
}
示例14: isCompatible
bool NTScalar::isCompatible(PVStructurePtr const & pvStructure)
{
if(!pvStructure) return false;
PVScalarPtr pvValue = pvStructure->getSubField<PVScalar>("value");
if(!pvValue) return false;
PVFieldPtr pvField = pvStructure->getSubField("descriptor");
if(pvField && !pvStructure->getSubField<PVString>("descriptor")) return false;
pvField = pvStructure->getSubField("alarm");
if(pvField && !ntField->isAlarm(pvField->getField())) return false;
pvField = pvStructure->getSubField("timeStamp");
if(pvField && !ntField->isTimeStamp(pvField->getField())) return false;
pvField = pvStructure->getSubField("display");
if(pvField && !ntField->isDisplay(pvField->getField())) return false;
pvField = pvStructure->getSubField("control");
if(pvField && !ntField->isControl(pvField->getField())) return false;
return true;
}
示例15: channelGetConnect
void PvValue::channelGetConnect(
const Status& status,
ChannelGet::shared_pointer const & channelGet,
PVStructure::shared_pointer const & pvStructure,
BitSet::shared_pointer const & bitSet)
{
if(!status.isOK()) {
this->status = status;
} else {
this->status = Status::Ok;
this->channelGet = channelGet;
pvGetStructure = pvStructure;
PVFieldPtr pvValue = pvGetStructure->getSubField("value");
PVFieldPtr pvAlarm = pvGetStructure->getSubField("alarm");
PVFieldPtr pvTimeStamp = pvGetStructure->getSubField("timeStamp");
bool allGood = true;
if(pvValue.get()==NULL) allGood = false;
if(!allGood) {
string builder("channel ");
builder += channelName;
if(pvValue.get()==NULL) builder += " no value field ";
if(pvAlarm.get()==NULL) builder += " no alarm field ";
if(pvTimeStamp.get()==NULL) builder += " no timeStamp field ";
this->status = Status(Status::STATUSTYPE_ERROR,builder);
builder.clear();
pvGetStructure->toString(&builder);
printf("channel %s pvGetStructure\n%s\n",
channelName.c_str(),builder.c_str());
}
}
event.signal();
}