add alert on check buffer
This commit is contained in:
@@ -2,7 +2,7 @@ package com.example.hpostesting.data.constant
|
||||
|
||||
enum class HemoCubeCommands(val command: String) {
|
||||
startBuffer("B\r"),
|
||||
getBuffer("B\r"),
|
||||
getBuffer("Q\r"),
|
||||
startSample("S\r"),
|
||||
getSample("P\r"),
|
||||
getSample("R\r"),
|
||||
}
|
||||
@@ -94,16 +94,42 @@ class HemoCubeFragment : Fragment() {
|
||||
}
|
||||
}
|
||||
|
||||
// if (checkBufferValue()) {
|
||||
if (checkBufferValue()) {
|
||||
// TODO("Call S command")
|
||||
// //We have to store the buffer value like this
|
||||
// with(sharedPreference.edit()) {
|
||||
// putInt(Constants.BUFFER_VALUE, 2000)
|
||||
// apply()
|
||||
// }
|
||||
// } else {
|
||||
//We have to store the buffer value like this
|
||||
with(sharedPreference.edit()) {
|
||||
putInt(Constants.BUFFER_VALUE, 2000)
|
||||
apply()
|
||||
}
|
||||
|
||||
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")
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
private fun checkBufferValue(): Boolean {
|
||||
@@ -240,7 +266,7 @@ class HemoCubeFragment : Fragment() {
|
||||
binding.tvSubtitle4.text = fullReadOutput
|
||||
resultData = fullReadOutput.toString()
|
||||
DataHolder.hemoCubeTestData?.resultData
|
||||
resultRatio = "" //TODO
|
||||
resultRatio = "" // TODO
|
||||
val pareseddata = parseUsbData(fullReadOutput.toString())
|
||||
Log.d("Result", data.toString())
|
||||
hemoCubeViewModel.progressBar.postValue(false)
|
||||
@@ -340,17 +366,17 @@ class HemoCubeFragment : Fragment() {
|
||||
if (stringData.contains("RESULT", true)) {
|
||||
// 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 deviceSerialNo = result[1]
|
||||
val led1Buffer = result[2].toDouble()
|
||||
val led2Buffer = result[3].toDouble()
|
||||
val led1Sample = result[4].toDouble()
|
||||
val led2Sample = result[5].toDouble()
|
||||
val led1Average = log10(led1Buffer / led1Sample)
|
||||
val led2Average = log10(led1Buffer / led1Sample)
|
||||
val led1Buffer = result[2].toDoubleOrNull()
|
||||
val led2Buffer = result[3].toDoubleOrNull()
|
||||
val led1Sample = result[4].toDoubleOrNull()
|
||||
val led2Sample = result[5].toDoubleOrNull()
|
||||
val led1Average = log10(led1Buffer?.div(led1Sample!!) ?: 0.0)
|
||||
val led2Average = log10(led2Buffer?.div(led2Sample!!) ?: 0.0)
|
||||
val deviceRatio = led1Average / led2Average
|
||||
DataHolder.hemoCubeTestData?.deviceSerialNumber = deviceSerialNo
|
||||
DataHolder.hemoCubeTestData?.led1Buffer = led1Buffer
|
||||
|
||||
Reference in New Issue
Block a user