diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/main.cpp | 2 | ||||
| -rw-r--r-- | src/obtsDevice.cpp | 4 | ||||
| -rw-r--r-- | src/testApp.cpp | 143 | ||||
| -rw-r--r-- | src/testApp.h | 9 |
4 files changed, 98 insertions, 60 deletions
diff --git a/src/main.cpp b/src/main.cpp index 904ded2..7119c0b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -6,7 +6,7 @@ int main( ){ ofAppGlutWindow window; - ofSetupOpenGL(&window, 1440,900, OF_FULLSCREEN); // <-------- setup the GL context + ofSetupOpenGL(&window, 1600,900, OF_FULLSCREEN); // <-------- setup the GL context printf("%ix%i on screen %ix%i\n",ofGetWidth(),ofGetHeight(),ofGetScreenWidth(),ofGetScreenHeight()); // this kicks off the running of my app // can be OF_WINDOW or OF_FULLSCREEN diff --git a/src/obtsDevice.cpp b/src/obtsDevice.cpp index ebb1fb6..5677d0a 100644 --- a/src/obtsDevice.cpp +++ b/src/obtsDevice.cpp @@ -116,7 +116,7 @@ void obtsDevice::draw(float t) timeScale=t;
float decay=2.0;
float now=ofGetElapsedTimef();
- if ((now-lastUsed) > 600) disconnect(); //connection timeout 10 minutes
+ if ((now-lastUsed) > 6) disconnect(); //connection timeout 10 minutes
float timeSeg=now-lastTime;
lastTime=now;
//draw a line at the angular position of the device
@@ -172,7 +172,7 @@ void obtsDevice::draw(float t) glVertex3f(cos(coords.x)*coords.y,sin(coords.x)*coords.y,etimepos);
glEnd();
} - if (((*i).endTime<0.1f)&&((now-(*i).startTime)>30.0f)) endCall();
+ if (((*i).endTime<0.1f)&&((now-(*i).startTime)>3.0f)) endCall(); //was 30
} diff --git a/src/testApp.cpp b/src/testApp.cpp index 8be99a6..5830c12 100644 --- a/src/testApp.cpp +++ b/src/testApp.cpp @@ -144,6 +144,11 @@ void testApp::setup(){ messageTime=0.0f; showFps=false; + + dragStartX=dragStartY=0; + dragSavedX=dragSavedY=dragOffsX=dragOffsY=0.0f; + + ofBackground(0); } @@ -204,57 +209,75 @@ void testApp::update(){ 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]); - string imsi=string(tokens[0].substr(4)); - //create a new device at a random position - float a=ofRandom(TWO_PI); - float r=ofRandom(windowWidth/3)+(windowWidth/6); - devices[number]=obtsDevice(imsi,imei,number,icons,ofVec2f(a,r)); - } - - if(tokens[3].find("retreived")==string::npos) 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) { - string t_number=split(tokens[3],' ')[4]; - printf(">>> SMS from %s to %s (%i)\n",number.c_str(),t_number.c_str(),devices.count(t_number)); - if (devices.count(t_number)) { - devices[t_number].excite(); //just in case it hasnt been recognised - devices[number].sms(&devices[t_number]); - } - } - if(tokens[3].find("connect acknowledge")!=string::npos) { - string t_number=split(tokens[3],' ')[3]; - printf(">>> call from %s to %s\n",number.c_str(),t_number.c_str()); - if (devices.count(t_number)) { - devices[t_number].excite(); //just in case it hasnt been recognised - devices[number].call(&devices[t_number]); - } - else devices[number].call(&devices["base"]); - } - if(tokens[3].find("call confirmed")!=string::npos) { - string t_number=split(tokens[3],' ')[4]; - printf(">>> ringing from %s to %s\n",number.c_str(),t_number.c_str()); - if (devices.count(t_number)) { - devices[t_number].excite(); //just in case it hasnt been recognised - devices[number].ringing(&devices[t_number]); - } - } - if(tokens[3].find("connect to")!=string::npos) { - string t_number=split(tokens[3],' ')[3]; - printf(">>> call connected from %s to %s\n",number.c_str(),t_number.c_str()); - if (devices.count(t_number)) { - devices[t_number].excite(); //just in case it hasnt been recognised - devices[number].connectCall(); - } - } - if(tokens[3].find("GSM release")!=string::npos) devices[number].endCall(); - + if (tokens.size()>3) { + 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]); + string imsi=string(tokens[0].substr(4)); + //create a new device at a random position + float a=ofRandom(TWO_PI); + float r=ofRandom(windowWidth/3)+(windowWidth/6); + + float x=cos(a)*r; + float y=sin(a)*r; + + //add subtlety + //for (int i=0;i<devices.size()) { + // float d= + //} + + devices[number]=obtsDevice(imsi,imei,number,icons,ofVec2f(a,r)); + } + + if(tokens[3].find("retreived")==string::npos) 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) { + if (split(tokens[3],' ').size()>4) { + string t_number=split(tokens[3],' ')[4]; + printf(">>> SMS from %s to %s (%i)\n",number.c_str(),t_number.c_str(),devices.count(t_number)); + if (devices.count(t_number)) { + devices[t_number].excite(); //just in case it hasnt been recognised + devices[number].sms(&devices[t_number]); + } + } + } + if(tokens[3].find("connect acknowledge")!=string::npos) { + if (split(tokens[3],' ').size()>3) { + string t_number=split(tokens[3],' ')[3]; + printf(">>> call from %s to %s\n",number.c_str(),t_number.c_str()); + if (devices.count(t_number)) { + devices[t_number].excite(); //just in case it hasnt been recognised + devices[number].call(&devices[t_number]); + } + else devices[number].call(&devices["base"]); + } + } + if(tokens[3].find("call confirmed")!=string::npos) { + if (split(tokens[3],' ').size()>4) { + string t_number=split(tokens[3],' ')[4]; + printf(">>> ringing from %s to %s\n",number.c_str(),t_number.c_str()); + if (devices.count(t_number)) { + devices[t_number].excite(); //just in case it hasnt been recognised + devices[number].ringing(&devices[t_number]); + } + } + } + if(tokens[3].find("connect to")!=string::npos) { + if (split(tokens[3],' ').size()>3) { + string t_number=split(tokens[3],' ')[3]; + printf(">>> call connected from %s to %s\n",number.c_str(),t_number.c_str()); + if (devices.count(t_number)) { + devices[t_number].excite(); //just in case it hasnt been recognised + devices[number].connectCall(); + } + } + } + if(tokens[3].find("GSM release")!=string::npos) devices[number].endCall(); + } } } @@ -272,7 +295,7 @@ void testApp::draw(){ ofEnableAlphaBlending(); ofSetColor(0xff,0xff,0xff,0x5f); - textimg.draw(0,windowHeight-(textimg.getHeight()*2),textimg.getWidth()*2,textimg.getHeight()*2); + textimg.draw(0,windowHeight-(textimg.getHeight())); //*2),textimg.getWidth()*2,textimg.getHeight()*2); ofDisableAlphaBlending(); camera.begin(); @@ -284,6 +307,8 @@ void testApp::draw(){ ofPushMatrix(); ofRotate(ofGetElapsedTimef(),0,0,1); + ofRotate(dragOffsX,0,0,1); + ofRotate(dragOffsY,1,0,0); ofNoFill(); @@ -369,17 +394,27 @@ void testApp::mouseMoved(int x, int y ){ //-------------------------------------------------------------- void testApp::mouseDragged(int x, int y, int button){ - + dragOffsX=dragSavedX+(x-dragStartX); + dragOffsY=dragSavedY+(y-dragStartY); + //if (button) { + // printf("drag: %f,%f\n",dragOffsX,dragOffsY); + //} } //-------------------------------------------------------------- void testApp::mousePressed(int x, int y, int button){ + dragStartX=x; + dragStartY=y; + //if (button) { + // printf("start: %i %i,%i\n",button,x,y); + //} } //-------------------------------------------------------------- void testApp::mouseReleased(int x, int y, int button){ - + dragSavedX+=x-dragStartX; + dragSavedY+=y-dragStartY; } //-------------------------------------------------------------- diff --git a/src/testApp.h b/src/testApp.h index 98c4527..b8066e0 100644 --- a/src/testApp.h +++ b/src/testApp.h @@ -25,7 +25,7 @@ class testApp : public ofBaseApp{ ofxUDPManager udpConnection; ofCamera camera; - + map<string,obtsDevice> devices; ofImage bgimg; @@ -33,11 +33,14 @@ class testApp : public ofBaseApp{ ofColor *cols; ofImage *icons; - + string message; float messageTime; - + bool showFps; + int dragStartX,dragStartY; + float dragSavedX,dragSavedY,dragOffsX,dragOffsY; + }; |
