New data timing now configurable

- There is a slider for each graph that allows you to specify how often
(in seconds) new data should appear. The amount of time it takes to fill
the screen is displayed when the GUI is open
This commit is contained in:
James Alliban 2014-01-11 06:13:04 +00:00
parent 1b1e884555
commit 3067d52e98
17 changed files with 98 additions and 32 deletions

View File

@ -1,18 +1,23 @@
<Widget> <Widget>
<Kind>4</Kind> <Kind>4</Kind>
<Name>Graph Item X Gap</Name> <Name>Graph Item X Gap</Name>
<Value>13.733552933</Value> <Value>11.809210777</Value>
</Widget> </Widget>
<Widget> <Widget>
<Kind>4</Kind> <Kind>4</Kind>
<Name>BarWidth</Name> <Name>BarWidth</Name>
<Value>8.157895088</Value> <Value>5.631578922</Value>
</Widget> </Widget>
<Widget> <Widget>
<Kind>4</Kind> <Kind>4</Kind>
<Name>Graph Height Max</Name> <Name>Graph Height Max</Name>
<Value>440.460510254</Value> <Value>440.460510254</Value>
</Widget> </Widget>
<Widget>
<Kind>4</Kind>
<Name>Data send speed (seconds)</Name>
<Value>4.944078445</Value>
</Widget>
<Widget> <Widget>
<Kind>4</Kind> <Kind>4</Kind>
<Name>Data0 red</Name> <Name>Data0 red</Name>

View File

@ -11,18 +11,23 @@
<Widget> <Widget>
<Kind>4</Kind> <Kind>4</Kind>
<Name>Graph Item X Gap</Name> <Name>Graph Item X Gap</Name>
<Value>7.220395088</Value> <Value>6.332236767</Value>
</Widget> </Widget>
<Widget> <Widget>
<Kind>4</Kind> <Kind>4</Kind>
<Name>Line width</Name> <Name>Line width</Name>
<Value>7.286184311</Value> <Value>6.157894611</Value>
</Widget> </Widget>
<Widget> <Widget>
<Kind>4</Kind> <Kind>4</Kind>
<Name>Graph Height Max</Name> <Name>Graph Height Max</Name>
<Value>443.421051025</Value> <Value>443.421051025</Value>
</Widget> </Widget>
<Widget>
<Kind>4</Kind>
<Name>Data send speed (seconds)</Name>
<Value>4.027631760</Value>
</Widget>
<Widget> <Widget>
<Kind>4</Kind> <Kind>4</Kind>
<Name>Data0 red</Name> <Name>Data0 red</Name>

View File

@ -1,12 +1,12 @@
<Widget> <Widget>
<Kind>2</Kind> <Kind>2</Kind>
<Name>Bar graph</Name> <Name>Bar graph</Name>
<Value>0</Value> <Value>1</Value>
</Widget> </Widget>
<Widget> <Widget>
<Kind>2</Kind> <Kind>2</Kind>
<Name>Solid Body graph</Name> <Name>Solid Body graph</Name>
<Value>1</Value> <Value>0</Value>
</Widget> </Widget>
<Widget> <Widget>
<Kind>2</Kind> <Kind>2</Kind>

View File

@ -1,7 +1,7 @@
<Widget> <Widget>
<Kind>2</Kind> <Kind>2</Kind>
<Name>Toggle Data Simulation</Name> <Name>Toggle Data Simulation</Name>
<Value>1</Value> <Value>0</Value>
</Widget> </Widget>
<Widget> <Widget>
<Kind>4</Kind> <Kind>4</Kind>

View File

@ -21,10 +21,12 @@ void DataManager::setup()
newData.resize(2); newData.resize(2);
isPublisher0DataReceived = false; //isPublisher0DataReceived = false;
isPublisher1DataReceived = false; //isPublisher1DataReceived = false;
setupSpacebrew(); setupSpacebrew();
nextDataSendTime = 0.1;
} }
@ -73,11 +75,18 @@ void DataManager::update()
} }
else else
{ {
if (isPublisher0DataReceived && isPublisher1DataReceived) /*if (isPublisher0DataReceived && isPublisher1DataReceived)
{ {
isPublisher0DataReceived = false; isPublisher0DataReceived = false;
isPublisher1DataReceived = false; isPublisher1DataReceived = false;
app->scene.addNewData(newData); app->scene.addNewData(newData);
}*/
//sendDataSpeed = app->scene.activeGraph->sendDataSpeed;
if (ofGetElapsedTimef() >= nextDataSendTime + app->scene.activeGraph->sendDataSpeed)
{
nextDataSendTime += app->scene.activeGraph->sendDataSpeed;
app->scene.addNewData(newData);
} }
} }
} }
@ -132,12 +141,12 @@ void DataManager::onMessage( Spacebrew::Message & m )
if (m.name == publisher0Name) if (m.name == publisher0Name)
{ {
isPublisher0DataReceived = true; //isPublisher0DataReceived = true;
newData[0] = dataObject; newData[0] = dataObject;
} }
else if (m.name == publisher1Name) else if (m.name == publisher1Name)
{ {
isPublisher1DataReceived = true; //isPublisher1DataReceived = true;
newData[1] = dataObject; newData[1] = dataObject;
} }
} }

View File

@ -27,6 +27,9 @@ class DataManager
void draw(); void draw();
vector<string> explode( const string &delimiter, const string &str); vector<string> explode( const string &delimiter, const string &str);
// listen to spacebrew Messages
void onMessage( Spacebrew::Message & m );
testApp* app; testApp* app;
int appId; int appId;
@ -39,14 +42,13 @@ class DataManager
vector<DataObject> newData; vector<DataObject> newData;
bool isPublisher0DataReceived; //bool isPublisher0DataReceived;
bool isPublisher1DataReceived; //bool isPublisher1DataReceived;
bool isDataSimulated; bool isDataSimulated;
float perlinXScale; float perlinXScale;
float perlinYScale; float perlinYScale;
float simulationSpeed; float simulationSpeed;
// listen to spacebrew Messages float nextDataSendTime;
void onMessage( Spacebrew::Message & m );
}; };

View File

@ -81,6 +81,7 @@ void GUI::addBarGraphDesignGUI()
gui->addSlider("Graph Item X Gap", 5, 50, &app->scene.barGraph.graphItemXGap, length, dim); gui->addSlider("Graph Item X Gap", 5, 50, &app->scene.barGraph.graphItemXGap, length, dim);
gui->addSlider("BarWidth", 2, 50, &app->scene.barGraph.barWidth, length, dim); gui->addSlider("BarWidth", 2, 50, &app->scene.barGraph.barWidth, length, dim);
gui->addSlider("Graph Height Max", 100, 1000, &app->scene.barGraph.graphHeightMax, length, dim); gui->addSlider("Graph Height Max", 100, 1000, &app->scene.barGraph.graphHeightMax, length, dim);
gui->addSlider("Data send speed (seconds)", 0.1, 20, &app->scene.barGraph.sendDataSpeed, length, dim);
gui->addSpacer(length, 1); gui->addSpacer(length, 1);
gui->addSlider("Data0 red", 0, 255, &app->scene.barGraph.col0[0], length, dim); gui->addSlider("Data0 red", 0, 255, &app->scene.barGraph.col0[0], length, dim);
@ -108,6 +109,7 @@ void GUI::addBodyGraphDesignGUI()
gui->addSlider("Graph Item X Gap", 5, 50, &app->scene.bodyGraph.graphItemXGap, length, dim); gui->addSlider("Graph Item X Gap", 5, 50, &app->scene.bodyGraph.graphItemXGap, length, dim);
gui->addSlider("Line width", 1, 50, &app->scene.bodyGraph.lineWidth, length, dim); gui->addSlider("Line width", 1, 50, &app->scene.bodyGraph.lineWidth, length, dim);
gui->addSlider("Graph Height Max", 100, 1000, &app->scene.bodyGraph.graphHeightMax, length, dim); gui->addSlider("Graph Height Max", 100, 1000, &app->scene.bodyGraph.graphHeightMax, length, dim);
gui->addSlider("Data send speed (seconds)", 0.1, 20, &app->scene.bodyGraph.sendDataSpeed, length, dim);
gui->addSpacer(length, 1); gui->addSpacer(length, 1);
gui->addSlider("Data0 red", 0, 255, &app->scene.bodyGraph.col0[0], length, dim); gui->addSlider("Data0 red", 0, 255, &app->scene.bodyGraph.col0[0], length, dim);

View File

@ -2,13 +2,13 @@
// TODO // TODO
// ==== // ====
// - Add option to resize video draw size (rather than making it fullscreen) and init size
// - Make system to slow down data - The screen should show 15-20 minutes worth of data // - Make system to slow down data - The screen should show 15-20 minutes worth of data
// - Make 3rd graph - separate fade // - Make 3rd graph - separate fade
// - Crosshairs in HUD // - Crosshairs in HUD
// - Create graph animation system // - Create graph animation system
// - Create a single config file to be loaded from online location. It will contain IP address and host name // - Create a single config file to be loaded from online location. It will contain IP address and host name
// - Add 'clear all data' button to UI // - Add 'clear all data' button to UI
// - If min or max values change - clear graph - ask bout this
// //
//-------------------------------------------------------------- //--------------------------------------------------------------
void testApp::setup() void testApp::setup()
@ -35,6 +35,7 @@ void testApp::update()
dataManager.update(); dataManager.update();
scene.update(); scene.update();
//if (gui.isVisible())
} }
@ -57,6 +58,8 @@ void testApp::keyPressed(int key)
isPaused = !isPaused; isPaused = !isPaused;
else if (key == 'f') else if (key == 'f')
ofToggleFullscreen(); ofToggleFullscreen();
else if (key == 'c')
scene.clearGraphData();
scene.keyPressed(key); scene.keyPressed(key);
} }

View File

@ -209,3 +209,10 @@ void Scene::keyPressed(int key)
{ {
} }
void Scene::clearGraphData()
{
barGraph.clear();
bodyGraph.clear();
}

View File

@ -28,8 +28,10 @@ public:
void drawHUDColourBars(); void drawHUDColourBars();
void drawTextBox(string copy, string align); void drawTextBox(string copy, string align);
void addNewData(vector<DataObject> newData); void addNewData(vector<DataObject> newData);
void clearGraphData();
void keyPressed(int key); void keyPressed(int key);
BarGraph barGraph; BarGraph barGraph;
BodyGraph bodyGraph; BodyGraph bodyGraph;
ofShader rgbShader; ofShader rgbShader;

View File

@ -19,7 +19,8 @@ void AbstractGraph::setup()
void AbstractGraph::update() void AbstractGraph::update()
{ {
maxData = (ofGetWidth() * (AbstractGraph::maxGraphPercent - AbstractGraph::minGraphPercent)) / graphItemXGap;
printf("ofGetWidth():%i, maxData:%i, graphItemXGap:%f, screen active:%f \n", ofGetWidth(), maxData, graphItemXGap, (AbstractGraph::maxGraphPercent - AbstractGraph::minGraphPercent));
} }
@ -34,11 +35,16 @@ void AbstractGraph::addNewData(vector<DataObject> newData)
publisher0Data.push_back(newData[0]); publisher0Data.push_back(newData[0]);
publisher1Data.push_back(newData[1]); publisher1Data.push_back(newData[1]);
maxData = (ofGetWidth() / graphItemXGap) * (AbstractGraph::maxGraphPercent - AbstractGraph::minGraphPercent);
while (publisher0Data.size() > maxData && publisher0Data.size() > maxData) while (publisher0Data.size() > maxData && publisher0Data.size() > maxData)
{ {
publisher0Data.erase(publisher0Data.begin()); publisher0Data.erase(publisher0Data.begin());
publisher1Data.erase(publisher1Data.begin()); publisher1Data.erase(publisher1Data.begin());
} }
} }
void AbstractGraph::clear()
{
publisher0Data.clear();
publisher1Data.clear();
}

View File

@ -11,6 +11,7 @@
#include "ofMain.h" #include "ofMain.h"
#include "DataManager.h" #include "DataManager.h"
class AbstractGraph class AbstractGraph
{ {
public: public:
@ -18,6 +19,7 @@ public:
virtual void update(); virtual void update();
virtual void draw(); virtual void draw();
virtual void addNewData(vector<DataObject> newData); virtual void addNewData(vector<DataObject> newData);
void clear();
vector<DataObject> publisher0Data; vector<DataObject> publisher0Data;
vector<DataObject> publisher1Data; vector<DataObject> publisher1Data;
@ -33,4 +35,7 @@ public:
float col0[4]; float col0[4];
float col1[4]; float col1[4];
string graphName;
float sendDataSpeed;
}; };

View File

@ -1,23 +1,29 @@
#include "BarGraph.h" #include "BarGraph.h"
#include "testApp.h"
void BarGraph::setup() void BarGraph::setup()
{ {
AbstractGraph::setup(); AbstractGraph::setup();
app = (testApp*)ofGetAppPtr();
graphItemXGap = 10; graphItemXGap = 10;
graphName = "BAR";
} }
void BarGraph::update() void BarGraph::update()
{ {
// if (ofGetFrameNum() % 30 == 0) AbstractGraph::update();
// printf("publisher0Data.size():%i \n", publisher0Data.size());
} }
void BarGraph::draw() void BarGraph::draw()
{ {
//printf("BarGraph::draw() - graphItemXGap = %f \n", graphItemXGap); if (app->gui.getVisible())
{
int timePerScreenfull = maxData * sendDataSpeed;
ofDrawBitmapString("Time to fill screen:" + ofToString(timePerScreenfull), 500, 150);
}
if (publisher0Data.size() > 1) if (publisher0Data.size() > 1)
{ {

View File

@ -3,6 +3,8 @@
#include "ofMain.h" #include "ofMain.h"
#include "AbstractGraph.h" #include "AbstractGraph.h"
class testApp;
class BarGraph : public AbstractGraph class BarGraph : public AbstractGraph
{ {
public: public:
@ -11,8 +13,7 @@ public:
virtual void draw(); virtual void draw();
virtual void addNewData(vector<DataObject> newData); virtual void addNewData(vector<DataObject> newData);
testApp *app;
float barWidth; float barWidth;
}; };

View File

@ -4,23 +4,32 @@
// //
#include "BodyGraph.h" #include "BodyGraph.h"
#include "testApp.h"
void BodyGraph::setup() void BodyGraph::setup()
{ {
AbstractGraph::setup(); AbstractGraph::setup();
app = (testApp*)ofGetAppPtr();
graphName = "BODY";
} }
void BodyGraph::update() void BodyGraph::update()
{ {
// if (ofGetFrameNum() % 30 == 0) AbstractGraph::update();
// printf("publisher0Data.size():%i \n", publisher0Data.size());
} }
void BodyGraph::draw() void BodyGraph::draw()
{ {
if (app->gui.getVisible())
{
float timePerScreenfull = (float)maxData * sendDataSpeed;
printf("timePerScreenfull:%f, maxData:%i, sendDataSpeed:%f \n", timePerScreenfull, maxData, sendDataSpeed);
ofDrawBitmapString("Time to fill screen:" + ofToString(timePerScreenfull), 500, 150);
}
if (publisher0Data.size() > 1) if (publisher0Data.size() > 1)
{ {
//for (int i = 0; i < publisher0Data.size() - 1; i++) //for (int i = 0; i < publisher0Data.size() - 1; i++)

View File

@ -4,6 +4,8 @@
#include "ofMain.h" #include "ofMain.h"
#include "AbstractGraph.h" #include "AbstractGraph.h"
class testApp;
class BodyGraph : public AbstractGraph class BodyGraph : public AbstractGraph
{ {
public: public:
@ -12,6 +14,8 @@ public:
virtual void draw(); virtual void draw();
virtual void addNewData(vector<DataObject> newData); virtual void addNewData(vector<DataObject> newData);
testApp *app;
float barWidth; float barWidth;
float lineWidth; float lineWidth;