/** * Copyright - See the COPYRIGHT that is included with this distribution. * pvxs is distributed subject to a Software License Agreement found * in file LICENSE that is included with this distribution. */ /** Meant to be run against the mailbox example. * eg. in one terminal run: * * ./mailbox some:pv:name * * And in another terminal run: * * ./client some:pv:name */ #include #include #include using namespace pvxs; int main(int argc, char* argv[]) { if(argc<2) { std::cerr<<"Usage: "<\n"; return 1; } // Read $PVXS_LOG from process environment and update // logging configuration. eg. // export PVXS_LOG=*=DEBUG // makes a lot of noise. logger_config_env(); // Create a client context client::Context ctxt(client::Config::fromEnv() .build()); // Fetch current value int32_t current; { std::cout<<"Getting current value of '"<wait(5.0); std::cout<<"Result is:\n"<(); } else { // an example. won't happen with mailbox server std::cerr<<"Server type doesn't have .value field!\n"; return 1; } } { // attempt to change. // uses simple builder form to assign .value ctxt.put(argv[1]) .set("value", current+1) .exec() ->wait(5.0); std::cout<<"First increment successful"< Value { // allocate an empty container auto toput(current.cloneEmpty()); // fill in .value. // Assignment implicitly marks .value as changed toput["value"] = current["value"].as() + 1; // return the container to be sent return toput; }) .exec(); op->wait(5.0); std::cout<<"Second increment successful"<wait(5.0); std::cout<<"Result is:\n"<