FACT++  1.0
test_server_ccpc.c
Go to the documentation of this file.
1 #include <stdio.h>
2 #include <dis.h>
3 
4 int registers[10];
5 int ids[10];
6 
7 void set_register(tag, data, size)
8 int *tag, *data, *size;
9 {
10 int index, value;
11 
12  index = data[0];
13  value = data[1];
14  printf("Setting register %d to value %d\n", index, value);
15 /* here we set the register, read it back and update the service*/
16  registers[index] = value;
17  dis_update_service(ids[index]);
18 
19 }
20 
21 main(argc,argv)
22 int argc;
23 char **argv;
24 {
25  int i;
26  char aux[80];
27 
28  for(i = 0; i< 10; i++)
29  {
30  sprintf(aux,"Register%03d",i);
31  ids[i] = dis_add_service( aux, "I", &registers[i], sizeof(int),
32  (void *)0, 0 );
33  }
34 
35  dis_add_cmnd("SET_REGISTER","I:2",set_register, 0);
36 
37  dis_start_serving( "TEST_REGISTERS" );
38 
39  while(1)
40  {
41  pause();
42  }
43 }
44 
int ids[10]
int i
Definition: db_dim_client.c:21
void set_register(int *tag, int *data, int *size)
#define dis_add_cmnd
Definition: dis.h:13
#define dis_start_serving
Definition: dis.h:8
#define dis_update_service
Definition: dis.h:18
main(int argc, char **argv)
int size
Definition: db_dim_server.c:17
float data[4 *1440]
#define dis_add_service
Definition: dis.h:12
int registers[10]
sprintf(name1,"NewService%d", i)