Mercurial > hg > Members > kono > Cerium
changeset 868:58b4fb8ad77c
[aquarium]: update screen scope on linda with protobuf
author | kazz <kazz@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 22 Jun 2010 16:10:28 +0900 |
parents | 58d426cece23 |
children | bcc81531a672 157f2ffeb526 |
files | Renderer/Test/aquarium.cc Renderer/Test/aquarium.h Renderer/Test/init_aquarium.cc TaskManager/include/types.h TaskManager/kernel/ppe/MailManager.cc |
diffstat | 5 files changed, 35 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/Renderer/Test/aquarium.cc Tue Jun 22 12:52:25 2010 +0900 +++ b/Renderer/Test/aquarium.cc Tue Jun 22 16:10:28 2010 +0900 @@ -3,12 +3,15 @@ #include "SceneGraphRoot.h" #include "lindaapi.h" #include "aquarium.h" +#include "aquarium.pb.h" #define GET_SERIAL_ID 65535 linda_t aquarium::linda_addr = { "localhost", 10000 }; int aquarium::linda; int aquarium::serial_id; +int aquarium::width; +int aquarium::start_x; const char *usr_help_str = "Usage: ./aquarium -linda LINDA_SERVER_NAME\n"; void TMend(TaskManager *manager); @@ -20,16 +23,12 @@ return new aquarium(); } -void init_network() { - aquarium::linda_connect(); - - -} - MainLoopPtr aquarium::init(Viewer *sgroot, int screen_w, int screen_h) { - init_network(); + width = screen_w; + linda_connect(); + update_screen_scope(); return sgroot; } @@ -45,9 +44,31 @@ data = psx_reply(seq); } while (data == NULL); serial_id = atoi((char *)data + LINDA_HEADER_SIZE); + psx_free(data); printf("Get serial_id: %d\n", serial_id); } +void +aquarium::update_screen_scope() { + int seq = psx_in(linda, 1); + unsigned char *data = NULL; + do { + psx_sync_n(); + data = psx_reply(seq); + } while (data == NULL); + aqua::Width *w = new aqua::Width(); + w->ParseFromArray(data + LINDA_HEADER_SIZE, *(int *)(data + LINDA_DATA_LENGTH_OFFSET)); + start_x = w->width(); // 現在の全長を取得 + w->set_width(start_x + width); // 自分の横幅を足す + int size = w->ByteSize(); + unsigned char *msg = (unsigned char *) malloc(sizeof(char) * size); + w->SerializeToArray(msg, size); // 更新したデータを再度シリアライズ + psx_out(linda, 1, msg, size); + psx_sync_n(); + printf("start_x = %d, width = %d\n", start_x, width); + delete w; +} + int TMmain(TaskManager *manager, int argc, char *argv[]) {
--- a/Renderer/Test/aquarium.h Tue Jun 22 12:52:25 2010 +0900 +++ b/Renderer/Test/aquarium.h Tue Jun 22 16:10:28 2010 +0900 @@ -13,6 +13,9 @@ static linda_t linda_addr; static int linda; static int serial_id; + static int start_x; + static int width; static void linda_connect(); + static void update_screen_scope(); MainLoopPtr init(Viewer *viewer, int screen_w, int screen_h); };
--- a/Renderer/Test/init_aquarium.cc Tue Jun 22 12:52:25 2010 +0900 +++ b/Renderer/Test/init_aquarium.cc Tue Jun 22 16:10:28 2010 +0900 @@ -13,6 +13,7 @@ int linda = open_linda_java("localhost", 10000); psx_out(linda, 1, msg, size); psx_sync_n(); + delete width; return 0; }
--- a/TaskManager/include/types.h Tue Jun 22 12:52:25 2010 +0900 +++ b/TaskManager/include/types.h Tue Jun 22 16:10:28 2010 +0900 @@ -22,7 +22,7 @@ #endif -#define New(Type,Count) ((Type *)malloc(sizeof(Type)*Count)) +#define Newq(Type,Count) ((Type *)malloc(sizeof(Type)*Count)) #define ReAlloc(Pointer,Type,Count) ((Type *)realloc((void*)Pointer,sizeof(Type)*Count))
--- a/TaskManager/kernel/ppe/MailManager.cc Tue Jun 22 12:52:25 2010 +0900 +++ b/TaskManager/kernel/ppe/MailManager.cc Tue Jun 22 16:10:28 2010 +0900 @@ -15,7 +15,7 @@ MailManager::MailManager(unsigned int qsize) { read = write = 0; calc_mask(qsize); - queue = New(memaddr,size); + queue = Newq(memaddr,size); } MailManager::~MailManager() { free(queue); } @@ -29,7 +29,7 @@ void MailManager::extend() { - memaddr *newq = New(memaddr,size*2); + memaddr *newq = Newq(memaddr,size*2); unsigned int i = 0; while(i<size) { newq[i++] = queue[read++];