source: trunk/FACT++/dim/src/examples/test_client_ccpc.c@ 18341

Last change on this file since 18341 was 11071, checked in by tbretz, 13 years ago
Replaced v19r21 by a version extracted with 'unzip -a' to get proper unix text format.
File size: 968 bytes
Line 
1#include <dic.h>
2
3int no_link = -1;
4int RegisterSet;
5int RegisterValue;
6
7void register_callback( tag, data, size )
8int *tag, *data, *size;
9{
10 RegisterValue = *data;
11 RegisterSet = *tag;
12/* In linux this is not necessary */
13#ifdef WIN32
14 dim_wake_up();
15#endif
16}
17
18int set_register_wait(index, value)
19int 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
36main(argc,argv)
37int argc;
38char **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}
Note: See TracBrowser for help on using the repository browser.