2020
2121import org .apache .commons .lang3 .ArrayUtils ;
2222
23- import com .shimmerresearch .driver .Configuration ;
24- import com .shimmerresearch .driver .ObjectCluster ;
2523import com .shimmerresearch .algorithms .AbstractAlgorithm ;
2624import com .shimmerresearch .algorithms .AlgorithmResultObject ;
2725import com .shimmerresearch .algorithms .gyroOnTheFlyCal .GyroOnTheFlyCalLoader ;
2826import com .shimmerresearch .algorithms .AlgorithmDetails ;
27+ import com .shimmerresearch .algorithms .AlgorithmDetails .SENSOR_CHECK_METHOD ;
2928import com .shimmerresearch .algorithms .AlgorithmLoaderInterface ;
3029import com .shimmerresearch .algorithms .orientation .OrientationModule6DOFLoader ;
3130import com .shimmerresearch .algorithms .orientation .OrientationModule9DOFLoader ;
3635import com .shimmerresearch .comms .serialPortInterface .AbstractSerialPortHal ;
3736import com .shimmerresearch .comms .wiredProtocol .UartComponentPropertyDetails ;
3837import com .shimmerresearch .driver .Configuration .COMMUNICATION_TYPE ;
39- import com .shimmerresearch .driver .Configuration .Shimmer3 ;
4038import com .shimmerresearch .driver .calibration .CalibDetails ;
4139import com .shimmerresearch .driver .calibration .CalibDetailsKinematic ;
4240import com .shimmerresearch .driver .calibration .CalibDetails .CALIB_READ_SOURCE ;
6765import com .shimmerresearch .sensors .SensorShimmerClock ;
6866import com .shimmerresearch .shimmerConfig .FixedShimmerConfigs ;
6967import com .shimmerresearch .shimmerConfig .FixedShimmerConfigs .FIXED_SHIMMER_CONFIG_MODE ;
70- import com .shimmerresearch .verisense .communication .VerisenseProtocolByteCommunication ;
7168import com .shimmerresearch .verisense .sensors .ISensorConfig ;
7269
7370public abstract class ShimmerDevice extends BasicProcessWithCallBack implements Serializable {
@@ -142,13 +139,17 @@ public abstract class ShimmerDevice extends BasicProcessWithCallBack implements
142139 private boolean mConfigurationReadSuccess = false ;
143140 public boolean mReadDaughterIDSuccess = false ;
144141 public boolean writeRealWorldClockFromPcTimeSuccess = false ;
142+ public boolean mReadBtVerSuccess = false ;
143+ public boolean mReadBtModeSuccess = false ;
145144
146145 protected boolean mIsConnected = false ;
147146 protected boolean mIsSensing = false ;
148147 protected boolean mIsStreaming = false ; // This is used to monitor whether the device is in streaming mode
149148 protected boolean mIsInitialised = false ;
150149 private boolean mIsDocked = false ;
151- private boolean mIsUsbPluggedIn = false ;
150+ private boolean mIsUsbPluggedIn = false ;
151+ private boolean mIsDockCommsSuccessful = false ;
152+ public boolean mIsUsbDfuMode = false ;
152153 protected boolean mHaveAttemptedToReadConfig = false ;
153154
154155 //BSL related start
@@ -754,7 +755,11 @@ public void addCommunicationRoute(COMMUNICATION_TYPE communicationType) {
754755// Collections.sort(mListOfAvailableCommunicationTypes);
755756
756757 if (communicationType ==COMMUNICATION_TYPE .DOCK ){
757- setIsDocked (true );
758+ if (mDockID .contains (DEVICE_TYPE .SHIMMER3R .toString ())) {
759+ setIsUsbPluggedIn (true );
760+ }else {
761+ setIsDocked (true );
762+ }
758763 }
759764
760765 //TODO temp here -> check if the best place for it
@@ -780,7 +785,8 @@ public void removeCommunicationRoute(COMMUNICATION_TYPE communicationType) {
780785 }
781786// Collections.sort(mListOfAvailableCommunicationTypes);
782787
783- if (communicationType ==COMMUNICATION_TYPE .DOCK ){
788+ if (communicationType ==COMMUNICATION_TYPE .DOCK ){
789+ setIsUsbPluggedIn (false );
784790 setIsDocked (false );
785791 setFirstDockRead ();
786792 clearDockInfo (mDockID , mSlotNumber );
@@ -1102,6 +1108,14 @@ public boolean isDocked() {
11021108 public boolean isUsbPluggedIn () {
11031109 return mIsUsbPluggedIn ;
11041110 }
1111+
1112+ public boolean isUsbDfuMode (){
1113+ return mIsUsbDfuMode ;
1114+ }
1115+
1116+ public void setUsbDfuMode (boolean state ) {
1117+ mIsUsbDfuMode = state ;
1118+ }
11051119
11061120 public void setIsConnected (boolean state ) {
11071121 mIsConnected = state ;
@@ -1691,6 +1705,8 @@ public void setFirstDockRead() {
16911705 mReadHwFwSuccess = false ;
16921706 mReadDaughterIDSuccess = false ;
16931707 writeRealWorldClockFromPcTimeSuccess = false ;
1708+ mReadBtVerSuccess = false ;
1709+ mReadBtModeSuccess = false ;
16941710 }
16951711
16961712 // ----------------- Overrides from ShimmerDevice end -------------
@@ -3076,9 +3092,22 @@ public void setIsAlgorithmEnabled(String algorithmName, boolean state){
30763092 if (abstractAlgorithm !=null && abstractAlgorithm .mAlgorithmDetails !=null ){
30773093 if (state ){
30783094 //switch on the required sensors
3079- //TODO add support for ANY/ALL sensors
30803095 for (Integer sensorId :abstractAlgorithm .mAlgorithmDetails .mListOfRequiredSensors ) {
3081- setSensorEnabledState (sensorId , true );
3096+ if (abstractAlgorithm .mAlgorithmDetails .mSensorCheckMethod ==SENSOR_CHECK_METHOD .ANY ) {
3097+
3098+ int tempSensorId = handleSpecCasesBeforeSetSensorState (sensorId ,state );
3099+ SensorDetails sensorDetails = getSensorDetails (tempSensorId );
3100+ if (sensorDetails !=null ){
3101+ setSensorEnabledState (sensorId , true );
3102+ }
3103+ }
3104+ else if (abstractAlgorithm .mAlgorithmDetails .mSensorCheckMethod ==SENSOR_CHECK_METHOD .ALL ) {
3105+ boolean success = setSensorEnabledState (sensorId , true );
3106+ if (!success ){
3107+ consolePrintErrLn ("Failed to enable required sensor ID " + sensorId + " for algorithm:\t " + abstractAlgorithm .getAlgorithmName ());
3108+ return ;
3109+ }
3110+ }
30823111 }
30833112 }
30843113 abstractAlgorithm .setIsEnabled (state );
@@ -4768,4 +4797,12 @@ public String getRadioModel() {
47684797 return "" ;
47694798 }
47704799
4800+ public boolean isDockCommsSuccessful () {
4801+ return mIsDockCommsSuccessful ;
4802+ }
4803+
4804+ public void setDockCommsSuccessful (boolean isDockCommsSuccessful ) {
4805+ mIsDockCommsSuccessful = isDockCommsSuccessful ;
4806+ }
4807+
47714808}
0 commit comments