summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Redfern <tim@eclectronics.org>2012-06-01 17:49:36 +0100
committerTim Redfern <tim@eclectronics.org>2012-06-01 17:49:36 +0100
commit4ca02e7856d0e660906e2a0f04150fbfce70214d (patch)
treeeeb15426d9fa1e5bca8d713177b567c88f87a01f
parente410b99203100c47674c92b910f6e0422b39ccdf (diff)
event streamer
-rwxr-xr-xeventStreamer/config.py6
-rwxr-xr-xeventStreamer/eventStreamer.py72
-rw-r--r--src/testApp.cpp47
-rw-r--r--src/testApp.h4
4 files changed, 110 insertions, 19 deletions
diff --git a/eventStreamer/config.py b/eventStreamer/config.py
new file mode 100755
index 0000000..88cf9ac
--- /dev/null
+++ b/eventStreamer/config.py
@@ -0,0 +1,6 @@
+mysql_ip="127.0.0.1"
+mysql_user="openBTS"
+mysql_pword="openBTS"
+mysql_db="openBTS"
+viz_port="7888"
+viz_ip="127.0.0.1" \ No newline at end of file
diff --git a/eventStreamer/eventStreamer.py b/eventStreamer/eventStreamer.py
new file mode 100755
index 0000000..326ff89
--- /dev/null
+++ b/eventStreamer/eventStreamer.py
@@ -0,0 +1,72 @@
+#!/usr/bin/python
+
+import MySQLdb,datetime,string
+import config
+
+from optparse import OptionParser
+
+parser = OptionParser()
+parser.add_option("-t", "--time", type="string", dest="time", default="",help="start time HH:MM:SS.sss")
+parser.add_option("-d", "--date", type="string", dest="date", default="",help="start date YYYY-MM-DD")
+(options, args) = parser.parse_args()
+
+def sqldatetime(t):
+ return string.replace(t.isoformat(),"T"," ")
+
+def main():
+
+ startTime=None
+
+ date=options.date
+ time=options.time
+
+ now=datetime.datetime.now()
+
+ if date=="":
+ date=str(now.year)+"-"+str(now.month)+"-"+str(now.day)
+
+ if time=="":
+ time="0:00:00.0"
+
+ startTime=datetime.datetime.strptime(date+" "+time,"%Y-%m-%d %H:%M:%S.%f")
+
+ db = MySQLdb.connect(config.mysql_ip,config.mysql_user,config.mysql_pword,config.mysql_db)
+ cursor = db.cursor()
+
+ sql = "SELECT * FROM IMSIs"
+ devices={}
+
+ try:
+ cursor.execute(sql)
+ results = cursor.fetchall()
+ for row in results:
+ d={}
+ d['IMSI']=row[1]
+ d['number']=row[2]
+ d['ts']=row[3]
+ devices[row[0]]=d
+ except:
+ print "Error: unable to fetch data"
+
+ #get 1st event
+ sql = "SELECT * FROM events Where ts Between '"+sqldatetime(startTime)+"' And '"+sqldatetime(now)+"' LIMIT 1"
+ print sql
+
+ try:
+ cursor.execute(sql)
+ results = cursor.fetchall()
+ id=long(results[0][0])
+ device_id=results[0][3]
+ print "id:",id,results[0][1],devices[device_id]['IMSI']
+ sql = "SELECT * FROM events Where id = "+str(id+1)
+ cursor.execute(sql)
+ results = cursor.fetchall()
+ print "next:",results[0][1]
+ except:
+ print "Error: unable to fetch data"
+
+ #2 modes of operation depending whether realtime or historical
+
+ db.close()
+
+if __name__ == '__main__': main() \ No newline at end of file
diff --git a/src/testApp.cpp b/src/testApp.cpp
index 6091759..629ffce 100644
--- a/src/testApp.cpp
+++ b/src/testApp.cpp
@@ -84,30 +84,39 @@ void testApp::setup(){
}
- //bgimg.allocate(256,256,OF_IMAGE_COLOR);
- //
- /*
+ bgimg.allocate(256,256,OF_IMAGE_COLOR);
+
+
cols=new ofColor[4];
- cols[0]=ofColor(80,80,80);
+ 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;
- float si=1.0f/bgimg.width;
- float sj=1.0f/bgimg.height;
- for (int i=0,fi=0.0f,ifi=1.0f;i<bgimg.width;i++,fi+=si,ifi-=si){
- for (int j=0,fj=0.0f,ifj=1.0f;j<bgimg.width;j++,fj+=sj,ifj-=sj){
- bgimg.getPixels()[(j*bgimg.width+i)*3]=(unsigned char)((ifj*((ifi*cols[0].r)+(fi*cols[1].r)))+(fj*((ifi*cols[2].r)+(fi*cols[3].r))));
- bgimg.getPixels()[(j*bgimg.width+i)*3+1]=(unsigned char)((ifj*((ifi*cols[0].g)+(fi*cols[1].g)))+(fj*((ifi*cols[2].g)+(fi*cols[3].g))));
- bgimg.getPixels()[(j*bgimg.width+i)*3+2]=(unsigned char)((ifj*((ifi*cols[0].b)+(fi*cols[1].b)))+(fj*((ifi*cols[2].b)+(fi*cols[3].b))));
- }
+ 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<bgimg.width;i++,fi+=si,ifi-=si){
+ fj=0.0f;
+ ifj=1.0f;
+ for (int j=0;j<bgimg.height;j++,fj+=sj,ifj-=sj){
+ px[(j*bgimg.width+i)*3]=(unsigned char)((ifj*((ifi*cols[0].r)+(fi*cols[1].r)))+(fj*((ifi*cols[2].r)+(fi*cols[3].r))));
+ px[(j*bgimg.width+i)*3+1]=(unsigned char)((ifj*((ifi*cols[0].g)+(fi*cols[1].g)))+(fj*((ifi*cols[2].g)+(fi*cols[3].g))));
+ px[(j*bgimg.width+i)*3+2]=(unsigned char)((ifj*((ifi*cols[0].b)+(fi*cols[1].b)))+(fj*((ifi*cols[2].b)+(fi*cols[3].b))));
+ }
}
- */
- bgimg.loadImage("TextureTrapdoor.jpg");
+
+
bgimg.setUseTexture(true);
bgimg.update();
-
+
+ icons=new ofImage[3];
+ icons[0].loadImage("Phone.png");
+ icons[1].loadImage("iPhone.png");
+ icons[2].loadImage("Tablet.png");
}
@@ -122,7 +131,7 @@ void testApp::update(){
void testApp::draw(){
glDisable(GL_LIGHTING);
- bgimg.draw(0,0,256,256); //windowWidth,windowHeight);
+ bgimg.draw(0,0,windowWidth,windowHeight);
camera.begin();
@@ -139,8 +148,10 @@ void testApp::draw(){
float rt=((ofGetElapsedTimef()*.25f)-floor(ofGetElapsedTimef()*.25f));
for (float f=rt*(windowWidth/10);f<windowWidth*0.9;f+=windowWidth/10) {
float rf=sin((f/(windowWidth*0.9))*TWO_PI);
- ofSetColor(0x7f*rf,0x7f*rf,0xff*rf);
+ ofSetColor(0x7f*rf,0x7f*rf,0xff*rf,0xff*rf);
+ ofEnableAlphaBlending();
ofCircle(0,0,0,f);
+ ofDisableAlphaBlending();
}
diff --git a/src/testApp.h b/src/testApp.h
index 3b6d4ba..7331ca5 100644
--- a/src/testApp.h
+++ b/src/testApp.h
@@ -1,6 +1,6 @@
#include "ofMain.h"
-
+#include "obtsDevice.h"
class testApp : public ofBaseApp{
@@ -29,6 +29,8 @@ class testApp : public ofBaseApp{
ofImage bgimg;
ofColor *cols;
+
+ ofImage *icons;
};