@@ -19,6 +19,7 @@ class NetworkStreamOut extends Thread {
1919 private int samplesSent = 0 ;
2020 private int sampleRateClock = 0 ;
2121 private int sampleRateClockInterval = 10000 ;
22+ private boolean debugSamplingRate = false ;
2223
2324 // OSC Objects
2425 private OscP5 osc;
@@ -228,6 +229,23 @@ class NetworkStreamOut extends Thread {
228229 }
229230 }
230231
232+ private void debugTimeSeriesDataSamplingRate () {
233+ // This code is used to check the sample rate of the data stream
234+ if (sampleRateClock == 0 ) sampleRateClock = millis ();
235+ samplesSent = samplesSent + nPointsPerUpdate;
236+ if (millis () > sampleRateClock + sampleRateClockInterval) {
237+ float timeDelta = float (millis () - sampleRateClock) / 1000 ;
238+ float sampleRateCheck = samplesSent / timeDelta;
239+ println (" \n Number of samples collected = " + samplesSent);
240+ println (" Time Interval (Desired) = " + (sampleRateClockInterval / 1000 ));
241+ println (" Time Interval (Actual) = " + timeDelta);
242+ println (" Sample Rate (Desired) = " + currentBoard. getSampleRate());
243+ println (" Sample Rate (Actual) = " + sampleRateCheck);
244+ sampleRateClock = 0 ;
245+ samplesSent = 0 ;
246+ }
247+ }
248+
231249 private void sendData () {
232250 switch (this . dataType) {
233251 case " TimeSeriesRaw" :
@@ -301,22 +319,9 @@ class NetworkStreamOut extends Thread {
301319 }
302320 }
303321
304- /*
305- // This code is used to check the sample rate of the data stream
306- if (sampleRateClock == 0) sampleRateClock = millis();
307- samplesSent = samplesSent + nPointsPerUpdate;
308- if (millis() > sampleRateClock + sampleRateClockInterval) {
309- float timeDelta = float(millis() - sampleRateClock) / 1000;
310- float sampleRateCheck = samplesSent / timeDelta;
311- println("\nNumber of samples collected = " + samplesSent);
312- println("Time Interval (Desired) = " + (sampleRateClockInterval / 1000));
313- println("Time Interval (Actual) = " + timeDelta);
314- println("Sample Rate (Desired) = " + currentBoard.getSampleRate());
315- println("Sample Rate (Actual) = " + sampleRateCheck);
316- sampleRateClock = 0;
317- samplesSent = 0;
322+ if (debugSamplingRate) {
323+ debugTimeSeriesDataSamplingRate();
318324 }
319- */
320325
321326 if (this . protocol. equals(" UDP" )) {
322327
@@ -1112,22 +1117,9 @@ class NetworkStreamOut extends Thread {
11121117 newDataFromBuffer[i] = w_networking. markerDataBufferToSend[i];
11131118 }
11141119
1115- /*
1116- // Check sampling rate for every networking protocol for this data type
1117- if (sampleRateClock == 0) sampleRateClock = millis();
1118- samplesSent = samplesSent + nPointsPerUpdate;
1119- if (millis() > sampleRateClock + sampleRateClockInterval) {
1120- float timeDelta = float(millis() - sampleRateClock) / 1000;
1121- float sampleRateCheck = samplesSent / timeDelta;
1122- println("\nNumber of samples collected = " + samplesSent);
1123- println("Time Interval (Desired) = " + (sampleRateClockInterval / 1000));
1124- println("Time Interval (Actual) = " + timeDelta);
1125- println("Sample Rate (Desired) = " + currentBoard.getSampleRate());
1126- println("Sample Rate (Actual) = " + sampleRateCheck);
1127- sampleRateClock = 0;
1128- samplesSent = 0;
1120+ if (debugSamplingRate) {
1121+ debugTimeSeriesDataSamplingRate();
11291122 }
1130- */
11311123
11321124 if (this . protocol. equals(" UDP" )) {
11331125
0 commit comments