本文整理汇总了C++中PVDataCreatePtr::createPVStructure方法的典型用法代码示例。如果您正苦于以下问题:C++ PVDataCreatePtr::createPVStructure方法的具体用法?C++ PVDataCreatePtr::createPVStructure怎么用?C++ PVDataCreatePtr::createPVStructure使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PVDataCreatePtr
的用法示例。
在下文中一共展示了PVDataCreatePtr::createPVStructure方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: create
PowerSupplyRecordPtr PowerSupplyRecord::create(
string const & recordName)
{
FieldCreatePtr fieldCreate = getFieldCreate();
StandardFieldPtr standardField = getStandardField();
PVDataCreatePtr pvDataCreate = getPVDataCreate();
StructureConstPtr topStructure = fieldCreate->createFieldBuilder()->
add("alarm",standardField->alarm()) ->
add("timeStamp",standardField->timeStamp()) ->
addNestedStructure("power") ->
add("value",pvDouble) ->
endNested()->
addNestedStructure("voltage") ->
add("value",pvDouble) ->
endNested()->
addNestedStructure("current") ->
add("value",pvDouble) ->
endNested()->
createStructure();
PVStructurePtr pvStructure = pvDataCreate->createPVStructure(topStructure);
PowerSupplyRecordPtr pvRecord(
new PowerSupplyRecord(recordName,pvStructure));
if(!pvRecord->init()) pvRecord.reset();
return pvRecord;
}
示例2: createPowerSupply
static PVStructurePtr createPowerSupply()
{
FieldCreatePtr fieldCreate = getFieldCreate();
StandardFieldPtr standardField = getStandardField();
PVDataCreatePtr pvDataCreate = getPVDataCreate();
size_t nfields = 5;
StringArray names;
names.reserve(nfields);
FieldConstPtrArray powerSupply;
powerSupply.reserve(nfields);
names.push_back("alarm");
powerSupply.push_back(standardField->alarm());
names.push_back("timeStamp");
powerSupply.push_back(standardField->timeStamp());
string properties("alarm,display");
names.push_back("voltage");
powerSupply.push_back(standardField->scalar(pvDouble,properties));
names.push_back("power");
powerSupply.push_back(standardField->scalar(pvDouble,properties));
names.push_back("current");
powerSupply.push_back(standardField->scalar(pvDouble,properties));
return pvDataCreate->createPVStructure(
fieldCreate->createStructure(names,powerSupply));
}
示例3: fromString
size_t fromString(PVStructureArrayPtr const &pv, StringArray const & from, size_t fromStartIndex = 0)
{
int processed = 0;
size_t fromValueCount = from.size();
// first get count
if (fromStartIndex >= fromValueCount)
throw std::runtime_error("not enough of values");
size_t numberOfStructures;
istringstream iss(from[fromStartIndex]);
iss >> numberOfStructures;
// not fail and entire value is parsed (e.g. to detect 1.2 parsing to 1)
if (iss.fail() || !iss.eof())
throw runtime_error("failed to parse element count value (uint) of field '" + pv->getFieldName() + "' from string value '" + from[fromStartIndex] + "'");
fromStartIndex++;
processed++;
PVStructureArray::svector pvStructures;
pvStructures.reserve(numberOfStructures);
PVDataCreatePtr pvDataCreate = getPVDataCreate();
for (size_t i = 0; i < numberOfStructures; ++i)
{
PVStructurePtr pvStructure = pvDataCreate->createPVStructure(pv->getStructureArray()->getStructure());
size_t count = fromString(pvStructure, from, fromStartIndex);
processed += count;
fromStartIndex += count;
pvStructures.push_back(pvStructure);
}
pv->replace(freeze(pvStructures));
return processed;
}
示例4: createDumbPowerSupplyRecord
static void createDumbPowerSupplyRecord(
PVDatabasePtr const &master,
string const &recordName)
{
StructureConstPtr top = fieldCreate->createFieldBuilder()->
add("alarm",standardField->alarm()) ->
add("timeStamp",standardField->timeStamp()) ->
addNestedStructure("power") ->
add("value",pvDouble) ->
add("alarm",standardField->alarm()) ->
endNested()->
addNestedStructure("voltage") ->
add("value",pvDouble) ->
add("alarm",standardField->alarm()) ->
endNested()->
addNestedStructure("current") ->
add("value",pvDouble) ->
add("alarm",standardField->alarm()) ->
endNested()->
createStructure();
PVStructurePtr pvStructure = pvDataCreate->createPVStructure(top);
PVRecordPtr pvRecord = PVRecord::create(recordName,pvStructure);
bool result = master->addRecord(pvRecord);
if(!result) cout<< "record " << recordName << " not added" << endl;
}
示例5: deserialize
void PVStructureArray::deserialize(ByteBuffer *pbuffer,
DeserializableControl *pcontrol) {
svector data(reuse());
size_t size = this->getArray()->getArraySizeType() == Array::fixed ?
this->getArray()->getMaximumCapacity() :
SerializeHelper::readSize(pbuffer, pcontrol);
data.resize(size);
StructureConstPtr structure = structureArray->getStructure();
PVDataCreatePtr pvDataCreate = getPVDataCreate();
for(size_t i = 0; i<size; i++) {
pcontrol->ensureData(1);
size_t temp = pbuffer->getByte();
if(temp==0) {
data[i].reset();
}
else {
if(data[i].get()==NULL) {
data[i] = pvDataCreate->createPVStructure(structure);
}
data[i]->deserialize(pbuffer, pcontrol);
}
}
replace(freeze(data)); // calls postPut()
}
示例6: monitorConnect
void pvaDriver::monitorConnect (Status const & status,
MonitorPtr const & monitor, StructureConstPtr const & structure)
{
const char *functionName = "monitorConnect";
asynPrint(pasynUserSelf, ASYN_TRACE_FLOW,
"%s::%s monitor connects [type=%s]\n",
driverName, functionName, Status::StatusTypeName[status.getType()]);
if (status.isSuccess())
{
PVDataCreatePtr PVDC = getPVDataCreate();
if(!NTNDArray::isCompatible(PVDC->createPVStructure(structure)))
{
asynPrint(pasynUserSelf, ASYN_TRACE_ERROR,
"%s::%s incompatible PVStructure. Not starting monitor\n",
driverName, functionName);
return;
}
asynPrint(pasynUserSelf, ASYN_TRACE_FLOW,
"%s::%s starting monitor\n",
driverName, functionName);
monitor->start();
}
}
示例7: create
RPCService::shared_pointer ExampleHelloRPC::create()
{
FieldCreatePtr fieldCreate = getFieldCreate();
PVDataCreatePtr pvDataCreate = getPVDataCreate();
StructureConstPtr topStructure = fieldCreate->createFieldBuilder()->
add("value",pvString)->
createStructure();
PVStructurePtr pvStructure = pvDataCreate->createPVStructure(topStructure);
ExampleHelloRPCPtr hello(
new ExampleHelloRPC(pvStructure));
return hello;
}
示例8: createVariantUnionRecord
static void createVariantUnionRecord(
PVDatabasePtr const &master,
string const &recordName)
{
StructureConstPtr top = fieldCreate->createFieldBuilder()->
add("value",fieldCreate->createVariantUnion())->
createStructure();
PVStructurePtr pvStructure = pvDataCreate->createPVStructure(top);
PVRecordPtr pvRecord = PVRecord::create(recordName,pvStructure);
bool result = master->addRecord(pvRecord);
if(!result) cout<< "record " << recordName << " not added" << endl;
}
示例9: createRegularUnionArrayRecord
static void createRegularUnionArrayRecord(
PVDatabasePtr const &master,
string const &recordName)
{
StructureConstPtr top = fieldCreate->createFieldBuilder()->
addNestedUnionArray("value")->
add("string",pvString)->
addArray("stringArray",pvString)->
endNested()->
createStructure();
PVStructurePtr pvStructure = pvDataCreate->createPVStructure(top);
PVRecordPtr pvRecord = PVRecord::create(recordName,pvStructure);
bool result = master->addRecord(pvRecord);
if(!result) cout<< "record " << recordName << " not added" << endl;
}
示例10: 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);
}
示例11: monitorConnect
void oleaClient::monitorConnect (Status const & status,
MonitorPtr const & monitor, StructureConstPtr const & structure)
{
if (status.isSuccess())
{
PVDataCreatePtr PVDC = getPVDataCreate();
if(!NTTable::isCompatible(PVDC->createPVStructure(structure)))
{
cout << "No NTTable support" << endl;
return;
}
monitor->start();
}
}
示例12: fromAttributes
void NTNDArrayConverter::fromAttributes (NDArray *src)
{
PVStructureArrayPtr dest(m_array->getAttribute());
NDAttributeList *srcList = src->pAttributeList;
NDAttribute *attr = NULL;
StructureConstPtr structure(dest->getStructureArray()->getStructure());
PVStructureArray::svector destVec(dest->reuse());
destVec.resize(srcList->count());
size_t i = 0;
while((attr = srcList->next(attr)))
{
if(!destVec[i].get() || !destVec[i].unique())
destVec[i] = PVDC->createPVStructure(structure);
PVStructurePtr pvAttr(destVec[i]);
pvAttr->getSubField<PVString>("name")->put(attr->getName());
pvAttr->getSubField<PVString>("descriptor")->put(attr->getDescription());
pvAttr->getSubField<PVString>("source")->put(attr->getSource());
NDAttrSource_t sourceType;
attr->getSourceInfo(&sourceType);
pvAttr->getSubField<PVInt>("sourceType")->put(sourceType);
switch(attr->getDataType())
{
case NDAttrInt8: fromAttribute <PVByte, int8_t> (pvAttr, attr); break;
case NDAttrUInt8: fromAttribute <PVUByte, uint8_t> (pvAttr, attr); break;
case NDAttrInt16: fromAttribute <PVShort, int16_t> (pvAttr, attr); break;
case NDAttrUInt16: fromAttribute <PVUShort, uint16_t>(pvAttr, attr); break;
case NDAttrInt32: fromAttribute <PVInt, int32_t> (pvAttr, attr); break;
case NDAttrUInt32: fromAttribute <PVUInt, uint32_t>(pvAttr, attr); break;
case NDAttrFloat32: fromAttribute <PVFloat, float> (pvAttr, attr); break;
case NDAttrFloat64: fromAttribute <PVDouble, double> (pvAttr, attr); break;
case NDAttrString: fromStringAttribute(pvAttr, attr); break;
case NDAttrUndefined: fromUndefinedAttribute(pvAttr); break;
default: throw std::runtime_error("invalid attribute data type");
}
++i;
}
dest->replace(freeze(destVec));
}
示例13: testPVNTField
void testPVNTField()
{
testDiag("testPVNTField");
StringArray choices;
choices.resize(3);
choices[0] = "one";
choices[1] = "two";
choices[2] = "three";
PVStructurePtr pvStructure = PVStructurePtr(
pvntField->createEnumerated(choices));
cout << *pvStructure << endl;
testOk1(ntField->isEnumerated(pvStructure->getStructure()));
pvStructure = PVStructurePtr(pvntField->createTimeStamp());
cout << *pvStructure << endl;
testOk1(ntField->isTimeStamp(pvStructure->getStructure()));
pvStructure = PVStructurePtr(pvntField->createAlarm());
cout << *pvStructure << endl;
testOk1(ntField->isAlarm(pvStructure->getStructure()));
pvStructure = PVStructurePtr(pvntField->createDisplay());
cout << *pvStructure << endl;
testOk1(ntField->isDisplay(pvStructure->getStructure()));
pvStructure = PVStructurePtr(pvDataCreate->createPVStructure(standardField->doubleAlarm()));
cout << *pvStructure << endl;
testOk1(ntField->isAlarmLimit(pvStructure->getStructure()));
PVStructureArrayPtr pvStructureArray = PVStructureArrayPtr(
pvntField->createEnumeratedArray());
cout << *pvStructure << endl;
cout << *pvStructureArray->getStructureArray()->getStructure();
pvStructureArray = PVStructureArrayPtr(
pvntField->createTimeStampArray());
cout << *pvStructure << endl;
cout << *pvStructureArray->getStructureArray()->getStructure();
pvStructureArray = PVStructureArrayPtr(
pvntField->createAlarmArray());
cout << *pvStructure << endl;
cout << *pvStructureArray->getStructureArray()->getStructure();
}
示例14: testCreatePVStructureWithInvalidName
static void testCreatePVStructureWithInvalidName()
{
testDiag("testCreatePVStructureWithInvalidName");
StringArray fieldNames;
fieldNames.push_back("ok");
fieldNames.push_back("this.is-wrong");
PVFieldPtrArray pvFields;
pvFields.push_back(pvDataCreate->createPVScalar(pvString));
pvFields.push_back(pvDataCreate->createPVScalar(pvInt));
try{
PVStructurePtr pvParent = pvDataCreate->createPVStructure(
fieldNames,pvFields);
testFail("Creation of invalid field name '%s' was allowed", fieldNames[1].c_str());
} catch(std::invalid_argument& e) {
testDiag("Exception: \"%s\"", e.what());
testPass("Creation of invalid field name '%s' fails as expected", fieldNames[1].c_str());
}
}
示例15: testCreatePVStructure
static void testCreatePVStructure()
{
PVStructurePtr pv0 = standardPVField->scalar(
pvDouble,alarmTimeStampValueAlarm);
PVScalarPtr pv1 = pvDataCreate->createPVScalar(pvString);
PVFieldPtrArray pvFields;
StringArray fieldNames;
pvFields.reserve(2);
fieldNames.reserve(2);
fieldNames.push_back("value");
fieldNames.push_back("extra");
pvFields.push_back(pv0);
pvFields.push_back(pv1);
PVStructurePtr pvParent = pvDataCreate->createPVStructure(
fieldNames,pvFields);
std::cout << "testCreatePVStructure PASSED" << std::endl;
}