Esempio n. 1
0
static void exampleDoubleArray(PvaClientPtr const &pva,string const & channelName,string const & providerName)
{
    cout << "__exampleDoubleArray__ channelName " << channelName << " providerName " << providerName << endl;
    PvaClientChannelPtr channel = pva->channel(channelName,providerName,2.0);
    PvaClientPutPtr put = channel->put();
    PvaClientPutDataPtr putData = put->getData();
    PvaClientMonitorPtr monitor = pva->channel(channelName,providerName,2.0)->monitor("value");
    PvaClientMonitorDataPtr monitorData = monitor->getData();
    size_t num = 5;
    shared_vector<double> data(num,0);
    for(size_t i=0; i<num; ++i) data[i] = .1*i;
    putData->putDoubleArray(freeze(data)); put->put();
    cout <<  channel->get("field(value)")->getData()->showChanged(cout) << endl;
    data = shared_vector<double>(num,0);
    for(size_t i=0; i<num; ++i) data[i] = .1*(i + 1);
    putData->putDoubleArray(freeze(data)); put->put();
    cout <<  channel->get("field(value)")->getData()->showChanged(cout) << endl;
    if(!monitor->waitEvent()) {
           cout << "waitEvent returned false. Why???";
    } else while(true) {
         cout << "monitor changed\n" << monitorData->showChanged(cout);
         monitor->releaseEvent();
         if(!monitor->poll()) break;
    }
}
static void exampleMonitor(PvaClientPtr const &pva,string provider)
{
    PvaClientMonitorPtr monitor = pva->channel("DBRdouble00",provider,2.0)->monitor("");
    PvaClientMonitorDataPtr monitorData = monitor->getData();
    PvaClientPutPtr put = pva->channel("DBRdouble00",provider,2.0)->put("");
    PvaClientPutDataPtr putData = put->getData();
    for(size_t ntimes=0; ntimes<5; ++ntimes)
    {
         double value = ntimes;
         cout << "put " << value << endl;
         putData->putDouble(value); put->put();
         if(!monitor->waitEvent(.1)) {
               cout << "waitEvent returned false. Why???";
               continue;
         } else while(true) {
             cout << "monitor " << monitorData->getDouble() << endl;
             cout << "changed\n";
             monitorData->showChanged(cout);
             cout << "overrun\n";
             monitorData->showOverrun(cout);
             monitor->releaseEvent();
             if(!monitor->poll()) break;
         }
     }
}
Esempio n. 3
0
static void exampleDouble(PvaClientPtr const &pva,string const & channelName,string const & providerName)
{
    cout << "__exampleDouble__ channelName " << channelName << " providerName " << providerName << endl;
    PvaClientChannelPtr channel = pva->channel(channelName,providerName,2.0);
    PvaClientPutPtr put = channel->put();
    PvaClientPutDataPtr putData = put->getData();
    PvaClientMonitorPtr monitor = pva->channel(channelName,providerName,2.0)->monitor("value");
    PvaClientMonitorDataPtr monitorData = monitor->getData();
    putData->putDouble(3.0); put->put();
    cout <<  channel->get("field(value)")->getData()->showChanged(cout) << endl;
    putData->putDouble(4.0); put->put();
    cout <<  channel->get("field(value)")->getData()->showChanged(cout) << endl;
    if(!monitor->waitEvent()) {
           cout << "waitEvent returned false. Why???";
    } else while(true) {
         cout << "monitor changed\n" << monitorData->showChanged(cout);
         monitor->releaseEvent();
         if(!monitor->poll()) break;
    }
}
static void examplePut(PvaClientPtr const &pva)
{
    cout << "example put\n";
    PvaClientChannelPtr channel = pva->channel("exampleDouble");
    PvaClientPutPtr put = channel->put();
    PvaClientPutDataPtr putData = put->getData();
    PvaClientMonitorPtr monitor = pva->channel("exampleDouble")->monitor("");
    PvaClientMonitorDataPtr monitorData = monitor->getData();
    try {
        putData->putDouble(3.0); put->put();
        cout <<  channel->get("field()")->getData()->showChanged(cout) << endl;
        putData->putDouble(4.0); put->put();
        cout <<  channel->get("field()")->getData()->showChanged(cout) << endl;
        if(!monitor->waitEvent()) {
               cout << "waitEvent returned false. Why???";
        } else while(true) {
             cout << "monitor changed\n" << monitorData->showChanged(cout);
             monitor->releaseEvent();
             if(!monitor->poll()) break;
        }
    } catch (std::runtime_error e) {
        cout << "exception " << e.what() << endl;
    }
}