From 7edaaf36d341d25ca72b57d305b9e3404475a248 Mon Sep 17 00:00:00 2001 From: Tim Redfern Date: Fri, 29 Jun 2012 10:19:21 +0100 Subject: live test --- src/testApp.cpp | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-) (limited to 'src/testApp.cpp') diff --git a/src/testApp.cpp b/src/testApp.cpp index 3ce4f36..cc15122 100644 --- a/src/testApp.cpp +++ b/src/testApp.cpp @@ -127,9 +127,12 @@ void testApp::setup(){ udpConnection.Bind(7888); udpConnection.SetNonBlocking(true); - string def="default"; + string def=""; devices["base"]=obtsDevice(def,def,def,icons,ofVec2f(0,0)); + + message=""; + messageTime=0.0f; } @@ -184,11 +187,14 @@ void testApp::update(){ */ char udpMessage[1024]; udpConnection.Receive(udpMessage,1024); - string message=udpMessage; - if(message.length()){ - vector tokens=split(message,','); + string mess=udpMessage; + if(mess.length()){ + messageTime=ofGetElapsedTimef(); + printf("%s\n",mess.c_str()); + vector tokens=split(mess,','); //long dev=atol(n.c_str()); something crazy going on. this always seems to read out 32 bits if (!tokens[0].substr(0,4).compare("IMSI")) { //this is an event + message=tokens[0]+" "+tokens[3]; string number=tokens[2]; if (!devices.count(number)) { string imei=string(tokens[1]); @@ -199,7 +205,6 @@ void testApp::update(){ devices[number]=obtsDevice(imsi,imei,number,icons,ofVec2f(a,r)); } devices[number].excite(); //whenever an event concerns a device it brightens - if(tokens[3].find("joined network")!=string::npos) devices[number].connect(); if(tokens[3].find("leaving network")!=string::npos) devices[number].disconnect(); if(tokens[3].find("queued")!=string::npos) { @@ -235,7 +240,6 @@ void testApp::update(){ } - else printf("%s\n",tokens[0].c_str()); } } @@ -245,6 +249,7 @@ void testApp::draw(){ ofSetLineWidth(1.5f); glDisable(GL_LIGHTING); + ofSetHexColor(0xffffff); bgimg.draw(0,0,windowWidth,windowHeight); camera.begin(); @@ -285,7 +290,7 @@ void testApp::draw(){ ofDrawBitmapString(imeis[i],p.x-20,p.y,p.z); } */ - float timeScale=windowHeight/ofGetElapsedTimef(); + float timeScale=windowHeight/ofGetElapsedTimef(); //pixels per second for (map::iterator i=devices.begin();i!=devices.end();i++){ (*i).second.draw(timeScale); @@ -296,9 +301,20 @@ void testApp::draw(){ ofSetHexColor(0xffffff); char reportStr[1024]; - sprintf(reportStr, "fps: %f", ofGetFrameRate()); - ofDrawBitmapString(reportStr, 10, windowHeight-10); + sprintf(reportStr, "fps: %3.0f", ofGetFrameRate()); + ofDrawBitmapString(reportStr, windowWidth-70, 12); + + int amt=255-((ofGetElapsedTimef()-messageTime)*25.0f); + if (amt>0) { + //ofEnableAlphaBlending(); + ofSetColor(amt,amt,amt); + sprintf(reportStr, "%s", message.c_str()); + ofDrawBitmapString(reportStr, 10, windowHeight-10); + //ofDisableAlphaBlending(); + } + + //ofSaveFrame(); } -- cgit v1.2.3