本文整理汇总了C++中pvstructure::shared_pointer::getSubField方法的典型用法代码示例。如果您正苦于以下问题:C++ shared_pointer::getSubField方法的具体用法?C++ shared_pointer::getSubField怎么用?C++ shared_pointer::getSubField使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pvstructure::shared_pointer
的用法示例。
在下文中一共展示了shared_pointer::getSubField方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: copy_DBR_CTRL
void copy_DBR_CTRL(const void * dbr, unsigned count, PVStructure::shared_pointer const & pvStructure)
{
const T* data = static_cast<const T*>(dbr);
PVStructure::shared_pointer alarm = pvStructure->getSubField<PVStructure>("alarm");
alarm->getSubField<PVInt>("status")->put(0);
alarm->getSubField<PVInt>("severity")->put(data->severity);
alarm->getSubField<PVString>("message")->put(dbrStatus2alarmMessage[data->status]);
PVStructure::shared_pointer disp = pvStructure->getSubField<PVStructure>("display");
disp->getSubField<PVString>("units")->put(std::string(data->units));
disp->getSubField<PVDouble>("limitHigh")->put(data->upper_disp_limit);
disp->getSubField<PVDouble>("limitLow")->put(data->lower_disp_limit);
copy_format<T>(dbr, disp);
PVStructure::shared_pointer va = pvStructure->getSubField<PVStructure>("valueAlarm");
std::tr1::static_pointer_cast<sF>(va->getSubField("highAlarmLimit"))->put(data->upper_alarm_limit);
std::tr1::static_pointer_cast<sF>(va->getSubField("highWarningLimit"))->put(data->upper_warning_limit);
std::tr1::static_pointer_cast<sF>(va->getSubField("lowWarningLimit"))->put(data->lower_warning_limit);
std::tr1::static_pointer_cast<sF>(va->getSubField("lowAlarmLimit"))->put(data->lower_alarm_limit);
PVStructure::shared_pointer ctrl = pvStructure->getSubField<PVStructure>("control");
ctrl->getSubField<PVDouble>("limitHigh")->put(data->upper_ctrl_limit);
ctrl->getSubField<PVDouble>("limitLow")->put(data->lower_ctrl_limit);
copy_DBR<pT, sT, sF, aF>(&data->value, count, pvStructure);
}
示例2: getDBRType
static chtype getDBRType(PVStructure::shared_pointer const & pvRequest, chtype nativeType)
{
// get "field" sub-structure
PVStructure::shared_pointer fieldSubField =
std::tr1::dynamic_pointer_cast<PVStructure>(pvRequest->getSubField("field"));
if (!fieldSubField)
fieldSubField = pvRequest;
Structure::const_shared_pointer fieldStructure = fieldSubField->getStructure();
// no fields or control -> DBR_CTRL_<type>
if (fieldStructure->getNumberFields() == 0 ||
fieldStructure->getField("control"))
return static_cast<chtype>(static_cast<int>(nativeType) + DBR_CTRL_STRING);
// display/valueAlarm -> DBR_GR_<type>
if (fieldStructure->getField("display") || fieldStructure->getField("valueAlarm"))
return static_cast<chtype>(static_cast<int>(nativeType) + DBR_GR_STRING);
// timeStamp -> DBR_TIME_<type>
// NOTE: that only DBR_TIME_<type> type holds timestamp, therefore if you request for
// the fields above, you will never get timestamp
if (fieldStructure->getField("timeStamp"))
return static_cast<chtype>(static_cast<int>(nativeType) + DBR_TIME_STRING);
// alarm -> DBR_STS_<type>
if (fieldStructure->getField("alarm"))
return static_cast<chtype>(static_cast<int>(nativeType) + DBR_STS_STRING);
return nativeType;
}
示例3:
int doPut_pvStructure<dbr_enum_t, pvString, PVString, PVStringArray>(CAChannel::shared_pointer const & channel, void *usrArg, PVStructure::shared_pointer const & pvStructure)
{
bool isScalarValue = pvStructure->getStructure()->getField("value")->getType() == structure;
if (isScalarValue)
{
std::tr1::shared_ptr<PVInt> value = std::tr1::static_pointer_cast<PVInt>(pvStructure->getSubField("value.index"));
dbr_enum_t val = value->get();
int result = ca_array_put_callback(channel->getNativeType(), 1,
channel->getChannelID(), &val,
ca_put_handler, usrArg);
if (result == ECA_NORMAL)
{
ca_flush_io();
}
return result;
}
else
{
// no enum arrays in V3
return ECA_NOSUPPORT;
}
}
示例4: printValue
void printValue(std::string const & channelName, PVStructure::shared_pointer const & pv)
{
if (mode == ValueOnlyMode)
{
PVField::shared_pointer value = pv->getSubField("value");
if (value.get() == 0)
{
std::cerr << "no 'value' field" << std::endl;
//std::cout << channelName << std::endl << *(pv.get()) << std::endl << std::endl;
pvutil_ostream myos(std::cout.rdbuf());
myos << channelName << std::endl << *(pv.get()) << std::endl << std::endl;
}
else
{
Type valueType = value->getField()->getType();
if (valueType != scalar && valueType != scalarArray)
{
// switch to structure mode, unless it's T-type
if (valueType == structure && isTType(static_pointer_cast<PVStructure>(value)))
{
std::cout << std::setw(30) << std::left << channelName;
std::cout << fieldSeparator;
formatTType(std::cout, static_pointer_cast<PVStructure>(value));
std::cout << std::endl;
}
else
{
//std::cout << channelName << std::endl << *(pv.get()) << std::endl << std::endl;
pvutil_ostream myos(std::cout.rdbuf());
myos << channelName << std::endl << *(pv.get()) << std::endl << std::endl;
}
}
else
{
if (fieldSeparator == ' ' && value->getField()->getType() == scalar)
std::cout << std::setw(30) << std::left << channelName;
else
std::cout << channelName;
std::cout << fieldSeparator;
terse(std::cout, value) << std::endl;
}
}
}
else if (mode == TerseMode)
terseStructure(std::cout, pv) << std::endl;
else
{
//std::cout << channelName << std::endl << *(pv.get()) << std::endl << std::endl;
pvutil_ostream myos(std::cout.rdbuf());
myos << channelName << std::endl << *(pv.get()) << std::endl << std::endl;
}
}
示例5: temp
void copy_DBR<dbr_long_t, pvInt, PVInt, PVIntArray>(const void * dbr, unsigned count, PVStructure::shared_pointer const & pvStructure)
{
if (count == 1)
{
std::tr1::shared_ptr<PVInt> value = std::tr1::static_pointer_cast<PVInt>(pvStructure->getSubField("value"));
value->put(static_cast<const int32*>(dbr)[0]);
}
else
{
std::tr1::shared_ptr<PVIntArray> value =
std::tr1::static_pointer_cast<PVIntArray>(pvStructure->getScalarArrayField("value", pvInt));
PVIntArray::svector temp(value->reuse());
temp.resize(count);
std::copy(static_cast<const int32*>(dbr), static_cast<const int32*>(dbr) + count, temp.begin());
value->replace(freeze(temp));
}
}
示例6: copy_DBR
void copy_DBR(const void * dbr, unsigned count, PVStructure::shared_pointer const & pvStructure)
{
if (count == 1)
{
std::tr1::shared_ptr<sF> value = std::tr1::static_pointer_cast<sF>(pvStructure->getSubField("value"));
value->put(static_cast<const pT*>(dbr)[0]);
}
else
{
std::tr1::shared_ptr<aF> value =
std::tr1::static_pointer_cast<aF>(pvStructure->getScalarArrayField("value", sT));
typename aF::svector temp(value->reuse());
temp.resize(count);
std::copy(static_cast<const pT*>(dbr), static_cast<const pT*>(dbr) + count, temp.begin());
value->replace(freeze(temp));
}
}
示例7: doPut_pvStructure
int doPut_pvStructure(CAChannel::shared_pointer const & channel, void *usrArg, PVStructure::shared_pointer const & pvStructure)
{
bool isScalarValue = pvStructure->getStructure()->getField("value")->getType() == scalar;
if (isScalarValue)
{
std::tr1::shared_ptr<sF> value = std::tr1::static_pointer_cast<sF>(pvStructure->getSubField("value"));
pT val = value->get();
int result = ca_array_put_callback(channel->getNativeType(), 1,
channel->getChannelID(), &val,
ca_put_handler, usrArg);
if (result == ECA_NORMAL)
{
ca_flush_io();
}
return result;
}
else
{
std::tr1::shared_ptr<aF> value =
std::tr1::static_pointer_cast<aF>(pvStructure->getScalarArrayField("value", sT));
const pT* val = value->view().data();
int result = ca_array_put_callback(channel->getNativeType(), static_cast<unsigned long>(value->getLength()),
channel->getChannelID(), val,
ca_put_handler, usrArg);
if (result == ECA_NORMAL)
{
ca_flush_io();
}
return result;
}
}
示例8: sA
void copy_DBR<string, pvString, PVString, PVStringArray>(const void * dbr, unsigned count, PVStructure::shared_pointer const & pvStructure)
{
if (count == 1)
{
std::tr1::shared_ptr<PVString> value = std::tr1::static_pointer_cast<PVString>(pvStructure->getSubField("value"));
value->put(std::string(static_cast<const char*>(dbr)));
}
else
{
std::tr1::shared_ptr<PVStringArray> value =
std::tr1::static_pointer_cast<PVStringArray>(pvStructure->getScalarArrayField("value", pvString));
const dbr_string_t* dbrStrings = static_cast<const dbr_string_t*>(dbr);
PVStringArray::svector sA(value->reuse());
sA.resize(count);
std::copy(dbrStrings, dbrStrings + count, sA.begin());
value->replace(freeze(sA));
}
}
示例9: stringArray
int doPut_pvStructure<string, pvString, PVString, PVStringArray>(CAChannel::shared_pointer const & channel, void *usrArg, PVStructure::shared_pointer const & pvStructure)
{
bool isScalarValue = pvStructure->getStructure()->getField("value")->getType() == scalar;
if (isScalarValue)
{
std::tr1::shared_ptr<PVString> value = std::tr1::static_pointer_cast<PVString>(pvStructure->getSubField("value"));
string val = value->get();
int result = ca_array_put_callback(channel->getNativeType(), 1,
channel->getChannelID(), val.c_str(),
ca_put_handler, usrArg);
if (result == ECA_NORMAL)
{
ca_flush_io();
}
return result;
}
else
{
std::tr1::shared_ptr<PVStringArray> value =
std::tr1::static_pointer_cast<PVStringArray>(pvStructure->getScalarArrayField("value", pvString));
PVStringArray::const_svector stringArray(value->view());
size_t arraySize = stringArray.size();
size_t ca_stringBufferSize = arraySize * MAX_STRING_SIZE;
char* ca_stringBuffer = new char[ca_stringBufferSize];
memset(ca_stringBuffer, 0, ca_stringBufferSize);
char *p = ca_stringBuffer;
for(size_t i = 0; i < arraySize; i++)
{
string value = stringArray[i];
size_t len = value.length();
if (len >= MAX_STRING_SIZE)
len = MAX_STRING_SIZE - 1;
memcpy(p, value.c_str(), len);
p += MAX_STRING_SIZE;
}
int result = ca_array_put_callback(channel->getNativeType(), arraySize,
channel->getChannelID(), ca_stringBuffer,
ca_put_handler, usrArg);
delete[] ca_stringBuffer;
if (result == ECA_NORMAL)
{
ca_flush_io();
}
return result;
}
}