本文整理汇总了C++中PVDataCreatePtr类的典型用法代码示例。如果您正苦于以下问题:C++ PVDataCreatePtr类的具体用法?C++ PVDataCreatePtr怎么用?C++ PVDataCreatePtr使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PVDataCreatePtr类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: fromString
size_t fromString(PVStructureArrayPtr const &pv, StringArray const & from, size_t fromStartIndex = 0)
{
int processed = 0;
size_t fromValueCount = from.size();
// first get count
if (fromStartIndex >= fromValueCount)
throw std::runtime_error("not enough of values");
size_t numberOfStructures;
istringstream iss(from[fromStartIndex]);
iss >> numberOfStructures;
// not fail and entire value is parsed (e.g. to detect 1.2 parsing to 1)
if (iss.fail() || !iss.eof())
throw runtime_error("failed to parse element count value (uint) of field '" + pv->getFieldName() + "' from string value '" + from[fromStartIndex] + "'");
fromStartIndex++;
processed++;
PVStructureArray::svector pvStructures;
pvStructures.reserve(numberOfStructures);
PVDataCreatePtr pvDataCreate = getPVDataCreate();
for (size_t i = 0; i < numberOfStructures; ++i)
{
PVStructurePtr pvStructure = pvDataCreate->createPVStructure(pv->getStructureArray()->getStructure());
size_t count = fromString(pvStructure, from, fromStartIndex);
processed += count;
fromStartIndex += count;
pvStructures.push_back(pvStructure);
}
pv->replace(freeze(pvStructures));
return processed;
}
示例2: asynPrint
void pvaDriver::monitorConnect (Status const & status,
MonitorPtr const & monitor, StructureConstPtr const & structure)
{
const char *functionName = "monitorConnect";
asynPrint(pasynUserSelf, ASYN_TRACE_FLOW,
"%s::%s monitor connects [type=%s]\n",
driverName, functionName, Status::StatusTypeName[status.getType()]);
if (status.isSuccess())
{
PVDataCreatePtr PVDC = getPVDataCreate();
if(!NTNDArray::isCompatible(PVDC->createPVStructure(structure)))
{
asynPrint(pasynUserSelf, ASYN_TRACE_ERROR,
"%s::%s incompatible PVStructure. Not starting monitor\n",
driverName, functionName);
return;
}
asynPrint(pasynUserSelf, ASYN_TRACE_FLOW,
"%s::%s starting monitor\n",
driverName, functionName);
monitor->start();
}
}
示例3: data
void PVUnionArray::deserialize(ByteBuffer *pbuffer,
DeserializableControl *pcontrol) {
svector data(reuse());
size_t size = this->getArray()->getArraySizeType() == Array::fixed ?
this->getArray()->getMaximumCapacity() :
SerializeHelper::readSize(pbuffer, pcontrol);
data.resize(size);
UnionConstPtr punion = unionArray->getUnion();
PVDataCreatePtr pvDataCreate = getPVDataCreate();
for(size_t i = 0; i<size; i++) {
pcontrol->ensureData(1);
size_t temp = pbuffer->getByte();
if(temp==0) {
data[i].reset();
}
else {
if(data[i].get()==NULL || !data[i].unique()) {
data[i] = pvDataCreate->createPVUnion(punion);
}
data[i]->deserialize(pbuffer, pcontrol);
}
}
replace(freeze(data)); // calls postPut()
}
示例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: 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;
}
示例6: xx
// TODO not thread-safe (local static initializers)
// TODO replace with non-locking singleton pattern
PVDataCreatePtr PVDataCreate::getPVDataCreate()
{
static PVDataCreatePtr pvDataCreate;
static Mutex mutex;
Lock xx(mutex);
if(pvDataCreate.get()==0) pvDataCreate = PVDataCreatePtr(new PVDataCreate());
return pvDataCreate;
}
示例7: getFieldCreate
RPCService::shared_pointer ExampleHelloRPC::create()
{
FieldCreatePtr fieldCreate = getFieldCreate();
PVDataCreatePtr pvDataCreate = getPVDataCreate();
StructureConstPtr topStructure = fieldCreate->createFieldBuilder()->
add("value",pvString)->
createStructure();
PVStructurePtr pvStructure = pvDataCreate->createPVStructure(topStructure);
ExampleHelloRPCPtr hello(
new ExampleHelloRPC(pvStructure));
return hello;
}
示例8: getPVDataCreate
void oleaClient::monitorConnect (Status const & status,
MonitorPtr const & monitor, StructureConstPtr const & structure)
{
if (status.isSuccess())
{
PVDataCreatePtr PVDC = getPVDataCreate();
if(!NTTable::isCompatible(PVDC->createPVStructure(structure)))
{
cout << "No NTTable support" << endl;
return;
}
monitor->start();
}
}
示例9: PVField
PVStructure::PVStructure(StructureConstPtr const & structurePtr)
: PVField(structurePtr),
structurePtr(structurePtr),
extendsStructureName("")
{
size_t numberFields = structurePtr->getNumberFields();
FieldConstPtrArray fields = structurePtr->getFields();
StringArray fieldNames = structurePtr->getFieldNames();
// PVFieldPtrArray * xxx = const_cast<PVFieldPtrArray *>(&pvFields);
pvFields.reserve(numberFields);
PVDataCreatePtr pvDataCreate = getPVDataCreate();
for(size_t i=0; i<numberFields; i++) {
pvFields.push_back(pvDataCreate->createPVField(fields[i]));
}
for(size_t i=0; i<numberFields; i++) {
pvFields[i]->setParentAndName(this,fieldNames[i]);
}
}
示例10: checkLength
size_t PVUnionArray::append(size_t number)
{
checkLength(value.size()+number);
svector data(reuse());
data.resize(data.size()+number);
UnionConstPtr punion = unionArray->getUnion();
PVDataCreatePtr pvDataCreate = getPVDataCreate();
for(svector::reverse_iterator it = data.rbegin(); number; ++it, --number)
*it = pvDataCreate->createPVUnion(punion);
size_t newLength = data.size();
const_svector cdata(freeze(data));
swap(cdata);
return newLength;
}
示例11: getFieldCreate
RecordListRecordPtr RecordListRecord::create(
std::string const & recordName)
{
FieldCreatePtr fieldCreate = getFieldCreate();
PVDataCreatePtr pvDataCreate = getPVDataCreate();
StructureConstPtr topStructure = fieldCreate->createFieldBuilder()->
addNestedStructure("argument")->
add("database",pvString)->
add("regularExpression",pvString)->
endNested()->
addNestedStructure("result") ->
add("status",pvString) ->
addArray("names",pvString) ->
endNested()->
createStructure();
PVStructurePtr pvStructure = pvDataCreate->createPVStructure(topStructure);
RecordListRecordPtr pvRecord(
new RecordListRecord(recordName,pvStructure));
if(!pvRecord->init()) pvRecord.reset();
return pvRecord;
}
示例12: 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;
}
示例13: 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());
}
示例14: setValue
static void setValue(PVUnionPtr const &pvUnion, double value)
{
UnionConstPtr u = pvUnion->getUnion();
FieldConstPtr field = u->getField(0);
Type type = field->getType();
if(type==scalar) {
ScalarConstPtr scalar = static_pointer_cast<const Scalar>(field);
ScalarType scalarType = scalar->getScalarType();
if(scalarType==pvDouble) {
PVDoublePtr pvValue = static_pointer_cast<PVDouble>(
pvDataCreate->createPVScalar(pvDouble));
pvValue->put(value);
pvUnion->set(0,pvValue);
return;
}
if(scalarType==pvString) {
PVStringPtr pvValue = static_pointer_cast<PVString>(
pvDataCreate->createPVScalar(pvString));
stringstream ss;
ss << "value" << value;
pvValue->put(ss.str());
pvUnion->set(0,pvValue);
return;
}
throw std::runtime_error("only pvDouble and pvString are supported");
}
if(type==scalarArray) {
ScalarArrayConstPtr scalarArray = static_pointer_cast<const ScalarArray>(field);
ScalarType scalarType = scalarArray->getElementType();
if(scalarType==pvDouble) {
size_t num = 5;
PVDoubleArrayPtr pvValue = static_pointer_cast<PVDoubleArray>(
pvDataCreate->createPVScalarArray(pvDouble));
shared_vector<double> data(num);
for(size_t i=0; i<num; ++i) data[i] = value +i;
pvValue->replace(freeze(data));
pvUnion->set(0,pvValue);
return;
}
if(scalarType==pvString) {
size_t num = 5;
PVStringArrayPtr pvValue = static_pointer_cast<PVStringArray>(
pvDataCreate->createPVScalarArray(pvString));
shared_vector<string> data(num);
for(size_t i=0; i<num; ++i) {
stringstream ss;
ss << "value" << value << i;
data[i] = ss.str();
}
pvValue->replace(freeze(data));
pvUnion->set(0,pvValue);
return;
}
throw std::runtime_error("only pvDouble and pvString are supported");
}
throw std::runtime_error("only scalar and scalarArray fields are supported");
}
示例15: 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;
}