/** * Copyright - See the COPYRIGHT that is included with this distribution. * pvAccessCPP is distributed subject to a Software License Agreement found * in file LICENSE that is included with this distribution. */ #include #if !defined(_WIN32) #include #define USE_SIGNAL #endif #include #include #include #include #include namespace pvd = epics::pvData; namespace pva = epics::pvAccess; namespace { epicsEvent done; #ifdef USE_SIGNAL void alldone(int num) { (void)num; done.signal(); } #endif static pvd::StructureConstPtr string_type(pvd::getFieldCreate()->createFieldBuilder() ->add("value", pvd::pvString) ->createStructure()); static pvd::StructureConstPtr int_type(pvd::getFieldCreate()->createFieldBuilder() ->add("value", pvd::pvInt) ->createStructure()); static pvd::StructureConstPtr real_type(pvd::getFieldCreate()->createFieldBuilder() ->add("value", pvd::pvDouble) ->createStructure()); }//namespace int main(int argc, char *argv[]) { try { if(argc<=1) { fprintf(stderr, "Usage: %s ...\n type: string, int, real", argv[0]); return 1; } // container for PVs pvas::StaticProvider provider("mailbox"); // provider name "mailbox" is arbitrary for(int i=1; iopen(string_type); } else if(type=="int") { pv->open(int_type); } else if(type=="real") { pv->open(real_type); } else { fprintf(stderr, "Unknown type '%s'\n", type.c_str()); return 1; } // add to container provider.add(argv[1], pv); } // create and run network server pva::ServerContext::shared_pointer server(pva::ServerContext::create( pva::ServerContext::Config() // use default config from environment .provider(provider.provider()) )); #ifdef USE_SIGNAL signal(SIGINT, alldone); signal(SIGTERM, alldone); signal(SIGQUIT, alldone); #endif server->printInfo(); printf("Running with mailbox '%s'\n", argv[1]); done.wait(); } catch(std::exception& e){ std::cerr<<"Error: "<