Skip to content

Commit e1a8766

Browse files
committed
cleaned up time profiling code. fixed bug with reconfiguring graph layout and scanning serial ports.
1 parent 4b8ca40 commit e1a8766

File tree

2 files changed

+6
-43
lines changed

2 files changed

+6
-43
lines changed

listener/Graph.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ public void Update( double[] newData, int time )
110110
// Validate
111111
if ( newData.length != 2 )
112112
{
113-
this.parent.println( "Invalid data passed to X v. Y graph." );
113+
//this.parent.println( "Invalid data passed to X v. Y graph." );
114114
return;
115115
}
116116

@@ -122,7 +122,7 @@ public void Update( double[] newData, int time )
122122
// Validate
123123
if ( newData.length != this.numVars )
124124
{
125-
this.parent.println( "Invalid data passed to time graph." );
125+
//this.parent.println( "Invalid data passed to time graph." );
126126
return;
127127
}
128128

listener/listener.pde

Lines changed: 4 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,10 @@ import java.util.concurrent.TimeUnit;
3535
import java.util.concurrent.TimeoutException;
3636

3737
// FLAG FOR DEBUG MODE
38-
final boolean DEBUG = true;
38+
final boolean DEBUG = false;
3939

4040
//CONSTANTS
4141
final char OUTER_KEY = '#';
42-
final String INNER_KEY = "@";
4342
final int MARGIN_SZ = 20; // between plots
4443
final int BG_COL = 75; // background
4544
final int PORT_INTERVAL = 5000; // time to sit on each port
@@ -94,10 +93,6 @@ void setup()
9493

9594
void draw()
9695
{
97-
// REMOVE ***
98-
int start = millis();
99-
// *** REMOVE
100-
10196
//PLOT ALL
10297
try
10398
{
@@ -143,30 +138,10 @@ void draw()
143138
}
144139
catch ( Exception e )
145140
{}
146-
147-
// REMOVE ***
148-
totalGraphing += ( millis() - start );
149-
// *** REMOVE
150141
}
151142

152-
// REMOVE **** timing vars
153-
int countTo = 1000;
154-
int count = 0;
155-
int startTrial = 0;
156-
int totalSerialEvent = 0;
157-
int totalGraphing = 0;
158-
// *** REMOVE
159-
160143
void serialEvent( Serial ser )
161144
{
162-
// REMOVE**** timing logic: start
163-
int start = millis();
164-
if ( count == 0 )
165-
{
166-
startTrial = start;
167-
}
168-
// ***** REMOVE
169-
170145
// Listen for serial data until #, the end of transmission key
171146
try
172147
{
@@ -198,9 +173,11 @@ void serialEvent( Serial ser )
198173
// If config code has changed, need to go through setup again
199174
if ( config && !configCode.equals( tempCode ) )
200175
{
176+
lastPortSwitch = millis(); // (likely on the right port, just need to reconfigure graph layout)
177+
201178
// Check for size of full transmission against expected to flag bad transmission
202179
numGraphs = json.getInt( "ng" );
203-
180+
204181
JSONArray jsonGraphs = json.getJSONArray( "g" );
205182

206183
if ( jsonGraphs.size() != numGraphs )
@@ -297,20 +274,6 @@ void serialEvent( Serial ser )
297274
{
298275
logMessage( "Exception in serialEvent: " + e.toString(), true );
299276
}
300-
301-
// REMOVE ***** timing logic: end
302-
int end = millis();
303-
totalSerialEvent += ( end - start );
304-
count++;
305-
if ( count == countTo )
306-
{
307-
logMessage( "Time per " + count + " counts: overall: " + ( end - startTrial ) + ", in serialEvent: "
308-
+ totalSerialEvent + ", graphing: " + totalGraphing, false );
309-
count = 0;
310-
totalSerialEvent = 0;
311-
totalGraphing = 0;
312-
}
313-
// ***** REMOVE
314277
}
315278

316279
// Helper method to calculate bounds of graphs

0 commit comments

Comments
 (0)