This commit is contained in:
smileomi18@gmail.com
2023-07-19 16:28:31 +05:30
committed by mohamedkaif356
parent ed567f6545
commit a28e4634e0

View File

@@ -52,6 +52,10 @@ class TestRightExpReference : Fragment() {
Log.e("mariya", "onViewCreated 1")
if (DataHolder.deviceType.equals(Constants.DEVICE_TYPE_HOMOCUBE) ) {
Log.e("mariya", "onViewCreated if")
fetchHemoCubeResult()
Log.e("mariya", "onViewCreated 1")
if (DataHolder.deviceType.equals(Constants.DEVICE_TYPE_HOMOCUBE) ) {
Log.e("mariya", "onViewCreated if")
// fetchHemoCubeResult()
}
// if (DataHolder.deviceConstant == null) {
@@ -118,6 +122,50 @@ class TestRightExpReference : Fragment() {
// }
}
// private fun sendCmdToFetchDeviceConstant(recursive: Boolean) {
private fun fetchHemoCubeResult() {
Log.d("mariya", "fetchHemoCubeResult() called")
viewModel.progressBar.postValue(true)
val fullReadOutput = StringBuilder()
(activity as TestRightActivity).mService.eventDrivenWrite(TestRightCommands.read,
object : UsbServiceListener {
override fun onUsbRead(data: ByteArray?) {
Log.d("mariya", data.toString())
data?.let {
val stringData = String(it)
fullReadOutput.append(stringData)
Log.d(TAG, "fullReadOutput = $fullReadOutput")
if (stringData.contains("OK", true)) {
Log.d(
TAG,
"onUsbRead() called in sendCmdToFetchDeviceConstant() found OK"
)
viewModel.mapDeviceConstants(fullReadOutput.toString())
viewModel.progressBar.postValue(false)
} else if (stringData.contains("FINE", true)) {
Log.d(TAG, "results = FINE")
viewModel.progressBar.postValue(false)
viewModel.errorTriggered.postValue(ErrorMessage("Please Try Again!!", Constants.ERROR_CRITICAL))
}
}
}
override fun onUsbError(e: Exception?) {
Log.e(TAG, "onUsbIoError() called in sendCmdToFetchDeviceConstant() -> $e")
viewModel.errorTriggered.postValue(ErrorMessage("Please Try Again this step", Constants.ERROR_NORMAL))
viewModel.progressBar.postValue(false)
}
})
}
// private fun sendCmdToFetchDeviceConstant(recursive: Boolean) {
private fun sendCmdToFetchDeviceConstant() {
Log.d(TAG, "sendCmdToFetchDeviceConstant() called")