summaryrefslogtreecommitdiff
path: root/src/testApp.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/testApp.cpp')
-rw-r--r--src/testApp.cpp34
1 files changed, 25 insertions, 9 deletions
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<string> tokens=split(message,',');
+ string mess=udpMessage;
+ if(mess.length()){
+ messageTime=ofGetElapsedTimef();
+ printf("%s\n",mess.c_str());
+ vector<string> 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<string,obtsDevice>::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();
}