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:
parent
1b1e884555
commit
3067d52e98
Binary file not shown.
@ -1,18 +1,23 @@
|
||||
<Widget>
|
||||
<Kind>4</Kind>
|
||||
<Name>Graph Item X Gap</Name>
|
||||
<Value>13.733552933</Value>
|
||||
<Value>11.809210777</Value>
|
||||
</Widget>
|
||||
<Widget>
|
||||
<Kind>4</Kind>
|
||||
<Name>BarWidth</Name>
|
||||
<Value>8.157895088</Value>
|
||||
<Value>5.631578922</Value>
|
||||
</Widget>
|
||||
<Widget>
|
||||
<Kind>4</Kind>
|
||||
<Name>Graph Height Max</Name>
|
||||
<Value>440.460510254</Value>
|
||||
</Widget>
|
||||
<Widget>
|
||||
<Kind>4</Kind>
|
||||
<Name>Data send speed (seconds)</Name>
|
||||
<Value>4.944078445</Value>
|
||||
</Widget>
|
||||
<Widget>
|
||||
<Kind>4</Kind>
|
||||
<Name>Data0 red</Name>
|
||||
|
||||
@ -11,18 +11,23 @@
|
||||
<Widget>
|
||||
<Kind>4</Kind>
|
||||
<Name>Graph Item X Gap</Name>
|
||||
<Value>7.220395088</Value>
|
||||
<Value>6.332236767</Value>
|
||||
</Widget>
|
||||
<Widget>
|
||||
<Kind>4</Kind>
|
||||
<Name>Line width</Name>
|
||||
<Value>7.286184311</Value>
|
||||
<Value>6.157894611</Value>
|
||||
</Widget>
|
||||
<Widget>
|
||||
<Kind>4</Kind>
|
||||
<Name>Graph Height Max</Name>
|
||||
<Value>443.421051025</Value>
|
||||
</Widget>
|
||||
<Widget>
|
||||
<Kind>4</Kind>
|
||||
<Name>Data send speed (seconds)</Name>
|
||||
<Value>4.027631760</Value>
|
||||
</Widget>
|
||||
<Widget>
|
||||
<Kind>4</Kind>
|
||||
<Name>Data0 red</Name>
|
||||
|
||||
@ -1,12 +1,12 @@
|
||||
<Widget>
|
||||
<Kind>2</Kind>
|
||||
<Name>Bar graph</Name>
|
||||
<Value>0</Value>
|
||||
<Value>1</Value>
|
||||
</Widget>
|
||||
<Widget>
|
||||
<Kind>2</Kind>
|
||||
<Name>Solid Body graph</Name>
|
||||
<Value>1</Value>
|
||||
<Value>0</Value>
|
||||
</Widget>
|
||||
<Widget>
|
||||
<Kind>2</Kind>
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
<Widget>
|
||||
<Kind>2</Kind>
|
||||
<Name>Toggle Data Simulation</Name>
|
||||
<Value>1</Value>
|
||||
<Value>0</Value>
|
||||
</Widget>
|
||||
<Widget>
|
||||
<Kind>4</Kind>
|
||||
|
||||
@ -21,10 +21,12 @@ void DataManager::setup()
|
||||
|
||||
newData.resize(2);
|
||||
|
||||
isPublisher0DataReceived = false;
|
||||
isPublisher1DataReceived = false;
|
||||
//isPublisher0DataReceived = false;
|
||||
//isPublisher1DataReceived = false;
|
||||
|
||||
setupSpacebrew();
|
||||
|
||||
nextDataSendTime = 0.1;
|
||||
}
|
||||
|
||||
|
||||
@ -73,11 +75,18 @@ void DataManager::update()
|
||||
}
|
||||
else
|
||||
{
|
||||
if (isPublisher0DataReceived && isPublisher1DataReceived)
|
||||
/*if (isPublisher0DataReceived && isPublisher1DataReceived)
|
||||
{
|
||||
isPublisher0DataReceived = false;
|
||||
isPublisher1DataReceived = false;
|
||||
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)
|
||||
{
|
||||
isPublisher0DataReceived = true;
|
||||
//isPublisher0DataReceived = true;
|
||||
newData[0] = dataObject;
|
||||
}
|
||||
else if (m.name == publisher1Name)
|
||||
{
|
||||
isPublisher1DataReceived = true;
|
||||
//isPublisher1DataReceived = true;
|
||||
newData[1] = dataObject;
|
||||
}
|
||||
}
|
||||
|
||||
@ -26,6 +26,9 @@ class DataManager
|
||||
void update();
|
||||
void draw();
|
||||
vector<string> explode( const string &delimiter, const string &str);
|
||||
|
||||
// listen to spacebrew Messages
|
||||
void onMessage( Spacebrew::Message & m );
|
||||
|
||||
testApp* app;
|
||||
|
||||
@ -39,14 +42,13 @@ class DataManager
|
||||
|
||||
vector<DataObject> newData;
|
||||
|
||||
bool isPublisher0DataReceived;
|
||||
bool isPublisher1DataReceived;
|
||||
//bool isPublisher0DataReceived;
|
||||
//bool isPublisher1DataReceived;
|
||||
|
||||
bool isDataSimulated;
|
||||
float perlinXScale;
|
||||
float perlinYScale;
|
||||
float simulationSpeed;
|
||||
|
||||
// listen to spacebrew Messages
|
||||
void onMessage( Spacebrew::Message & m );
|
||||
|
||||
float nextDataSendTime;
|
||||
};
|
||||
|
||||
@ -81,6 +81,7 @@ void GUI::addBarGraphDesignGUI()
|
||||
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("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->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("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("Data send speed (seconds)", 0.1, 20, &app->scene.bodyGraph.sendDataSpeed, length, dim);
|
||||
|
||||
gui->addSpacer(length, 1);
|
||||
gui->addSlider("Data0 red", 0, 255, &app->scene.bodyGraph.col0[0], length, dim);
|
||||
|
||||
@ -2,13 +2,13 @@
|
||||
|
||||
// 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 3rd graph - separate fade
|
||||
// - Crosshairs in HUD
|
||||
// - Create graph animation system
|
||||
// - 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
|
||||
// - If min or max values change - clear graph - ask bout this
|
||||
//
|
||||
//--------------------------------------------------------------
|
||||
void testApp::setup()
|
||||
@ -35,6 +35,7 @@ void testApp::update()
|
||||
|
||||
dataManager.update();
|
||||
scene.update();
|
||||
//if (gui.isVisible())
|
||||
}
|
||||
|
||||
|
||||
@ -57,6 +58,8 @@ void testApp::keyPressed(int key)
|
||||
isPaused = !isPaused;
|
||||
else if (key == 'f')
|
||||
ofToggleFullscreen();
|
||||
else if (key == 'c')
|
||||
scene.clearGraphData();
|
||||
|
||||
scene.keyPressed(key);
|
||||
}
|
||||
|
||||
@ -208,4 +208,11 @@ void Scene::addNewData(vector<DataObject> newData)
|
||||
void Scene::keyPressed(int key)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
void Scene::clearGraphData()
|
||||
{
|
||||
barGraph.clear();
|
||||
bodyGraph.clear();
|
||||
}
|
||||
@ -28,7 +28,9 @@ public:
|
||||
void drawHUDColourBars();
|
||||
void drawTextBox(string copy, string align);
|
||||
void addNewData(vector<DataObject> newData);
|
||||
void clearGraphData();
|
||||
void keyPressed(int key);
|
||||
|
||||
|
||||
BarGraph barGraph;
|
||||
BodyGraph bodyGraph;
|
||||
|
||||
@ -19,7 +19,8 @@ void AbstractGraph::setup()
|
||||
|
||||
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]);
|
||||
publisher1Data.push_back(newData[1]);
|
||||
|
||||
maxData = (ofGetWidth() / graphItemXGap) * (AbstractGraph::maxGraphPercent - AbstractGraph::minGraphPercent);
|
||||
|
||||
while (publisher0Data.size() > maxData && publisher0Data.size() > maxData)
|
||||
{
|
||||
publisher0Data.erase(publisher0Data.begin());
|
||||
publisher1Data.erase(publisher1Data.begin());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void AbstractGraph::clear()
|
||||
{
|
||||
publisher0Data.clear();
|
||||
publisher1Data.clear();
|
||||
}
|
||||
@ -11,6 +11,7 @@
|
||||
#include "ofMain.h"
|
||||
#include "DataManager.h"
|
||||
|
||||
|
||||
class AbstractGraph
|
||||
{
|
||||
public:
|
||||
@ -18,7 +19,8 @@ public:
|
||||
virtual void update();
|
||||
virtual void draw();
|
||||
virtual void addNewData(vector<DataObject> newData);
|
||||
|
||||
void clear();
|
||||
|
||||
vector<DataObject> publisher0Data;
|
||||
vector<DataObject> publisher1Data;
|
||||
int maxData; // calculated from graphWidth and graphItemXGap
|
||||
@ -33,4 +35,7 @@ public:
|
||||
float col0[4];
|
||||
float col1[4];
|
||||
|
||||
string graphName;
|
||||
float sendDataSpeed;
|
||||
|
||||
};
|
||||
@ -1,23 +1,29 @@
|
||||
#include "BarGraph.h"
|
||||
#include "testApp.h"
|
||||
|
||||
void BarGraph::setup()
|
||||
{
|
||||
AbstractGraph::setup();
|
||||
|
||||
app = (testApp*)ofGetAppPtr();
|
||||
graphItemXGap = 10;
|
||||
graphName = "BAR";
|
||||
}
|
||||
|
||||
|
||||
void BarGraph::update()
|
||||
{
|
||||
// if (ofGetFrameNum() % 30 == 0)
|
||||
// printf("publisher0Data.size():%i \n", publisher0Data.size());
|
||||
AbstractGraph::update();
|
||||
}
|
||||
|
||||
|
||||
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)
|
||||
{
|
||||
|
||||
@ -3,6 +3,8 @@
|
||||
#include "ofMain.h"
|
||||
#include "AbstractGraph.h"
|
||||
|
||||
class testApp;
|
||||
|
||||
class BarGraph : public AbstractGraph
|
||||
{
|
||||
public:
|
||||
@ -10,9 +12,8 @@ public:
|
||||
virtual void update();
|
||||
virtual void draw();
|
||||
virtual void addNewData(vector<DataObject> newData);
|
||||
|
||||
testApp *app;
|
||||
|
||||
float barWidth;
|
||||
|
||||
|
||||
|
||||
};
|
||||
@ -4,23 +4,32 @@
|
||||
//
|
||||
|
||||
#include "BodyGraph.h"
|
||||
#include "testApp.h"
|
||||
|
||||
|
||||
void BodyGraph::setup()
|
||||
{
|
||||
AbstractGraph::setup();
|
||||
app = (testApp*)ofGetAppPtr();
|
||||
graphName = "BODY";
|
||||
}
|
||||
|
||||
|
||||
void BodyGraph::update()
|
||||
{
|
||||
// if (ofGetFrameNum() % 30 == 0)
|
||||
// printf("publisher0Data.size():%i \n", publisher0Data.size());
|
||||
}
|
||||
AbstractGraph::update();
|
||||
}
|
||||
|
||||
|
||||
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)
|
||||
{
|
||||
//for (int i = 0; i < publisher0Data.size() - 1; i++)
|
||||
|
||||
@ -4,6 +4,8 @@
|
||||
#include "ofMain.h"
|
||||
#include "AbstractGraph.h"
|
||||
|
||||
class testApp;
|
||||
|
||||
class BodyGraph : public AbstractGraph
|
||||
{
|
||||
public:
|
||||
@ -11,6 +13,8 @@ public:
|
||||
virtual void update();
|
||||
virtual void draw();
|
||||
virtual void addNewData(vector<DataObject> newData);
|
||||
|
||||
testApp *app;
|
||||
|
||||
float barWidth;
|
||||
float lineWidth;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user