From 3e0523e163f95ada1038f9788b7f9e76ed75854d Mon Sep 17 00:00:00 2001 From: Pritimay Sarkar Date: Sun, 4 Feb 2024 14:59:07 +0530 Subject: [PATCH] refactor kit scan --- .../presentation/KitScanActivity.kt | 30 ------------------- .../presentation/trueheme/TrueHemeFragment.kt | 4 +++ 2 files changed, 4 insertions(+), 30 deletions(-) diff --git a/app/src/main/java/com/example/hpostesting/presentation/KitScanActivity.kt b/app/src/main/java/com/example/hpostesting/presentation/KitScanActivity.kt index bfbbb99..cb9eb40 100644 --- a/app/src/main/java/com/example/hpostesting/presentation/KitScanActivity.kt +++ b/app/src/main/java/com/example/hpostesting/presentation/KitScanActivity.kt @@ -208,51 +208,21 @@ class KitScanActivity : AppCompatActivity(), IDcsSdkApiDelegate { } } - //Setting up the SDK handler - //Setting up the SDK handler sdkHandler = SDKHandler(this) - - //Registers a particular object which conforms to IDcsSdkApiDelegate interface as a receiver of SDK notifications. - //Registers a particular object which conforms to IDcsSdkApiDelegate interface as a receiver of SDK notifications. sdkHandler!!.dcssdkSetDelegate(this) - - //this command is telling the sdk that we're going to be connecting to the scanner via USB - //this command is telling the sdk that we're going to be connecting to the scanner via USB sdkHandler!!.dcssdkSetOperationalMode(DCSSDKDefs.DCSSDK_MODE.DCSSDK_OPMODE_SNAPI) - - //deciding what kind of notifications we want to receive. Explained more in the function - //first we use bitmapping to set these values into the notifications_mask. - - //deciding what kind of notifications we want to receive. Explained more in the function //first we use bitmapping to set these values into the notifications_mask. var notifications_mask = 0 // We would like to subscribe to all barcode events - // We would like to subscribe to all barcode events notifications_mask = notifications_mask or DCSSDKDefs.DCSSDK_EVENT.DCSSDK_EVENT_BARCODE.value - // subscribe to events set in notification mask - // subscribe to events set in notification mask sdkHandler!!.dcssdkSubsribeForEvents(notifications_mask) - - - //so adding all the scanners to the mScannerInfoList, then connecting to the first scanner. - //There's only one scanner so this step is unnecessary, I did it thinking about possible scalability. - //here I just get the list of available scanners which also returns the USB scanner attached to the tinker board. - - - //so adding all the scanners to the mScannerInfoList, then connecting to the first scanner. - //There's only one scanner so this step is unnecessary, I did it thinking about possible scalability. - //here I just get the list of available scanners which also returns the USB scanner attached to the tinker board. mScannerInfoList.addAll(sdkHandler!!.dcssdkGetAvailableScannersList()) - - //I'm doing mScannerInfoList.get(0) because there's only one scanner which will be at position 0. - - //I'm doing mScannerInfoList.get(0) because there's only one scanner which will be at position 0. sdkHandler!!.dcssdkEstablishCommunicationSession(mScannerInfoList[0].scannerID) } diff --git a/app/src/main/java/com/example/hpostesting/presentation/trueheme/TrueHemeFragment.kt b/app/src/main/java/com/example/hpostesting/presentation/trueheme/TrueHemeFragment.kt index d1a4bf8..de000f5 100644 --- a/app/src/main/java/com/example/hpostesting/presentation/trueheme/TrueHemeFragment.kt +++ b/app/src/main/java/com/example/hpostesting/presentation/trueheme/TrueHemeFragment.kt @@ -1143,4 +1143,8 @@ class TrueHemeFragment : Fragment() { val coefficient2 = currentDeviceData?.coefficients?.get(1) ?: 0.0 return coefficient1 * ratio + coefficient2 } + + private fun reconnect() { + (activity as HemocubeActivity).reconnectDevice() + } } \ No newline at end of file