add alert on check buffer

This commit is contained in:
Pritimay Sarkar
2023-08-03 16:45:27 +05:30
parent 281d206492
commit 82b3944d94
2 changed files with 45 additions and 19 deletions

View File

@@ -2,7 +2,7 @@ package com.example.hpostesting.data.constant
enum class HemoCubeCommands(val command: String) { enum class HemoCubeCommands(val command: String) {
startBuffer("B\r"), startBuffer("B\r"),
getBuffer("B\r"), getBuffer("Q\r"),
startSample("S\r"), startSample("S\r"),
getSample("P\r"), getSample("R\r"),
} }

View File

@@ -94,16 +94,42 @@ class HemoCubeFragment : Fragment() {
} }
} }
// if (checkBufferValue()) { if (checkBufferValue()) {
// TODO("Call S command") // TODO("Call S command")
// //We have to store the buffer value like this //We have to store the buffer value like this
// with(sharedPreference.edit()) { with(sharedPreference.edit()) {
// putInt(Constants.BUFFER_VALUE, 2000) putInt(Constants.BUFFER_VALUE, 2000)
// apply() apply()
// } }
// } else {
UIUtils.createAlertDialog(
requireContext(),
"WARNING",
"Please check if you have placed the sample of this person",
getString(R.string.no),
"Yes",
object : MyDialogListener {
override fun onClickNegativeButton() {}
override fun onClickPositiveButton() {
UIUtils.createAlertDialog(
requireContext(),
getString(R.string.have_you_placed_sample),
getString(R.string.please_place_sample),
getString(R.string.no),
getString(R.string.yes_and_run),
object : MyDialogListener {
override fun onClickNegativeButton() {}
override fun onClickPositiveButton() {
// fetchHemoCubeResult()
getSampleResult()
}
})
}
}
)
} else {
// TODO("Call B command") // TODO("Call B command")
// } }
} }
private fun checkBufferValue(): Boolean { private fun checkBufferValue(): Boolean {
@@ -240,7 +266,7 @@ class HemoCubeFragment : Fragment() {
binding.tvSubtitle4.text = fullReadOutput binding.tvSubtitle4.text = fullReadOutput
resultData = fullReadOutput.toString() resultData = fullReadOutput.toString()
DataHolder.hemoCubeTestData?.resultData DataHolder.hemoCubeTestData?.resultData
resultRatio = "" //TODO resultRatio = "" // TODO
val pareseddata = parseUsbData(fullReadOutput.toString()) val pareseddata = parseUsbData(fullReadOutput.toString())
Log.d("Result", data.toString()) Log.d("Result", data.toString())
hemoCubeViewModel.progressBar.postValue(false) hemoCubeViewModel.progressBar.postValue(false)
@@ -340,17 +366,17 @@ class HemoCubeFragment : Fragment() {
if (stringData.contains("RESULT", true)) { if (stringData.contains("RESULT", true)) {
// hemoCubeViewModel.mapDeviceConstants(fullReadOutput.toString()) // hemoCubeViewModel.mapDeviceConstants(fullReadOutput.toString())
val response: String = "RESULT SN18291 1937.23 2828.11 28211.20 121829.12" // val response: String = "RESULT SN18291 1937.23 2828.11 28211.20 121829.12"
// val response = stringData val response = stringData
val result = response.split(" ") val result = response.split(" ")
val deviceSerialNo = result[1] val deviceSerialNo = result[1]
val led1Buffer = result[2].toDouble() val led1Buffer = result[2].toDoubleOrNull()
val led2Buffer = result[3].toDouble() val led2Buffer = result[3].toDoubleOrNull()
val led1Sample = result[4].toDouble() val led1Sample = result[4].toDoubleOrNull()
val led2Sample = result[5].toDouble() val led2Sample = result[5].toDoubleOrNull()
val led1Average = log10(led1Buffer / led1Sample) val led1Average = log10(led1Buffer?.div(led1Sample!!) ?: 0.0)
val led2Average = log10(led1Buffer / led1Sample) val led2Average = log10(led2Buffer?.div(led2Sample!!) ?: 0.0)
val deviceRatio = led1Average / led2Average val deviceRatio = led1Average / led2Average
DataHolder.hemoCubeTestData?.deviceSerialNumber = deviceSerialNo DataHolder.hemoCubeTestData?.deviceSerialNumber = deviceSerialNo
DataHolder.hemoCubeTestData?.led1Buffer = led1Buffer DataHolder.hemoCubeTestData?.led1Buffer = led1Buffer