fix sample name and device id empty

This commit is contained in:
Pritimay Sarkar
2024-01-25 12:15:41 +05:30
parent 2c21a29d22
commit 97ec931814

View File

@@ -317,9 +317,7 @@ class HemoCubeFragment : Fragment() {
} }
private fun listenToHemoCube() { private fun listenToHemoCube() {
if (DataHolder.hemoCubeTestData == null) { DataHolder.hemoCubeTestData = DataHolder.selectedTest?.toHemoCubeTestData()
DataHolder.hemoCubeTestData = DataHolder.selectedTest?.toHemoCubeTestData()
}
hemoCubeViewModel.progressBar.postValue(true) hemoCubeViewModel.progressBar.postValue(true)
val fullReadOutput = StringBuilder() val fullReadOutput = StringBuilder()
@@ -584,7 +582,7 @@ class HemoCubeFragment : Fragment() {
} }
if (!Constants.DEVICE_CONFIGURATION.containsKey(deviceHardwareId)) { if (!Constants.DEVICE_CONFIGURATION.containsKey(deviceHardwareId)) {
assignDefaultDevice() assignDefaultDevice(resultData)
allErrorMessages += "Calibration configuration for this device id is not found\n" allErrorMessages += "Calibration configuration for this device id is not found\n"
} }
if (!Constants.BUFFER_INTENSITY_THRESHOLDS.containsKey(deviceHardwareId)) { if (!Constants.BUFFER_INTENSITY_THRESHOLDS.containsKey(deviceHardwareId)) {
@@ -592,8 +590,12 @@ class HemoCubeFragment : Fragment() {
} }
} }
fun assignDefaultDevice() { fun assignDefaultDevice(configData: String) {
deviceHardwareId = "HCV-000-3001" deviceHardwareId = "HCV-000-3001"
with(sharedPreferences.edit()) {
putString(Constants.DEVICE_ID, configData)
apply()
}
testStatusCode = TestStatus.CONFIG_COMPLETED.code testStatusCode = TestStatus.CONFIG_COMPLETED.code
activity?.runOnUiThread { activity?.runOnUiThread {
binding.btnPlacebuffer.visibility = View.VISIBLE binding.btnPlacebuffer.visibility = View.VISIBLE
@@ -602,7 +604,7 @@ class HemoCubeFragment : Fragment() {
} }
fun extractMiddleString(input: String): String? { fun extractMiddleString(input: String): String? {
val pattern = Regex("SNS\\s(.*?)\\sSNE") val pattern = Regex("SNS\\s*(.*?)\\s*SNE")
val matchResult: MatchResult? = pattern.find(input) val matchResult: MatchResult? = pattern.find(input)
return matchResult?.groups?.get(1)?.value return matchResult?.groups?.get(1)?.value