#include "testApp.h" /* openBTS visualisation ALL units relative to screen size in H or W viewpoint dynamic? focus on 'interesting' events? FRAMING REPRESENTATION OF TIME LABELLING & INFO handset class represents a handset how to deal with time/ range being limited -exponential -choose VP carefully- perspective -just decide the longest time that it will be active scalability -amount of text on screen icons -worthwhile? call/sms -pointer from caller to callee position update function to interpolate position basically working -antialisaing on polys in crazy -colours of everything pretty naff -fading feature -draw incoming events text //logarithmic time //better colours/ thicker lines? //line in middle? //colours from networks //ripples from events //ringing and connected segments of call - polygons much more transparent */ std::vector split(std::string l, char delim) { std::istringstream stm(l); std::vector tokens; for (;;) { std::string word; if (!getline(stm, word, delim)) break; tokens.push_back(word); } return tokens; } void testApp::setup(){ printf("setup: %ix%i on screen %ix%i\n",ofGetWidth(),ofGetHeight(),ofGetScreenWidth(),ofGetScreenHeight()); int windowMode = ofGetWindowMode(); if(windowMode == OF_FULLSCREEN){ this->windowWidth = ofGetScreenWidth(); this->windowHeight = ofGetScreenHeight(); } else if(windowMode == OF_WINDOW){ this->windowWidth = ofGetWidth(); this->windowHeight = ofGetHeight(); } //Q Why is it that if you put a camera at (0,0,-100) looking at (0,0,0) and an object at (0,0,0) the camera isn't pointing at the object? //A Because ortho is different /* camera.enableOrtho(); camera.setPosition(-windowWidth/2,-windowHeight*4.1f,windowWidth); //camera.lookAt(ofVec3f(-windowWidth/2,-windowHeight,0),ofVec3f(0, 1, 0)); camera.rotate(70,1,0,0); camera.cacheMatrices(); //stop error messages */ //ofSetFrameRate(25); ofSetCircleResolution(windowWidth); ofEnableSmoothing(); camera.setPosition(0,windowHeight*10,windowHeight); camera.lookAt(ofVec3f(0,0,-windowHeight*.5),ofVec3f(0, 0, 1)); camera.setFov(6.5); camera.cacheMatrices(); bgimg.allocate(256,256,OF_IMAGE_COLOR); cols=new ofColor[4]; cols[0]=ofColor(80,80,120); cols[1]=ofColor(80,80,80); cols[2]=ofColor(0,0,0); cols[3]=ofColor(0,0,0); float fi,fj,ifi,ifj; fi=0.0f; ifi=1.0f; float si=1.0f/bgimg.width; float sj=1.0f/bgimg.height; unsigned char* px=bgimg.getPixels(); for (int i=0;i" at call commence. * "GSM disconnect" and then "GSM release" at call end. b.) To a mobile number: * "GSM alerting " when ringing. * "GSM call confirmed to " when ringing at both ends. * "GSM connect to " at pickup. * "GSM disconnect" as above at end, then "GSM release from mysql -u tim -h 134.226.86.120 -p > use openbts */ char udpMessage[1024]; udpConnection.Receive(udpMessage,1024); 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]); 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)); } 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[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[number].call(&devices[t_number]); } else devices[number].call(&devices["default"]); } 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[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[number].connectCall(); } } if(tokens[3].find("GSM release")!=string::npos) devices[number].endCall(); } } } //-------------------------------------------------------------- void testApp::draw(){ devices["base"].excite(); ofSetLineWidth(1.5f); glDisable(GL_LIGHTING); ofSetHexColor(0xffffff); bgimg.draw(0,0,windowWidth,windowHeight); ofEnableAlphaBlending(); ofSetColor(0xff,0xff,0xff,0x1f); textimg.draw(0,windowHeight-textimg.getHeight()); ofDisableAlphaBlending(); camera.begin(); //ofSphere(0,0,0,10); glDisable(GL_DEPTH_TEST); glDisable(GL_BLEND); ofPushMatrix(); ofRotate(ofGetElapsedTimef(),0,0,1); ofNoFill(); float rt=((ofGetElapsedTimef()*.25f)-floor(ofGetElapsedTimef()*.25f)); for (float f=rt*(windowWidth/10);f::iterator i=devices.begin();i!=devices.end();i++){ (*i).second.draw(timeScale); } ofPopMatrix(); camera.end(); ofSetHexColor(0xffffff); char reportStr[1024]; if (showFps) { 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(); } //-------------------------------------------------------------- void testApp::keyPressed(int key){ switch (key){ case ' ': ofSaveFrame(); printf("[%8.2f] saved an image\n",ofGetElapsedTimef()); break; case 'f': showFps=!showFps; } } //-------------------------------------------------------------- void testApp::keyReleased(int key){ } //-------------------------------------------------------------- void testApp::mouseMoved(int x, int y ){ } //-------------------------------------------------------------- void testApp::mouseDragged(int x, int y, int button){ } //-------------------------------------------------------------- void testApp::mousePressed(int x, int y, int button){ } //-------------------------------------------------------------- void testApp::mouseReleased(int x, int y, int button){ } //-------------------------------------------------------------- void testApp::windowResized(int w, int h){ } //-------------------------------------------------------------- void testApp::gotMessage(ofMessage msg){ } //-------------------------------------------------------------- void testApp::dragEvent(ofDragInfo dragInfo){ }