本文整理汇总了C++中StandardFieldPtr类的典型用法代码示例。如果您正苦于以下问题:C++ StandardFieldPtr类的具体用法?C++ StandardFieldPtr怎么用?C++ StandardFieldPtr使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了StandardFieldPtr类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getFieldCreate
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: xx
StandardFieldPtr StandardField::getStandardField()
{
static StandardFieldPtr standardFieldCreate;
static Mutex mutex;
Lock xx(mutex);
if(standardFieldCreate.get()==0)
{
standardFieldCreate = StandardFieldPtr(new StandardField());
standardFieldCreate->init();
}
return standardFieldCreate;
}
示例3: createStructure
static Structure::const_shared_pointer createStructure(CAChannel::shared_pointer const & channel, string const & properties)
{
StandardFieldPtr standardField = getStandardField();
Structure::const_shared_pointer structure;
chtype channelType = channel->getNativeType();
if (channelType != DBR_ENUM)
{
ScalarType st = dbr2ST[channelType];
structure = (channel->getElementCount() > 1) ?
standardField->scalarArray(st, properties) :
standardField->scalar(st, properties);
}
else
{
// NOTE: enum arrays not supported
structure = standardField->enumerated(properties);
}
return structure;
}
示例4: 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));
}
示例5: getStandardField
ExampleHelloPtr ExampleHello::create(
string const & recordName)
{
StandardFieldPtr standardField = getStandardField();
FieldCreatePtr fieldCreate = getFieldCreate();
PVDataCreatePtr pvDataCreate = getPVDataCreate();
StructureConstPtr topStructure = fieldCreate->createFieldBuilder()->
addNestedStructure("argument")->
add("value",pvString)->
endNested()->
addNestedStructure("result") ->
add("value",pvString) ->
add("timeStamp",standardField->timeStamp()) ->
endNested()->
createStructure();
PVStructurePtr pvStructure = pvDataCreate->createPVStructure(topStructure);
ExampleHelloPtr pvRecord(
new ExampleHello(recordName,pvStructure));
if(!pvRecord->init()) pvRecord.reset();
return pvRecord;
}
示例6: getStandardField
void DbPv::init()
{
// this requires valid existance of dbPv::shared_pointer instance
StandardFieldPtr standardField = getStandardField();
ScalarType scalarType = pvBoolean;
switch(dbChannelFinalFieldType(dbChan)) {
case DBF_CHAR:
scalarType = pvByte; break;
case DBF_UCHAR:
scalarType = pvUByte; break;
case DBF_SHORT:
scalarType = pvShort; break;
case DBF_USHORT:
scalarType = pvUShort; break;
case DBF_LONG:
scalarType = pvInt; break;
case DBF_ULONG:
scalarType = pvUInt; break;
case DBF_FLOAT:
scalarType = pvFloat; break;
case DBF_DOUBLE:
scalarType = pvDouble; break;
case DBF_STRING:
scalarType = pvString; break;
case DBF_ENUM:
case DBF_MENU:
case DBF_DEVICE:
recordField = standardField->enumerated("value,timeStamp,alarm");
return;
case DBF_INLINK:
case DBF_OUTLINK:
case DBF_FWDLINK:
scalarType = pvString; break;
default:
break;
}
bool isArray = (dbChannelFinalElements(dbChan) > 1) ? true : false;
if(scalarType==pvString) {
if(isArray) {
recordField = standardField->scalarArray(scalarType,
"value,timeStamp,alarm");
} else {
recordField = standardField->scalar(scalarType,
"value,timeStamp,alarm");
}
}
else if(scalarType!=pvBoolean) {
if(isArray) {
recordField = standardField->scalarArray(scalarType,
"value,timeStamp,alarm,display");
} else {
recordField = standardField->scalar(scalarType,
"value,timeStamp,alarm,display,control,valueAlarm");
}
}
}
示例7: createPowerSupply
PVStructurePtr createPowerSupply()
{
FieldCreatePtr fieldCreate = getFieldCreate();
StandardFieldPtr standardField = getStandardField();
PVDataCreatePtr pvDataCreate = getPVDataCreate();
return pvDataCreate->createPVStructure(
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());
}
示例8: printf
void ExampleServiceRPC::request(
ChannelRPCRequester::shared_pointer const & channelRPCRequester,
epics::pvData::PVStructure::shared_pointer const & pvArgument)
{
String buffer;
PVStringPtr pvfunction = pvArgument->getStringField("function");
PVStringArrayPtr pvnames = static_pointer_cast<PVStringArray>
(pvArgument->getScalarArrayField("names",pvString));
PVStringArrayPtr pvvalues = static_pointer_cast<PVStringArray>
(pvArgument->getScalarArrayField("values",pvString));
buffer += "pvArgument ";
bool is = true;
if(pvfunction==0) is = false;
if(pvnames==0) is = false;
if(pvvalues==0) is = false;
if(is) {
buffer += "is a NTNameValue\n";
} else {
buffer += "is not a NTNameValue\n ";
}
pvArgument->toString(&buffer);
printf("%s\n",buffer.c_str());
StandardFieldPtr standardField = getStandardField();
StandardPVFieldPtr standardPVField = getStandardPVField();
FieldCreatePtr fieldCreate = getFieldCreate();
PVDataCreatePtr pvDataCreate = getPVDataCreate();
size_t n = 5;
FieldConstPtrArray fields;
StringArray names;
fields.reserve(n);
names.reserve(n);
names.push_back("alarm");
names.push_back("timeStamp");
names.push_back("label");
names.push_back("position");
names.push_back("alarms");
StructureConstPtr xxx = standardField->alarm();
printf("xxx %p\n",xxx.get());
fields.push_back(standardField->alarm());
fields.push_back(standardField->timeStamp());
fields.push_back(fieldCreate->createScalarArray(pvString));
fields.push_back(fieldCreate->createScalarArray(pvDouble));
fields.push_back(fieldCreate->createStructureArray(standardField->alarm()));
StructureConstPtr structure = fieldCreate->createStructure(names,fields);
printf("structure %p\n",structure.get());
buffer.clear();
structure->toString(&buffer);
printf("structure\n%s\n",buffer.c_str());
PVStructurePtr pvStructure = pvDataCreate->createPVStructure(structure);
PVTimeStamp pvTimeStamp;
TimeStamp timeStamp;
pvTimeStamp.attach(pvStructure->getStructureField("timeStamp"));
timeStamp.getCurrent();
pvTimeStamp.set(timeStamp);
StringArray label;
label.reserve(2);
for(int i=0; i<2; i++) {
label.push_back(names[i+3]);
}
PVStringArrayPtr pvLabel = static_pointer_cast<PVStringArray>
(pvStructure->getScalarArrayField("label",pvString));
pvLabel->put(0,2,label,0);
PVDoubleArrayPtr pvPositions = static_pointer_cast<PVDoubleArray>
(pvStructure->getScalarArrayField("position",pvDouble));
double positions[2];
positions[0] = 1.0;
positions[1] = 2.0;
pvPositions->put(0,2,positions,0);
PVStructureArrayPtr pvAlarms = static_pointer_cast<PVStructureArray>
(pvStructure->getStructureArrayField("alarms"));
PVAlarm pvAlarm;
Alarm alarm;
PVStructurePtrArray palarms;
size_t na=2;
palarms.reserve(na);
for(size_t i=0; i<na; i++) {
palarms.push_back(pvDataCreate->createPVStructure(standardField->alarm()));
}
for(size_t i=0; i<na; i++) {
pvAlarm.attach(palarms[i]);
alarm.setMessage("test");
alarm.setSeverity(majorAlarm);
alarm.setStatus(clientStatus);
pvAlarm.set(alarm);
}
pvAlarms->put(0,2,palarms,0);
String labels[2];
labels[0] = pvPositions->getFieldName();
labels[1] = pvAlarms->getFieldName();
pvLabel->put(0,2,labels,0);
buffer.erase();
pvStructure->toString(&buffer);
printf("%s\n",buffer.c_str());
channelRPCRequester->requestDone(Status::Ok,pvStructure);
}
示例9: getStandardField
StructureConstPtr NTMultiChannelBuilder::createStructure()
{
StandardFieldPtr standardField = getStandardField();
size_t nfields = 3;
size_t extraCount = extraFieldNames.size();
nfields += extraCount;
if(descriptor) ++nfields;
if(alarm) ++nfields;
if(timeStamp) ++nfields;
if(severity) ++nfields;
if(status) ++nfields;
if(message) ++nfields;
if(secondsPastEpoch) ++nfields;
if(nanoseconds) ++nfields;
if(userTag) ++nfields;
FieldConstPtrArray fields(nfields);
StringArray names(nfields);
size_t ind = 0;
names[ind] = "value";
if(valueType) {
fields[ind++] = fieldCreate->createUnionArray(valueType);
} else {
fields[ind++] = fieldCreate->createVariantUnionArray();
}
names[ind] = "channelName";
fields[ind++] = fieldCreate->createScalarArray(pvString);
names[ind] = "isConnected";
fields[ind++] = fieldCreate->createScalarArray(pvBoolean);
if(timeStamp) {
names[ind] = "timeStamp";
fields[ind++] = standardField->timeStamp();
}
if(alarm) {
names[ind] = "alarm";
fields[ind++] = standardField->alarm();
}
if(descriptor) {
names[ind] = "descriptor";
fields[ind++] = fieldCreate->createScalar(pvString);
}
if(severity) {
names[ind] = "severity";
fields[ind++] = fieldCreate->createScalarArray(pvInt);
}
if(status) {
names[ind] = "status";
fields[ind++] = fieldCreate->createScalarArray(pvInt);
}
if(message) {
names[ind] = "message";
fields[ind++] = fieldCreate->createScalarArray(pvString);
}
if(secondsPastEpoch) {
names[ind] = "secondsPastEpoch";
fields[ind++] = fieldCreate->createScalarArray(pvLong);
}
if(nanoseconds) {
names[ind] = "nanoseconds";
fields[ind++] = fieldCreate->createScalarArray(pvInt);
}
if(userTag) {
names[ind] = "userTag";
fields[ind++] = fieldCreate->createScalarArray(pvInt);
}
for (size_t i = 0; i< extraCount; i++) {
names[ind] = extraFieldNames[i];
fields[ind++] = extraFields[i];
}
StructureConstPtr st = fieldCreate->createStructure(NTMultiChannel::URI,names,fields);
reset();
return st;
}
示例10: 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;
}
示例11: test_builder
void test_builder()
{
testDiag("test_builder");
NTEnumBuilderPtr builder = NTEnum::createBuilder();
testOk(builder.get() != 0, "Got builder");
StructureConstPtr structure = builder->
addDescriptor()->
addAlarm()->
addTimeStamp()->
add("valueAlarm",standardField->doubleAlarm()) ->
add("extra",fieldCreate->createScalarArray(pvString)) ->
createStructure();
testOk1(structure.get() != 0);
if (!structure)
return;
testOk1(NTEnum::is_a(structure));
testOk1(structure->getID() == NTEnum::URI);
testOk1(structure->getNumberFields() == 6);
testOk1(structure->getField("value").get() != 0);
testOk1(structure->getField("descriptor").get() != 0);
testOk1(structure->getField("alarm").get() != 0);
testOk1(structure->getField("timeStamp").get() != 0);
FieldConstPtr valueField = structure->getField("value");
testOk(valueField.get() != 0 &&
ntField->isEnumerated(valueField), "value is enum");
std::cout << *structure << std::endl;
}
示例12: testPostPut
static void testPostPut()
{
testDiag("== testPostPut ==");
StructureConstPtr structure =
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();
PvaClientPutDataPtr pvaData = PvaClientPutData::create(structure);
PVStructurePtr pvStructure = pvaData->getPVStructure();
BitSetPtr change = pvaData->getChangedBitSet();
PVDoublePtr powerValue = pvStructure->getSubField<PVDouble>("power.value");
PVDoublePtr voltageValue = pvStructure->getSubField<PVDouble>("voltage.value");
PVDoublePtr currentValue = pvStructure->getSubField<PVDouble>("current.value");
size_t powerOffset = powerValue->getFieldOffset();
size_t voltageOffset = voltageValue->getFieldOffset();
size_t currentOffset = currentValue->getFieldOffset();
change->clear();
powerValue->put(1.0);
voltageValue->put(2.0);
currentValue->put(.5);
testOk(change->cardinality()==3,"3 fields changed");
testOk(change->get(powerOffset),"power changed");
testOk(change->get(voltageOffset),"voltage changed");
testOk(change->get(currentOffset),"current changed");
}
示例13: test_builder
void test_builder()
{
testDiag("test_builder");
NTScalarBuilderPtr builder = NTScalar::createBuilder();
testOk(builder.get() != 0, "Got builder");
StructureConstPtr structure = builder->
value(pvDouble)->
addDescriptor()->
addAlarm()->
addTimeStamp()->
addDisplay()->
addControl()->
add("valueAlarm",standardField->doubleAlarm()) ->
add("extra",fieldCreate->createScalarArray(pvString)) ->
createStructure();
testOk1(structure.get() != 0);
if (!structure)
return;
testOk1(NTScalar::is_a(structure));
testOk1(structure->getID() == NTScalar::URI);
testOk1(structure->getNumberFields() == 8);
testOk1(structure->getField("value").get() != 0);
testOk1(structure->getField("descriptor").get() != 0);
testOk1(structure->getField("alarm").get() != 0);
testOk1(structure->getField("timeStamp").get() != 0);
testOk1(structure->getField("display").get() != 0);
testOk1(structure->getField("control").get() != 0);
testOk(dynamic_pointer_cast<const Scalar>(structure->getField("value")).get() != 0 &&
dynamic_pointer_cast<const Scalar>(structure->getField("value"))->getScalarType() == pvDouble, "value type");
std::cout << *structure << std::endl;
// no value set
try
{
structure = builder->
addDescriptor()->
addAlarm()->
addTimeStamp()->
addDisplay()->
addControl()->
createStructure();
testFail("no value type set");
} catch (std::runtime_error &) {
testPass("no value type set");
}
}
示例14: 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();
}
示例15: testNTField
void testNTField()
{
testDiag("testNTField");
StructureConstPtr structureConstPtr = ntField->createEnumerated();
cout << *structureConstPtr << endl;
testOk1(ntField->isEnumerated(structureConstPtr));
structureConstPtr = ntField->createTimeStamp();
cout << *structureConstPtr << endl;
testOk1(ntField->isTimeStamp(structureConstPtr));
structureConstPtr = ntField->createAlarm();
cout << *structureConstPtr << endl;
testOk1(ntField->isAlarm(structureConstPtr));
structureConstPtr = ntField->createDisplay();
cout << *structureConstPtr << endl;
testOk1(ntField->isDisplay(structureConstPtr));
structureConstPtr = standardField->doubleAlarm();
cout << *structureConstPtr << endl;
testOk1(ntField->isAlarmLimit(structureConstPtr));
structureConstPtr = ntField->createControl();
cout << *structureConstPtr << endl;
testOk1(ntField->isControl(structureConstPtr));
StructureArrayConstPtr structureArrayConstPtr
= ntField->createEnumeratedArray();
cout << *structureConstPtr << endl;
structureArrayConstPtr = ntField->createTimeStampArray();
cout << *structureConstPtr << endl;
structureArrayConstPtr = ntField->createAlarmArray();
cout << *structureConstPtr << endl;
}