-
Notifications
You must be signed in to change notification settings - Fork 4
DEV-574 improved throw bytes performance and console prints #256
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
7c6786b
DEV-574 #time 1h better byte throwing handling and timestamp fail-safe
marknolan eb801c3
Merge remote-tracking branch 'origin/master' into DEV-574_corrupted_d…
marknolan 9e495e6
DEV-574 #time 5m ability to disable contiguous time stamp check
marknolan 61c2fca
DEV-574 #time 5m more efficient removal of time stamp per byte from list
marknolan 101a281
Update ShimmerDriver/src/main/java/com/shimmerresearch/bluetooth/Shim…
marknolan 831e332
Update ShimmerDriver/src/main/java/com/shimmerresearch/bluetooth/Shim…
marknolan 456b185
Update ShimmerDriver/src/main/java/com/shimmerresearch/driver/ObjectC…
marknolan a21639a
Update ShimmerDriver/src/main/java/com/shimmerresearch/driver/Shimmer…
marknolan 0d0efd6
Update ShimmerDriver/src/main/java/com/shimmerresearch/bluetooth/Shim…
marknolan 322ef02
DEV-574 #time 1m minor update from PR
marknolan 834c5bc
DEV-574 #time 10m applying PR comments
marknolan db28957
DEV-574 #time 5m removed contiguous check
marknolan d5b2c3d
DEV-574 #time 10m restored some formatting and improved console print
marknolan 992069d
Update ShimmerDriver/src/main/java/com/shimmerresearch/bluetooth/Shim…
marknolan 1214fef
Update ShimmerDriver/src/main/java/com/shimmerresearch/bluetooth/Shim…
marknolan 8693d41
added unit test
JongChern File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
114 changes: 114 additions & 0 deletions
114
...himmer3/communication/API_0000X_ByteCommunicationShimmer3_Streaming_Contiguous_Check.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,114 @@ | ||
| package com.shimmerresearch.shimmer3.communication; | ||
| import org.junit.Before; | ||
| import org.junit.BeforeClass; | ||
| import org.junit.FixMethodOrder; | ||
| import org.junit.Test; | ||
| import org.junit.runners.MethodSorters; | ||
|
|
||
| import com.shimmerresearch.bluetooth.ShimmerBluetooth.BT_STATE; | ||
| import com.shimmerresearch.driver.BasicProcessWithCallBack; | ||
| import com.shimmerresearch.driver.CallbackObject; | ||
| import com.shimmerresearch.driver.ObjectCluster; | ||
| import com.shimmerresearch.driver.ShimmerMsg; | ||
| import com.shimmerresearch.driver.Configuration.COMMUNICATION_TYPE; | ||
| import com.shimmerresearch.driverUtilities.ChannelDetails; | ||
| import com.shimmerresearch.driverUtilities.SensorDetails; | ||
| import com.shimmerresearch.driverUtilities.ShimmerVerDetails.HW_ID; | ||
| import com.shimmerresearch.exceptions.ShimmerException; | ||
| import com.shimmerresearch.pcDriver.ShimmerPC; | ||
| import com.shimmerresearch.sensors.AbstractSensor; | ||
| import com.shimmerresearch.sensors.AbstractSensor.SENSORS; | ||
|
|
||
| import bolts.TaskCompletionSource; | ||
|
|
||
| import static org.junit.Assert.assertEquals; | ||
|
|
||
| import java.util.ArrayList; | ||
| import java.util.LinkedHashMap; | ||
| import java.util.concurrent.TimeUnit; | ||
| @FixMethodOrder(MethodSorters.NAME_ASCENDING) // Test methods will be run in alphabetical order | ||
| public class API_0000X_ByteCommunicationShimmer3_Streaming_Contiguous_Check extends BasicProcessWithCallBack{ | ||
| ShimmerPC mDevice; | ||
| TaskCompletionSource<Boolean> mCalibrationTask; | ||
| TaskCompletionSource<Boolean> mStreamingTask; | ||
| ByteCommunicationSimulatorS3 mByteCommunicationSimulatorS3; | ||
|
|
||
| @Before | ||
| public void setUp() { | ||
| mByteCommunicationSimulatorS3 = new ByteCommunicationSimulatorS3_streaming_timestamp_contiguous_check("COM99"); | ||
| mDevice = new ShimmerPC("COM99"); | ||
| mDevice.setTestRadio(mByteCommunicationSimulatorS3); | ||
| setWaitForData(mDevice); | ||
| } | ||
|
|
||
| ArrayList<ObjectCluster> mListOJC; | ||
| @Test | ||
| public void test001_testStreaming() { | ||
| mListOJC = new ArrayList<ObjectCluster>(); | ||
| mByteCommunicationSimulatorS3.setIsNewBMPSupported(false); | ||
| mCalibrationTask = new TaskCompletionSource<Boolean>(); | ||
| mDevice.connect("",""); | ||
|
|
||
| mCalibrationTask = new TaskCompletionSource<>(); | ||
| mStreamingTask = new TaskCompletionSource<Boolean>(); | ||
| try { | ||
| boolean result = mCalibrationTask.getTask().waitForCompletion(5, TimeUnit.SECONDS); | ||
| } catch (InterruptedException e) { | ||
| // TODO Auto-generated catch block | ||
| e.printStackTrace(); | ||
| } | ||
|
|
||
| try { | ||
| mDevice.startStreaming(); | ||
| } catch (ShimmerException e) { | ||
| // TODO Auto-generated catch block | ||
| e.printStackTrace(); | ||
| } | ||
| try { | ||
| mStreamingTask.getTask().waitForCompletion(2, TimeUnit.SECONDS); | ||
| if(mListOJC.size()!=2) {//only one is expected because only the first packet is followed which meets ShimmerBluetooth.processPacket requirements | ||
| assert(false); | ||
| } | ||
| } catch (InterruptedException e) { | ||
| // TODO Auto-generated catch block | ||
| e.printStackTrace(); | ||
| } | ||
|
|
||
|
|
||
|
|
||
| } | ||
|
|
||
|
|
||
| @Override | ||
| protected void processMsgFromCallback(ShimmerMsg shimmerMSG) { | ||
| // TODO Auto-generated method stub | ||
| int ind = shimmerMSG.mIdentifier; | ||
|
|
||
| Object object = (Object) shimmerMSG.mB; | ||
|
|
||
| if (ind == ShimmerPC.MSG_IDENTIFIER_STATE_CHANGE) { | ||
| if (ind == ShimmerPC.MSG_IDENTIFIER_STATE_CHANGE) { | ||
| CallbackObject callbackObject = (CallbackObject)object; | ||
|
|
||
| if (callbackObject.mState == BT_STATE.CONNECTED) { | ||
| if (mDevice.isInitialised()) { | ||
| try { | ||
| Thread.sleep(200); | ||
| } catch (InterruptedException e) { | ||
| // TODO Auto-generated catch block | ||
| e.printStackTrace(); | ||
| } | ||
|
|
||
| } | ||
|
|
||
| } | ||
| } | ||
| } else if (ind == ShimmerPC.MSG_IDENTIFIER_DATA_PACKET) { | ||
| System.out.println("Shimmer MSG_IDENTIFIER_DATA_PACKET"); | ||
| ObjectCluster objc = (ObjectCluster) shimmerMSG.mB; | ||
| mListOJC.add(objc); | ||
| } | ||
|
|
||
| } | ||
|
|
||
| } |
116 changes: 116 additions & 0 deletions
116
...r3/communication/API_0000X_ByteCommunicationShimmer3_Streaming_Contiguous_Check_Fail.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,116 @@ | ||
| package com.shimmerresearch.shimmer3.communication; | ||
| import org.junit.Before; | ||
| import org.junit.BeforeClass; | ||
| import org.junit.FixMethodOrder; | ||
| import org.junit.Test; | ||
| import org.junit.runners.MethodSorters; | ||
|
|
||
| import com.shimmerresearch.bluetooth.ShimmerBluetooth.BT_STATE; | ||
| import com.shimmerresearch.driver.BasicProcessWithCallBack; | ||
| import com.shimmerresearch.driver.CallbackObject; | ||
| import com.shimmerresearch.driver.ObjectCluster; | ||
| import com.shimmerresearch.driver.ShimmerMsg; | ||
| import com.shimmerresearch.driver.ShimmerObject; | ||
| import com.shimmerresearch.driver.Configuration.COMMUNICATION_TYPE; | ||
| import com.shimmerresearch.driverUtilities.ChannelDetails; | ||
| import com.shimmerresearch.driverUtilities.SensorDetails; | ||
| import com.shimmerresearch.driverUtilities.ShimmerVerDetails.HW_ID; | ||
| import com.shimmerresearch.exceptions.ShimmerException; | ||
| import com.shimmerresearch.pcDriver.ShimmerPC; | ||
| import com.shimmerresearch.sensors.AbstractSensor; | ||
| import com.shimmerresearch.sensors.AbstractSensor.SENSORS; | ||
|
|
||
| import bolts.TaskCompletionSource; | ||
|
|
||
| import static org.junit.Assert.assertEquals; | ||
|
|
||
| import java.util.ArrayList; | ||
| import java.util.LinkedHashMap; | ||
| import java.util.concurrent.TimeUnit; | ||
| @FixMethodOrder(MethodSorters.NAME_ASCENDING) // Test methods will be run in alphabetical order | ||
| public class API_0000X_ByteCommunicationShimmer3_Streaming_Contiguous_Check_Fail extends BasicProcessWithCallBack{ | ||
| ShimmerPC mDevice; | ||
| TaskCompletionSource<Boolean> mCalibrationTask; | ||
| TaskCompletionSource<Boolean> mStreamingTask; | ||
| ByteCommunicationSimulatorS3 mByteCommunicationSimulatorS3; | ||
| public static int CONTIGUOUS_TIMESTAMP_TICKS_LIMIT = (10*32768); | ||
| @Before | ||
| public void setUp() { | ||
| mByteCommunicationSimulatorS3 = new ByteCommunicationSimulatorS3_streaming_timestamp_contiguous_check_fail("COM99"); | ||
| mDevice = new ShimmerPC("COM99"); | ||
| mDevice.setTestRadio(mByteCommunicationSimulatorS3); | ||
| setWaitForData(mDevice); | ||
| } | ||
|
|
||
| ArrayList<ObjectCluster> mListOJC; | ||
| @Test | ||
| public void test001_testStreaming() { | ||
| mListOJC = new ArrayList<ObjectCluster>(); | ||
| mByteCommunicationSimulatorS3.setIsNewBMPSupported(false); | ||
| mCalibrationTask = new TaskCompletionSource<Boolean>(); | ||
| mDevice.connect("",""); | ||
|
|
||
| mCalibrationTask = new TaskCompletionSource<>(); | ||
| mStreamingTask = new TaskCompletionSource<Boolean>(); | ||
| try { | ||
| boolean result = mCalibrationTask.getTask().waitForCompletion(5, TimeUnit.SECONDS); | ||
| } catch (InterruptedException e) { | ||
| // TODO Auto-generated catch block | ||
| e.printStackTrace(); | ||
| } | ||
|
|
||
| try { | ||
| mDevice.startStreaming(); | ||
| System.out.println("Limit = " + CONTIGUOUS_TIMESTAMP_TICKS_LIMIT); | ||
| } catch (ShimmerException e) { | ||
| // TODO Auto-generated catch block | ||
| e.printStackTrace(); | ||
| } | ||
| try { | ||
| mStreamingTask.getTask().waitForCompletion(2, TimeUnit.SECONDS); | ||
| if(mListOJC.size()!=2) {//only one is expected because only the first packet is followed which meets ShimmerBluetooth.processPacket requirements | ||
| assert(false); | ||
| } | ||
| } catch (InterruptedException e) { | ||
| // TODO Auto-generated catch block | ||
| e.printStackTrace(); | ||
| } | ||
|
|
||
|
|
||
|
|
||
| } | ||
|
|
||
|
|
||
| @Override | ||
| protected void processMsgFromCallback(ShimmerMsg shimmerMSG) { | ||
| // TODO Auto-generated method stub | ||
| int ind = shimmerMSG.mIdentifier; | ||
|
|
||
| Object object = (Object) shimmerMSG.mB; | ||
|
|
||
| if (ind == ShimmerPC.MSG_IDENTIFIER_STATE_CHANGE) { | ||
| if (ind == ShimmerPC.MSG_IDENTIFIER_STATE_CHANGE) { | ||
| CallbackObject callbackObject = (CallbackObject)object; | ||
|
|
||
| if (callbackObject.mState == BT_STATE.CONNECTED) { | ||
| if (mDevice.isInitialised()) { | ||
| try { | ||
| Thread.sleep(200); | ||
| } catch (InterruptedException e) { | ||
| // TODO Auto-generated catch block | ||
| e.printStackTrace(); | ||
| } | ||
|
|
||
| } | ||
|
|
||
| } | ||
| } | ||
| } else if (ind == ShimmerPC.MSG_IDENTIFIER_DATA_PACKET) { | ||
| System.out.println("Shimmer MSG_IDENTIFIER_DATA_PACKET"); | ||
| ObjectCluster objc = (ObjectCluster) shimmerMSG.mB; | ||
| mListOJC.add(objc); | ||
| } | ||
|
|
||
| } | ||
|
|
||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.