本文整理汇总了C++中PVStringArrayPtr::put方法的典型用法代码示例。如果您正苦于以下问题:C++ PVStringArrayPtr::put方法的具体用法?C++ PVStringArrayPtr::put怎么用?C++ PVStringArrayPtr::put使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PVStringArrayPtr
的用法示例。
在下文中一共展示了PVStringArrayPtr::put方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: test
void test()
{
String builder;
int n = 9;
StringArray channelName(n);
channelName[0] = "masarExample0000";
channelName[1] = "masarExample0001";
channelName[2] = "masarExample0002";
channelName[3] = "masarExample0003";
channelName[4] = "masarExample0004";
channelName[5] = "masarExampleCharArray";
channelName[6] = "masarExampleStringArray";
channelName[7] = "masarExampleLongArray";
channelName[8] = "masarExampleDoubleArray";
GatherV3DataPtr gather(new GatherV3Data(channelName,n));
bool result = gather->connect(5.0);
if(!result) {
printf("connect failed\n%s\n",gather->getMessage().c_str());
printf("This test requires iocBoot/iocAll ");
printf("It must be started before running this test\n");
exit(1);
}
NTTablePtr nttable = gather->getNTTable();
BooleanArrayData booldata;
PVBooleanArrayPtr pvIsArray = static_pointer_cast<PVBooleanArray>
(nttable->getPVStructure()->getScalarArrayField("isArray",pvBoolean));
pvIsArray->get(0,n,booldata);
BooleanArray & isArray = booldata.data;
DoubleArrayData ddata;
gather->getDoubleValue()->get(0,n,ddata);
DoubleArray & dvalue = ddata.data;
StringArrayData sdata;
gather->getStringValue()->get(0,n,sdata);
StringArray & svalue = sdata.data;
LongArrayData ldata;
gather->getLongValue()->get(0,n,ldata);
LongArray & lvalue = ldata.data;
IntArrayData idata;
StructureArrayData structdata;
gather->getArrayValue()->get(0,n,structdata);
PVStructurePtrArray & structvalue = structdata.data;
gather->getDBRType()->get(0,n,idata);
IntArray & dbrType = idata.data;
for(int i=0; i<n; i++) {
if(isArray[i]) {
PVStructurePtr pvStructure = structvalue[i];
switch(dbrType[i]) {
case DBF_STRING: {
PVStringArrayPtr pvValue = static_pointer_cast<PVStringArray>(
pvStructure->getScalarArrayField("stringValue",pvString));
int num = 4;
String value[4];
value[0] = "aaa";
value[1] = "bbb";
value[2] = "ccc";
value[3] = "ddd";
pvValue->put(0,num,value,0);
break;
}
case DBF_CHAR:
case DBF_INT:
case DBF_LONG: {
PVIntArrayPtr pvValue = static_pointer_cast<PVIntArray>(
pvStructure->getScalarArrayField("intValue",pvInt));
int num = 4;
int32 value[4] = {1,2,3,4};
pvValue->put(0,num,value,0);
break;
}
case DBF_FLOAT:
case DBF_DOUBLE: {
PVDoubleArrayPtr pvValue = static_pointer_cast<PVDoubleArray>(
pvStructure->getScalarArrayField("doubleValue",pvDouble));
int num = 4;
double value[4] = {1e1,1e2,1e3,1e4};
pvValue->put(0,num,value,0);
break;
}
default:
printf("got an unexpected DBF type. Logic error\n");
exit(1);
}
continue;
}
switch(dbrType[i]) {
case DBF_STRING:
svalue[i] = String("this is set by gatherV3DataPut"); break;
case DBF_ENUM:
svalue[i] = String("one"); break;
case DBF_CHAR:
case DBF_INT:
case DBF_LONG:
lvalue[i] = i; break;
case DBF_FLOAT:
case DBF_DOUBLE:
dvalue[i] = i; break;
default:
printf("got an unexpected DBF type. Logic error\n");
exit(1);
}
//.........这里部分代码省略.........
示例2: request
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);
}