1.baud rate is added,
2. existing buffer popup is added, 3. submit button make visible 4.handlevalidresult function changes, added code for fetch ledbuffer1 to ledbuffer4 values and sample1 to sample4 values
This commit is contained in:
@@ -79,9 +79,8 @@ class HemoCubeFragment : Fragment() {
|
|||||||
binding.nameEditText.visibility = View.GONE
|
binding.nameEditText.visibility = View.GONE
|
||||||
binding.tvTitle.visibility = View.GONE
|
binding.tvTitle.visibility = View.GONE
|
||||||
binding.btnGo.visibility = View.GONE
|
binding.btnGo.visibility = View.GONE
|
||||||
binding.btnSubmit.isEnabled = false
|
binding.btnSubmit.isEnabled = true
|
||||||
binding.btnSubmit.isClickable = false
|
binding.btnSubmit.isClickable = true
|
||||||
|
|
||||||
|
|
||||||
binding.tvName.text = "Name: ${testDetails?.name}\n ID: ${testDetails?._id}"
|
binding.tvName.text = "Name: ${testDetails?.name}\n ID: ${testDetails?._id}"
|
||||||
Log.e("nametext", binding.tvName.text.toString())
|
Log.e("nametext", binding.tvName.text.toString())
|
||||||
@@ -92,8 +91,8 @@ class HemoCubeFragment : Fragment() {
|
|||||||
binding.tvSubtitle4.visibility = View.VISIBLE
|
binding.tvSubtitle4.visibility = View.VISIBLE
|
||||||
binding.tvSubtitle4.text = "Place Sample"
|
binding.tvSubtitle4.text = "Place Sample"
|
||||||
}
|
}
|
||||||
startSampleProcess()
|
startSampleProcess()
|
||||||
it.visibility = View.GONE
|
it.visibility = View.GONE
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.btnPlacebuffer.setOnClickListener {
|
binding.btnPlacebuffer.setOnClickListener {
|
||||||
@@ -104,7 +103,6 @@ class HemoCubeFragment : Fragment() {
|
|||||||
binding.tvSubtitle4.visibility = View.VISIBLE
|
binding.tvSubtitle4.visibility = View.VISIBLE
|
||||||
binding.tvSubtitle4.text = "Place Buffer"
|
binding.tvSubtitle4.text = "Place Buffer"
|
||||||
}
|
}
|
||||||
|
|
||||||
checkAndStartProcess()
|
checkAndStartProcess()
|
||||||
it.visibility = View.GONE
|
it.visibility = View.GONE
|
||||||
}
|
}
|
||||||
@@ -258,13 +256,15 @@ class HemoCubeFragment : Fragment() {
|
|||||||
Log.e("nametext", stringData)
|
Log.e("nametext", stringData)
|
||||||
|
|
||||||
when {
|
when {
|
||||||
stringData.contains("#BC") -> {
|
stringData.contains("#BC") -> {
|
||||||
activity?.runOnUiThread {
|
activity?.runOnUiThread {
|
||||||
binding.btnSamplestart.visibility = View.VISIBLE
|
binding.btnSamplestart.visibility = View.VISIBLE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
stringData.contains("#SC") -> {
|
stringData.contains("#SC") -> {
|
||||||
binding.btnSubmit.visibility = View.VISIBLE
|
activity?.runOnUiThread {
|
||||||
|
binding.btnSubmit.visibility = View.VISIBLE
|
||||||
|
}
|
||||||
fetchResult()
|
fetchResult()
|
||||||
testingTrace.stop()
|
testingTrace.stop()
|
||||||
}
|
}
|
||||||
@@ -351,43 +351,70 @@ class HemoCubeFragment : Fragment() {
|
|||||||
private fun handleValidResult(validString: String, fullReadOutput: String) {
|
private fun handleValidResult(validString: String, fullReadOutput: String) {
|
||||||
try {
|
try {
|
||||||
val resultLines = validString.split("\n")
|
val resultLines = validString.split("\n")
|
||||||
if (resultLines.size == 9) {
|
// if (resultLines.size == 9) {
|
||||||
val deviceLog = fullReadOutput
|
val deviceLog = fullReadOutput
|
||||||
val led1BufferForDevice = resultLines.find { it.startsWith("LB1") }?.substring(4)
|
// val led1BufferForDevice = if (isUsingExistingBuffer) {
|
||||||
?.toDoubleOrNull()
|
// sharedPreferences.getString(Constants.BUFFER_VALUE_1, "")?.toDoubleOrNull()
|
||||||
?: 0.0
|
// } else {
|
||||||
val led2BufferForDevice = resultLines.find { it.startsWith("LB2") }?.substring(4)
|
// resultLines.find { it.startsWith("LB1") }?.substring(4)
|
||||||
?.toDoubleOrNull()
|
// ?.toDoubleOrNull()
|
||||||
?: 0.0
|
// ?: 0.0
|
||||||
val led3BufferForDevice = resultLines.find { it.startsWith("LB3") }?.substring(4)
|
// }
|
||||||
?.toDoubleOrNull()
|
val led1BufferForDevice = resultLines.find { it.startsWith("LB1") }?.substring(4)?.toDoubleOrNull() ?: 0.0
|
||||||
?: 0.0
|
val led2BufferForDevice = resultLines.find { it.startsWith("LB2") }?.substring(4)?.toDoubleOrNull() ?: 0.0
|
||||||
val led4BufferForDevice = resultLines.find { it.startsWith("LB4") }?.substring(4)
|
val led3BufferForDevice = resultLines.find { it.startsWith("LB3") }?.substring(4)?.toDoubleOrNull() ?: 0.0
|
||||||
?.toDoubleOrNull()
|
val led4BufferForDevice = resultLines.find { it.startsWith("LB4") }?.substring(4)?.toDoubleOrNull() ?: 0.0
|
||||||
?: 0.0
|
val led1Sample = resultLines.find { it.startsWith("LS1") }?.substring(4)?.toDoubleOrNull() ?: 0.0
|
||||||
|
val led2Sample = resultLines.find { it.startsWith("LS2") }?.substring(4)?.toDoubleOrNull() ?: 0.0
|
||||||
|
val led3Sample = resultLines.find { it.startsWith("LS3") }?.substring(4)?.toDoubleOrNull() ?: 0.0
|
||||||
|
val led4Sample = resultLines.find { it.startsWith("LS4") }?.substring(4)?.toDoubleOrNull() ?: 0.0
|
||||||
|
|
||||||
val pInfo = requireActivity().packageManager.getPackageInfo(
|
// val led1BufferForDevice = resultLines.find { it.startsWith("LB1") }?.let {
|
||||||
requireActivity().packageName, 0
|
// try {
|
||||||
)
|
// it.substring(4).toDoubleOrNull() ?: 0.0
|
||||||
val version = pInfo.versionName
|
// } catch (e: NumberFormatException) {
|
||||||
|
// // Handle invalid number format, log an error, or set a default value
|
||||||
|
// Log.e("Parsing Error", "Invalid format for LB1: $it")
|
||||||
|
// 0.0
|
||||||
|
// }
|
||||||
|
// } ?: 0.0
|
||||||
|
//
|
||||||
|
// val led2BufferForDevice = if (isUsingExistingBuffer) {
|
||||||
|
// sharedPreferences.getString(Constants.BUFFER_VALUE_2, "")?.toDoubleOrNull()
|
||||||
|
// } else {
|
||||||
|
// resultLines.find { it.startsWith("LB2") }?.substring(4)
|
||||||
|
// ?.toDoubleOrNull()
|
||||||
|
// ?: 0.0
|
||||||
|
// }
|
||||||
|
// val led3BufferForDevice = resultLines.find { it.startsWith("LB3") }?.substring(4)
|
||||||
|
// ?.toDoubleOrNull()
|
||||||
|
// ?: 0.0
|
||||||
|
// val led4BufferForDevice = resultLines.find { it.startsWith("LB4") }?.substring(4)
|
||||||
|
// ?.toDoubleOrNull()
|
||||||
|
// ?: 0.0
|
||||||
|
|
||||||
val led1Sample = resultLines.find { it.startsWith("LS1") }?.substring(4)
|
val pInfo = requireActivity().packageManager.getPackageInfo(
|
||||||
?.toDoubleOrNull()
|
requireActivity().packageName, 0
|
||||||
?: 0.0
|
)
|
||||||
val led2Sample = resultLines.find { it.startsWith("LS2") }?.substring(4)
|
val version = pInfo.versionName
|
||||||
?.toDoubleOrNull()
|
|
||||||
?: 0.0
|
|
||||||
val led3Sample = resultLines.find { it.startsWith("LS3") }?.substring(4)
|
|
||||||
?.toDoubleOrNull()
|
|
||||||
?: 0.0
|
|
||||||
val led4Sample = resultLines.find { it.startsWith("LS4") }?.substring(4)
|
|
||||||
?.toDoubleOrNull()
|
|
||||||
?: 0.0
|
|
||||||
|
|
||||||
val led1Average = log10(led1BufferForDevice?.div(led1Sample!!) ?: 0.0)
|
// val led1Sample = resultLines.find { it.startsWith("LS1") }?.substring(4)
|
||||||
val led2Average = log10(led2BufferForDevice?.div(led2Sample!!) ?: 0.0)
|
// ?.toDoubleOrNull()
|
||||||
val led3Average = log10(led3BufferForDevice?.div(led3Sample!!) ?: 0.0)
|
// ?: 0.0
|
||||||
val deviceRatio = led1Average / led2Average
|
// val led2Sample = resultLines.find { it.startsWith("LS2") }?.substring(4)
|
||||||
|
// ?.toDoubleOrNull()
|
||||||
|
// ?: 0.0
|
||||||
|
// val led3Sample = resultLines.find { it.startsWith("LS3") }?.substring(4)
|
||||||
|
// ?.toDoubleOrNull()
|
||||||
|
// ?: 0.0
|
||||||
|
// val led4Sample = resultLines.find { it.startsWith("LS4") }?.substring(4)
|
||||||
|
// ?.toDoubleOrNull()
|
||||||
|
// ?: 0.0
|
||||||
|
|
||||||
|
val led1Average = log10(led1BufferForDevice?.div(led1Sample!!) ?: 0.0)
|
||||||
|
val led2Average = log10(led2BufferForDevice?.div(led2Sample!!) ?: 0.0)
|
||||||
|
val led3Average = log10(led3BufferForDevice?.div(led3Sample!!) ?: 0.0)
|
||||||
|
val deviceRatio = led1Average / led2Average
|
||||||
// if (led1BufferForDevice!! > 20000 && led1BufferForDevice < 24000 && led2BufferForDevice!! > 20000 && led2BufferForDevice < 24000) {
|
// if (led1BufferForDevice!! > 20000 && led1BufferForDevice < 24000 && led2BufferForDevice!! > 20000 && led2BufferForDevice < 24000) {
|
||||||
// if (led1Sample!! < led1BufferForDevice && led1Sample < 24000 && led2Sample!! < led2BufferForDevice && led2Sample < 24000) {
|
// if (led1Sample!! < led1BufferForDevice && led1Sample < 24000 && led2Sample!! < led2BufferForDevice && led2Sample < 24000) {
|
||||||
// if (deviceRatio < 0.08) {
|
// if (deviceRatio < 0.08) {
|
||||||
@@ -398,47 +425,47 @@ class HemoCubeFragment : Fragment() {
|
|||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
if (led1Average < 0 || led2Average < 0) {
|
if (led1Average < 0 || led2Average < 0) {
|
||||||
activity?.runOnUiThread{
|
activity?.runOnUiThread{
|
||||||
binding.errorMessage.text = "Warning: Negative Abs. Retake Blank Reading"
|
binding.errorMessage.text = "Warning: Negative Abs. Retake Blank Reading"
|
||||||
binding.errorMessage.visibility = View.VISIBLE
|
binding.errorMessage.visibility = View.VISIBLE
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
DataHolder.hemoCubeTestData?.apply {
|
|
||||||
// deviceId = deviceSerialNo
|
|
||||||
led1Buffer = led1BufferForDevice
|
|
||||||
led2Buffer = led2BufferForDevice
|
|
||||||
led3Buffer = led3BufferForDevice
|
|
||||||
led4Buffer = led4BufferForDevice
|
|
||||||
appVersion = version
|
|
||||||
this.led1Sample = led1Sample
|
|
||||||
this.led2Sample = led2Sample
|
|
||||||
this.led3Sample = led3Sample
|
|
||||||
this.led4Sample = led4Sample
|
|
||||||
this.led1Average = led1Average
|
|
||||||
this.led2Average = led2Average
|
|
||||||
this.deviceRatio = deviceRatio
|
|
||||||
this.calculatedRatio = calculateRatio(deviceRatio)
|
|
||||||
this.coefficients = currentDeviceData?.coefficients?.get(0).toString() + ", " + currentDeviceData?.coefficients?.get(1).toString()
|
|
||||||
this.classificationResult = findResult(calculatedRatio)
|
|
||||||
hemoCubeViewModel.messages.postValue(this.classificationResult)
|
|
||||||
this.resultData = deviceLog
|
|
||||||
if (!isUsingExistingBuffer) {
|
|
||||||
with(sharedPreferences.edit()) {
|
|
||||||
putString(Constants.BUFFER_VALUE_1, led1Buffer.toString())
|
|
||||||
putString(Constants.BUFFER_VALUE_2, led2Buffer.toString())
|
|
||||||
apply()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
activity?.runOnUiThread {
|
|
||||||
binding.btnSubmit.visibility = View.VISIBLE
|
|
||||||
binding.btnSubmit.isEnabled = true
|
|
||||||
binding.btnSubmit.isClickable = true
|
|
||||||
binding.clParent.setBackgroundColor(Color.parseColor("#edfffd"))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DataHolder.hemoCubeTestData?.apply {
|
||||||
|
// deviceId = deviceSerialNo
|
||||||
|
led1Buffer = led1BufferForDevice
|
||||||
|
led2Buffer = led2BufferForDevice
|
||||||
|
led3Buffer = led3BufferForDevice
|
||||||
|
led4Buffer = led4BufferForDevice
|
||||||
|
appVersion = version
|
||||||
|
this.led1Sample = led1Sample
|
||||||
|
this.led2Sample = led2Sample
|
||||||
|
this.led3Sample = led3Sample
|
||||||
|
this.led4Sample = led4Sample
|
||||||
|
this.led1Average = led1Average
|
||||||
|
this.led2Average = led2Average
|
||||||
|
this.deviceRatio = deviceRatio
|
||||||
|
this.calculatedRatio = calculateRatio(deviceRatio)
|
||||||
|
this.coefficients = currentDeviceData?.coefficients?.get(0).toString() + ", " + currentDeviceData?.coefficients?.get(1).toString()
|
||||||
|
this.classificationResult = findResult(calculatedRatio)
|
||||||
|
hemoCubeViewModel.messages.postValue(this.classificationResult)
|
||||||
|
this.resultData = deviceLog
|
||||||
|
if (!isUsingExistingBuffer) {
|
||||||
|
with(sharedPreferences.edit()) {
|
||||||
|
putString(Constants.BUFFER_VALUE_1, led1Buffer.toString())
|
||||||
|
putString(Constants.BUFFER_VALUE_2, led2Buffer.toString())
|
||||||
|
apply()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
activity?.runOnUiThread {
|
||||||
|
binding.btnSubmit.visibility = View.VISIBLE
|
||||||
|
binding.btnSubmit.isEnabled = true
|
||||||
|
binding.btnSubmit.isClickable = true
|
||||||
|
binding.clParent.setBackgroundColor(Color.parseColor("#edfffd"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Toast.makeText(
|
Toast.makeText(
|
||||||
requireContext(),
|
requireContext(),
|
||||||
|
|||||||
Reference in New Issue
Block a user