FACT++  1.0
test_client_ccpc.c
Go to the documentation of this file.
1 #include <dic.h>
2 
3 int no_link = -1;
6 
7 void register_callback( tag, data, size )
8 int *tag, *data, *size;
9 {
11  RegisterSet = *tag;
12 /* In linux this is not necessary */
13 #ifdef WIN32
14  dim_wake_up();
15 #endif
16 }
17 
18 int set_register_wait(index, value)
19 int index, value;
20 {
21  int pars[2];
22 
23  pars[0] = index;
24  pars[1] = value;
25  RegisterSet = -1;
26  dic_cmnd_service("SET_REGISTER",pars,sizeof(pars));
27  while(RegisterSet == -1)
28  {
29  dim_wait();
30  }
31  if(RegisterSet == index)
32  return(RegisterValue);
33  return(-1);
34 }
35 
36 main(argc,argv)
37 int argc;
38 char **argv;
39 {
40  int i, index = 0, value;
41  char aux[80];
42 
43  for(i = 0; i< 10; i++)
44  {
45  sprintf(aux,"Register%03d",i);
46  dic_info_service( aux, MONIT_ONLY, 0, 0, 0,
47  register_callback, i, &no_link, sizeof(int) );
48  }
49 
50  while(1)
51  {
52  value = set_register_wait(index%10, index);
53  printf("Register %d: wrote %d, readback = %d\n",
54  index%10, index, value);
55  index ++;
56  sleep(1);
57  }
58 }
unsigned dic_info_service(char *serv_name, int req_type, int req_timeout, void *serv_address, int serv_size, void(*usr_routine)(), dim_long tag, void *fill_addr, int fill_size)
Definition: dic.c:601
int dim_wait(void)
Definition: dim_thr.c:409
void register_callback(int *tag, int *data, int *size)
int i
Definition: db_dim_client.c:21
int RegisterSet
int set_register_wait(int index, int value)
int RegisterValue
int dic_cmnd_service(char *serv_name, void *serv_address, int serv_size)
Definition: dic.c:694
main(int argc, char **argv)
int no_link
int size
Definition: db_dim_server.c:17
float data[4 *1440]
sprintf(name1,"NewService%d", i)
#define MONIT_ONLY
Definition: dim_common.h:12