Exemplo n.º 1
0
void ChannelPutGetLocal::putGet(
    PVStructurePtr const &pvPutStructure,BitSetPtr const &putBitSet)
{
    ChannelPutGetRequester::shared_pointer requester = channelPutGetRequester.lock();
    if(!requester) return;
    if(isDestroyed) {
         requester->putGetDone(
             channelDestroyedStatus,getPtrSelf(),nullPVStructure,nullBitSet);
         return;
    } 
    try {
        {
            epicsGuard <PVRecord> guard(*pvRecord);
            pvRecord->beginGroupPut();
            pvPutCopy->updateMaster(pvPutStructure, putBitSet);
            if(callProcess) pvRecord->process();
            getBitSet->clear();
            pvGetCopy->updateCopySetBitSet(pvGetStructure, getBitSet);
            pvRecord->endGroupPut();
        }
        requester->putGetDone(
            Status::Ok,getPtrSelf(),pvGetStructure,getBitSet);
        if(pvRecord->getTraceLevel()>1)
        {
            cout << "ChannelPutGetLocal::putGet" << endl;
        }
    } catch(std::exception& ex) {
        Status status = Status(Status::STATUSTYPE_FATAL, ex.what());
        requester->putGetDone(status,getPtrSelf(),pvGetStructure,getBitSet);
    }
}
Exemplo n.º 2
0
static void testPVScalar(
    string const & valueNameMaster,
    string const & valueNameCopy,
    PVStructurePtr const & pvMaster,
    PVCopyPtr const & pvCopy)
{
    PVStructurePtr pvStructureCopy;
    PVScalarPtr pvValueMaster;
    PVScalarPtr pvValueCopy;
    BitSetPtr bitSet;
    size_t offset;
    ConvertPtr convert = getConvert();

    pvValueMaster = pvMaster->getSubField<PVScalar>(valueNameMaster);
    convert->fromDouble(pvValueMaster,.04);
    StructureConstPtr structure = pvCopy->getStructure();
    if(debug) { cout << "structure from copy" << endl << *structure << endl; }
    pvStructureCopy = pvCopy->createPVStructure();
    pvValueCopy = pvStructureCopy->getSubField<PVScalar>(valueNameCopy);
    bitSet = BitSetPtr(new BitSet(pvStructureCopy->getNumberFields()));
    pvCopy->initCopy(pvStructureCopy, bitSet);
    if(debug) { cout << "after initCopy pvValueCopy " << convert->toDouble(pvValueCopy); }
    if(debug) { cout << endl; }
    convert->fromDouble(pvValueMaster,.06);
    testOk1(convert->toDouble(pvValueCopy)==.04);
    pvCopy->updateCopySetBitSet(pvStructureCopy,bitSet);
    testOk1(convert->toDouble(pvValueCopy)==.06);
    testOk1(bitSet->get(pvValueCopy->getFieldOffset()));
    if(debug) { cout << "after put(.06) pvValueCopy " << convert->toDouble(pvValueCopy); }
    if(debug) { cout << " bitSet " << *bitSet; }
    if(debug) { cout << endl; }
    offset = pvCopy->getCopyOffset(pvValueMaster);
    if(debug) { cout << "getCopyOffset() " << offset; }
    if(debug) { cout << " pvValueCopy->getOffset() " << pvValueCopy->getFieldOffset(); }
    if(debug) { cout << " pvValueMaster->getOffset() " << pvValueMaster->getFieldOffset(); }
    if(debug) { cout << " bitSet " << *bitSet; }
    if(debug) { cout << endl; }
    bitSet->clear();
    convert->fromDouble(pvValueMaster,1.0);
    if(debug) { cout << "before updateCopyFromBitSet"; }
    if(debug) { cout << " masterValue " << convert->toDouble(pvValueMaster); }
    if(debug) { cout << " copyValue " << convert->toDouble(pvValueCopy); }
    if(debug) { cout << " bitSet " << *bitSet; }
    if(debug) { cout << endl; }
    bitSet->set(0);
    testOk1(convert->toDouble(pvValueCopy)==0.06);
    pvCopy->updateCopyFromBitSet(pvStructureCopy,bitSet);
    testOk1(convert->toDouble(pvValueCopy)==1.0);
    if(debug) { cout << "after updateCopyFromBitSet"; }
    if(debug) { cout << " masterValue " << convert->toDouble(pvValueMaster); }
    if(debug) { cout << " copyValue " << convert->toDouble(pvValueCopy); }
    if(debug) { cout << " bitSet " << *bitSet; }
    if(debug) { cout << endl; }
    convert->fromDouble(pvValueCopy,2.0);
    bitSet->set(0);
    if(debug) { cout << "before updateMaster"; }
    if(debug) { cout << " masterValue " << convert->toDouble(pvValueMaster); }
    if(debug) { cout << " copyValue " << convert->toDouble(pvValueCopy); }
    if(debug) { cout << " bitSet " << *bitSet; }
    if(debug) { cout << endl; }
    testOk1(convert->toDouble(pvValueMaster)==1.0);
    pvCopy->updateMaster(pvStructureCopy,bitSet);
    testOk1(convert->toDouble(pvValueMaster)==2.0);
    if(debug) { cout << "after updateMaster"; }
    if(debug) { cout << " masterValue " << convert->toDouble(pvValueMaster); }
    if(debug) { cout << " copyValue " << convert->toDouble(pvValueCopy); }
    if(debug) { cout << " bitSet " << *bitSet; }
    if(debug) { cout << endl; }
}
Exemplo n.º 3
0
static void testPVScalarArray(
    string const & valueNameMaster,
    string const & valueNameCopy,
    PVStructurePtr const & pvMaster,
    PVCopyPtr const & pvCopy)
{
    PVStructurePtr pvStructureCopy;
    PVScalarArrayPtr pvValueMaster;
    PVScalarArrayPtr pvValueCopy;
    BitSetPtr bitSet;
    size_t offset;
    size_t n = 5;
    shared_vector<double> values(n);
    shared_vector<const double> cvalues;

    pvValueMaster = pvMaster->getSubField<PVScalarArray>(valueNameMaster);
    for(size_t i=0; i<n; i++) values[i] = i;
    const shared_vector<const double> xxx(freeze(values));
    pvValueMaster->putFrom(xxx);
    StructureConstPtr structure = pvCopy->getStructure();
    if(debug) { cout << "structure from copy" << endl << *structure << endl;}
    pvStructureCopy = pvCopy->createPVStructure();
    pvValueCopy = pvStructureCopy->getSubField<PVScalarArray>(valueNameCopy);
    bitSet = BitSetPtr(new BitSet(pvStructureCopy->getNumberFields()));
    pvCopy->initCopy(pvStructureCopy, bitSet);
    if(debug) { cout << "after initCopy pvValueCopy " << *pvValueCopy << endl; }
    if(debug) { cout << endl; }
    values.resize(n);
    for(size_t i=0; i<n; i++) values[i] = i + .06;
    const shared_vector<const double> yyy(freeze(values));
    pvValueMaster->putFrom(yyy);
    pvValueCopy->getAs(cvalues);
    testOk1(cvalues[0]==0.0);
    pvCopy->updateCopySetBitSet(pvStructureCopy,bitSet);
    pvValueCopy->getAs(cvalues);
    testOk1(cvalues[0]==0.06);
    if(debug) { cout << "after put(i+ .06) pvValueCopy " << *pvValueCopy << endl; }
    if(debug) { cout << " bitSet " << *bitSet; }
    if(debug) { cout << endl; }
    offset = pvCopy->getCopyOffset(pvValueMaster);
    if(debug) { cout << "getCopyOffset() " << offset; }
    if(debug) { cout << " pvValueCopy->getOffset() " << pvValueCopy->getFieldOffset(); }
    if(debug) { cout << " pvValueMaster->getOffset() " << pvValueMaster->getFieldOffset(); }
    if(debug) { cout << " bitSet " << *bitSet; }
    if(debug) { cout << endl; }
    bitSet->clear();
    values.resize(n);
    for(size_t i=0; i<n; i++) values[i] = i + 1.0;
    const shared_vector<const double> zzz(freeze(values));
    pvValueMaster->putFrom(zzz);
    if(debug) { cout << "before updateCopyFromBitSet"; }
    if(debug) { cout << " masterValue " << *pvValueMaster << endl; }
    if(debug) { cout << " copyValue " << *pvValueCopy << endl; }
    if(debug) { cout << " bitSet " << *bitSet; }
    if(debug) { cout << endl; }
    bitSet->set(0);
    pvValueCopy->getAs(cvalues);
    testOk1(cvalues[0]==0.06);
    pvCopy->updateCopyFromBitSet(pvStructureCopy,bitSet);
    pvValueCopy->getAs(cvalues);
    testOk1(cvalues[0]==1.0);
    if(debug) { cout << "after updateCopyFromBitSet"; }
    if(debug) { cout << " masterValue " << *pvValueMaster << endl; }
    if(debug) { cout << " copyValue " << *pvValueCopy << endl; }
    if(debug) { cout << " bitSet " << *bitSet; }
    if(debug) { cout << endl; }
    values.resize(n);
    for(size_t i=0; i<n; i++) values[i] = i + 2.0;
    const shared_vector<const double> ttt(freeze(values));
    pvValueMaster->putFrom(ttt);
    bitSet->set(0);
    if(debug) { cout << "before updateMaster"; }
    if(debug) { cout << " masterValue " << *pvValueMaster << endl; }
    if(debug) { cout << " copyValue " << *pvValueCopy << endl; }
    if(debug) { cout << " bitSet " << *bitSet; }
    if(debug) { cout << endl; }
    pvValueMaster->getAs(cvalues);
    testOk1(cvalues[0]==2.0);
    pvCopy->updateMaster(pvStructureCopy,bitSet);
    pvValueMaster->getAs(cvalues);
    testOk1(cvalues[0]==1.0);
    if(debug) { cout << "before updateMaster"; }
    if(debug) { cout << " masterValue " << *pvValueMaster << endl; }
    if(debug) { cout << " copyValue " << *pvValueCopy << endl; }
    if(debug) { cout << " bitSet " << *bitSet; }
    if(debug) { cout << endl; }
}
Exemplo n.º 4
0
static void testPVScalar(
    string const & valueNameRecord,
    string const & valueNameCopy,
    PVRecordPtr const & pvRecord,
    PVCopyPtr const & pvCopy)
{
    PVStructurePtr pvStructureRecord;
    PVStructurePtr pvStructureCopy;
    PVFieldPtr pvField;
    PVScalarPtr pvValueRecord;
    PVScalarPtr pvValueCopy;
    BitSetPtr bitSet;
    size_t offset;
    ConvertPtr convert = getConvert();

    cout << endl;
    pvStructureRecord = pvRecord->getPVRecordStructure()->getPVStructure();
    pvField = pvStructureRecord->getSubField(valueNameRecord);
    pvValueRecord = static_pointer_cast<PVScalar>(pvField);
    convert->fromDouble(pvValueRecord,.04);
    StructureConstPtr structure = pvCopy->getStructure();
    cout << "structure from copy" << endl << *structure << endl;
    pvStructureCopy = pvCopy->createPVStructure();
    pvField = pvStructureCopy->getSubField(valueNameCopy);
    pvValueCopy = static_pointer_cast<PVScalar>(pvField);
    bitSet = BitSetPtr(new BitSet(pvStructureCopy->getNumberFields()));
    pvCopy->initCopy(pvStructureCopy, bitSet);
    cout << "after initCopy pvValueCopy " << convert->toDouble(pvValueCopy);
    cout << endl;
    convert->fromDouble(pvValueRecord,.06);
    pvCopy->updateCopySetBitSet(pvStructureCopy,bitSet);
    cout << "after put(.06) pvValueCopy " << convert->toDouble(pvValueCopy);
    cout << " bitSet " << *bitSet;
    cout << endl;
    offset = pvCopy->getCopyOffset(pvValueRecord);
    cout << "getCopyOffset() " << offset;
    cout << " pvValueCopy->getOffset() " << pvValueCopy->getFieldOffset();
    cout << " pvValueRecord->getOffset() " << pvValueRecord->getFieldOffset();
    cout << " bitSet " << *bitSet;
    cout << endl;
    bitSet->clear();
    convert->fromDouble(pvValueRecord,1.0);
    cout << "before updateCopyFromBitSet";
    cout << " recordValue " << convert->toDouble(pvValueRecord);
    cout << " copyValue " << convert->toDouble(pvValueCopy);
    cout << " bitSet " << *bitSet;
    cout << endl;
    bitSet->set(0);
    pvCopy->updateCopyFromBitSet(pvStructureCopy,bitSet);
    cout << "after updateCopyFromBitSet";
    cout << " recordValue " << convert->toDouble(pvValueRecord);
    cout << " copyValue " << convert->toDouble(pvValueCopy);
    cout << " bitSet " << *bitSet;
    cout << endl;
    convert->fromDouble(pvValueCopy,2.0);
    bitSet->set(0);
    cout << "before updateMaster";
    cout << " recordValue " << convert->toDouble(pvValueRecord);
    cout << " copyValue " << convert->toDouble(pvValueCopy);
    cout << " bitSet " << *bitSet;
    cout << endl;
    pvCopy->updateMaster(pvStructureCopy,bitSet);
    cout << "after updateMaster";
    cout << " recordValue " << convert->toDouble(pvValueRecord);
    cout << " copyValue " << convert->toDouble(pvValueCopy);
    cout << " bitSet " << *bitSet;
    cout << endl;
}
Exemplo n.º 5
0
static void testPVScalarArray(
    ScalarType scalarType,
    string const & valueNameRecord,
    string const & valueNameCopy,
    PVRecordPtr const & pvRecord,
    PVCopyPtr const & pvCopy)
{
    PVStructurePtr pvStructureRecord;
    PVStructurePtr pvStructureCopy;
    PVScalarArrayPtr pvValueRecord;
    PVScalarArrayPtr pvValueCopy;
    BitSetPtr bitSet;
    size_t offset;
    size_t n = 5;
    shared_vector<double> values(n);
    cout << endl;
    pvStructureRecord = pvRecord->getPVRecordStructure()->getPVStructure();
    pvValueRecord = pvStructureRecord->getScalarArrayField(valueNameRecord,scalarType);
    for(size_t i=0; i<n; i++) values[i] = i;
    const shared_vector<const double> xxx(freeze(values));
    pvValueRecord->putFrom(xxx);
    StructureConstPtr structure = pvCopy->getStructure();
    cout << "structure from copy" << endl << *structure << endl;
    pvStructureCopy = pvCopy->createPVStructure();
    pvValueCopy = pvStructureCopy->getScalarArrayField(valueNameCopy,scalarType);
    bitSet = BitSetPtr(new BitSet(pvStructureCopy->getNumberFields()));
    pvCopy->initCopy(pvStructureCopy, bitSet);
    cout << "after initCopy pvValueCopy " << *pvValueCopy << endl;
    cout << endl;
    values.resize(n);
    for(size_t i=0; i<n; i++) values[i] = i + .06;
    const shared_vector<const double> yyy(freeze(values));
    pvValueRecord->putFrom(yyy);
    pvCopy->updateCopySetBitSet(pvStructureCopy,bitSet);
    cout << "after put(i+ .06) pvValueCopy " << *pvValueCopy << endl;
    cout << " bitSet " << *bitSet;
    cout << endl;
    offset = pvCopy->getCopyOffset(pvValueRecord);
    cout << "getCopyOffset() " << offset;
    cout << " pvValueCopy->getOffset() " << pvValueCopy->getFieldOffset();
    cout << " pvValueRecord->getOffset() " << pvValueRecord->getFieldOffset();
    cout << " bitSet " << *bitSet;
    cout << endl;
    bitSet->clear();
    values.resize(n);
    for(size_t i=0; i<n; i++) values[i] = i + 1.0;
    const shared_vector<const double> zzz(freeze(values));
    pvValueRecord->putFrom(zzz);
    cout << "before updateCopyFromBitSet";
    cout << " recordValue " << *pvValueRecord << endl;
    cout << " copyValue " << *pvValueCopy << endl;
    cout << " bitSet " << *bitSet;
    cout << endl;
    bitSet->set(0);
    pvCopy->updateCopyFromBitSet(pvStructureCopy,bitSet);
    cout << "after updateCopyFromBitSet";
    cout << " recordValue " << *pvValueRecord << endl;
    cout << " copyValue " << *pvValueCopy << endl;
    cout << " bitSet " << *bitSet;
    cout << endl;
    values.resize(n);
    for(size_t i=0; i<n; i++) values[i] = i + 2.0;
    const shared_vector<const double> ttt(freeze(values));
    pvValueRecord->putFrom(ttt);
    bitSet->set(0);
    cout << "before updateMaster";
    cout << " recordValue " << *pvValueRecord << endl;
    cout << " copyValue " << *pvValueCopy << endl;
    cout << " bitSet " << *bitSet;
    cout << endl;
    pvCopy->updateMaster(pvStructureCopy,bitSet);
    cout << "after updateMaster";
    cout << " recordValue " << *pvValueRecord << endl;
    cout << " copyValue " << *pvValueRecord << endl;
    cout << " bitSet " << *bitSet;
    cout << endl;
}