source: trunk/FACT++/dim/src/examples/test_client_many.c@ 13913

Last change on this file since 13913 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: 2.4 KB
Line 
1
2#include <dic.h>
3#include <time.h>
4
5char str[80];
6char str_res[10][80];
7char client_str[80];
8int no_link = -1;
9float no_link_float = -1.0;
10char buff[80];
11
12typedef struct {
13 int i;
14 int j;
15 int k;
16 double d;
17 short s;
18 char c;
19 short t;
20 float f;
21 char str[20];
22}TT;
23
24TT t;
25/*
26void big_rout( tag, buf, size )
27int *buf;
28int *tag, *size;
29{
30
31 printf("Received %d for TestMem\n", *buf);
32}
33*/
34void rout_many( tag, buf, size )
35float *buf;
36int *tag, *size;
37{
38 if(*tag == 50000)
39 {
40 dim_print_date_time();
41 printf("Received %f for service %d\n", *buf, *tag);
42 }
43}
44
45void rout( tag, buf, size )
46char *buf;
47int *tag, *size;
48{
49 int conn_id;
50 char server[128];
51
52 if(*tag == 1100)
53 {
54 printf("Received ONCE_ONLY : %s\n",buff);
55 return;
56 }
57 if(*tag == 1200)
58 {
59 char node[128], str[256];
60 int secs, millis;
61 time_t tsecs;
62
63 dic_get_dns_node(node);
64 printf("DNS node = %s\n",node);
65 printf("size = %d\n",*size);
66 memcpy(&t, buf, *size);
67 printf("t.i = %d, t.d = %2.2f, t.s = %d, t.c = %c, t.f = %2.2f, t.str = %s\n",
68 t.i,t.d,t.s,t.c,t.f,t.str);
69 dic_get_timestamp(0, &secs, &millis);
70 tsecs = secs;
71 my_ctime(&tsecs, str, 128);
72 str[strlen(str)-1] = '\0';
73 printf("timestamp = %s.%d\n",str,millis);
74
75 return;
76 }
77 else
78 printf("%s Received %s for Service%03d\n",client_str,buf, *tag);
79
80/*
81 if(conn_id = dic_get_server(server))
82 printf("received from %d, %s\n",conn_id, server);
83*/
84
85}
86
87main(argc,argv)
88int argc;
89char **argv;
90{
91 int i, *ptr;
92 char aux[80];
93 int id = 123;
94
95/*
96 dic_set_debug_on();
97*/
98/*
99 dic_set_dns_node("pclhcb99.cern.ch");
100*/
101
102 sprintf(str,"%s/SET_EXIT_HANDLER",argv[2]);
103 dic_cmnd_service(str, &id, 4);
104 dic_get_id(aux);
105 printf("%s\n",aux);
106 strcpy(client_str,argv[1]);
107/*
108 for(i = 0; i< 10; i++)
109 {
110 sprintf(str,"%s/Service_%03d",argv[2],i);
111 dic_info_service( str, TIMED, 10, 0, 0, rout, i,
112 "No Link", 8 );
113 }
114
115 sprintf(aux,"%s/TEST_SWAP",argv[2]);
116 dic_info_service_stamped( aux, TIMED, 5, 0, 0, rout, 1200,
117 &no_link, 4 );
118*/
119/*
120 sprintf(aux,"%s/TestMem",argv[2]);
121 dic_info_service( aux, MONITORED, 0, 0, 0, big_rout, 0,
122 &no_link, 4 );
123*/
124
125 for(i = 0; i< 100000; i++)
126 {
127 sprintf(aux,"%s/ServiceMany%05d",argv[2],i);
128 dic_info_service( aux, MONITORED, 60, 0, 0, rout_many, i,
129 &no_link_float, 4 );
130 }
131
132 sprintf(aux,"%s/TEST_CMD",argv[2]);
133 while(1)
134 {
135 int index = 0;
136 sleep(10);
137/*
138 printf("Sending Command, size = %d, i = %d\n",sizeof(t), t.i);
139 dic_cmnd_service(aux,&t,sizeof(t));
140*/
141 }
142}
Note: See TracBrowser for help on using the repository browser.