annotate Renderer/Test/test_linda.cc @ 1479:163220e54cc0 draft

remove hard code for TaskLog
author Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
date Tue, 24 Jul 2012 17:15:15 +0900
parents 841034b1d197
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
921
841034b1d197 add test_linda
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1 #include <stdio.h>
841034b1d197 add test_linda
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2 #include <stdlib.h>
841034b1d197 add test_linda
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3 #include "lindaapi.h"
841034b1d197 add test_linda
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
4 #include "aquarium.pb.h"
841034b1d197 add test_linda
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
5
841034b1d197 add test_linda
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
6 int main(int argc, char *argv[]) {
841034b1d197 add test_linda
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
7 init_linda();
841034b1d197 add test_linda
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
8 srandom(time(0));
841034b1d197 add test_linda
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
9 aqua::Width *width = new aqua::Width();
841034b1d197 add test_linda
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
10 width->set_width(random() % 30);
841034b1d197 add test_linda
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
11 printf("send: %d\n", width->width());
841034b1d197 add test_linda
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
12 int size = width->ByteSize();
841034b1d197 add test_linda
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
13 unsigned char *msg = (unsigned char *) malloc(sizeof(char) * size);
841034b1d197 add test_linda
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
14 width->SerializeToArray(msg, size);
841034b1d197 add test_linda
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
15
841034b1d197 add test_linda
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
16 int linda = open_linda_java("localhost", 10000);
841034b1d197 add test_linda
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
17 int seq = psx_update(linda, 1, msg, size);
841034b1d197 add test_linda
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
18 unsigned char *reply = NULL;
841034b1d197 add test_linda
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
19 while (true) {
841034b1d197 add test_linda
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
20 psx_sync_n();
841034b1d197 add test_linda
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
21 reply = psx_reply(seq);
841034b1d197 add test_linda
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
22 if (reply != NULL)
841034b1d197 add test_linda
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
23 break;
841034b1d197 add test_linda
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
24 }
841034b1d197 add test_linda
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
25 int len = psx_get_datalength(reply);
841034b1d197 add test_linda
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
26 if (len != 0) {
841034b1d197 add test_linda
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
27 width->ParseFromArray(reply + LINDA_HEADER_SIZE, len);
841034b1d197 add test_linda
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
28 printf("recv: %d\n", width->width());
841034b1d197 add test_linda
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
29 }
841034b1d197 add test_linda
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
30 delete width;
841034b1d197 add test_linda
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
31
841034b1d197 add test_linda
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
32 return 0;
841034b1d197 add test_linda
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
33 }