summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Redfern <tim@eclectronics.org>2012-06-29 18:36:46 +0100
committerTim Redfern <tim@eclectronics.org>2012-06-29 18:36:46 +0100
commitafed229f7f70d51313239394f6e1079fa6086da3 (patch)
tree4a2573cadf335eff1201f5a4833dcabf963d1151
parent4fdefc87b20f2a0c10f6497232edb9fd0cdfd58a (diff)
nearly finished
-rw-r--r--bin/data/text.pngbin0 -> 49310 bytes
-rwxr-xr-xeventStreamer/eventStreamer.py20
-rw-r--r--src/obtsDevice.cpp84
-rw-r--r--src/obtsDevice.h9
-rw-r--r--src/testApp.cpp39
-rw-r--r--src/testApp.h3
6 files changed, 123 insertions, 32 deletions
diff --git a/bin/data/text.png b/bin/data/text.png
new file mode 100644
index 0000000..31a5650
--- /dev/null
+++ b/bin/data/text.png
Binary files differ
diff --git a/eventStreamer/eventStreamer.py b/eventStreamer/eventStreamer.py
index ca64542..d35bcd8 100755
--- a/eventStreamer/eventStreamer.py
+++ b/eventStreamer/eventStreamer.py
@@ -27,7 +27,7 @@ devices={}
def sendevent(e):
#send all data in each event to avoid translation script having a state
print str(e[3]),devices[e[3]]['IMSI'],devices[e[3]]['IMEI'],devices[e[3]]['number'],str(e[1])
- outsock.sendto( devices[e[3]]['IMSI']+","+devices[e[3]]['IMEI']+","+devices[e[3]]['number']+","+str(e[1]), (config.viz_ip, config.viz_port) )
+ outsock.sendto( devices[e[3]]['IMSI']+"^"+devices[e[3]]['IMEI']+"^"+devices[e[3]]['number']+"^"+str(e[1]), (config.viz_ip, config.viz_port) )
def main():
@@ -124,15 +124,15 @@ def main():
if not devices.has_key(results[0][3]):
sql = "SELECT * FROM IMSIs Where id = "+str(results[0][3])
try:
- cursor.execute(sql)
- imresults = cursor.fetchall()
- for row in imresults:
- d={}
- d['IMSI']=row[1]
- d['number']=row[2]
- d['ts']=row[3]
- devices[row[0]]=d
- print "new IMSI: ",d['IMSI']
+ cursor.execute(sql)
+ imresults = cursor.fetchall()
+ for row in imresults:
+ d={}
+ d['IMSI']=row[1]
+ d['IMEI']=row[2]
+ d['number']=row[3]
+ devices[row[0]]=d
+ print "new IMSI: ",d['IMSI']
except:
print "Error: unable to fetch event handset"
exit()
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<timeseg>::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<tsms>::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<tcall>::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);
diff --git a/src/obtsDevice.h b/src/obtsDevice.h
index 33c130e..5f01277 100644
--- a/src/obtsDevice.h
+++ b/src/obtsDevice.h
@@ -69,7 +69,7 @@ class obtsDevice
obtsDevice();
obtsDevice(string &imsi,string &imei,string &num,ofImage *_icon,ofVec2f _coords);
virtual ~obtsDevice();
- void draw(float timeScale); //units per second
+ void draw(float ts); //units per second
void connect();
void disconnect();
void ringing(obtsDevice *to);
@@ -78,9 +78,12 @@ class obtsDevice
void endCall();
void sms(obtsDevice *to);
void excite(float amount=0.99);
+ float timeCoord(float t);
protected:
private:
- float exciteLevel;
+ float exciteLevel;
+ float lastUsed;
+ float timeScale;
string IMSI,IMEI,number;
ofVec2f coords; //angular coords
vector<timeseg> connectionHistory;
@@ -90,6 +93,8 @@ class obtsDevice
bool active,calling;
float lastTime;
+
+ ofColor colour;
};
diff --git a/src/testApp.cpp b/src/testApp.cpp
index cc15122..9de5fab 100644
--- a/src/testApp.cpp
+++ b/src/testApp.cpp
@@ -39,6 +39,13 @@ basically working
-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<std::string> split(std::string l, char delim)
@@ -111,6 +118,7 @@ void testApp::setup(){
}
}
+ textimg.loadImage("text.png");
bgimg.setUseTexture(true);
@@ -130,9 +138,12 @@ void testApp::setup(){
string def="";
devices["base"]=obtsDevice(def,def,def,icons,ofVec2f(0,0));
+ devices["base"].connect();
message="";
messageTime=0.0f;
+
+ showFps=false;
}
@@ -191,7 +202,7 @@ void testApp::update(){
if(mess.length()){
messageTime=ofGetElapsedTimef();
printf("%s\n",mess.c_str());
- vector<string> tokens=split(mess,',');
+ 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];
@@ -208,15 +219,15 @@ void testApp::update(){
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],' ')[2];
- printf("SMS from %s to %s\n",number.c_str(),t_number.c_str());
+ 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());
+ 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]);
}
@@ -224,14 +235,14 @@ void testApp::update(){
}
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());
+ 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());
+ printf(">>> call connected from %s to %s\n",number.c_str(),t_number.c_str());
if (devices.count(t_number)) {
devices[number].connectCall();
}
@@ -245,12 +256,18 @@ void testApp::update(){
//--------------------------------------------------------------
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();
@@ -300,9 +317,13 @@ void testApp::draw(){
camera.end();
ofSetHexColor(0xffffff);
+
char reportStr[1024];
- sprintf(reportStr, "fps: %3.0f", ofGetFrameRate());
- ofDrawBitmapString(reportStr, windowWidth-70, 12);
+
+ if (showFps) {
+ sprintf(reportStr, "fps: %3.0f", ofGetFrameRate());
+ ofDrawBitmapString(reportStr, windowWidth-70, 12);
+ }
int amt=255-((ofGetElapsedTimef()-messageTime)*25.0f);
@@ -325,6 +346,8 @@ void testApp::keyPressed(int key){
ofSaveFrame();
printf("[%8.2f] saved an image\n",ofGetElapsedTimef());
break;
+ case 'f':
+ showFps=!showFps;
}
}
diff --git a/src/testApp.h b/src/testApp.h
index cbcb8b0..98c4527 100644
--- a/src/testApp.h
+++ b/src/testApp.h
@@ -29,12 +29,15 @@ class testApp : public ofBaseApp{
map<string,obtsDevice> devices;
ofImage bgimg;
+ ofImage textimg;
ofColor *cols;
ofImage *icons;
string message;
float messageTime;
+
+ bool showFps;
};