1 | // db_dim_client.c : Defines the entry point for the console application.
|
---|
2 | //
|
---|
3 | // Dietrich Beck
|
---|
4 | //
|
---|
5 | // This is a very simple DIM service. It listens to a DIM service
|
---|
6 | // "SERV_BY_BUFFER" via a callback routine. Each time THIS client
|
---|
7 | // receives a service, it sends a new command to the DIM server.
|
---|
8 |
|
---|
9 | #include <stdio.h>
|
---|
10 | #include <dic.h>
|
---|
11 |
|
---|
12 | #define BUFFSIZE 10000000
|
---|
13 |
|
---|
14 | int buffer[BUFFSIZE];
|
---|
15 | int buff[BUFFSIZE];
|
---|
16 | char message[1024];
|
---|
17 | int no_link = -1;
|
---|
18 | int version;
|
---|
19 | int counter;
|
---|
20 | int lastValue;
|
---|
21 | int i;
|
---|
22 | unsigned service_id;
|
---|
23 |
|
---|
24 | serv_received(tag,address,size)
|
---|
25 | int *tag;
|
---|
26 | char *address;
|
---|
27 | int *size;
|
---|
28 | {
|
---|
29 | for (i=0;i<BUFFSIZE;i++) buff[i] = buffer[i]; //copy data to do something useful
|
---|
30 | counter++;
|
---|
31 | sprintf(message, "service received %d\n", counter);
|
---|
32 | printf(message);
|
---|
33 | }
|
---|
34 |
|
---|
35 | void main(int argc, char* argv[])
|
---|
36 | {
|
---|
37 |
|
---|
38 | //service_id = dic_info_service("testBuffer",MONITORED,0,0,0,serv_received,0,&no_link,4);
|
---|
39 | // printf("registering to service\n");
|
---|
40 | // counter = 0;
|
---|
41 | // service_id = dic_info_service("testBuffer",MONITORED,0,0,0,serv_received,0,&no_link,4);
|
---|
42 | while(1)
|
---|
43 | {
|
---|
44 | printf("registering to service\n");
|
---|
45 | counter = 0;
|
---|
46 | service_id = dic_info_service("testBuffer",MONITORED,0,0,0,serv_received,0,&no_link,4);
|
---|
47 | sleep(1);
|
---|
48 | printf("releasing service\n");
|
---|
49 | dic_release_service(service_id);
|
---|
50 | printf("released service\n");
|
---|
51 | sleep(1);
|
---|
52 | //sprintf(message, "%s", dic_get_error_services());
|
---|
53 | }
|
---|
54 | }
|
---|
55 |
|
---|