diff --git a/app/src/main/java/com/example/hpos/data/constant/Constants.kt b/app/src/main/java/com/example/hpos/data/constant/Constants.kt index dd70cb8..f0ee6d6 100644 --- a/app/src/main/java/com/example/hpos/data/constant/Constants.kt +++ b/app/src/main/java/com/example/hpos/data/constant/Constants.kt @@ -5,6 +5,7 @@ object Constants { const val WRITE_TIMEOUT_MILLIS = 30000 // 30 sec const val READ_TIMEOUT_MILLIS = 60000 // 1 min + const val DELAY_BETWEEN_COMMANDS: Long = 1000 const val TEST_RIGHT_TOTAL_PIXEL = 3694 // const val TEST_RIGHT_TOTAL_PIXEL = 12 diff --git a/app/src/main/java/com/example/hpos/presentation/testRight/TestRightExpReference.kt b/app/src/main/java/com/example/hpos/presentation/testRight/TestRightExpReference.kt index 9a2713c..4bac324 100644 --- a/app/src/main/java/com/example/hpos/presentation/testRight/TestRightExpReference.kt +++ b/app/src/main/java/com/example/hpos/presentation/testRight/TestRightExpReference.kt @@ -12,6 +12,7 @@ import androidx.fragment.app.Fragment import androidx.fragment.app.activityViewModels import com.example.hpos.R import com.example.hpos.data.DataHolder +import com.example.hpos.data.constant.Constants import com.example.hpos.data.constant.TestRightCommands import com.example.hpos.databinding.FragmentTestRightExpReferenceBinding import com.example.hpos.presentation.UsbServiceListener @@ -46,7 +47,7 @@ class TestRightExpReference : Fragment() { if (DataHolder.deviceConstant == null) { viewModel.progressBar.postValue(true) - Handler(Looper.getMainLooper()).postDelayed({ sendCmdToFetchDeviceConstant() }, 1000) + Handler(Looper.getMainLooper()).postDelayed({ sendCmdToFetchDeviceConstant() }, Constants.DELAY_BETWEEN_COMMANDS) } } @@ -149,32 +150,22 @@ class TestRightExpReference : Fragment() { (activity as TestRightActivity).mService.eventDrivenWrite(TestRightCommands.led2Set50, object : UsbServiceListener { override fun onUsbRead(data: ByteArray?) { -// requireActivity().runOnUiThread { data?.let { val stringData = String(it) fullReadOutput.append(stringData) if (stringData.contains("OK", true)) { Log.d(TAG, "onUsbRead() called in sendCmdToSetLed()") -// viewModel.progressBar.postValue(false) -// requireActivity().runOnUiThread { -// Thread.sleep(2000) -// sendCmdToAutoset() -// } Handler(Looper.getMainLooper()).postDelayed( Runnable { viewModel.progressBar.postValue(false) sendCmdToAutoset() }, - 2000 + Constants.DELAY_BETWEEN_COMMANDS ) - - -// sendCmdToAutoset() } } -// } } override fun onUsbError(e: Exception?) { @@ -205,7 +196,7 @@ class TestRightExpReference : Fragment() { viewModel.progressBar.postValue(false) sendCmdToRun() }, - 2000 + Constants.DELAY_BETWEEN_COMMANDS ) } @@ -221,6 +212,7 @@ class TestRightExpReference : Fragment() { } private fun sendCmdToRun() { + Log.d(TAG, "sendCmdToRun() called") viewModel.progressBar.postValue(true) val fullReadOutput = StringBuilder() (activity as TestRightActivity).mService.eventDrivenWrite(TestRightCommands.run, @@ -241,7 +233,7 @@ class TestRightExpReference : Fragment() { viewModel.progressBar.postValue(false) sendCmdToFetchLightIntensities() }, - 2000 + Constants.DELAY_BETWEEN_COMMANDS ) } } @@ -256,6 +248,7 @@ class TestRightExpReference : Fragment() { } private fun sendCmdToFetchLightIntensities() { + Log.d(TAG, "sendCmdToFetchLightIntensities() called") viewModel.progressBar.postValue(true) val fullReadOutput = StringBuilder() (activity as TestRightActivity).mService.eventDrivenWrite(TestRightCommands.printAll, @@ -277,7 +270,7 @@ class TestRightExpReference : Fragment() { viewModel.progressBar.postValue(false) moveToSamplePage() }, - 2000 + Constants.DELAY_BETWEEN_COMMANDS ) } } @@ -312,7 +305,7 @@ class TestRightExpReference : Fragment() { // Runnable { // sendCmdToFetchDeviceConstant() // }, -// 2000 +// Constants.DELAY_BETWEEN_COMMANDS // ) // } // } @@ -366,7 +359,7 @@ class TestRightExpReference : Fragment() { // val handler = Handler() // handler.postDelayed(Runnable { // Do something after 5s = 5000ms // mService.read() -// }, 10000) +// }, Constants.DELAY_BETWEEN_COMMANDS) // // } } \ No newline at end of file diff --git a/app/src/main/java/com/example/hpos/presentation/testRight/TestRightExpSample.kt b/app/src/main/java/com/example/hpos/presentation/testRight/TestRightExpSample.kt index 5830e0a..1214b38 100644 --- a/app/src/main/java/com/example/hpos/presentation/testRight/TestRightExpSample.kt +++ b/app/src/main/java/com/example/hpos/presentation/testRight/TestRightExpSample.kt @@ -10,6 +10,7 @@ import android.view.ViewGroup import androidx.fragment.app.Fragment import androidx.fragment.app.activityViewModels import com.example.hpos.R +import com.example.hpos.data.constant.Constants import com.example.hpos.data.constant.TestRightCommands import com.example.hpos.data.model.PatientData import com.example.hpos.data.model.TestRightResultType @@ -121,7 +122,7 @@ class TestRightExpSample : Fragment() { viewModel.progressBar.postValue(false) sendCmdToFetchLightIntensities() }, - 2000 + Constants.DELAY_BETWEEN_COMMANDS ) }