summaryrefslogtreecommitdiff
path: root/src/testApp.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/testApp.cpp')
-rw-r--r--src/testApp.cpp143
1 files changed, 89 insertions, 54 deletions
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;
}
//--------------------------------------------------------------