diff options
Diffstat (limited to 'src/obtsDevice.cpp')
| -rw-r--r-- | src/obtsDevice.cpp | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/src/obtsDevice.cpp b/src/obtsDevice.cpp new file mode 100644 index 0000000..70e60c3 --- /dev/null +++ b/src/obtsDevice.cpp @@ -0,0 +1,47 @@ +#include "obtsDevice.h"
+
+obtsDevice::obtsDevice()
+{
+}
+
+obtsDevice::obtsDevice(string &imsi,ofImage *_icon,ofVec2f _coords)
+{
+ IMSI=imsi;
+ coords=_coords;
+ icon=_icon;
+ connect();
+ printf("new device: IMSI%s\n",IMSI.c_str());
+}
+
+void obtsDevice::connect(){
+ connectionHistory.push_back(timeseg(ofGetElapsedTimef(),0.0f));
+}
+
+void obtsDevice::disconnect(){
+ connectionHistory[connectionHistory.size()-1].endTime=ofGetElapsedTimef();
+}
+
+obtsDevice::~obtsDevice()
+{
+ //dtor
+}
+
+void obtsDevice::draw(float timeScale)
+{
+ //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
+ //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
+ float rf=sin((coords.y/(ofGetWidth()*0.9))*TWO_PI);
+ ofSetColor(0x8f*rf,0x8f*rf,0x8f*rf);
+ float now=ofGetElapsedTimef();
+ 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;
+ 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);
+ }
+}
|
