示例#1
0
bool RecordListRecord::init()
{
    initPVRecord();
    PVStructurePtr pvStructure = getPVStructure();
    database = pvStructure->getStringField("argument.database");
    if(database.get()==NULL) return false;
    regularExpression = pvStructure->getStringField(
        "argument.regularExpression");
    if(regularExpression.get()==NULL) return false;
    status = pvStructure->getStringField("result.status");
    if(status.get()==NULL) return false;
    PVFieldPtr pvField = pvStructure->getSubField("result.names");
    if(pvField.get()==NULL) {
        std::cerr << "no result.names" << std::endl;
        return false;
    }
    name = static_pointer_cast<PVStringArray>(
         pvStructure->getScalarArrayField("result.names",pvString));
    if(name.get()==NULL) return false;
    return true;
}
示例#2
0
bool PVDisplay::attach(PVFieldPtr const & pvField)
{
    if(pvField->getField()->getType()!=structure) {
            pvField->message(noDisplayFound,errorMessage);
            return false;
    }
    PVStructurePtr pvStructure = static_pointer_cast<PVStructure>(pvField);
    pvDescription = pvStructure->getStringField("description");
    if(pvDescription.get()==NULL) {
        pvField->message(noDisplayFound,errorMessage);
        return false;
    }
    pvFormat = pvStructure->getStringField("format");
    if(pvFormat.get()==NULL) {
        pvField->message(noDisplayFound,errorMessage);
        detach();
        return false;
    }
    pvUnits = pvStructure->getStringField("units");
    if(pvUnits.get()==NULL) {
        pvField->message(noDisplayFound,errorMessage);
        detach();
        return false;
    }
    pvLow = pvStructure->getDoubleField(String("limitLow"));
    if(pvLow.get()==NULL) {
        pvField->message(noDisplayFound,errorMessage);
        detach();
        return false;
    }
    pvHigh = pvStructure->getDoubleField(String("limitHigh"));
    if(pvHigh.get()==NULL) {
        pvField->message(noDisplayFound,errorMessage);
        detach();
        return false;
    }
    return true;
}
示例#3
0
bool PVAlarm::attach(PVFieldPtr const & pvField)
{
    if(pvField->getField()->getType()!=structure) return false;
    PVStructurePtr pvStructure = static_pointer_cast<PVStructure>(pvField);
    pvSeverity = pvStructure->getIntField("severity");
    if(pvSeverity.get()==NULL) return false;
    pvStatus = pvStructure->getIntField("status");
    if(pvStatus.get()==NULL) {
        pvSeverity.reset();
        return false;
    }
    pvMessage = pvStructure->getStringField("message");
    if(pvMessage.get()==NULL) {
        pvSeverity.reset();
        pvStatus.reset();
        return false;
    }
    return true;
}
/**
 * Creates an NTURI request.
 *
 * @param  path          the value of the NTURI path field
 * @param  fieldnames    the names of fields in the NTURI query
 * @return values        the values of fields in the NTURI query
 */
PVStructurePtr createRequest(const std::string & path,
    const std::vector<std::string> & fieldnames,
    const std::vector<std::string> & values)
{    
    StructureConstPtr archiverStructure = makeRequestStructure(*getFieldCreate(), fieldnames);
    PVStructurePtr request(getPVDataCreate()->createPVStructure(archiverStructure));

    // set scheme.
    request->getStringField("scheme")->put("pva");

    // set path.
    request->getStringField("path")->put(path);

    // Set query.
    PVStructurePtr query = request->getStructureField("query");

    for (size_t i = 0; i < fieldnames.size(); ++i)
    {
        query->getStringField(fieldnames[i])->put(values[i]);
    }
 
    return request;
}