Added condition to check corner case + Added delay when running the sample test again + Going back on critical error.

This commit is contained in:
vsuryakumar
2023-02-06 00:52:39 +05:30
parent eac577f1a1
commit 00864ae755
3 changed files with 17 additions and 5 deletions

View File

@@ -265,7 +265,8 @@ class TestRightExpReference : Fragment() {
// Log.d(TAG, stringData)
// 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, fullReadOutput.toString())

View File

@@ -65,6 +65,9 @@ class TestRightExpSample : Fragment() {
viewModel.errorTriggered.observe(viewLifecycleOwner) {
if (it != null){
UIUtils.onShowErrorToast(requireContext(), it.message)
if (it.code == Constants.ERROR_CRITICAL){
activity?.onBackPressed()
}
}
}
@@ -138,7 +141,8 @@ class TestRightExpSample : Fragment() {
Log.d(TAG, stringData)
// if (stringData.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()")
Handler(Looper.getMainLooper()).postDelayed(
Runnable {
@@ -173,14 +177,21 @@ class TestRightExpSample : Fragment() {
// if (stringData.contains("OK", 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 (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()")
viewModel.mapIntensityValues(fullReadOutput.toString(), false)
// viewModel.saveLogTest(requireContext().applicationContext, false, fullReadOutput.toString())
// showResultsAfterAcquiring()
checkIfToRunAgain()
Handler(Looper.getMainLooper()).postDelayed(
{
checkIfToRunAgain()
},
Constants.DELAY_BETWEEN_COMMANDS
)
}
}
}

View File

@@ -153,7 +153,7 @@ class TestRightViewModel : ViewModel() {
fun mapWavelengthToAbsorbance() {
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}")
}