diff --git a/of/Active Tripod/bin/Active_Tripod.lib b/of/Active Tripod/bin/Active_Tripod.lib index 2c76e8c..91d6c18 100644 Binary files a/of/Active Tripod/bin/Active_Tripod.lib and b/of/Active Tripod/bin/Active_Tripod.lib differ diff --git a/of/Active Tripod/bin/Active_Tripod_debug.ilk b/of/Active Tripod/bin/Active_Tripod_debug.ilk new file mode 100644 index 0000000..e69de29 diff --git a/of/Active Tripod/bin/Active_Tripod_debug.lib b/of/Active Tripod/bin/Active_Tripod_debug.lib new file mode 100644 index 0000000..d8afbc9 Binary files /dev/null and b/of/Active Tripod/bin/Active_Tripod_debug.lib differ diff --git a/of/Active Tripod/bin/data/GUI/GRAPH GLOBALguiPagesettings.xml b/of/Active Tripod/bin/data/GUI/GRAPH GLOBALguiPagesettings.xml index fdc0ea6..9056bea 100644 --- a/of/Active Tripod/bin/data/GUI/GRAPH GLOBALguiPagesettings.xml +++ b/of/Active Tripod/bin/data/GUI/GRAPH GLOBALguiPagesettings.xml @@ -1,12 +1,12 @@ 2 Bar graph - 0 + 1 2 Solid Body graph - 1 + 0 2 diff --git a/of/Active Tripod/src/data/DataManager.cpp b/of/Active Tripod/src/data/DataManager.cpp index 55a2c2b..de8d38d 100644 --- a/of/Active Tripod/src/data/DataManager.cpp +++ b/of/Active Tripod/src/data/DataManager.cpp @@ -116,7 +116,25 @@ void DataManager::onMessage( Spacebrew::Message & m ) } if (data[i].substr(0, 6) == "value:") { - dataObject.value = ofToFloat(data[i].substr(6, -1).c_str()); + string valString = data[i].substr(6, -1).c_str(); + dataObject.value = ofToFloat(valString); + + if (dataObject.value > 1000000000) + { + // create long long int + stringstream sstr(valString); + __int64 val; + sstr >> val; + dataObject.longlongIntValue = val; + dataObject.stringValue = addCommasToNumberString(valString); + } + else + { + dataObject.longlongIntValue = 0; + dataObject.stringValue = (dataObject.value > 999) ? addCommasToNumberString(valString) : valString; + } + + printf("\ndataObject.longlongValue = %llli \n\n",dataObject.longlongIntValue); } if (data[i].substr(0, 4) == "min:") { @@ -129,7 +147,6 @@ void DataManager::onMessage( Spacebrew::Message & m ) if (data[i].substr(0, 5) == "unit:") { dataObject.unitMeasure = data[i].substr(5, -1).c_str(); - printf("------------ dataObject.unitMeasure = %s", data[i].substr(5, -1).c_str()); } } @@ -180,4 +197,40 @@ vector DataManager::explode(const string &delimiter, const string &str) } arr.push_back( str.substr(k, i-k) ); return arr; +} + + +string DataManager::addCommasToNumberString(string num) +{ + printf("adding commas \n"); + string temp; + string integral = num; + string fractional; + int decimalLocation = integral.find('.'); + + if (decimalLocation != -1) + { + integral = integral.substr(0 , decimalLocation); + fractional = integral.substr(decimalLocation); + } + else + { + integral = num; + fractional = ""; + } + + int endstring = integral.length(); + int i; + for(i = endstring - 3; i >= 0; i -= 3) { + if (i > 0) { + temp = ","+ integral.substr(i, 3) + temp; + } else { + temp = integral.substr(i, 3) + temp; + } + } + if (i < 0) { + temp = integral.substr(0, 3+i) + temp; + } + printf("adding commas - temp = %s\n", temp.c_str()); + return temp + fractional; } \ No newline at end of file diff --git a/of/Active Tripod/src/data/DataManager.h b/of/Active Tripod/src/data/DataManager.h index fba8d45..d8f773c 100644 --- a/of/Active Tripod/src/data/DataManager.h +++ b/of/Active Tripod/src/data/DataManager.h @@ -13,6 +13,8 @@ struct DataObject { string info; float value; + string stringValue; + long long int longlongIntValue; float min; float max; string unitMeasure; @@ -27,6 +29,7 @@ class DataManager void update(); void draw(); vector explode( const string &delimiter, const string &str); + string addCommasToNumberString(string num); // listen to spacebrew Messages void onMessage( Spacebrew::Message & m ); diff --git a/of/Active Tripod/src/visual/Scene.cpp b/of/Active Tripod/src/visual/Scene.cpp index ef6c65f..7d860a5 100644 --- a/of/Active Tripod/src/visual/Scene.cpp +++ b/of/Active Tripod/src/visual/Scene.cpp @@ -82,11 +82,11 @@ void Scene::drawGraphValues() ofSetColor(graphTextColour[0], graphTextColour[1], graphTextColour[2], graphTextColour[3]); text.setSize(graphTextSize); text.drawString( - ofToString(activeGraph->publisher0Data.back().value) + " " + activeGraph->publisher0Data[activeGraph->publisher0Data.size() - 1].unitMeasure, + activeGraph->publisher0Data.back().stringValue + " " + activeGraph->publisher0Data.back().unitMeasure, val0.x + 10, val0.y); text.drawString( - ofToString(activeGraph->publisher1Data.back().value) + " " + activeGraph->publisher1Data[activeGraph->publisher1Data.size() - 1].unitMeasure, + activeGraph->publisher1Data.back().stringValue + " " + activeGraph->publisher1Data.back().unitMeasure, val1.x + 10, val1.y); ofPopStyle(); @@ -156,30 +156,70 @@ void Scene::drawHUDCopy() vector *p0Data = &activeGraph->publisher0Data; vector *p1Data = &activeGraph->publisher1Data; + + + int amountToAverage = MIN(p0Data->size(), averageAmount); if (p0Data->size() > 2) { - float average0 = 0; - for (int i = 0; i < (int)amountToAverage; i++) - average0 += p0Data->at(p0Data->size() - i - 1).value; - average0 /= (int)amountToAverage; + if (p0Data->back().longlongIntValue > 0) + { + long long int average0 = 0; + for (int i = 0; i < (int)amountToAverage; i++) + average0 += p0Data->at(p0Data->size() - i - 1).value; + average0 /= (int)amountToAverage; - // (p0Data->back() + p0Data->at(p0Data->size() - 2) + p0Data->at(p0Data->size() - 2)) - blStr = "Increase: " + ofToString(p0Data->back().value - p0Data->at(p0Data->size() - 2).value) + "\n" + - "Current Value: " + ofToString(p0Data->back().value) + "\n" + - "Running average: " + ofToString(average0); - drawTextBox(blStr, "BOTTOM LEFT"); - + string valueWithCommas = addCommasToNumberString(ofToString(average0)); - float average1 = 0; - for (int i = 0; i < (int)amountToAverage; i++) - average1 += p1Data->at(p1Data->size() - i - 1).value; - average1 /= (int)amountToAverage; + blStr = "Increase: " + ofToString(p0Data->back().value - p0Data->at(p0Data->size() - 2).value) + "\n" + + "Current Value: " + p0Data->back().stringValue + "\n" + + "Running average: " + valueWithCommas; + drawTextBox(blStr, "BOTTOM LEFT"); + } + else + { + float average0 = 0; + for (int i = 0; i < (int)amountToAverage; i++) + average0 += p0Data->at(p0Data->size() - i - 1).value; + average0 /= (int)amountToAverage; + + string valueWithCommas = (average0 > 999) ? addCommasToNumberString(ofToString(average0)) : ofToString(average0); - brStr = "Increase: " + ofToString(p1Data->back().value - p1Data->at(p1Data->size() - 2).value) + "\n" + - "Current Value: " + ofToString(p1Data->back().value) + "\n" + - "Running average: " + ofToString(average1); - drawTextBox(brStr, "BOTTOM RIGHT"); + blStr = "Increase: " + ofToString(p0Data->back().value - p0Data->at(p0Data->size() - 2).value) + "\n" + + "Current Value: " + p0Data->back().stringValue + "\n" + + "Running average: " + valueWithCommas; + drawTextBox(blStr, "BOTTOM LEFT"); + } + + + if (p1Data->back().longlongIntValue > 0) + { + float average1 = 0; + for (int i = 0; i < (int)amountToAverage; i++) + average1 += p1Data->at(p1Data->size() - i - 1).value; + average1 /= (int)amountToAverage; + + string valueWithCommas = addCommasToNumberString(ofToString(average1)); + + brStr = "Increase: " + ofToString(p1Data->back().value - p1Data->at(p1Data->size() - 2).value) + "\n" + + "Current Value: " + p1Data->back().stringValue + "\n" + + "Running average: " + valueWithCommas; + drawTextBox(brStr, "BOTTOM RIGHT"); + } + else + { + long long int average1 = 0; + for (int i = 0; i < (int)amountToAverage; i++) + average1 += p1Data->at(p1Data->size() - i - 1).value; + average1 /= (int)amountToAverage; + + string valueWithCommas = (average1 > 999) ? addCommasToNumberString(ofToString(average1)) : ofToString(average1); + + brStr = "Increase: " + ofToString(p1Data->back().value - p1Data->at(p1Data->size() - 2).value) + "\n" + + "Current Value: " + p1Data->back().stringValue + "\n" + + "Running average: " + valueWithCommas; + drawTextBox(brStr, "BOTTOM RIGHT"); + } } } @@ -247,14 +287,13 @@ void Scene::addNewData(vector newData) bodyGraph.addNewData(newData); separateBodyGraph.addNewData(newData); - tlStr = newData[0].info + newData[0].unitMeasure + "\n" + ofToString(newData[0].value); - trStr = newData[1].info + newData[1].unitMeasure + "\n" + ofToString(newData[1].value); + tlStr = newData[0].info + newData[0].unitMeasure + "\n" + ofToString(newData[0].stringValue); + trStr = newData[1].info + newData[1].unitMeasure + "\n" + ofToString(newData[1].stringValue); } void Scene::keyPressed(int key) { - } @@ -263,4 +302,44 @@ void Scene::clearGraphData() barGraph.clear(); bodyGraph.clear(); separateBodyGraph.clear(); +} + + + + + + + + +string Scene::addCommasToNumberString(string num) +{ + string temp; + string integral = num; + string fractional; + int decimalLocation = integral.find('.'); + + if (decimalLocation != -1) + { + integral = integral.substr(0 , decimalLocation); + fractional = integral.substr(decimalLocation); + } + else + { + integral = num; + fractional = ""; + } + + int endstring = integral.length(); + int i; + for(i = endstring - 3; i >= 0; i -= 3) { + if (i > 0) { + temp = ","+ integral.substr(i, 3) + temp; + } else { + temp = integral.substr(i, 3) + temp; + } + } + if (i < 0) { + temp = integral.substr(0, 3+i) + temp; + } + return temp + fractional; } \ No newline at end of file diff --git a/of/Active Tripod/src/visual/Scene.h b/of/Active Tripod/src/visual/Scene.h index 5bad73c..35f83a2 100644 --- a/of/Active Tripod/src/visual/Scene.h +++ b/of/Active Tripod/src/visual/Scene.h @@ -1,10 +1,4 @@ -// -// GUI.h -// emptyExample -// -// Created by James Alliban on 25/06/2013. -// -// + #pragma once @@ -33,7 +27,7 @@ public: void addNewData(vector newData); void clearGraphData(); void keyPressed(int key); - + string addCommasToNumberString(string num); BarGraph barGraph; BodyGraph bodyGraph; diff --git a/of/Utility_Box/bin/Utility_Box.lib b/of/Utility_Box/bin/Utility_Box.lib index 20d8d9e..a778369 100644 Binary files a/of/Utility_Box/bin/Utility_Box.lib and b/of/Utility_Box/bin/Utility_Box.lib differ diff --git a/of/Utility_Box/bin/data/subscriber_log.txt b/of/Utility_Box/bin/data/subscriber_log.txt index 3298f83..674d064 100644 --- a/of/Utility_Box/bin/data/subscriber_log.txt +++ b/of/Utility_Box/bin/data/subscriber_log.txt @@ -13,33 +13,25 @@ Cryptocurrency exchange rate on mtgox.com 7 = Number of likes of the transmediale fan page on Facebook 8 = Haus der Kulturen Main Foyer - Noise Level -9 = Total twitter updates - +9 = 10 = Haus der Kulturen Bar Area - Noise Level -11 = HUAWEI Guangdong Stock Price on the Shenzen Exchange - +11 = 12 = Haus der Kulturen Beneath Main Foyer - Power Consumption (Amperes) -13 = Google Inc. Stock Price on the NASDAQ Exchange - +13 = 14 = Haus der Kulturen Main Foyer - Power Consumption (Amperes) 15 = 16 = Haus der Kulturen Back Smoking Area - Air Quality 17 = 18 = Haus der Kulturen Mezanine Smoking Area - Air Quality -19 = Percentage of books about media art out of all books on sale on ebay - +19 = 20 = Haus der Kulturen Mezanine Smoking Area - Air Quality -21 = Number of photos tagged with berlin on Flickr - +21 = 22 = -23 = Number of photos tagged with berlin on Instagram - +23 = 24 = -25 = Number of photos tagged with transmediale on Instagram - +25 = 26 = -27 = Number of downvotes on reddit.com/r/funny - +27 = 28 = 29 = diff --git a/of/Utility_Box/obj/Release/CL.read.1.tlog b/of/Utility_Box/obj/Release/CL.read.1.tlog index 6d09d59..71ba4d0 100644 Binary files a/of/Utility_Box/obj/Release/CL.read.1.tlog and b/of/Utility_Box/obj/Release/CL.read.1.tlog differ diff --git a/of/Utility_Box/obj/Release/Scene.obj b/of/Utility_Box/obj/Release/Scene.obj index 89a49df..136a39b 100644 Binary files a/of/Utility_Box/obj/Release/Scene.obj and b/of/Utility_Box/obj/Release/Scene.obj differ diff --git a/of/Utility_Box/obj/Release/Utility_Box.log b/of/Utility_Box/obj/Release/Utility_Box.log index 3e96c23..22978b9 100644 --- a/of/Utility_Box/obj/Release/Utility_Box.log +++ b/of/Utility_Box/obj/Release/Utility_Box.log @@ -1,4 +1,4 @@ -Build started 16/1/2014 4:59:12 AM. +Build started 16/1/2014 2:57:32 PM. 1>Project "C:\Users\James Alliban\Work\of_v0.8.0_vs_release\CRITICAL-INFRASTRUCTURE\of\Utility_Box\Utility_Box.vcxproj" on node 2 (Build target(s)). 1>ClCompile: C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\bin\CL.exe /c /I..\..\..\libs\openFrameworks /I..\..\..\libs\openFrameworks\graphics /I..\..\..\libs\openFrameworks\app /I..\..\..\libs\openFrameworks\sound /I..\..\..\libs\openFrameworks\utils /I..\..\..\libs\openFrameworks\communication /I..\..\..\libs\openFrameworks\video /I..\..\..\libs\openFrameworks\types /I..\..\..\libs\openFrameworks\math /I..\..\..\libs\openFrameworks\3d /I..\..\..\libs\openFrameworks\gl /I..\..\..\libs\openFrameworks\events /I..\..\..\libs\glut\include /I..\..\..\libs\rtAudio\include /I..\..\..\libs\quicktime\include /I..\..\..\libs\freetype\include /I..\..\..\libs\freetype\include\freetype2 /I..\..\..\libs\freeImage\include /I..\..\..\libs\fmodex\include /I..\..\..\libs\videoInput\include /I..\..\..\libs\glew\include\ /I..\..\..\libs\glu\include /I..\..\..\libs\tess2\include /I..\..\..\libs\cairo\include\cairo /I..\..\..\libs\poco\include /I..\..\..\libs\glfw\include /I..\..\..\..\libs\openssl\include /I..\..\..\addons /Isrc /Isrc\data /Isrc\gui /Isrc\visual /Isrc\visual\graph /I..\..\..\addons\ofxLibwebsockets\libs\jsoncpp /I..\..\..\addons\ofxLibwebsockets\libs\jsoncpp\json /I..\..\..\addons\ofxLibwebsockets\libs\libwebsockets\include\ /I..\..\..\addons\ofxLibwebsockets\libs\openssl\openssl /I..\..\..\addons\ofxLibwebsockets\libs\ofxLibwebsockets\include /I..\..\..\addons\ofxLibwebsockets\libs\ofxLibwebsockets\include\ofxLibwebsockets /I..\..\..\addons\ofxLibwebsockets\libs\ofxLibwebsockets\src /I..\..\..\addons\ofxLibwebsockets\src /I..\..\..\addons\ofxLibwebsockets\libs\libwebsockets\include\win32port /I..\..\..\addons\ofxLibwebsockets\libs\libwebsockets\include\win32port\win32helpers /I..\..\..\addons\ofxSpacebrew\src /I..\..\..\addons\ofxUI\src /I..\..\..\addons\ofxXmlSettings\libs /I..\..\..\addons\ofxXmlSettings\src /I..\..\..\addons\ofxFTGL\src /I..\..\..\addons\ofxFTGL\libs\FTGL\include\FTGL /I..\..\..\addons\ofxFTGL\libs\FTGL\include /I..\..\..\addons\ofxFTGL\libs\FTGL /Zi /nologo /W3 /WX- /O2 /Oy- /D WIN32 /D NDEBUG /D _CONSOLE /D POCO_STATIC /D CAIRO_WIN32_STATIC_BUILD /D DISABLE_SOME_FLOATING_POINT /D _UNICODE /D UNICODE /Gm- /EHsc /MD /GS /fp:precise /Zc:wchar_t /Zc:forScope /Fo"obj\Release\\" /Fd"obj\Release\vc110.pdb" /Gd /TP /analyze- /errorReport:prompt src\testApp.cpp src\visual\Scene.cpp @@ -118,4 +118,4 @@ Build succeeded. -Time Elapsed 00:00:10.33 +Time Elapsed 00:00:11.17 diff --git a/of/Utility_Box/obj/Release/Utility_Box.write.1.tlog b/of/Utility_Box/obj/Release/Utility_Box.write.1.tlog index 5a4d276..83e531b 100644 --- a/of/Utility_Box/obj/Release/Utility_Box.write.1.tlog +++ b/of/Utility_Box/obj/Release/Utility_Box.write.1.tlog @@ -1233,3 +1233,8 @@ C:\Users\James Alliban\Work\of_v0.8.0_vs_release\CRITICAL-INFRASTRUCTURE\of\Util C:\Users\James Alliban\Work\of_v0.8.0_vs_release\CRITICAL-INFRASTRUCTURE\of\Utility_Box\bin\Utility_Box.lib C:\Users\James Alliban\Work\of_v0.8.0_vs_release\CRITICAL-INFRASTRUCTURE\of\Utility_Box\bin\Utility_Box.exp C:\Users\James Alliban\Work\of_v0.8.0_vs_release\CRITICAL-INFRASTRUCTURE\of\Utility_Box\bin\Utility_Box.exp +^C:\Users\James Alliban\Work\of_v0.8.0_vs_release\CRITICAL-INFRASTRUCTURE\of\Utility_Box\Utility_Box.vcxproj +C:\Users\James Alliban\Work\of_v0.8.0_vs_release\CRITICAL-INFRASTRUCTURE\of\Utility_Box\bin\Utility_Box.lib +C:\Users\James Alliban\Work\of_v0.8.0_vs_release\CRITICAL-INFRASTRUCTURE\of\Utility_Box\bin\Utility_Box.lib +C:\Users\James Alliban\Work\of_v0.8.0_vs_release\CRITICAL-INFRASTRUCTURE\of\Utility_Box\bin\Utility_Box.exp +C:\Users\James Alliban\Work\of_v0.8.0_vs_release\CRITICAL-INFRASTRUCTURE\of\Utility_Box\bin\Utility_Box.exp diff --git a/of/Utility_Box/obj/Release/testApp.obj b/of/Utility_Box/obj/Release/testApp.obj index aff92af..fb13276 100644 Binary files a/of/Utility_Box/obj/Release/testApp.obj and b/of/Utility_Box/obj/Release/testApp.obj differ diff --git a/of/Utility_Box/obj/Release/vc110.pdb b/of/Utility_Box/obj/Release/vc110.pdb index f8e9c90..2288c3b 100644 Binary files a/of/Utility_Box/obj/Release/vc110.pdb and b/of/Utility_Box/obj/Release/vc110.pdb differ diff --git a/of/Utility_Box/src/testApp.cpp b/of/Utility_Box/src/testApp.cpp index 725e514..13ad0d5 100644 --- a/of/Utility_Box/src/testApp.cpp +++ b/of/Utility_Box/src/testApp.cpp @@ -2,7 +2,7 @@ // TODO // ==== -// - Add a minimum time for each angle +// - Add a minimum time for each angle to avoif unslightly quick switching // - optimise - don't calculate graph point values evey frame // - investigate backward graph animation (use alternating colours) // - Colour range - tween between 2-3 points diff --git a/of/Utility_Box/src/visual/Camera.cpp b/of/Utility_Box/src/visual/Camera.cpp index 654ef92..f9eda18 100644 --- a/of/Utility_Box/src/visual/Camera.cpp +++ b/of/Utility_Box/src/visual/Camera.cpp @@ -6,11 +6,13 @@ void Camera::setup(int _camID) camID = _camID; lookAtNode.setPosition(0, 0, 0); setDistance(100); + minSecondsBeforeSwapping = 2; } void Camera::update() { + positionVec.x = sin(ofGetElapsedTimef() * rotSpeed) * distance; //positionVec.y = 40; positionVec.z = cos(ofGetElapsedTimef() * rotSpeed) * distance; @@ -18,4 +20,15 @@ void Camera::update() lookAtNode.setPosition(lookAtVec); setPosition(positionVec); lookAt(lookAtNode); +} + + +void Camera::activate() +{ + timeBecameActive = ofGetElapsedTimef(); +} + + +void Camera::deactivate() +{ } \ No newline at end of file diff --git a/of/Utility_Box/src/visual/Camera.h b/of/Utility_Box/src/visual/Camera.h index 68abce4..8774e02 100644 --- a/of/Utility_Box/src/visual/Camera.h +++ b/of/Utility_Box/src/visual/Camera.h @@ -15,6 +15,8 @@ class Camera : public ofEasyCam public: void setup(int _camID); void update(); + void activate(); + void deactivate(); int camID; @@ -26,4 +28,6 @@ public: float distance; float rotSpeed; float swapProbability; + float minSecondsBeforeSwapping; + float timeBecameActive; }; \ No newline at end of file diff --git a/of/Utility_Box/src/visual/Scene.cpp b/of/Utility_Box/src/visual/Scene.cpp index 7f482e1..ac1eb9c 100644 --- a/of/Utility_Box/src/visual/Scene.cpp +++ b/of/Utility_Box/src/visual/Scene.cpp @@ -144,6 +144,7 @@ void Scene::switchCamera() newCamID = (ofRandom(2) < 0.5) ? 0 : 1; printf("************ changing cameras to %i ************** \n", newCamID); - + activeCamera->deactivate(); activeCamera = &cameras[newCamID]; + activeCamera->activate(); } \ No newline at end of file