summaryrefslogtreecommitdiff
path: root/src/obtsDevice.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/obtsDevice.cpp')
-rw-r--r--src/obtsDevice.cpp96
1 files changed, 86 insertions, 10 deletions
diff --git a/src/obtsDevice.cpp b/src/obtsDevice.cpp
index 70e60c3..85d5f18 100644
--- a/src/obtsDevice.cpp
+++ b/src/obtsDevice.cpp
@@ -4,30 +4,82 @@ obtsDevice::obtsDevice()
{
}
-obtsDevice::obtsDevice(string &imsi,ofImage *_icon,ofVec2f _coords)
+obtsDevice::obtsDevice(string &imsi,string &imei,string &num,ofImage *_icon,ofVec2f _coords)
{
IMSI=imsi;
+ IMEI=imei;
+ number=num;
coords=_coords;
icon=_icon;
- connect();
+ active=false;
+ calling=false;
+ exciteLevel=1.0;
+ lastTime=ofGetElapsedTimef();
printf("new device: IMSI%s\n",IMSI.c_str());
}
+obtsDevice::~obtsDevice()
+{
+ //dtor
+}
+
+
void obtsDevice::connect(){
- connectionHistory.push_back(timeseg(ofGetElapsedTimef(),0.0f));
+ if (!active) {
+ connectionHistory.push_back(timeseg());
+ active=true;
+ }
}
void obtsDevice::disconnect(){
- connectionHistory[connectionHistory.size()-1].endTime=ofGetElapsedTimef();
+ if (active) {
+ connectionHistory[connectionHistory.size()-1].endTime=ofGetElapsedTimef();
+ active=false;
+ }
}
-obtsDevice::~obtsDevice()
-{
- //dtor
+void obtsDevice::ringing(obtsDevice *to){
+ if (!calling) {
+ callHistory.push_back(tcall(to,false));
+ calling=true;
+ }
+}
+
+void obtsDevice::connectCall(){
+ if (calling) {
+ callHistory[callHistory.size()-1].connect();
+ }
+}
+
+void obtsDevice::call(obtsDevice *to){
+ if (!calling) {
+ callHistory.push_back(tcall(to,true));
+ calling=true;
+ }
+}
+
+void obtsDevice::endCall(){
+ if (calling) {
+ callHistory[callHistory.size()-1].endTime=ofGetElapsedTimef();
+ callHistory[callHistory.size()-1].connected=false;
+ calling=false;
+ }
+}
+
+void obtsDevice::sms(obtsDevice *to){
+ smsHistory.push_back(tsms(to));
+}
+
+void obtsDevice::excite(float amount) {
+ exciteLevel=amount;
}
void obtsDevice::draw(float timeScale)
{
+ float decay=1.0;
+ float now=ofGetElapsedTimef();
+ float timeSeg=now-lastTime;
+ lastTime=now;
//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
@@ -37,11 +89,35 @@ void obtsDevice::draw(float timeScale)
//for fixed/dynamic, pass a scaling parameter when drawing
float rf=sin((coords.y/(ofGetWidth()*0.9))*TWO_PI);
ofSetColor(0x8f*rf,0x8f*rf,0x8f*rf);
- float now=ofGetElapsedTimef();
+ float endPos;
for (vector<timeseg>::iterator i=connectionHistory.begin();i!=connectionHistory.end();i++){
- float startPos=(-now+(*i).startTime)/timeScale;
- float endPos=(*i).endTime>0.0f?(-now+(*i).endTime)/timeScale:0.0f;
+ float startPos=((*i).startTime-now)/timeScale;
+ endPos=(*i).endTime>0.0f?((*i).endTime-now)/timeScale: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;
+ 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);
+ }
+
+ for (vector<tcall>::iterator i=callHistory.begin();i!=callHistory.end();i++){
+ ofSetColor(0xff,0xff,0x8f);
+ float stimepos=((*i).startTime-now)/timeScale;
+ float etimepos=((*i).endTime>0.0f?((*i).endTime-now)/timeScale:0.0f);
+ 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,etimepos);
+ glVertex3f(cos(coords.x)*coords.y,sin(coords.x)*coords.y,etimepos);
+ glEnd();
+ }
+
+ int greylev=0x7f+((int)(128.0f*exciteLevel));
+ ofSetHexColor(greylev+(greylev<<8)+(greylev<<16));
+ ofSetDrawBitmapMode(OF_BITMAPMODE_MODEL_BILLBOARD);
+ ofDrawBitmapString(number,cos(coords.x)*coords.y,sin(coords.x)*coords.y,endPos);
+ ofSetDrawBitmapMode(OF_BITMAPMODE_SIMPLE);
+ exciteLevel=pow(exciteLevel,1+(timeSeg*decay));
}