add buffer validation withn bounds
This commit is contained in:
@@ -74,4 +74,7 @@ object Constants {
|
|||||||
const val BUFFER_VALUE_3 = "BufferValue3"
|
const val BUFFER_VALUE_3 = "BufferValue3"
|
||||||
const val BUFFER_VALUE_4 = "BufferValue4"
|
const val BUFFER_VALUE_4 = "BufferValue4"
|
||||||
const val DEVICE_ID = "DEVICE_ID"
|
const val DEVICE_ID = "DEVICE_ID"
|
||||||
|
|
||||||
|
const val BUFFER_LED_LOWER_BOUND = 20000
|
||||||
|
const val BUFFER_LED_HIGHER_BOUND = 24000
|
||||||
}
|
}
|
||||||
@@ -45,12 +45,13 @@ class HemoCubeFragment : Fragment() {
|
|||||||
private val testingTrace = Firebase.performance.newTrace("testing_trace")
|
private val testingTrace = Firebase.performance.newTrace("testing_trace")
|
||||||
private var led1BufferForDevice = 0.0
|
private var led1BufferForDevice = 0.0
|
||||||
private var led2BufferForDevice = 0.0
|
private var led2BufferForDevice = 0.0
|
||||||
private var led3BufferForDevice = 0.0
|
private var led3BufferForDevice = 0.0
|
||||||
private var led4BufferForDevice = 0.0
|
private var led4BufferForDevice = 0.0
|
||||||
private var led1SampleForDevice = 0.0
|
private var led1SampleForDevice = 0.0
|
||||||
private var led2SampleForDevice = 0.0
|
private var led2SampleForDevice = 0.0
|
||||||
private var led3SampleForDevice = 0.0
|
private var led3SampleForDevice = 0.0
|
||||||
private var led4SampleForDevice = 0.0
|
private var led4SampleForDevice = 0.0
|
||||||
|
private var validationError = false
|
||||||
|
|
||||||
override fun onCreateView(
|
override fun onCreateView(
|
||||||
inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?,
|
inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?,
|
||||||
@@ -96,8 +97,8 @@ class HemoCubeFragment : Fragment() {
|
|||||||
binding.tvSubtitle4.visibility = View.VISIBLE
|
binding.tvSubtitle4.visibility = View.VISIBLE
|
||||||
binding.tvSubtitle4.text = "Sample Started"
|
binding.tvSubtitle4.text = "Sample Started"
|
||||||
}
|
}
|
||||||
startSampleProcess()
|
startSampleProcess()
|
||||||
it.visibility = View.GONE
|
it.visibility = View.GONE
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.btnPlacebuffer.setOnClickListener {
|
binding.btnPlacebuffer.setOnClickListener {
|
||||||
@@ -355,7 +356,8 @@ class HemoCubeFragment : Fragment() {
|
|||||||
sampleIntensity = resultLines[7].split(' ')[1].trim()
|
sampleIntensity = resultLines[7].split(' ')[1].trim()
|
||||||
led3SampleForDevice = resultLines[7].split(' ')[1].trim().toDoubleOrNull()!!
|
led3SampleForDevice = resultLines[7].split(' ')[1].trim().toDoubleOrNull()!!
|
||||||
sampleIntensity = resultLines[8].split(' ')[1].split('\r')[0].trim()
|
sampleIntensity = resultLines[8].split(' ')[1].split('\r')[0].trim()
|
||||||
led4SampleForDevice = resultLines[8].split(' ')[1].split('\r')[0].trim().toDoubleOrNull()!!
|
led4SampleForDevice =
|
||||||
|
resultLines[8].split(' ')[1].split('\r')[0].trim().toDoubleOrNull()!!
|
||||||
processResult()
|
processResult()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -406,9 +408,34 @@ class HemoCubeFragment : Fragment() {
|
|||||||
val led4Average = log10(led4BufferForDevice?.div(led4SampleForDevice!!) ?: 0.0)
|
val led4Average = log10(led4BufferForDevice?.div(led4SampleForDevice!!) ?: 0.0)
|
||||||
val deviceRatio = led3Average / led1Average
|
val deviceRatio = led3Average / led1Average
|
||||||
|
|
||||||
if (led1Average < 0 || led2Average < 0) {
|
if (led1Average < 0 || led2Average < 0 || led3Average < 0 || led4Average < 0) {
|
||||||
|
validationError = true
|
||||||
activity?.runOnUiThread {
|
activity?.runOnUiThread {
|
||||||
binding.errorMessage.text = "Warning: Negative Abs. Retake Blank Reading"
|
binding.errorMessage.text = "Error: Negative Abs. Retake Blank Reading"
|
||||||
|
binding.errorMessage.visibility = View.VISIBLE
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (led1BufferForDevice < Constants.BUFFER_LED_LOWER_BOUND
|
||||||
|
|| led2BufferForDevice < Constants.BUFFER_LED_LOWER_BOUND
|
||||||
|
|| led3BufferForDevice < Constants.BUFFER_LED_LOWER_BOUND
|
||||||
|
|| led4BufferForDevice < Constants.BUFFER_LED_LOWER_BOUND
|
||||||
|
) {
|
||||||
|
validationError = true
|
||||||
|
activity?.runOnUiThread {
|
||||||
|
binding.errorMessage.text = "Error: Invalid Test. Blank reading is too low"
|
||||||
|
binding.errorMessage.visibility = View.VISIBLE
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (led1BufferForDevice > Constants.BUFFER_LED_HIGHER_BOUND
|
||||||
|
|| led2BufferForDevice > Constants.BUFFER_LED_HIGHER_BOUND
|
||||||
|
|| led3BufferForDevice > Constants.BUFFER_LED_HIGHER_BOUND
|
||||||
|
|| led4BufferForDevice > Constants.BUFFER_LED_HIGHER_BOUND
|
||||||
|
) {
|
||||||
|
validationError = true
|
||||||
|
activity?.runOnUiThread {
|
||||||
|
binding.errorMessage.text = "Error: Invalid Test. Blank reading is too high"
|
||||||
binding.errorMessage.visibility = View.VISIBLE
|
binding.errorMessage.visibility = View.VISIBLE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -444,11 +471,13 @@ class HemoCubeFragment : Fragment() {
|
|||||||
apply()
|
apply()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
activity?.runOnUiThread {
|
if (!validationError) {
|
||||||
binding.btnSubmit.visibility = View.VISIBLE
|
activity?.runOnUiThread {
|
||||||
binding.btnSubmit.isEnabled = true
|
binding.btnSubmit.visibility = View.VISIBLE
|
||||||
binding.btnSubmit.isClickable = true
|
binding.btnSubmit.isEnabled = true
|
||||||
binding.clParent.setBackgroundColor(Color.parseColor("#edfffd"))
|
binding.btnSubmit.isClickable = true
|
||||||
|
binding.clParent.setBackgroundColor(Color.parseColor("#edfffd"))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
@@ -480,14 +509,14 @@ class HemoCubeFragment : Fragment() {
|
|||||||
if (calculatedRatio > 0.35)
|
if (calculatedRatio > 0.35)
|
||||||
return "Inconclusive. Repeat with test with lower volume of blood"
|
return "Inconclusive. Repeat with test with lower volume of blood"
|
||||||
} else {
|
} else {
|
||||||
return "NULL"
|
return "INVALID"
|
||||||
}
|
}
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
showToast("error while performing classification")
|
showToast("error while performing classification")
|
||||||
Firebase.crashlytics.recordException(e)
|
Firebase.crashlytics.recordException(e)
|
||||||
return "ERROR"
|
return "ERROR"
|
||||||
}
|
}
|
||||||
return "NULL"
|
return "INVALID"
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun showToast(message: String) {
|
private fun showToast(message: String) {
|
||||||
|
|||||||
Reference in New Issue
Block a user