int main(int argc,char *argv[])
{
    cout << "_____examplePvaClientPut starting_______\n";
    try {
        PvaClientPtr pva = PvaClient::get("pva ca");
        exampleDouble(pva,"PVRdouble","pva");
        exampleDoubleArray(pva,"PVRdoubleArray","pva");
        examplePVFieldPut(pva,"PVRint","pva");
        PvaClientChannelPtr pvaChannel = pva->createChannel("DBRdouble00","ca");
        pvaChannel->issueConnect();
        Status status = pvaChannel->waitConnect(1.0);
        if(status.isOK()) {
            exampleDouble(pva,"DBRdouble00","pva");
            exampleDouble(pva,"DBRdouble00","ca");
            exampleDoubleArray(pva,"DBRdoubleArray","pva");
            exampleDoubleArray(pva,"DBRdoubleArray","ca");
            examplePVFieldPut(pva,"DBRint00","pva");
            examplePVFieldPut(pva,"DBRint00","ca");
        } else {
             cout << "DBRdouble00 not found\n";
        }
        cout << "_____examplePvaClientPut done_______\n";
    } catch (std::runtime_error e) {
        cerr << "exception " << e.what() << endl;
        return 1;
    }
    return 0;
}
int main(int argc,char *argv[])
{
    cout << "_____examplePvaClientNTMulti starting_______\n";
    PvaClientPtr pva = PvaClient::create();
    size_t num = 4;
    shared_vector<string> channelNames(num);
    channelNames[0] = "PVRdouble";
    channelNames[1] = "PVRstring";
    channelNames[2] = "PVRdoubleArray";
    channelNames[3] = "PVRstringArray";
    shared_vector<const string> names(freeze(channelNames));
    example(pva,"pva",names);
    PvaClientChannelPtr pvaChannel = pva->createChannel("DBRdouble00","ca");
    pvaChannel->issueConnect();
    Status status = pvaChannel->waitConnect(1.0);
    if(status.isOK()) {
        channelNames = shared_vector<string>(num);
        channelNames[0] = "DBRdouble01";
        channelNames[1] = "DBRstring01";
        channelNames[2] = "DBRdoubleArray01";
        channelNames[3] = "DBRstringArray01";
        names = freeze(channelNames);
        example(pva,"pva",names);
        example(pva,"ca",names);
    } else {
         cout << "DBRdouble00 not found\n";
    }
    cout << "_____examplePvaClientNTMulti done_______\n";
    return 0;
}
int main(int argc,char *argv[])
{
    cout << "_____examplePvaClientMonitor starting_______\n";
    try {
        PvaClientPtr pva = PvaClient::get("pva ca");
//PvaClient::setDebug(true);
        exampleMonitor(pva,"PVRdouble","pva");
        PvaClientChannelPtr pvaChannel = pva->createChannel("DBRdouble00","ca");
        pvaChannel->issueConnect();
        Status status = pvaChannel->waitConnect(1.0);
        if(status.isOK()) {
            cout << "exampleMonitor pva\n";
            exampleMonitor(pva,"DBRdouble00","pva");
            cout << "exampleMonitor ca\n";
            exampleMonitor(pva,"DBRdouble00","ca");
        } else {
             cout << "DBRdouble00 not found\n";
        }
        cout << "_____examplePvaClientMonitor done_______\n";
    } catch (std::runtime_error e) {
            cerr << "exception " << e.what() << endl;
            return 1;
    }
    return 0;
}
int main(int argc,char *argv[])
{
    cout << "_____examplePvaClientGet starting_______\n";
    PvaClientPtr pva= PvaClient::create();
    exampleDouble(pva);
    exampleDoubleArray(pva);
    PvaClientChannelPtr pvaChannel = pva->createChannel("DBRdouble00","ca");
    pvaChannel->issueConnect();
    Status status = pvaChannel->waitConnect(1.0);
    if(status.isOK()) {
        exampleCADouble(pva);
        exampleCADoubleArray(pva);
    } else {
         cout << "DBRdouble00 not found\n";
    }
    cout << "_____examplePvaClientGet done_______\n";
    return 0;
}
int main(int argc,char *argv[])
{
    cout << "_____examplePvaClientMultiDouble starting_______\n";
    try {
        PvaClientPtr pva = PvaClient::get("pva ca");
//PvaClient::setDebug(true);
        size_t num = 5;
        shared_vector<string> channelNames(num);
        channelNames[0] = "PVRdouble01";
        channelNames[1] = "PVRint";
        channelNames[2] = "PVRdouble03";
        channelNames[3] = "PVRdouble04";
        channelNames[4] = "PVRdouble05";
        shared_vector<const string> names(freeze(channelNames));
        example(pva,"pva",names);
        PvaClientChannelPtr pvaChannel = pva->createChannel("DBRdouble00","pva");
        pvaChannel->issueConnect();
        Status status = pvaChannel->waitConnect(1.0);
        if(status.isOK()) {
            channelNames = shared_vector<string>(num);
            channelNames[0] = "DBRdouble01";
            channelNames[1] = "DBRint01";
            channelNames[2] = "DBRdouble03";
            channelNames[3] = "DBRdouble04";
            channelNames[4] = "DBRdouble05";
            names = freeze(channelNames);
            example(pva,"pva",names);
            example(pva,"ca",names);
        } else {
            cout << "DBRdouble00 not found\n";
        }
        cout << "_____examplePvaClientMultiDouble done_______\n";
     } catch (std::runtime_error e) {
        cout << "exception " << e.what() << endl;
        return 1;
    }
    return 0;
}
static void exampleCADouble(PvaClientPtr const &pva)
{
    cout << "__exampleCADouble__\n";
    double value;
    try {
        cout << "short way\n";
        value =  pva->channel("DBRdouble00","ca",5.0)->get()->getData()->getDouble();
        cout << "as double " << value << endl;
    } catch (std::runtime_error e) {
        cout << "exception " << e.what() << endl;
    }
    cout << "long way\n";
    PvaClientChannelPtr pvaChannel = pva->createChannel("DBRdouble00","ca");
    pvaChannel->issueConnect();
    Status status = pvaChannel->waitConnect(2.0);
    if(!status.isOK()) {cout << " connect failed\n"; return;}
    PvaClientGetPtr pvaGet = pvaChannel->createGet();
    pvaGet->issueConnect();
    status = pvaGet->waitConnect();
    if(!status.isOK()) {cout << " createGet failed\n"; return;}
    PvaClientGetDataPtr pvaData = pvaGet->getData();
    value = pvaData->getDouble();
    cout << "as double " << value << endl;
}