new arduino code Result work for molbio is pending
This commit is contained in:
@@ -56,7 +56,7 @@ class HemoCubeFragment : Fragment() {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
initViews()
|
||||
observeViewModel()
|
||||
checkAndStartProcess()
|
||||
// checkAndStartProcess()
|
||||
}
|
||||
|
||||
private fun initViews() {
|
||||
@@ -85,6 +85,29 @@ class HemoCubeFragment : Fragment() {
|
||||
|
||||
binding.tvName.text = "Name: ${testDetails?.name}\n ID: ${testDetails?._id}"
|
||||
Log.e("nametext", binding.tvName.text.toString())
|
||||
|
||||
|
||||
binding.btnSamplestart.setOnClickListener {
|
||||
activity?.runOnUiThread {
|
||||
binding.tvSubtitle4.visibility = View.VISIBLE
|
||||
binding.tvSubtitle4.text = "Place Sample"
|
||||
}
|
||||
if(binding.tvSubtitle4.text.toString().contains("Place Sample") ){
|
||||
startSampleProcess()
|
||||
it.visibility = View.GONE
|
||||
}
|
||||
}
|
||||
|
||||
binding.btnPlacebuffer.setOnClickListener {
|
||||
activity?.runOnUiThread {
|
||||
binding.tvSubtitle4.visibility = View.VISIBLE
|
||||
binding.tvSubtitle4.text = "Place Buffer"
|
||||
}
|
||||
checkAndStartProcess()
|
||||
it.visibility = View.GONE
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private fun observeViewModel() {
|
||||
@@ -150,12 +173,8 @@ class HemoCubeFragment : Fragment() {
|
||||
}
|
||||
|
||||
private fun checkAndStartProcess() {
|
||||
if (isBufferValueAvailable()) {
|
||||
showBufferAlertDialog()
|
||||
} else {
|
||||
listenToHemoCube()
|
||||
startBufferProcess()
|
||||
}
|
||||
listenToHemoCube()
|
||||
startBufferProcess()
|
||||
}
|
||||
|
||||
private fun isBufferValueAvailable(): Boolean {
|
||||
@@ -226,42 +245,6 @@ class HemoCubeFragment : Fragment() {
|
||||
}
|
||||
}
|
||||
|
||||
// private fun handleUsbData(stringData: String, fullReadOutput: StringBuilder) {
|
||||
// if (stringData.contains("#")) {
|
||||
// hemoCubeViewModel.messages.postValue(stringData)
|
||||
// isTestOngoing = true
|
||||
// }
|
||||
//
|
||||
// resultData += stringData
|
||||
//
|
||||
// when {
|
||||
// stringData.contains("#Buffer Completed") -> showStartSampleDialog()
|
||||
// stringData.contains("#Sample Completed") -> {
|
||||
// fetchResult()
|
||||
// testingTrace.stop()
|
||||
// }
|
||||
//
|
||||
// stringData.contains("RESULT") || resultData.contains("REND") -> {
|
||||
// var validString: String
|
||||
// val results: List<String>
|
||||
// if (stringData.contains("RESULT")) {
|
||||
// validString = isValidResult(stringData)
|
||||
// if (validString.isEmpty()) {
|
||||
// results = resultData.split("\n")
|
||||
// validString = parseResult(results)
|
||||
// }
|
||||
// } else {
|
||||
// results = resultData.split("\n")
|
||||
// validString = parseResult(results)
|
||||
// }
|
||||
// if (validString.isNotEmpty()) {
|
||||
// handleValidResult(validString, resultData)
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
private fun handleUsbData(stringData: String, fullReadOutput: StringBuilder) {
|
||||
if (stringData.contains("#")) {
|
||||
hemoCubeViewModel.messages.postValue(stringData)
|
||||
@@ -269,10 +252,15 @@ class HemoCubeFragment : Fragment() {
|
||||
}
|
||||
|
||||
resultData += stringData
|
||||
Log.e("nametext", stringData)
|
||||
|
||||
when {
|
||||
stringData.contains("#Buffer Completed") -> showStartSampleDialog()
|
||||
stringData.contains("#Sample Completed") -> {
|
||||
stringData.contains("#BC") -> {
|
||||
activity?.runOnUiThread {
|
||||
binding.btnSamplestart.visibility = View.VISIBLE
|
||||
}
|
||||
}
|
||||
stringData.contains("#SC") -> {
|
||||
fetchResult()
|
||||
testingTrace.stop()
|
||||
}
|
||||
@@ -291,16 +279,7 @@ class HemoCubeFragment : Fragment() {
|
||||
validString = parseResult(results)
|
||||
}
|
||||
if (validString.isNotEmpty()) {
|
||||
// Extract labels and corresponding values
|
||||
val resultLines = validString.split("\n")
|
||||
val formattedResult = StringBuilder()
|
||||
for (line in resultLines) {
|
||||
val parts = line.split(" ")
|
||||
if (parts.size == 2) {
|
||||
formattedResult.append("${parts[0]}\n${parts[1]}\n")
|
||||
}
|
||||
}
|
||||
handleValidResult(formattedResult.toString().trim(), resultData)
|
||||
handleValidResult(validString, resultData)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -310,7 +289,13 @@ class HemoCubeFragment : Fragment() {
|
||||
|
||||
|
||||
|
||||
|
||||
private fun isValidResult(line: String): String {
|
||||
return if (line.contains("RESULT") && line.split(" ").size == 8) {
|
||||
line
|
||||
} else {
|
||||
""
|
||||
}
|
||||
}
|
||||
|
||||
private fun showError() {
|
||||
activity?.runOnUiThread {
|
||||
@@ -361,37 +346,40 @@ class HemoCubeFragment : Fragment() {
|
||||
|
||||
private fun handleValidResult(validString: String, fullReadOutput: String) {
|
||||
try {
|
||||
val result = validString.split(" ")
|
||||
val deviceLog = resultData
|
||||
if (result.size == 8) {
|
||||
val deviceSerialNo = result[2]
|
||||
with(sharedPreferences.edit()) {
|
||||
putString(Constants.DEVICE_ID, deviceSerialNo)
|
||||
apply()
|
||||
}
|
||||
val loginId = sharedPreferences.getString(Constants.USER_ID, "").toString()
|
||||
if (checkDeviceIdMismatch(deviceSerialNo, loginId)) {
|
||||
activity?.runOnUiThread {
|
||||
binding.errorMessage.text = "Warning: Login Id is different"
|
||||
binding.errorMessage.visibility = View.VISIBLE
|
||||
}
|
||||
}
|
||||
val led1BufferForDevice = if (isUsingExistingBuffer) {
|
||||
sharedPreferences.getString(Constants.BUFFER_VALUE_1, "")?.toDoubleOrNull()
|
||||
} else {
|
||||
result[3].toDoubleOrNull()
|
||||
}
|
||||
val led2BufferForDevice = if (isUsingExistingBuffer) {
|
||||
sharedPreferences.getString(Constants.BUFFER_VALUE_2, "")?.toDoubleOrNull()
|
||||
} else {
|
||||
result[4].toDoubleOrNull()
|
||||
}
|
||||
val resultLines = validString.split("\n")
|
||||
if (resultLines.size == 9) {
|
||||
val deviceLog = fullReadOutput
|
||||
val led1BufferForDevice = resultLines.find { it.startsWith("LB1") }?.substring(4)
|
||||
?.toDoubleOrNull()
|
||||
?: 0.0
|
||||
val led2BufferForDevice = 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 pInfo = requireActivity().packageManager.getPackageInfo(
|
||||
requireActivity().packageName, 0
|
||||
)
|
||||
val version = pInfo.versionName
|
||||
val led1Sample = result[5].toDoubleOrNull()
|
||||
val led2Sample = result[6].toDoubleOrNull()
|
||||
|
||||
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 led1Average = log10(led1BufferForDevice?.div(led1Sample!!) ?: 0.0)
|
||||
val led2Average = log10(led2BufferForDevice?.div(led2Sample!!) ?: 0.0)
|
||||
val deviceRatio = led1Average / led2Average
|
||||
@@ -413,7 +401,7 @@ class HemoCubeFragment : Fragment() {
|
||||
}
|
||||
|
||||
DataHolder.hemoCubeTestData?.apply {
|
||||
deviceId = deviceSerialNo
|
||||
// deviceId = deviceSerialNo
|
||||
led1Buffer = led1BufferForDevice
|
||||
led2Buffer = led2BufferForDevice
|
||||
appVersion = version
|
||||
@@ -545,13 +533,7 @@ class HemoCubeFragment : Fragment() {
|
||||
return ""
|
||||
}
|
||||
|
||||
private fun isValidResult(line: String): String {
|
||||
return if (line.contains("RESULT") && line.split(" ").size == 8) {
|
||||
line
|
||||
} else {
|
||||
""
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private fun checkDeviceIdMismatch(deviceId: String, loginId: String): Boolean {
|
||||
if (!deviceId.isNullOrEmpty() && !loginId.isNullOrEmpty() && deviceId.last() != loginId.last())
|
||||
|
||||
@@ -147,8 +147,35 @@
|
||||
app:layout_constraintHorizontal_bias="1.0"
|
||||
app:layout_constraintStart_toEndOf="@id/et_abha_id"
|
||||
app:layout_constraintTop_toTopOf="@id/et_abha_id" />
|
||||
<Button
|
||||
android:visibility="gone"
|
||||
android:id="@+id/btn_samplestart"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginHorizontal="16dp"
|
||||
android:layout_marginTop="24dp"
|
||||
android:clickable="false"
|
||||
android:text="@string/Start_Sample"
|
||||
android:textColor="@color/white"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/btn_placebuffer" />
|
||||
|
||||
|
||||
|
||||
<Button
|
||||
android:id="@+id/btn_placebuffer"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginHorizontal="16dp"
|
||||
android:layout_marginTop="24dp"
|
||||
android:clickable="false"
|
||||
android:text="@string/place_buffer"
|
||||
android:textColor="@color/white"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/btn_submit" />
|
||||
|
||||
<Button
|
||||
android:visibility="gone"
|
||||
android:id="@+id/btn_submit"
|
||||
@@ -178,61 +205,6 @@
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/btn_submit" />
|
||||
|
||||
<!-- <com.google.android.material.textfield.TextInputLayout-->
|
||||
<!-- android:id="@+id/til_blood_group"-->
|
||||
<!-- style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.ExposedDropdownMenu"-->
|
||||
<!-- android:layout_width="match_parent"-->
|
||||
<!-- android:layout_height="wrap_content"-->
|
||||
<!-- android:layout_marginHorizontal="24dp"-->
|
||||
<!-- android:layout_marginTop="16dp"-->
|
||||
<!-- app:layout_constraintEnd_toEndOf="parent"-->
|
||||
<!-- app:layout_constraintStart_toStartOf="parent"-->
|
||||
<!-- app:layout_constraintTop_toBottomOf="@id/tv_subtitle4">-->
|
||||
|
||||
<!-- <AutoCompleteTextView-->
|
||||
<!-- android:id="@+id/et_blood_group"-->
|
||||
<!-- android:layout_width="match_parent"-->
|
||||
<!-- android:layout_height="wrap_content"-->
|
||||
<!-- android:hint="@string/select_blood_group"-->
|
||||
<!-- android:inputType="none"-->
|
||||
<!-- android:labelFor="@id/til_blood_group"-->
|
||||
<!-- app:simpleItems="@array/blood_group" />-->
|
||||
|
||||
<!-- </com.google.android.material.textfield.TextInputLayout>-->
|
||||
|
||||
<!-- <Button-->
|
||||
<!-- android:id="@+id/btn_kit"-->
|
||||
<!-- android:layout_width="wrap_content"-->
|
||||
<!-- android:layout_height="wrap_content"-->
|
||||
<!-- android:layout_margin="10dp"-->
|
||||
<!-- android:text="@string/new_kit"-->
|
||||
<!-- android:textColor="@color/white"-->
|
||||
<!-- app:layout_constraintBottom_toBottomOf="parent"-->
|
||||
<!-- app:layout_constraintEnd_toEndOf="parent"-->
|
||||
<!-- app:layout_constraintStart_toStartOf="parent" />-->
|
||||
|
||||
<!-- <Button-->
|
||||
<!-- android:id="@+id/btn_buffer"-->
|
||||
<!-- android:layout_width="wrap_content"-->
|
||||
<!-- android:layout_height="wrap_content"-->
|
||||
<!-- android:text="@string/new_buffer"-->
|
||||
<!-- android:textColor="@color/white"-->
|
||||
<!-- android:layout_margin="10dp"-->
|
||||
<!-- app:layout_constraintBottom_toBottomOf="parent"-->
|
||||
<!-- app:layout_constraintStart_toStartOf="parent"-->
|
||||
<!-- app:layout_constraintEnd_toStartOf="@id/btn_kit"/>-->
|
||||
|
||||
<!-- <Button-->
|
||||
<!-- android:id="@+id/btn_read"-->
|
||||
<!-- android:layout_width="wrap_content"-->
|
||||
<!-- android:layout_height="wrap_content"-->
|
||||
<!-- android:text="@string/read"-->
|
||||
<!-- android:layout_margin="16dp"-->
|
||||
<!-- android:clickable="false"-->
|
||||
<!-- app:layout_constraintTop_toBottomOf="@id/btn_set_reference"-->
|
||||
<!-- app:layout_constraintStart_toStartOf="parent" />-->
|
||||
|
||||
<!-- </androidx.constraintlayout.widget.ConstraintLayout>-->
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/progressBar"
|
||||
|
||||
Reference in New Issue
Block a user