summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--addons.make2
-rwxr-xr-xeventStreamer/config.py2
-rwxr-xr-xeventStreamer/eventStreamer.py49
-rw-r--r--openBTSviz.layout8
-rw-r--r--src/testApp.cpp19
-rw-r--r--src/testApp.h5
6 files changed, 57 insertions, 28 deletions
diff --git a/addons.make b/addons.make
index 8b13789..17bb504 100644
--- a/addons.make
+++ b/addons.make
@@ -1 +1 @@
-
+ofxNetwork
diff --git a/eventStreamer/config.py b/eventStreamer/config.py
index 88cf9ac..7389ab9 100755
--- a/eventStreamer/config.py
+++ b/eventStreamer/config.py
@@ -2,5 +2,5 @@ mysql_ip="127.0.0.1"
mysql_user="openBTS"
mysql_pword="openBTS"
mysql_db="openBTS"
-viz_port="7888"
+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
index 326ff89..9f062e0 100755
--- a/eventStreamer/eventStreamer.py
+++ b/eventStreamer/eventStreamer.py
@@ -1,6 +1,6 @@
#!/usr/bin/python
-import MySQLdb,datetime,string
+import MySQLdb,datetime,string,time,socket
import config
from optparse import OptionParser
@@ -8,6 +8,7 @@ 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")
+parser.add_option("-a", "--accelerate", type="float", dest="acc", default=1.0,help="playback acceleration factor")
(options, args) = parser.parse_args()
def sqldatetime(t):
@@ -18,17 +19,20 @@ def main():
startTime=None
date=options.date
- time=options.time
+ logtime=options.time
now=datetime.datetime.now()
+ if logtime=="":
+ if date=="":
+ logtime=str(now.hour)+":"+str(now.minute)+":"+str(now.second+now.microsecond)
+ else:
+ logtime="0:00:00.0"
+
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")
+ startTime=datetime.datetime.strptime(date+" "+logtime,"%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()
@@ -50,20 +54,31 @@ def main():
#get 1st event
sql = "SELECT * FROM events Where ts Between '"+sqldatetime(startTime)+"' And '"+sqldatetime(now)+"' LIMIT 1"
- print sql
+
+ outsock = socket.socket( socket.AF_INET,socket.SOCK_DGRAM )
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]
+ cursor.execute(sql)
+ results = cursor.fetchall()
+ id=long(results[0][0])
+ device_id=results[0][3]
+ now=results[0][2]
+ print str(results[0][3])+" "+str(results[0][1])+" "+devices[results[0][3]]['IMSI'], (config.viz_ip, config.viz_port)
+ outsock.sendto( str(results[0][3])+" "+str(results[0][1])+" "+devices[results[0][3]]['IMSI'], (config.viz_ip, config.viz_port) )
+ while True:
+ id+=1
+ sql = "SELECT * FROM events Where id = "+str(id)
+ print sql
+ cursor.execute(sql)
+ results = cursor.fetchall()
+ print "waiting ",(((results[0][2]-now).total_seconds()+(results[0][2]-now).microseconds))*options.acc
+ time.sleep((((results[0][2]-now).total_seconds()+(results[0][2]-now).microseconds))*options.acc)
+ now=results[0][2]
+ print str(results[0][3])+" "+str(results[0][1])+" "+devices[results[0][3]]['IMSI']
+ outsock.sendto( str(results[0][3])+" "+str(results[0][1])+" "+devices[results[0][3]]['IMSI'], (config.viz_ip, config.viz_port) )
except:
- print "Error: unable to fetch data"
+ outsock.sendto( "end of data", (config.viz_ip, config.viz_port) )
+ print "Error: unable to fetch data"
#2 modes of operation depending whether realtime or historical
diff --git a/openBTSviz.layout b/openBTSviz.layout
index 0431eae..f5bc507 100644
--- a/openBTSviz.layout
+++ b/openBTSviz.layout
@@ -5,7 +5,7 @@
<Cursor position="0" topLine="0" />
</File>
<File name="addons.make" open="1" top="0" tabpos="2">
- <Cursor position="0" topLine="0" />
+ <Cursor position="10" topLine="0" />
</File>
<File name="config.make" open="1" top="0" tabpos="3">
<Cursor position="328" topLine="0" />
@@ -14,9 +14,9 @@
<Cursor position="519" topLine="0" />
</File>
<File name="src/testApp.cpp" open="1" top="1" tabpos="4">
- <Cursor position="553" topLine="7" />
+ <Cursor position="3347" topLine="120" />
</File>
- <File name="src/testApp.h" open="0" top="0" tabpos="6">
- <Cursor position="976" topLine="29" />
+ <File name="src/testApp.h" open="1" top="0" tabpos="5">
+ <Cursor position="570" topLine="0" />
</File>
</CodeBlocks_layout_file>
diff --git a/src/testApp.cpp b/src/testApp.cpp
index 629ffce..3b0b9b1 100644
--- a/src/testApp.cpp
+++ b/src/testApp.cpp
@@ -101,29 +101,40 @@ void testApp::setup(){
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){
+ 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.setUseTexture(true);
bgimg.update();
-
+
icons=new ofImage[3];
+
icons[0].loadImage("Phone.png");
icons[1].loadImage("iPhone.png");
icons[2].loadImage("Tablet.png");
+ //create the socket and bind to port 7888
+ udpConnection.Create();
+ udpConnection.Bind(7888);
+ udpConnection.SetNonBlocking(true);
+
}
//--------------------------------------------------------------
void testApp::update(){
-
+ char udpMessage[1024];
+ udpConnection.Receive(udpMessage,1024);
+ string message=udpMessage;
+ if(message!=""){
+ printf("%s\n",message.c_str());
+ }
}
diff --git a/src/testApp.h b/src/testApp.h
index 7331ca5..bb7e6b1 100644
--- a/src/testApp.h
+++ b/src/testApp.h
@@ -1,6 +1,7 @@
#include "ofMain.h"
#include "obtsDevice.h"
+#include "ofxNetwork.h"
class testApp : public ofBaseApp{
@@ -21,6 +22,8 @@ class testApp : public ofBaseApp{
int windowWidth, windowHeight;
+ ofxUDPManager udpConnection;
+
ofCamera camera;
int numLines;
@@ -29,7 +32,7 @@ class testApp : public ofBaseApp{
ofImage bgimg;
ofColor *cols;
-
+
ofImage *icons;
};