summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xeventStreamer/eventStreamer.py38
-rw-r--r--openBTSviz.layout4
-rw-r--r--src/main.cpp2
-rw-r--r--src/obtsDevice.cpp41
-rw-r--r--src/testApp.cpp72
5 files changed, 91 insertions, 66 deletions
diff --git a/eventStreamer/eventStreamer.py b/eventStreamer/eventStreamer.py
index 35c7033..7e97821 100755
--- a/eventStreamer/eventStreamer.py
+++ b/eventStreamer/eventStreamer.py
@@ -25,11 +25,24 @@ outsock = socket.socket( socket.AF_INET,socket.SOCK_DGRAM )
devices={}
def sendevent(e):
+ if not devices[e[3]].has_key('IMSI'):
+ devices[e[3]]['IMSI']="123456789012345"
+ elif devices[e[3]]['IMSI']==None:
+ devices[e[3]]['IMSI']="123456789012345"
+ if not devices[e[3]].has_key('IMEI'):
+ devices[e[3]]['IMEI']="1234567890"
+ elif devices[e[3]]['IMEI']==None:
+ devices[e[3]]['IMEI']="1234567890"
+ if not devices[e[3]].has_key('number'):
+ devices[e[3]]['number']="1234"
+ elif devices[e[3]]['number']==None:
+ devices[e[3]]['number']="1234"
#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) )
def senddevice(d):
+ print d['IMSI'],d['IMEI'],d['number'],",retreived"
outsock.sendto( d['IMSI']+"^"+d['IMEI']+"^"+d['number']+"^"+"retreived", (config.viz_ip, config.viz_port) )
def main():
@@ -62,12 +75,18 @@ def main():
cursor.execute(sql)
results = cursor.fetchall()
for row in results:
- d={}
- d['IMSI']=row[1]
- d['IMEI']=row[2]
- d['number']=row[3]
- devices[row[0]]=d
- senddevice(d)
+ try:
+ d={}
+ d['IMSI']=row[1]
+ try:
+ d['IMEI']=row[2]
+ except:
+ d['IMEI']="dummy"
+ d['number']=row[3]
+ devices[row[0]]=d
+ senddevice(d)
+ except:
+ print "Error: handset with missing fields"
except:
print "Error: unable to fetch handset list"
@@ -133,7 +152,10 @@ def main():
for row in imresults:
d={}
d['IMSI']=row[1]
- d['IMEI']=row[2]
+ try:
+ d['IMEI']=row[2]
+ except:
+ d['IMEI']="dummy"
d['number']=row[3]
devices[row[0]]=d
print "new IMSI: ",d['IMSI']
@@ -148,4 +170,4 @@ def main():
db.close()
-if __name__ == '__main__': main() \ No newline at end of file
+if __name__ == '__main__': main()
diff --git a/openBTSviz.layout b/openBTSviz.layout
index 3a0aa18..2f8ee02 100644
--- a/openBTSviz.layout
+++ b/openBTSviz.layout
@@ -14,13 +14,13 @@
<Cursor position="215" topLine="0" />
</File>
<File name="src/obtsDevice.cpp" open="1" top="1" tabpos="7">
- <Cursor position="1320" topLine="30" />
+ <Cursor position="1320" topLine="79" />
</File>
<File name="src/obtsDevice.h" open="1" top="0" tabpos="8">
<Cursor position="1726" topLine="37" />
</File>
<File name="src/testApp.cpp" open="1" top="0" tabpos="6">
- <Cursor position="5636" topLine="164" />
+ <Cursor position="5636" topLine="173" />
</File>
<File name="src/testApp.h" open="1" top="0" tabpos="4">
<Cursor position="629" topLine="0" />
diff --git a/src/main.cpp b/src/main.cpp
index ad74a97..904ded2 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -6,7 +6,7 @@
int main( ){
ofAppGlutWindow window;
- ofSetupOpenGL(&window, 450,800, OF_WINDOW ); // <-------- setup the GL context
+ ofSetupOpenGL(&window, 1440,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 630af69..ebb1fb6 100644
--- a/src/obtsDevice.cpp
+++ b/src/obtsDevice.cpp
@@ -15,15 +15,15 @@ obtsDevice::obtsDevice(string &imsi,string &imei,string &num,ofImage *_icon,ofVe
calling=false;
exciteLevel=0.99;
lastTime=ofGetElapsedTimef();
-
-
+
+
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);
}
@@ -42,7 +42,7 @@ obtsDevice::obtsDevice(string &imsi,string &imei,string &num,ofImage *_icon,ofVe
else colour=ofColor(160,160,160);
}
else colour=ofColor(0,0,0);
-
+
}
obtsDevice::~obtsDevice()
@@ -116,23 +116,23 @@ void obtsDevice::draw(float t)
timeScale=t;
float decay=2.0;
float now=ofGetElapsedTimef();
- if ((now-lastUsed) > 6000) disconnect(); //connection timeout 10 minutes
+ if ((now-lastUsed) > 600) disconnect(); //connection timeout 10 minutes
float timeSeg=now-lastTime;
lastTime=now;
- //draw a line at the angular position of the device
+ //draw a line at the angular position of the device
//z=0 is the 'surface' i.e. now.
- //the device know the time now and when it was created
+ //the device know the time now and when it was created
//needs to know the time the app began in order to scale the line vertically
//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.
-
+
if (connectionHistory.size()) {
-
+
float rf=sin((coords.y/(ofGetWidth()*0.9))*TWO_PI);
ofSetColor(colour); //*rf);
float endPos;
@@ -147,9 +147,9 @@ void obtsDevice::draw(float t)
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++){
float stimepos=-timeCoord(now-(*i).startTime);
float etimepos=((*i).endTime>0.0f?-timeCoord(now-(*i).endTime):0.0f);
@@ -171,12 +171,15 @@ void obtsDevice::draw(float t)
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();
- }
- }
-
+ }
+ if (((*i).endTime<0.1f)&&((now-(*i).startTime)>30.0f)) endCall();
+ }
+
+
+
ofDisableAlphaBlending();
-
- int greylev=0x7f+((int)(128.0f*exciteLevel));
+
+ int greylev=160+((int)(95.0f*exciteLevel));
//printf("%s %i\n",number.c_str(),greylev);
ofSetColor(greylev,greylev,greylev,0xff);
ofSetDrawBitmapMode(OF_BITMAPMODE_MODEL_BILLBOARD);
diff --git a/src/testApp.cpp b/src/testApp.cpp
index 7b28acd..8be99a6 100644
--- a/src/testApp.cpp
+++ b/src/testApp.cpp
@@ -66,8 +66,8 @@ void testApp::setup(){
int windowMode = ofGetWindowMode();
if(windowMode == OF_FULLSCREEN){
- this->windowWidth = ofGetScreenWidth();
- this->windowHeight = ofGetScreenHeight();
+ this->windowWidth = ofGetWidth(); //Screen
+ this->windowHeight = ofGetHeight(); //Screen
}
else if(windowMode == OF_WINDOW){
this->windowWidth = ofGetWidth();
@@ -90,16 +90,16 @@ void testApp::setup(){
ofEnableSmoothing();
camera.setPosition(0,windowHeight*10,windowHeight);
- camera.lookAt(ofVec3f(0,0,-windowHeight*.5),ofVec3f(0, 0, 1));
+ camera.lookAt(ofVec3f(0,0,-windowHeight*.49),ofVec3f(0, 0, 1));
camera.setFov(6.5);
- camera.cacheMatrices();
+// camera.cacheMatrices();3047
bgimg.allocate(256,256,OF_IMAGE_COLOR);
cols=new ofColor[4];
- cols[0]=ofColor(80,80,120);
- cols[1]=ofColor(80,80,80);
+ cols[0]=ofColor(100,100,150);
+ cols[1]=ofColor(100,100,100);
cols[2]=ofColor(0,0,0);
cols[3]=ofColor(0,0,0);
float fi,fj,ifi,ifj;
@@ -134,42 +134,42 @@ void testApp::setup(){
udpConnection.Create();
udpConnection.Bind(7888);
udpConnection.SetNonBlocking(true);
-
+
string def="";
devices["base"]=obtsDevice(def,def,def,icons,ofVec2f(0,0));
devices["base"].connect();
-
+
message="";
messageTime=0.0f;
-
+
showFps=false;
}
//--------------------------------------------------------------
void testApp::update(){
-
+
//check incoming messages
//create device or update as necessary
//also display a feed of events in text form
-
+
/*
-
+
MESSAGE FORMAT
NETWORK
-
+
* "GSM joined network" for a first time connection
* "GSM rejoined network" for a phone coming back
- * "GSM leaving network" for a phone leaving. (Though these can't be relied upon)
+ * "GSM leaving network" for a phone leaving. (Though these can't be relied upon)
SMS
-
+
* "SMS to IMSIXXXXXXXXXXXXXXX queued for sending" for an attempt to text a valid number
* "SMS to XX failed. Number not found" for an attempt to text an invalid number
* "SMS Message acknowledged" A message sent by this IMSI was delivered.
-
+
CALLS
a.) To a non-mobile number:
@@ -179,11 +179,11 @@ void testApp::update(){
b.) To a mobile number:
- * "GSM alerting <phone_number>" when ringing.
+ * "GSM alerting <phone_number>" when ringing.
* "GSM call confirmed to <phone_number>" when ringing at both ends.
* "GSM connect to <phone_number>" at pickup.
* "GSM disconnect" as above at end, then "GSM release from <phone_number".
-
+
username: "tim"
password: "Visualise this"
host: 134.226.86.120
@@ -194,7 +194,7 @@ void testApp::update(){
> mysql -u tim -h 134.226.86.120 -p
<Enter password>
> use openbts
-
+
*/
char udpMessage[1024];
udpConnection.Receive(udpMessage,1024);
@@ -215,16 +215,16 @@ void testApp::update(){
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].connect(); //just in case it hasnt been recognised
+ devices[t_number].excite(); //just in case it hasnt been recognised
devices[number].sms(&devices[t_number]);
}
}
@@ -232,16 +232,16 @@ void testApp::update(){
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].connect(); //just in case it hasnt been recognised
+ devices[t_number].excite(); //just in case it hasnt been recognised
devices[number].call(&devices[t_number]);
}
- else devices[number].call(&devices["default"]);
+ 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].connect(); //just in case it hasnt been recognised
+ devices[t_number].excite(); //just in case it hasnt been recognised
devices[number].ringing(&devices[t_number]);
}
}
@@ -249,13 +249,13 @@ void testApp::update(){
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].connect(); //just in case it hasnt been recognised
+ 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();
-
-
+
+
}
}
}
@@ -269,10 +269,10 @@ void testApp::draw(){
glDisable(GL_LIGHTING);
ofSetHexColor(0xffffff);
bgimg.draw(0,0,windowWidth,windowHeight);
-
+
ofEnableAlphaBlending();
- ofSetColor(0xff,0xff,0xff,0x1f);
- textimg.draw(0,windowHeight-textimg.getHeight());
+ ofSetColor(0xff,0xff,0xff,0x5f);
+ textimg.draw(0,windowHeight-(textimg.getHeight()*2),textimg.getWidth()*2,textimg.getHeight()*2);
ofDisableAlphaBlending();
camera.begin();
@@ -323,16 +323,16 @@ void testApp::draw(){
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);
+
+ int amt=255-((ofGetElapsedTimef()-messageTime)*8.0f);
if (amt>0) {
//ofEnableAlphaBlending();
ofSetColor(amt,amt,amt);
@@ -341,7 +341,7 @@ void testApp::draw(){
//ofDisableAlphaBlending();
}
-
+
//ofSaveFrame();
}