示例#1
0
void RecordProcess::initialize()
{
    pvRecord.lock();
    try {
        if(trace) traceMessage(" initialize");
        PVRecordStructure &pvRecordStructure = pvRecord.getPVRecordStructure();
        PVStructure &pvStructure = pvRecordStructure.getPVStructure();
        fieldSupport = const_cast<Support *>(pvRecordStructure.getSupport());
        if(fieldSupport==0) {
            throw std::logic_error(pvRecord.getRecordName() + " has no support");
        }
        PVFieldPtrArray pvFields = pvStructure.getPVFields();
        PVRecordFieldPtrArray pvRecordFields =
            pvRecordStructure.getPVRecordFields();
        StructureConstPtr structure = pvStructure.getStructure();
        int index;
        index = structure->getFieldIndex("timeStamp");
        if(index>=0) {
            pvTimeStamp.attach(pvFields[index]);
        }
        index = structure->getFieldIndex("scan");
        if(index>=0) {
            scanSupport = pvRecordFields[index]->getSupport();
            scanField = ScanField::create(pvRecord);
            if(scanField.get()!=0) {
            	pvSingleProcessRequester = 
                     &scanField->getSingleProcessRequesterPV();
            	pvRecordFieldSingleProcessRequester =
                     &pvRecord.findPVRecordField(*pvSingleProcessRequester);
                pvProcessAfterStart = &scanField->getProcessAfterStartPV();
            }
        }
        fieldSupport->initialize();
        pvRecord.unlock();
    } catch(...) {
        pvRecord.unlock();
        throw;
    }
}
示例#2
0
void PVStructure::fixParentStructure()
{
    PVStructure *parent = getParent();
    if(parent==NULL) return;
    StructureConstPtr parentStructure = parent->structurePtr;
    String fieldName = getFieldName();
    size_t index = parentStructure->getFieldIndex(fieldName);
    StringArray const &fieldNames = parentStructure->getFieldNames();
    size_t num = fieldNames.size();
    FieldConstPtrArray fields(num);
    FieldConstPtrArray const & oldFields = parentStructure->getFields();
    for(size_t i=0; i< num; i++) {
        if(i==index) {
            fields[i] = structurePtr;
        } else {
            fields[i] = oldFields[i];
        }
    }
    FieldConstPtr field = getFieldCreate()->createStructure(
        parentStructure->getID(),fieldNames,fields);
    parent->replaceField(field);
    parent->fixParentStructure();
}