Ejemplo n.º 1
0
bool ExampleLink::init()
{
    initPVRecord();

    PVStructurePtr pvStructure = getPVRecordStructure()->getPVStructure();
    pvValue = pvStructure->getSubField<PVDoubleArray>("value");
    if(!pvValue) {
        return false;
    }
    ChannelProvider::shared_pointer provider =
        getChannelProviderRegistry()->getProvider(providerName);
    if(!provider) {
         cout << getRecordName() << " provider "
              << providerName << " does not exist" << endl;
        return false;
    }
    ChannelRequester::shared_pointer channelRequester =
        dynamic_pointer_cast<ChannelRequester>(getPtrSelf());
    channel = provider->createChannel(channelName,channelRequester);
    event.wait();
    if(!status.isOK()) {
        cout << getRecordName() << " createChannel failed "
             << status.getMessage() << endl;
        return false;
    }
    PVStructurePtr pvRequest = CreateRequest::create()->createRequest(
        "value");
    MonitorRequester::shared_pointer  monitorRequester =
        dynamic_pointer_cast<MonitorRequester>(getPtrSelf());
    monitor = channel->createMonitor(monitorRequester,pvRequest);
    return true;
}
Ejemplo n.º 2
0
void DbPvPut::put(PVStructurePtr const &pvStructure, BitSetPtr const & bitSet)
{
    if(DbPvDebug::getLevel()>0) printf("dbPvPut::put()\n");
    Lock lock(dataMutex);
    this->pvStructure = pvStructure;
    this->bitSet = bitSet;
    PVFieldPtr pvField = pvStructure.get()->getPVFields()[0];
    if(propertyMask&dbUtil->dbPutBit) {
        Status status = dbUtil->putField(
            channelPutRequester,propertyMask,dbAddr,pvField);
        lock.unlock();
        channelPutRequester->putDone(status,getPtrSelf());
        return;
    }
    dbScanLock(dbAddr.precord);
    Status status = dbUtil->put(
                channelPutRequester, propertyMask, dbAddr, pvField);
    if (process && !block) dbProcess(dbAddr.precord);
    dbScanUnlock(dbAddr.precord);
    lock.unlock();
    if (block && process) {
        epicsUInt8 value = 1;
        pNotify.get()->pbuffer = &value;
        dbPutNotify(pNotify.get());
    } else {
        channelPutRequester->putDone(status, getPtrSelf());
    }
}
Ejemplo n.º 3
0
void PvaClientMonitor::monitorEvent(MonitorPtr const & monitor)
{
    if(isDestroyed) throw std::runtime_error("pvaClientMonitor was destroyed");
    PvaClientMonitorRequesterPtr req = pvaClientMonitorRequester.lock();
    if(req) req->event(getPtrSelf());
    if(userWait) waitForEvent.signal();
}
Ejemplo n.º 4
0
void DbPvPut::get()
{
    if(DbPvDebug::getLevel()>0) printf("dbPvPut::get()\n");
    {
        Lock lock(dataMutex);
        dbScanLock(dbChannelRecord(dbPv->getDbChannel()));
        bitSet->clear();
        Status status = dbUtil->get(
                    channelPutRequester,
                    propertyMask,
                    dbPv->getDbChannel(),
                    pvStructure,
                    bitSet,
                    0);
        dbScanUnlock(dbChannelRecord(dbPv->getDbChannel()));
        if(firstTime) {
            firstTime = false;
            bitSet->set(pvStructure->getFieldOffset());
        }
    }
    channelPutRequester->getDone(
                status,
                getPtrSelf(),
                pvStructure,
                bitSet);
}
Ejemplo n.º 5
0
void DbPvPut::put(PVStructurePtr const &pvStructure, BitSetPtr const & bitSet)
{
    if (DbPvDebug::getLevel() > 0) printf("dbPvPut::put()\n");

    this->pvStructure = pvStructure;
    this->bitSet = bitSet;

    if (block && process) {
        dbProcessNotify(pNotify.get());
        return;
    }

    Lock lock(dataMutex);
    PVFieldPtr pvField = pvStructure.get()->getPVFields()[0];
    if (propertyMask & dbUtil->dbPutBit) {
        status = dbUtil->putField(
                    channelPutRequester,
                    propertyMask,
                    dbPv->getDbChannel(),
                    pvField);
    } else {
        dbScanLock(dbChannelRecord(dbPv->getDbChannel()));
        status = dbUtil->put(
                    channelPutRequester, propertyMask, dbPv->getDbChannel(), pvField);
        if (process) dbProcess(dbChannelRecord(dbPv->getDbChannel()));
        dbScanUnlock(dbChannelRecord(dbPv->getDbChannel()));
    }
    lock.unlock();
    channelPutRequester->putDone(status, getPtrSelf());
}
Ejemplo n.º 6
0
bool ExampleLink::init()
{
    initPVRecord();

    PVStructurePtr pvStructure = getPVRecordStructure()->getPVStructure();
    pvTimeStamp.attach(pvStructure->getSubField("timeStamp"));
    pvAlarm.attach(pvStructure->getSubField("alarm"));
    pvValue = static_pointer_cast<PVDoubleArray>(
        pvStructure->getScalarArrayField("value",pvDouble));
    if(!pvValue) {
        return false;
    }
    ChannelProvider::shared_pointer provider =
        getChannelProviderRegistry()->getProvider(providerName);
    if(!provider) {
         cout << getRecordName() << " provider "
              << providerName << " does not exist" << endl;
        return false;
    }
    ChannelRequester::shared_pointer channelRequester =
        dynamic_pointer_cast<ChannelRequester>(getPtrSelf());
    channel = provider->createChannel(channelName,channelRequester);
    event.wait();
    if(!status.isOK()) {
        cout << getRecordName() << " createChannel failed "
             << status.getMessage() << endl;
        return false;
    }
    ChannelGetRequester::shared_pointer channelGetRequester =
        dynamic_pointer_cast<ChannelGetRequester>(getPtrSelf());
    PVStructurePtr pvRequest = CreateRequest::create()->createRequest(
        "value,alarm,timeStamp");
    channelGet = channel->createChannelGet(channelGetRequester,pvRequest);
    event.wait();
    if(!status.isOK()) {
        cout << getRecordName() << " createChannelGet failed "
             << status.getMessage() << endl;
        return false;
    }
    getPVValue = static_pointer_cast<PVDoubleArray>(
        getPVStructure->getScalarArrayField("value",pvDouble));
    if(!getPVValue) {
        cout << getRecordName() << " get value not  PVDoubleArray" << endl;
        return false;
    }
    return true;
}
Ejemplo n.º 7
0
bool NTNDArrayRecord::init()
{   
    initPVRecord();
    NTNDArrayRecordPtr xxx = dynamic_pointer_cast<NTNDArrayRecord>(getPtrSelf());
    ntndarrayServerThread = NTNDArrayRecordThreadPtr(new NTNDArrayRecordThread(xxx));
    ntndarrayServerThread->init();
    ntndarrayServerThread->start();
    return true;
}
Ejemplo n.º 8
0
ChannelProcess::shared_pointer DbPv::createChannelProcess(
        ChannelProcessRequester::shared_pointer const & channelProcessRequester,
        PVStructure::shared_pointer const & pvRequest)
{
    DbPvProcess::shared_pointer dbPvProcess(
          new DbPvProcess(getPtrSelf(),channelProcessRequester));
    dbPvProcess->init(pvRequest);
    return dbPvProcess;
}
PvaClientNTMultiMonitorPtr PvaClientMultiChannel::createNTMonitor(std::string const &request)
{
    checkConnected();
    PVStructurePtr pvRequest = createRequest->createRequest(request);
    if(!pvRequest) {
        string message = " PvaClientMultiChannel::createNTMonitor invalid pvRequest: "
             + createRequest->getMessage();
        throw std::runtime_error(message);
    }
    return PvaClientNTMultiMonitor::create(getPtrSelf(), pvaClientChannelArray,pvRequest);
}
Ejemplo n.º 10
0
bool DbPvPut::init(PVStructure::shared_pointer const &pvRequest)
{
    propertyMask = dbUtil->getProperties(
        channelPutRequester,
        pvRequest,
        dbAddr,
        true);
    if(propertyMask==dbUtil->noAccessBit) return false;
    if(propertyMask==dbUtil->noModBit) {
        channelPutRequester->message(
             "field not allowed to be changed",errorMessage);
        return 0;
    }
    pvStructure = PVStructure::shared_pointer(
        dbUtil->createPVStructure(
            channelPutRequester,
            propertyMask,
            dbAddr,
            pvRequest));
    if (!pvStructure.get()) return false;
    if (propertyMask & dbUtil->dbPutBit) {
        if (propertyMask & dbUtil->processBit) {
            channelPutRequester->message(
                        "process determined by dbPutField", errorMessage);
        }
    } else if (propertyMask&dbUtil->processBit) {
        process = true;
        pNotify.reset(new (struct putNotify)());
        notifyAddr.reset(new DbAddr());
        memcpy(notifyAddr.get(), &dbAddr, sizeof(DbAddr));
        DbAddr *paddr = notifyAddr.get();
        struct dbCommon *precord = paddr->precord;
        char buffer[sizeof(precord->name) + 10];
        strcpy(buffer, precord->name);
        strcat(buffer, ".PROC");
        if (dbNameToAddr(buffer, paddr)) {
            throw std::logic_error("dbNameToAddr failed");
        }
        struct putNotify *pn = pNotify.get();
        pn->userCallback = this->notifyCallback;
        pn->paddr        = paddr;
        pn->nRequest     = 1;
        pn->dbrType      = DBR_CHAR;
        pn->usrPvt       = this;
        if (propertyMask & dbUtil->blockBit) block = true;
    }
    int numFields = pvStructure->getNumberFields();
    bitSet.reset(new BitSet(numFields));
    channelPutRequester->channelPutConnect(
       Status::Ok,
       getPtrSelf(),
       pvStructure->getStructure());
    return true;
}
Ejemplo n.º 11
0
bool ExampleMonitorLinkRecord::init(PvaClientPtr const & pva,string const & channelName,string const & providerName)
{
    initPVRecord();

    PVStructurePtr pvStructure = getPVRecordStructure()->getPVStructure();
    pvValue = pvStructure->getSubField<PVDoubleArray>("value");
    if(!pvValue) {
        return false;
    }
    PvaClientChannelPtr pvaClientChannel = pva->channel(channelName,providerName,0.0);
    monitorRequester = dynamic_pointer_cast<PvaClientMonitorRequester>(getPtrSelf());
    pvaClientMonitor = pvaClientChannel->monitor("value",monitorRequester);
    return true;
}
Ejemplo n.º 12
0
void PvaClientMonitor::issueConnect()
{
    if(isDestroyed) throw std::runtime_error("pvaClientMonitor was destroyed");
    if(connectState!=connectIdle) {
        string message = string("channel ") + channel->getChannelName() 
            + " pvaClientMonitor already connected ";
        throw std::runtime_error(message);
    }
    MonitorRequester::shared_pointer  monitorRequester =
        dynamic_pointer_cast<MonitorRequester>(getPtrSelf());
    //monitorRequester = ChannelMonitorRequester::shared_pointer(new ChannelMonitorRequester(this));
    connectState = connectActive;
    monitor = channel->createMonitor(monitorRequester,pvRequest);
}
Ejemplo n.º 13
0
ChannelPut::shared_pointer DbPv::createChannelPut(
        ChannelPutRequester::shared_pointer const &channelPutRequester,
        PVStructure::shared_pointer const &pvRequest)
{
    DbPvPut::shared_pointer dbPvPut(
          new DbPvPut(getPtrSelf(),channelPutRequester));
    if(!dbPvPut->init(pvRequest)) {
        Status createFailed(Status::STATUSTYPE_ERROR, "create dbPvPut failed");
        channelPutRequester->channelPutConnect(
            createFailed,
            dbPvPut,
            nullStructure);
    }
    return dbPvPut;
}
Ejemplo n.º 14
0
ChannelArray::shared_pointer DbPv::createChannelArray(
        ChannelArrayRequester::shared_pointer const &channelArrayRequester,
        PVStructure::shared_pointer const &pvRequest)
{
    DbPvArray::shared_pointer dbPvArray(
         new DbPvArray(getPtrSelf(),channelArrayRequester));
    if(!dbPvArray->init(pvRequest)) {
        Status createFailed(Status::STATUSTYPE_ERROR, "create dbPvArray failed");
        ScalarArrayConstPtr xxx;
        channelArrayRequester->channelArrayConnect(
            createFailed,
            dbPvArray,
            xxx);
    }
    return dbPvArray;
}
Ejemplo n.º 15
0
Monitor::shared_pointer DbPv::createMonitor(
        MonitorRequester::shared_pointer const &monitorRequester,
        PVStructure::shared_pointer const &pvRequest)
{
    DbPvMonitor::shared_pointer dbPvMonitor(
         new DbPvMonitor(getPtrSelf(),monitorRequester));
    if(!dbPvMonitor->init(pvRequest)) {
        Status createFailed(Status::STATUSTYPE_ERROR, "create dbPvMonitor failed");
        StructureConstPtr xxx;
        monitorRequester->monitorConnect(
            createFailed,
            dbPvMonitor,
            xxx);
    }
    return dbPvMonitor;
}
Ejemplo n.º 16
0
bool DbPvPut::init(PVStructure::shared_pointer const &pvRequest)
{
    propertyMask = dbUtil->getProperties(
        channelPutRequester,
        pvRequest,
        dbPv->getDbChannel(),
        true);
    if (propertyMask == dbUtil->noAccessBit) return false;
    if (propertyMask == dbUtil->noModBit) {
        channelPutRequester->message(
                    "field not allowed to be changed",
                    errorMessage);
        return 0;
    }
    pvStructure = PVStructure::shared_pointer(
        dbUtil->createPVStructure(
            channelPutRequester,
            propertyMask,
            dbPv->getDbChannel()));
    if (!pvStructure.get()) return false;
    if (propertyMask & dbUtil->dbPutBit) {
        if (propertyMask & dbUtil->processBit) {
            channelPutRequester->message(
                        "process determined by dbPutField",
                        errorMessage);
        }
    } else if (propertyMask&dbUtil->processBit) {
        process = true;
        pNotify.reset(new (struct processNotify)());
        struct processNotify *pn = pNotify.get();
        pn->chan = dbPv->getDbChannel();
        pn->requestType = putProcessRequest;
        pn->putCallback  = this->putCallback;
        pn->doneCallback = this->doneCallback;
        pn->usrPvt = this;
        if (propertyMask & dbUtil->blockBit) block = true;
    }
    int numFields = pvStructure->getNumberFields();
    bitSet.reset(new BitSet(numFields));
    channelPutRequester->channelPutConnect(
       Status::Ok,
       getPtrSelf(),
       pvStructure->getStructure());
    return true;
}
Channel::shared_pointer ChannelProviderLocal::createChannel(
    string const & channelName,
    ChannelRequester::shared_pointer  const &channelRequester,
    short priority)
{
    Lock xx(mutex);
    PVRecordPtr pvRecord = pvDatabase->findRecord(channelName);
    if(pvRecord) {
        ChannelLocalPtr channel(new ChannelLocal(
            getPtrSelf(),channelRequester,pvRecord));
        channelRequester->channelCreated(
            Status::Ok,
            channel);
        pvRecord->addPVRecordClient(channel);
        return channel;
    }   
    Status notFoundStatus(Status::STATUSTYPE_ERROR,"pv not found");
    channelRequester->channelCreated(
        notFoundStatus,
        Channel::shared_pointer());
    return Channel::shared_pointer();
    
}
Ejemplo n.º 18
0
Channel::shared_pointer DbPvProvider::createChannel(
    string const & channelName,
    ChannelRequester::shared_pointer  const &channelRequester,
    short priority,
    string const & address)
{
    struct dbAddr dbAddr;
    long result = dbNameToAddr(channelName.c_str(),&dbAddr);
    if(result!=0) {
        Status notFoundStatus(Status::STATUSTYPE_ERROR,"pv not found");
        channelRequester->channelCreated(
            notFoundStatus,
            Channel::shared_pointer());
        return Channel::shared_pointer();
    }
    std::tr1::shared_ptr<DbAddr> addr(new DbAddr());
    memcpy(addr.get(),&dbAddr,sizeof(dbAddr));
    DbPvPtr v3Channel(new DbPv(
            getPtrSelf(),
            channelRequester,channelName,addr));
    v3Channel->init();
    channelRequester->channelCreated(Status::Ok,v3Channel);
    return v3Channel;
}
PvaClientNTMultiPutPtr PvaClientMultiChannel::createNTPut()
{
    checkConnected();
    return PvaClientNTMultiPut::create(getPtrSelf(), pvaClientChannelArray);
}
PvaClientMultiMonitorDoublePtr PvaClientMultiChannel::createMonitor()
{
    checkConnected();
     return PvaClientMultiMonitorDouble::create(getPtrSelf(), pvaClientChannelArray);
}