22 memcpy(ppv->value, args.dbr, dbr_size_n(args.type, args.count));
42 auto result = ca_context_create(ca_enable_preemptive_callback);
43 if(result != ECA_NORMAL) {
44 std::cerr <<
"CA error " << ca_message(result)
45 <<
" occurred while trying "
46 "to start channel access"
50 pv* mypv = (
pv*)calloc(1,
sizeof(
pv));
51 std::string pvName(
"ctkTest:ao");
52 mypv->
name = (
char*)pvName.c_str();
53 epicsTimeGetCurrent(&tsStart);
54 result = ca_create_channel(mypv->
name, &state_handler, &mypv, default_ca_priority, &mypv->
chid);
55 if(result != ECA_NORMAL) {
56 std::cerr <<
"CA error " << ca_message(result)
57 <<
" occurred while trying "
59 << mypv->
name <<
"'." << std::endl;
62 result = ca_pend_io(1);
63 if(result == ECA_TIMEOUT) {
64 std::cerr <<
"Channel time out for PV: " << pvName << std::endl;
68 if(result != ECA_NORMAL) {
69 std::cerr <<
"CA error " << ca_message(result) <<
" occurred while trying to create channel " << mypv->
name
73 std::this_thread::sleep_for(std::chrono::milliseconds(100));
75 unsigned long nElems = ca_element_count(mypv->
chid);
78 if(ca_state(mypv->
chid) == cs_conn) {
83 fprintf(stderr,
"Memory allocation failed\n");
86 evid*
id =
new evid();
87 ca_create_subscription(mypv->
dbrType, mypv->
nElems, mypv->
chid, DBE_VALUE, event_handler, &mypv[0],
id);
93 result = ca_flush_io();
98 std::cerr <<
"No connection..." << std::endl;
105 ca_context_destroy();