Added condition to check corner case + Added delay when running the sample test again + Going back on critical error.
This commit is contained in:
@@ -265,7 +265,8 @@ class TestRightExpReference : Fragment() {
|
|||||||
|
|
||||||
// Log.d(TAG, stringData)
|
// Log.d(TAG, stringData)
|
||||||
// if (stringData.contains("OK", true)) {
|
// if (stringData.contains("OK", true)) {
|
||||||
if (fullReadOutput.substring(Math.max(fullReadOutput.length - 15, 0)).contains("OK", true)) {
|
// if (fullReadOutput.substring(Math.max(fullReadOutput.length - 15, 0)).contains("OK", true)) {
|
||||||
|
if (stringData.trim().isNotEmpty() && fullReadOutput.substring(Math.max(fullReadOutput.length - 15, 0)).contains("OK [0]", true)) {
|
||||||
|
|
||||||
Log.d(TAG, "onUsbRead() called in sendCmdToFetchLightIntensities()")
|
Log.d(TAG, "onUsbRead() called in sendCmdToFetchLightIntensities()")
|
||||||
// Log.d(TAG, fullReadOutput.toString())
|
// Log.d(TAG, fullReadOutput.toString())
|
||||||
|
|||||||
@@ -65,6 +65,9 @@ class TestRightExpSample : Fragment() {
|
|||||||
viewModel.errorTriggered.observe(viewLifecycleOwner) {
|
viewModel.errorTriggered.observe(viewLifecycleOwner) {
|
||||||
if (it != null){
|
if (it != null){
|
||||||
UIUtils.onShowErrorToast(requireContext(), it.message)
|
UIUtils.onShowErrorToast(requireContext(), it.message)
|
||||||
|
if (it.code == Constants.ERROR_CRITICAL){
|
||||||
|
activity?.onBackPressed()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -138,7 +141,8 @@ class TestRightExpSample : Fragment() {
|
|||||||
Log.d(TAG, stringData)
|
Log.d(TAG, stringData)
|
||||||
// if (stringData.contains("OK", true)) {
|
// if (stringData.contains("OK", true)) {
|
||||||
// if (stringData.contains("OK", true) || fullReadOutput.substring(Math.max(fullReadOutput.length - 15, 0)).contains("OK", true)) {
|
// if (stringData.contains("OK", true) || fullReadOutput.substring(Math.max(fullReadOutput.length - 15, 0)).contains("OK", true)) {
|
||||||
if (fullReadOutput.substring(Math.max(fullReadOutput.length - 15, 0)).contains("OK", true)) {
|
// if (fullReadOutput.substring(Math.max(fullReadOutput.length - 15, 0)).contains("OK", true)) {
|
||||||
|
if (fullReadOutput.substring(Math.max(fullReadOutput.length - 15, 0)).contains("OK [0]", true)) {
|
||||||
Log.d(TAG, "onUsbRead() called in sendCmdToRun()")
|
Log.d(TAG, "onUsbRead() called in sendCmdToRun()")
|
||||||
Handler(Looper.getMainLooper()).postDelayed(
|
Handler(Looper.getMainLooper()).postDelayed(
|
||||||
Runnable {
|
Runnable {
|
||||||
@@ -173,14 +177,21 @@ class TestRightExpSample : Fragment() {
|
|||||||
// if (stringData.contains("OK", true)) {
|
// if (stringData.contains("OK", true)) {
|
||||||
// if (stringData.contains("OK", true) || stringData.contains("O", true) || stringData.contains("K", true)) {
|
// if (stringData.contains("OK", true) || stringData.contains("O", true) || stringData.contains("K", true)) {
|
||||||
// if (stringData.contains("OK", true) || fullReadOutput.substring(Math.max(fullReadOutput.length - 15, 0)).contains("OK", true)) {
|
// if (stringData.contains("OK", true) || fullReadOutput.substring(Math.max(fullReadOutput.length - 15, 0)).contains("OK", true)) {
|
||||||
if (fullReadOutput.substring(Math.max(fullReadOutput.length - 15, 0)).contains("OK", true)) {
|
// if (fullReadOutput.substring(Math.max(fullReadOutput.length - 15, 0)).contains("OK", true)) {
|
||||||
|
if (stringData.trim().isNotEmpty() && fullReadOutput.substring(Math.max(fullReadOutput.length - 15, 0)).contains("OK [0]", true)) {
|
||||||
Log.d(TAG, "onUsbRead() called in sendCmdToFetchLightIntensities()")
|
Log.d(TAG, "onUsbRead() called in sendCmdToFetchLightIntensities()")
|
||||||
|
|
||||||
viewModel.mapIntensityValues(fullReadOutput.toString(), false)
|
viewModel.mapIntensityValues(fullReadOutput.toString(), false)
|
||||||
// viewModel.saveLogTest(requireContext().applicationContext, false, fullReadOutput.toString())
|
// viewModel.saveLogTest(requireContext().applicationContext, false, fullReadOutput.toString())
|
||||||
|
|
||||||
// showResultsAfterAcquiring()
|
// showResultsAfterAcquiring()
|
||||||
checkIfToRunAgain()
|
Handler(Looper.getMainLooper()).postDelayed(
|
||||||
|
{
|
||||||
|
checkIfToRunAgain()
|
||||||
|
},
|
||||||
|
Constants.DELAY_BETWEEN_COMMANDS
|
||||||
|
)
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -153,7 +153,7 @@ class TestRightViewModel : ViewModel() {
|
|||||||
|
|
||||||
fun mapWavelengthToAbsorbance() {
|
fun mapWavelengthToAbsorbance() {
|
||||||
if (DataHolder.intensityReferenceArray.size != intensitySampleArray.size || DataHolder.wavelengthToPixelArray.size != intensitySampleArray.size || DataHolder.wavelengthToPixelArray.size != DataHolder.intensityReferenceArray.size) {
|
if (DataHolder.intensityReferenceArray.size != intensitySampleArray.size || DataHolder.wavelengthToPixelArray.size != intensitySampleArray.size || DataHolder.wavelengthToPixelArray.size != DataHolder.intensityReferenceArray.size) {
|
||||||
errorTriggered.postValue(ErrorMessage("Error 205: Unable to fetch data from device, please try again by reopening the app", Constants.ERROR_NORMAL))
|
errorTriggered.postValue(ErrorMessage("Error 205: Unable to fetch data from device, please try again by reopening the app", Constants.ERROR_CRITICAL))
|
||||||
|
|
||||||
throw Exception("Inconsistency in the data, size of arrays are not same. \nintensityReferenceArray.size = ${DataHolder.intensityReferenceArray.size} ; intensitySampleArray.size = ${intensitySampleArray.size} ; wavelengthToPixelArray.size = ${DataHolder.wavelengthToPixelArray.size}")
|
throw Exception("Inconsistency in the data, size of arrays are not same. \nintensityReferenceArray.size = ${DataHolder.intensityReferenceArray.size} ; intensitySampleArray.size = ${intensitySampleArray.size} ; wavelengthToPixelArray.size = ${DataHolder.wavelengthToPixelArray.size}")
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user