本文整理汇总了C++中PVStringArrayPtr::view方法的典型用法代码示例。如果您正苦于以下问题:C++ PVStringArrayPtr::view方法的具体用法?C++ PVStringArrayPtr::view怎么用?C++ PVStringArrayPtr::view使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PVStringArrayPtr
的用法示例。
在下文中一共展示了PVStringArrayPtr::view方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc,char *argv[])
{
PVDatabasePtr master = PVDatabase::getMaster();
PVRecordPtr pvRecord;
bool result = false;
string recordName;
recordName = "exampleServer";
pvRecord = ExampleServer::create(recordName);
result = master->addRecord(pvRecord);
if(!result) cout<< "record " << recordName << " not added" << endl;
recordName = "traceRecordPGRPC";
pvRecord = TraceRecord::create(recordName);
result = master->addRecord(pvRecord);
if(!result) cout<< "record " << recordName << " not added" << endl;
ContextLocal::shared_pointer contextLocal = ContextLocal::create();
contextLocal->start();
PVStringArrayPtr pvNames = master->getRecordNames();
shared_vector<const string> names = pvNames->view();
for(size_t i=0; i<names.size(); ++i) cout << names[i] << endl;
contextLocal->waitForExit();
return 0;
}
示例2: test_labels
void test_labels()
{
testDiag("test_labels");
NTTableBuilderPtr builder = NTTable::createBuilder();
testOk(builder.get() != 0, "Got builder");
PVStructurePtr pvStructure = builder->
addColumn("column0", pvDouble)->
addColumn("column1", pvString)->
addColumn("column2", pvInt)->
createPVStructure();
testOk1(pvStructure.get() != 0);
if (!pvStructure)
return;
testOk1(NTTable::isCompatible(pvStructure)==true);
std::cout << *pvStructure << std::endl;
PVStringArrayPtr labels = pvStructure->getSubField<PVStringArray>("labels");
testOk1(labels.get() != 0);
testOk1(labels->getLength() == 3);
PVStringArray::const_svector l(labels->view());
testOk1(l[0] == "column0");
testOk1(l[1] == "column1");
testOk1(l[2] == "column2");
}
示例3: Expected
static PyObject * _getLabels(PyObject *willBeNull, PyObject *args)
{
PyObject *pcapsule = 0;
if(!PyArg_ParseTuple(args,"O:nttablePy",
&pcapsule))
{
PyErr_SetString(PyExc_SyntaxError,
"Bad argument. Expected (pvt)");
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);
PVStringArrayPtr pvLabel = pvt->nttable->getLabels();
shared_vector<const string> data(pvLabel->view());
int num = data.size();
PyObject *result = PyTuple_New(num);
for(int i=0; i<num; i++) {
PyObject *elem = Py_BuildValue("s",data[i].c_str());
PyTuple_SetItem(result, i, elem);
}
return result;
}
示例4: runtime_error
shared_vector<const string> PvaClientPutData::getStringArray()
{
checkValue();
PVStringArrayPtr pv = pvStructure->getSubField<PVStringArray>("value");
if(!pv) {
throw std::runtime_error(messagePrefix + notStringArray);
}
return pv->view();
}
示例5: channelList
ChannelFind::shared_pointer ChannelProviderLocal::channelList(
ChannelListRequester::shared_pointer const & channelListRequester)
{
PVStringArrayPtr records;
{
Lock guard(mutex);
records = pvDatabase->getRecordNames();
}
channelListRequester->channelListResult(Status::Ok, channelFinder, records->view(), false);
return channelFinder;
}
示例6: process
void RecordListRecord::process()
{
PVStringArrayPtr pvNames = PVDatabase::getMaster()->getRecordNames();
name->replace(pvNames->view());
string message("");
if(database->get().compare("master")!=0) {
message += " can only access master ";
}
string regEx = regularExpression->get();
if(regEx.compare("")!=0 && regEx.compare(".*")!=0) {
message += " regularExpression not implemented ";
}
status->put(message);
}
示例7: test_ntenum
void test_ntenum()
{
testDiag("test_ntenum");
NTEnumBuilderPtr builder = NTEnum::createBuilder();
testOk(builder.get() != 0, "Got builder");
NTEnumPtr ntEnum = builder->
addDescriptor()->
addAlarm()->
addTimeStamp()->
add("valueAlarm",standardField->intAlarm()) ->
create();
testOk1(ntEnum.get() != 0);
testOk1(NTEnum::is_a(ntEnum->getPVStructure()));
testOk1(NTEnum::isCompatible(ntEnum->getPVStructure()));
testOk1(ntEnum->getPVStructure().get() != 0);
testOk1(ntEnum->getValue().get() != 0);
testOk1(ntEnum->getDescriptor().get() != 0);
testOk1(ntEnum->getAlarm().get() != 0);
testOk1(ntEnum->getTimeStamp().get() != 0);
//
// example how to set a value
//
PVStructurePtr pvValue = ntEnum->getValue();
//PVStringArray pvChoices = pvValue->getSubField<PVStringArray>("choices");
PVStringArray::svector choices(2);
choices[0] = "Off";
choices[1] = "On";
pvValue->getSubField<PVStringArray>("choices")->replace(freeze(choices));
pvValue->getSubField<PVInt>("index")->put(1);
//
// example how to get a value
//
int32 value = ntEnum->getValue()->getSubField<PVInt>("index")->get();
testOk1(value == 1);
PVStringArrayPtr pvChoices = ntEnum->getValue()->getSubField<PVStringArray>("choices");
std::string choice0 = pvChoices->view()[0];
std::string choice1 = pvChoices->view()[1];
testOk1(choice0 == "Off");
testOk1(choice1 == "On");
//
// timeStamp ops
//
PVTimeStamp pvTimeStamp;
if (ntEnum->attachTimeStamp(pvTimeStamp))
{
testPass("timeStamp attach");
// example how to set current time
TimeStamp ts;
ts.getCurrent();
pvTimeStamp.set(ts);
// example how to get EPICS time
TimeStamp ts2;
pvTimeStamp.get(ts2);
testOk1(ts2.getEpicsSecondsPastEpoch() != 0);
}
else
testFail("timeStamp attach fail");
//
// alarm ops
//
PVAlarm pvAlarm;
if (ntEnum->attachAlarm(pvAlarm))
{
testPass("alarm attach");
// example how to set an alarm
Alarm alarm;
alarm.setStatus(deviceStatus);
alarm.setSeverity(minorAlarm);
alarm.setMessage("simulation alarm");
pvAlarm.set(alarm);
}
else
testFail("alarm attach fail");
//
// set descriptor
//
ntEnum->getDescriptor()->put("This is a test NTEnum");
// dump ntEnum
std::cout << *ntEnum->getPVStructure() << std::endl;
}
示例8: test_ntcontinuum
void test_ntcontinuum()
{
testDiag("test_ntcontinuum");
NTContinuumBuilderPtr builder = NTContinuum::createBuilder();
testOk(builder.get() != 0, "Got builder");
NTContinuumPtr ntContinuum = builder->
addDescriptor()->
addAlarm()->
addTimeStamp()->
add("extra1",fieldCreate->createScalar(pvString)) ->
add("extra2",fieldCreate->createScalarArray(pvString)) ->
create();
testOk1(ntContinuum.get() != 0);
testOk1(ntContinuum->getPVStructure().get() != 0);
testOk1(ntContinuum->getDescriptor().get() != 0);
testOk1(ntContinuum->getAlarm().get() != 0);
testOk1(ntContinuum->getTimeStamp().get() != 0);
testOk1(ntContinuum->getBase().get() != 0);
testOk1(ntContinuum->getValue().get() != 0);
//
// example how to set base
//
PVDoubleArray::svector newBase;
newBase.push_back(1.0);
newBase.push_back(2.0);
PVDoubleArrayPtr pvBaseField = ntContinuum->getBase();
pvBaseField->replace(freeze(newBase));
//
// example how to get bases
//
PVDoubleArray::const_svector base(pvBaseField->view());
testOk1(base.size() == 2);
testOk1(base[0] == 1.0);
testOk1(base[1] == 2.0);
//
// example how to set values
//
PVDoubleArray::svector newValue;
newValue.push_back(1.0);
newValue.push_back(2.0);
newValue.push_back(10.0);
newValue.push_back(20.0);
newValue.push_back(100.0);
newValue.push_back(200.0);
PVDoubleArrayPtr pvValueField = ntContinuum->getValue();
pvValueField->replace(freeze(newValue));
//
// example how to get values
//
PVDoubleArray::const_svector value(pvValueField->view());
testOk1(value.size() == 6);
testOk1(value[0] == 1.0);
testOk1(value[1] == 2.0);
testOk1(value[2] == 10.0);
testOk1(value[3] == 20.0);
testOk1(value[4] == 100.0);
testOk1(value[5] == 200.0);
//
// example how to set units
//
PVStringArray::svector newUnits;
newUnits.push_back("s");
newUnits.push_back("ms");
newUnits.push_back("us");
newUnits.push_back("s");
PVStringArrayPtr pvUnitsField = ntContinuum->getUnits();
pvUnitsField->replace(freeze(newUnits));
//
// example how to get units
//
PVStringArray::const_svector units(pvUnitsField->view());
testOk1(units.size() == 4);
testOk1(units[0] == "s");
testOk1(units[1] == "ms");
testOk1(units[2] == "us");
testOk1(units[3] == "s");
//
// test isValid
//
testOk1(ntContinuum->isValid());
//
// timeStamp ops
//
PVTimeStamp pvTimeStamp;
if (ntContinuum->attachTimeStamp(pvTimeStamp))
//.........这里部分代码省略.........
示例9: switch
static PyObject *getScalarArrayValue(PVScalarArrayPtr pvScalarArray)
{
ScalarType scalarType = pvScalarArray->getScalarArray()->getElementType();
switch(scalarType) {
case pvBoolean: {
PVBooleanArrayPtr pvArray = static_pointer_cast<PVBooleanArray>(pvScalarArray);
shared_vector<const boolean> data(pvArray->view());
int num = data.size();
PyObject *result = PyTuple_New(num);
for(int i=0; i<num; i++) {
int value = (data[i] ? 1 : 0);
PyObject *elem = Py_BuildValue("i",value);
PyTuple_SetItem(result, i, elem);
}
return result;
}
case pvByte: {
PVByteArrayPtr pvArray = static_pointer_cast<PVByteArray>(pvScalarArray);
shared_vector<const int8> data(pvArray->view());
int num = data.size();
PyObject *result = PyTuple_New(num);
for(int i=0; i<num; i++) {
int value = data[i];
PyObject *elem = Py_BuildValue("i",value);
PyTuple_SetItem(result, i, elem);
}
return result;
}
case pvUByte: {
PVUByteArrayPtr pvArray = static_pointer_cast<PVUByteArray>(pvScalarArray);
shared_vector<const uint8> data(pvArray->view());
int num = data.size();
PyObject *result = PyTuple_New(num);
for(int i=0; i<num; i++) {
int value = data[i];
PyObject *elem = Py_BuildValue("i",value);
PyTuple_SetItem(result, i, elem);
}
return result;
}
case pvShort: {
PVShortArrayPtr pvArray = static_pointer_cast<PVShortArray>(pvScalarArray);
shared_vector<const int16> data(pvArray->view());
int num = data.size();
PyObject *result = PyTuple_New(num);
for(int i=0; i<num; i++) {
int value = data[i];
PyObject *elem = Py_BuildValue("i",value);
PyTuple_SetItem(result, i, elem);
}
return result;
}
case pvUShort: {
PVUShortArrayPtr pvArray = static_pointer_cast<PVUShortArray>(pvScalarArray);
shared_vector<const uint16> data(pvArray->view());
int num = data.size();
PyObject *result = PyTuple_New(num);
for(int i=0; i<num; i++) {
int value = data[i];
PyObject *elem = Py_BuildValue("i",value);
PyTuple_SetItem(result, i, elem);
}
return result;
}
case pvInt: {
PVIntArrayPtr pvArray = static_pointer_cast<PVIntArray>(pvScalarArray);
shared_vector<const int32> data(pvArray->view());
int num = data.size();
PyObject *result = PyTuple_New(num);
for(int i=0; i<num; i++) {
PyObject *elem = Py_BuildValue("i",data[i]);
PyTuple_SetItem(result, i, elem);
}
return result;
}
case pvUInt: {
PVUIntArrayPtr pvArray = static_pointer_cast<PVUIntArray>(pvScalarArray);
shared_vector<const uint32> data(pvArray->view());
int num = data.size();
PyObject *result = PyTuple_New(num);
for(int i=0; i<num; i++) {
PyObject *elem = Py_BuildValue("i",data[i]);
PyTuple_SetItem(result, i, elem);
}
return result;
}
case pvLong: {
PVLongArrayPtr pvArray = static_pointer_cast<PVLongArray>(pvScalarArray);
shared_vector<const int64> data(pvArray->view());
int num = data.size();
PyObject *result = PyTuple_New(num);
for(int i=0; i<num; i++) {
PyObject *elem = Py_BuildValue("k",data[i]);
PyTuple_SetItem(result, i, elem);
}
return result;
}
case pvULong: {
PVULongArrayPtr pvArray = static_pointer_cast<PVULongArray>(pvScalarArray);
shared_vector<const uint64> data(pvArray->view());
//.........这里部分代码省略.........
示例10: test_ntnameValue
void test_ntnameValue()
{
testDiag("test_ntnameValue");
NTNameValueBuilderPtr builder = NTNameValue::createBuilder();
testOk(builder.get() != 0, "Got builder");
NTNameValuePtr ntNameValue = builder->
value(pvInt)->
addDescriptor()->
addAlarm()->
addTimeStamp()->
add("extra1",fieldCreate->createScalar(pvString)) ->
add("extra2",fieldCreate->createScalarArray(pvString)) ->
create();
testOk1(ntNameValue.get() != 0);
testOk1(NTNameValue::is_a(ntNameValue->getPVStructure()));
testOk1(NTNameValue::isCompatible(ntNameValue->getPVStructure()));
testOk1(ntNameValue->getPVStructure().get() != 0);
testOk1(ntNameValue->getDescriptor().get() != 0);
testOk1(ntNameValue->getAlarm().get() != 0);
testOk1(ntNameValue->getTimeStamp().get() != 0);
testOk1(ntNameValue->getName().get() != 0);
testOk1(ntNameValue->getValue().get() != 0);
//
// example how to set name
//
PVStringArray::svector newName;
newName.push_back("name1");
newName.push_back("name2");
newName.push_back("name3");
PVStringArrayPtr pvNameField = ntNameValue->getName();
pvNameField->replace(freeze(newName));
//
// example how to get name
//
PVStringArray::const_svector name(pvNameField->view());
testOk1(name.size() == 3);
testOk1(name[0] == "name1");
testOk1(name[1] == "name2");
testOk1(name[2] == "name3");
//
// example how to set value
//
PVIntArray::svector newValue;
newValue.push_back(1);
newValue.push_back(2);
newValue.push_back(8);
PVIntArrayPtr pvValueField = ntNameValue->getValue<PVIntArray>();
pvValueField->replace(freeze(newValue));
//
// example how to get column value
//
PVIntArray::const_svector value(pvValueField->view());
testOk1(value.size() == 3);
testOk1(value[0] == 1);
testOk1(value[1] == 2);
testOk1(value[2] == 8);
//
// timeStamp ops
//
PVTimeStamp pvTimeStamp;
if (ntNameValue->attachTimeStamp(pvTimeStamp))
{
testPass("timeStamp attach");
// example how to set current time
TimeStamp ts;
ts.getCurrent();
pvTimeStamp.set(ts);
// example how to get EPICS time
TimeStamp ts2;
pvTimeStamp.get(ts2);
testOk1(ts2.getEpicsSecondsPastEpoch() != 0);
}
else
testFail("timeStamp attach fail");
//
// alarm ops
//
PVAlarm pvAlarm;
if (ntNameValue->attachAlarm(pvAlarm))
{
testPass("alarm attach");
// example how to set an alarm
Alarm alarm;
//.........这里部分代码省略.........