From afed229f7f70d51313239394f6e1079fa6086da3 Mon Sep 17 00:00:00 2001 From: Tim Redfern Date: Fri, 29 Jun 2012 18:36:46 +0100 Subject: nearly finished --- src/obtsDevice.cpp | 84 ++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 72 insertions(+), 12 deletions(-) (limited to 'src/obtsDevice.cpp') diff --git a/src/obtsDevice.cpp b/src/obtsDevice.cpp index c8255b4..7138475 100644 --- a/src/obtsDevice.cpp +++ b/src/obtsDevice.cpp @@ -15,7 +15,34 @@ obtsDevice::obtsDevice(string &imsi,string &imei,string &num,ofImage *_icon,ofVe calling=false; exciteLevel=0.99; lastTime=ofGetElapsedTimef(); - printf("new device: IMSI%s\n",IMSI.c_str()); + + + if (IMSI.size()) { + + //colour based on IMSI + string cc=IMSI.substr(3,2); + + printf("new device: carrier code %s\n",cc.c_str()); + + if(!cc.compare("02")) { //O2 + colour=ofColor(0,88,150); + } + else if (!cc.compare("01")) { //vodafone + colour=ofColor(248,0,0); + } + else if (!cc.compare("03")) { //meteor + colour=ofColor(242,105,0); + } + else if (!cc.compare("05")) { //three + colour=ofColor(0,168,0); + } + else if (!cc.compare("07")) { //eircom + colour=ofColor(241,91,37); + } + else colour=ofColor(160,160,160); + } + else colour=ofColor(0,0,0); + } obtsDevice::~obtsDevice() @@ -68,16 +95,28 @@ void obtsDevice::endCall(){ void obtsDevice::sms(obtsDevice *to){ smsHistory.push_back(tsms(to)); + printf("%s: %i sms in history\n",number.c_str(),smsHistory.size()); } void obtsDevice::excite(float amount) { + if (!active) connect(); //we lost it for some reason exciteLevel=amount; + lastUsed=ofGetElapsedTimef(); +} + +float obtsDevice::timeCoord(float t){ + //function to map time to the z dimension + //timescale is the number of pixels per second + //return t*timeScale; + return log10(t+1)*(ofGetHeight()/5); } -void obtsDevice::draw(float timeScale) +void obtsDevice::draw(float t) { + timeScale=t; float decay=2.0; float now=ofGetElapsedTimef(); + if ((now-lastUsed) > 6000) disconnect(); //connection timeout 10 minutes float timeSeg=now-lastTime; lastTime=now; //draw a line at the angular position of the device @@ -87,33 +126,54 @@ void obtsDevice::draw(float timeScale) //dynamic scaling or fixed vertical scale? //for dynamic, just scale vertically based on time //for fixed/dynamic, pass a scaling parameter when drawing + + //enable depth? possible? + //colour based on IMSI, excitation and movement + //sms and calls coloured based on the phone that made them. + float rf=sin((coords.y/(ofGetWidth()*0.9))*TWO_PI); - ofSetColor(0x8f*rf,0x8f*rf,0x8f*rf); + ofSetColor(colour); //*rf); float endPos; for (vector::iterator i=connectionHistory.begin();i!=connectionHistory.end();i++){ - float startPos=((*i).startTime-now)*timeScale; - endPos=(*i).endTime>0.0f?((*i).endTime-now)*timeScale:0.0f; + float startPos=-timeCoord(now-(*i).startTime); + endPos=(*i).endTime>0.0f?-timeCoord(now-(*i).endTime):0.0f; ofLine(cos(coords.x)*coords.y,sin(coords.x)*coords.y,startPos,cos(coords.x)*coords.y,sin(coords.x)*coords.y,endPos); //printf("%f drawing %f,%f,%f to %f,%f,%f\n",ofGetElapsedTimef(),cos(coords.x)*coords.y,sin(coords.x)*coords.y,startPos,cos(coords.x)*coords.y,sin(coords.x)*coords.y,endPos); } - ofSetColor(0xff,0x8f,0x8f); + for (vector::iterator i=smsHistory.begin();i!=smsHistory.end();i++){ - float timepos=((*i).time-now)*timeScale; + float timepos=-timeCoord(now-(*i).time); ofLine(cos(coords.x)*coords.y,sin(coords.x)*coords.y,timepos,cos((*i).recipient->coords.x)*(*i).recipient->coords.y,sin((*i).recipient->coords.x)*(*i).recipient->coords.y,timepos); } + ofEnableAlphaBlending(); + for (vector::iterator i=callHistory.begin();i!=callHistory.end();i++){ - ofSetColor(0xff,0xff,0x8f,0x7f); - float stimepos=((*i).startTime-now)*timeScale; - float etimepos=((*i).endTime>0.0f?((*i).endTime-now)*timeScale:0.0f); - glBegin(GL_QUADS); + float stimepos=-timeCoord(now-(*i).startTime); + float etimepos=((*i).endTime>0.0f?-timeCoord(now-(*i).endTime):0.0f); + float ctimepos=(*i).connected?-timeCoord(now-(*i).connectedTime):0.0f; + if ((*i).connectedTime>(*i).startTime||!(*i).connected) { //draw ringing section + ofSetColor(colour.r,colour.g,colour.b,0x2f); + glBegin(GL_QUADS); glVertex3f(cos(coords.x)*coords.y,sin(coords.x)*coords.y,stimepos); glVertex3f(cos((*i).recipient->coords.x)*(*i).recipient->coords.y,sin((*i).recipient->coords.x)*(*i).recipient->coords.y,stimepos); + glVertex3f(cos((*i).recipient->coords.x)*(*i).recipient->coords.y,sin((*i).recipient->coords.x)*(*i).recipient->coords.y,ctimepos); + glVertex3f(cos(coords.x)*coords.y,sin(coords.x)*coords.y,ctimepos); + glEnd(); + } + if ((*i).connected) { //draw connected section + ofSetColor(colour.r,colour.g,colour.b,0x4f); + glBegin(GL_QUADS); + glVertex3f(cos(coords.x)*coords.y,sin(coords.x)*coords.y,ctimepos); + glVertex3f(cos((*i).recipient->coords.x)*(*i).recipient->coords.y,sin((*i).recipient->coords.x)*(*i).recipient->coords.y,ctimepos); glVertex3f(cos((*i).recipient->coords.x)*(*i).recipient->coords.y,sin((*i).recipient->coords.x)*(*i).recipient->coords.y,etimepos); glVertex3f(cos(coords.x)*coords.y,sin(coords.x)*coords.y,etimepos); - glEnd(); + glEnd(); + } } + ofDisableAlphaBlending(); + int greylev=0x7f+((int)(128.0f*exciteLevel)); //printf("%s %i\n",number.c_str(),greylev); ofSetColor(greylev,greylev,greylev,0xff); -- cgit v1.2.3