예제 #1
0
ChannelPut::shared_pointer CAChannelPut::create(
        CAChannel::shared_pointer const & channel,
        ChannelPutRequester::shared_pointer const & channelPutRequester,
        epics::pvData::PVStructure::shared_pointer const & pvRequest)
{
    // TODO use std::make_shared
    std::tr1::shared_ptr<CAChannelPut> tp(
                    new CAChannelPut(channel, channelPutRequester, pvRequest)
                );
    ChannelPut::shared_pointer thisPtr = tp;
    static_cast<CAChannelPut*>(thisPtr.get())->activate();
    return thisPtr;
}
예제 #2
0
void ChannelPutRequesterImpl::channelPutConnect(const epics::pvData::Status& status,
                                                        ChannelPut::shared_pointer const & channelPut,
                                                        epics::pvData::PVStructure::shared_pointer const & pvStructure,
                                                        epics::pvData::BitSet::shared_pointer const & bitSet)
{
    if (status.isSuccess()) {
        // show warning
        if (!status.isOK()) {
            std::cerr << "[" << m_channelName << "] channel put create: " << status.toString() << std::endl;
        }

        // assign smart pointers
        {
            Lock lock(m_pointerMutex);
            m_channelPut = channelPut;
            m_pvStructure = pvStructure;
            m_bitSet = bitSet;
        }

        // we always put all
        m_bitSet->set(0);

        // get immediately old value
        channelPut->get();
    } else {
        std::cerr << "[" << m_channelName << "] failed to create channel put: " << status.toString() << std::endl;
    }
}
예제 #3
0
void PvaClientPut::channelPutConnect(
    const Status& status,
    ChannelPut::shared_pointer const & channelPut,
    StructureConstPtr const & structure)
{
    if(PvaClient::getDebug()) {
        cout << "PvaClientPut::channelPutConnect"
           << " channelName " << pvaClientChannel->getChannel()->getChannelName()
           << " status.isOK " << (status.isOK() ? "true" : "false")
           << endl;
    }
    {
        Lock xx(mutex);
        this->channelPut = channelPut;
        if(status.isOK()) {
            channelPutConnectStatus = status;
            connectState = connected;
            pvaClientData = PvaClientPutData::create(structure);
            pvaClientData->setMessagePrefix(channelPut->getChannel()->getChannelName());
        } else {
             stringstream ss;
             ss << pvRequest;
             string message = string("\nPvaClientPut::channelPutConnect)")
               + "\npvRequest\n" + ss.str()
               + "\nerror\n" + status.getMessage();
             channelPutConnectStatus = Status(Status::STATUSTYPE_ERROR,message);
        }
    }
    PvaClientPutRequesterPtr  req(pvaClientPutRequester.lock());
    if(req) {
          req->channelPutConnect(status,shared_from_this());
    }
    waitForConnect.signal();
    
}
int main()
{
    for (int i = 0; i < 10; i++) {
    {
    /*
    ClientContextImpl::shared_pointer context = createClientContextImpl();
    context->printInfo();

    context->initialize();
    context->printInfo();

    epicsThreadSleep ( SLEEP_TIME );
    
    ChannelProvider::shared_pointer provider = context->getProvider();
    */
    
    ClientFactory::start();
    ChannelProvider::shared_pointer provider = getChannelProviderRegistry()->getProvider("pva");

    ChannelFindRequester::shared_pointer findRequester(new ChannelFindRequesterImpl());
    ChannelFind::shared_pointer channelFind = provider->channelFind("testSomething", findRequester);
    epicsThreadSleep ( SLEEP_TIME );
    //channelFind->destroy();

    ChannelRequester::shared_pointer channelRequester(new ChannelRequesterImpl());
    Channel::shared_pointer channel = provider->createChannel("testStructureArrayTest", channelRequester);
    epicsThreadSleep ( SLEEP_TIME );
    channel->printInfo();
        
        {
    GetFieldRequester::shared_pointer getFieldRequesterImpl(new GetFieldRequesterImpl());
    channel->getField(getFieldRequesterImpl, "");
    epicsThreadSleep ( SLEEP_TIME );
        }
        
        {
    ChannelProcessRequester::shared_pointer channelProcessRequester(new ChannelProcessRequesterImpl());
    PVStructure::shared_pointer pvRequest;
    ChannelProcess::shared_pointer channelProcess = channel->createChannelProcess(channelProcessRequester, pvRequest);
    epicsThreadSleep ( SLEEP_TIME );
    channelProcess->process();
    epicsThreadSleep ( SLEEP_TIME );
    channelProcess->destroy();
    epicsThreadSleep ( SLEEP_TIME );
        }
        
        {
    ChannelGetRequester::shared_pointer channelGetRequesterImpl(new ChannelGetRequesterImpl());
    PVStructure::shared_pointer pvRequest = CreateRequest::create()->createRequest("field()");
    ChannelGet::shared_pointer channelGet = channel->createChannelGet(channelGetRequesterImpl, pvRequest);
    epicsThreadSleep ( 3.0 );
    channelGet->get();
    epicsThreadSleep ( 3.0 );
    channelGet->destroy();
        }
    
        {
    ChannelPutRequester::shared_pointer channelPutRequesterImpl(new ChannelPutRequesterImpl());
    PVStructure::shared_pointer pvRequest = CreateRequest::create()->createRequest("field(value,timeStamp)");
    ChannelPut::shared_pointer channelPut = channel->createChannelPut(channelPutRequesterImpl, pvRequest);
    epicsThreadSleep ( SLEEP_TIME );
    channelPut->get();
    epicsThreadSleep ( SLEEP_TIME );
    // TODO !!!
    //channelPut->put();
    //epicsThreadSleep ( SLEEP_TIME );
    channelPut->destroy();
        }

        {
    ChannelPutGetRequester::shared_pointer channelPutGetRequesterImpl(new ChannelPutGetRequesterImpl());
    PVStructure::shared_pointer pvRequest = CreateRequest::create()->createRequest("putField(value,timeStamp)getField(timeStamp)");
    ChannelPutGet::shared_pointer channelPutGet = channel->createChannelPutGet(channelPutGetRequesterImpl, pvRequest);
    epicsThreadSleep ( SLEEP_TIME );
    channelPutGet->getGet();
    epicsThreadSleep ( SLEEP_TIME );
    channelPutGet->getPut();
    epicsThreadSleep ( SLEEP_TIME );
    // TODO !!!
    //channelPutGet->putGet();
    //epicsThreadSleep ( SLEEP_TIME );
    channelPutGet->destroy();
        }

        {
    ChannelRPCRequester::shared_pointer channelRPCRequesterImpl(new ChannelRPCRequesterImpl());
    PVStructure::shared_pointer pvRequest = CreateRequest::create()->createRequest("record[]field(arguments)");
    ChannelRPC::shared_pointer channelRPC = channel->createChannelRPC(channelRPCRequesterImpl, pvRequest);
    epicsThreadSleep ( SLEEP_TIME );
    // for test simply use pvRequest as arguments
    channelRPC->request(pvRequest);
    epicsThreadSleep ( SLEEP_TIME );
    channelRPC->destroy();
        }
         
        {
    ChannelArrayRequester::shared_pointer channelArrayRequesterImpl(new ChannelArrayRequesterImpl());
    StringArray fieldNames; fieldNames.push_back("field");
    FieldConstPtrArray fields; fields.push_back(getFieldCreate()->createScalar(pvString));
    PVStructure::shared_pointer pvRequest(getPVDataCreate()->createPVStructure(getFieldCreate()->createStructure(fieldNames, fields)));

    ChannelArray::shared_pointer channelArray = channel->createChannelArray(channelArrayRequesterImpl, pvRequest);
    epicsThreadSleep ( SLEEP_TIME );
    channelArray->getArray(0,0,1);
    epicsThreadSleep ( SLEEP_TIME );
    // TODO !!!
    //channelArray->putArray(0,0,1);
    //epicsThreadSleep ( SLEEP_TIME );
    channelArray->setLength(3);
    epicsThreadSleep ( SLEEP_TIME );
    channelArray->getLength();
    epicsThreadSleep ( SLEEP_TIME );
    channelArray->destroy();
        }

        {
    MonitorRequester::shared_pointer monitorRequesterImpl(new MonitorRequesterImpl());
    PVStructure::shared_pointer pvRequest = CreateRequest::create()->createRequest("field()");
    Monitor::shared_pointer monitor = channel->createMonitor(monitorRequesterImpl, pvRequest);

    epicsThreadSleep( SLEEP_TIME );

    Status status = monitor->start();
    std::cout << "monitor->start() = " << status << std::endl;

    epicsThreadSleep( 3*SLEEP_TIME );

    status = monitor->stop();
    std::cout << "monitor->stop() = " << status << std::endl;


    monitor->destroy();
        }
    
    epicsThreadSleep ( 3*SLEEP_TIME );
    printf("Destroying channel... \n");
    channel->destroy();
    printf("done.\n");

    epicsThreadSleep ( 3*SLEEP_TIME );
        
    }
    
    ClientFactory::stop();

    /*
    printf("Destroying context... \n");
    context->destroy();
    printf("done.\n");
    */
    
    epicsThreadSleep ( SLEEP_TIME ); }
    //std::cout << "-----------------------------------------------------------------------" << std::endl;
    //epicsExitCallAtExits();
    return(0);
}