本文整理汇总了C++中StandardFieldPtr::scalar方法的典型用法代码示例。如果您正苦于以下问题:C++ StandardFieldPtr::scalar方法的具体用法?C++ StandardFieldPtr::scalar怎么用?C++ StandardFieldPtr::scalar使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StandardFieldPtr
的用法示例。
在下文中一共展示了StandardFieldPtr::scalar方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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));
}
示例2: init
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");
}
}
}
示例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: test
static void test()
{
std::ostringstream oss;
testDiag("\ntestBitSetUtil\n");
StringArray fieldNames;
PVFieldPtrArray pvFields;
fieldNames.reserve(5);
pvFields.reserve(5);
fieldNames.push_back("timeStamp");
fieldNames.push_back("alarm");
fieldNames.push_back("voltage");
fieldNames.push_back("power");
fieldNames.push_back("current");
pvFields.push_back(
pvDataCreate->createPVStructure(standardField->timeStamp()));
pvFields.push_back(
pvDataCreate->createPVStructure(standardField->alarm()));
pvFields.push_back(
pvDataCreate->createPVStructure(
standardField->scalar(pvDouble,"alarm")));
pvFields.push_back(
pvDataCreate->createPVStructure(
standardField->scalar(pvDouble,"alarm")));
pvFields.push_back(
pvDataCreate->createPVStructure(
standardField->scalar(pvDouble,"alarm")));
PVStructurePtr pvs = pvDataCreate->createPVStructure(
fieldNames,pvFields);
int32 nfields = (int32)pvs->getNumberFields();
BitSetPtr bitSet = BitSet::create(nfields);
for(int32 i=0; i<nfields; i++) bitSet->set(i);
BitSetUtil::compress(bitSet,pvs);
bitSet->clear();
PVFieldPtr pvField = pvs->getSubField<PVStructure>("timeStamp");
int32 offsetTimeStamp = (int32)pvField->getFieldOffset();
pvField = pvs->getSubField<PVLong>("timeStamp.secondsPastEpoch");
int32 offsetSeconds = (int32)pvField->getFieldOffset();
pvField = pvs->getSubField<PVInt>("timeStamp.nanoseconds");
int32 offsetNano = (int32)pvField->getFieldOffset();
pvField = pvs->getSubField<PVInt>("timeStamp.userTag");
int32 offsetUserTag = (int32)pvField->getFieldOffset();
bitSet->set(offsetSeconds);
BitSetUtil::compress(bitSet,pvs);
testOk1(bitSet->get(offsetSeconds)==true);
bitSet->set(offsetNano);
bitSet->set(offsetUserTag);
BitSetUtil::compress(bitSet,pvs);
testOk1(bitSet->get(offsetSeconds)==false);
testOk1(bitSet->get(offsetTimeStamp)==true);
bitSet->clear();
pvField = pvs->getSubField<PVStructure>("current");
int32 offsetCurrent = (int32)pvField->getFieldOffset();
pvField = pvs->getSubField<PVDouble>("current.value");
int32 offsetValue = (int32)pvField->getFieldOffset();
pvField = pvs->getSubField<PVStructure>("current.alarm");
int32 offsetAlarm = (int32)pvField->getFieldOffset();
pvField = pvs->getSubField<PVInt>("current.alarm.severity");
int32 offsetSeverity = (int32)pvField->getFieldOffset();
pvField = pvs->getSubField<PVInt>("current.alarm.status");
int32 offsetStatus = (int32)pvField->getFieldOffset();
pvField = pvs->getSubField<PVString>("current.alarm.message");
int32 offsetMessage = (int32)pvField->getFieldOffset();
bitSet->set(offsetValue);
bitSet->set(offsetSeverity);
bitSet->set(offsetStatus);
bitSet->set(offsetMessage);
BitSetUtil::compress(bitSet,pvs);
testOk1(bitSet->get(offsetCurrent)==true);
bitSet->clear();
bitSet->set(offsetSeverity);
bitSet->set(offsetStatus);
bitSet->set(offsetMessage);
BitSetUtil::compress(bitSet,pvs);
testOk1(bitSet->get(offsetAlarm)==true);
bitSet->clear();
printf("testBitSetUtil PASSED\n");
}