add EPROM retrival
This commit is contained in:
@@ -9,6 +9,7 @@ enum class HemoCubeCommands(val command: String) {
|
|||||||
PRINT_COMMAND("P\r"),
|
PRINT_COMMAND("P\r"),
|
||||||
READ_DAC_COMMAND("R\r"),
|
READ_DAC_COMMAND("R\r"),
|
||||||
DEVICE_CONFIGURATION_COMMAND("I\r"),
|
DEVICE_CONFIGURATION_COMMAND("I\r"),
|
||||||
|
LOAD_DAC_VALUES("E\r"),
|
||||||
FIRST_GAIN_COMMAND("T\r"),
|
FIRST_GAIN_COMMAND("T\r"),
|
||||||
SECOND_GAIN_COMMAND("U\r"),
|
SECOND_GAIN_COMMAND("U\r"),
|
||||||
THIRD_GAIN_COMMAND("V\r"),
|
THIRD_GAIN_COMMAND("V\r"),
|
||||||
|
|||||||
@@ -8,6 +8,8 @@ enum class TestStatus(val code: Double) {
|
|||||||
FIRST_EMPTY_AIR_READING_COMPLETED(4.2),
|
FIRST_EMPTY_AIR_READING_COMPLETED(4.2),
|
||||||
FIRST_EMPTY_AIR_READING_PRINT_STARTED(4.3),
|
FIRST_EMPTY_AIR_READING_PRINT_STARTED(4.3),
|
||||||
FIRST_EMPTY_AIR_READING_PRINT_COMPLETED(4.4),
|
FIRST_EMPTY_AIR_READING_PRINT_COMPLETED(4.4),
|
||||||
|
EPROM_ADC_RETRIEVAL_STARTED(4.5),
|
||||||
|
EPROM_ADC_RETRIEVAL_COMPLETED(4.6),
|
||||||
BUFFER_STARTED(4.0),
|
BUFFER_STARTED(4.0),
|
||||||
BUFFER_COMPLETED(5.0),
|
BUFFER_COMPLETED(5.0),
|
||||||
BUFFER_PRINT_STARTED(6.0),
|
BUFFER_PRINT_STARTED(6.0),
|
||||||
|
|||||||
@@ -45,7 +45,6 @@ data class PatientDetails(
|
|||||||
OTHER
|
OTHER
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
data class Address(
|
data class Address(
|
||||||
var house: String?,
|
var house: String?,
|
||||||
val street: String?,
|
val street: String?,
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ import javax.inject.Named
|
|||||||
class NetworkException(message: String, cause: Throwable) : Exception(message, cause)
|
class NetworkException(message: String, cause: Throwable) : Exception(message, cause)
|
||||||
class DatabaseRepository @Inject constructor(
|
class DatabaseRepository @Inject constructor(
|
||||||
@Named("Auth") private val molbioAuthApi: MolbioAuthApi,
|
@Named("Auth") private val molbioAuthApi: MolbioAuthApi,
|
||||||
private val molbioResultApi: MolbioResultApi
|
private val molbioResultApi: MolbioResultApi,
|
||||||
) : Repository {
|
) : Repository {
|
||||||
|
|
||||||
private val db: FirebaseFirestore = Firebase.firestore
|
private val db: FirebaseFirestore = Firebase.firestore
|
||||||
@@ -81,6 +81,7 @@ class DatabaseRepository @Inject constructor(
|
|||||||
override suspend fun downloadClientCertificate(): Result<ResponseBody> {
|
override suspend fun downloadClientCertificate(): Result<ResponseBody> {
|
||||||
return safeApiCall { molbioResultApi.downloadClientCertificate() }
|
return safeApiCall { molbioResultApi.downloadClientCertificate() }
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun uploadLogs(logFile: MultipartBody.Part): Result<UploadLogsResponse> {
|
override suspend fun uploadLogs(logFile: MultipartBody.Part): Result<UploadLogsResponse> {
|
||||||
return safeApiCall { molbioResultApi.uploadLogs(logFile) }
|
return safeApiCall { molbioResultApi.uploadLogs(logFile) }
|
||||||
}
|
}
|
||||||
@@ -149,7 +150,7 @@ class DatabaseRepository @Inject constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun uploadFileToStorage(
|
override suspend fun uploadFileToStorage(
|
||||||
patientID: String, filePath: String
|
patientID: String, filePath: String,
|
||||||
): Response<Boolean> {
|
): Response<Boolean> {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
@@ -240,5 +241,4 @@ class DatabaseRepository @Inject constructor(
|
|||||||
override fun <UserData> addTestToDatabase(testDetails: UserData): Any {
|
override fun <UserData> addTestToDatabase(testDetails: UserData): Any {
|
||||||
TODO("Not yet implemented")
|
TODO("Not yet implemented")
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -119,7 +119,6 @@ class KitScanActivity : AppCompatActivity(), IDcsSdkApiDelegate {
|
|||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (checkHemoCubeKitData()) {
|
if (checkHemoCubeKitData()) {
|
||||||
DataHolder.selectedTest!!.kitSerial =
|
DataHolder.selectedTest!!.kitSerial =
|
||||||
@@ -156,7 +155,6 @@ class KitScanActivity : AppCompatActivity(), IDcsSdkApiDelegate {
|
|||||||
pullTrigger()
|
pullTrigger()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
binding.btnGo.setOnClickListener {
|
binding.btnGo.setOnClickListener {
|
||||||
val serialNumber = binding.nameEditText.text.toString().trim()
|
val serialNumber = binding.nameEditText.text.toString().trim()
|
||||||
if (serialNumber.isNotEmpty() && isSerialValid(serialNumber)) {
|
if (serialNumber.isNotEmpty() && isSerialValid(serialNumber)) {
|
||||||
@@ -258,7 +256,6 @@ class KitScanActivity : AppCompatActivity(), IDcsSdkApiDelegate {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//this function is called if barcode is detected.
|
//this function is called if barcode is detected.
|
||||||
override fun dcssdkEventBarcode(barcodeData: ByteArray?, barcodeType: Int, fromScannerID: Int) {
|
override fun dcssdkEventBarcode(barcodeData: ByteArray?, barcodeType: Int, fromScannerID: Int) {
|
||||||
val result = String(barcodeData!!)
|
val result = String(barcodeData!!)
|
||||||
|
|||||||
@@ -163,13 +163,11 @@ class CalibrationActivity : AppCompatActivity() {
|
|||||||
manager.requestPermission(device, mPendingIntent)
|
manager.requestPermission(device, mPendingIntent)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fun setupService() {
|
fun setupService() {
|
||||||
val intent = Intent(this, UsbService::class.java)
|
val intent = Intent(this, UsbService::class.java)
|
||||||
bindService(intent, connection, Context.BIND_AUTO_CREATE)
|
bindService(intent, connection, Context.BIND_AUTO_CREATE)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
override fun onCreateOptionsMenu(menu: Menu?): Boolean {
|
override fun onCreateOptionsMenu(menu: Menu?): Boolean {
|
||||||
menuInflater.inflate(R.menu.my_menu, menu)
|
menuInflater.inflate(R.menu.my_menu, menu)
|
||||||
return true
|
return true
|
||||||
|
|||||||
@@ -50,7 +50,6 @@ class CalibrationFragment : Fragment() {
|
|||||||
loadSavedCalibration()
|
loadSavedCalibration()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private fun initViews() {
|
private fun initViews() {
|
||||||
binding.btnSubmit.visibility = View.GONE
|
binding.btnSubmit.visibility = View.GONE
|
||||||
listenToHemoCube()
|
listenToHemoCube()
|
||||||
|
|||||||
@@ -356,12 +356,22 @@ class HomeFragment : Fragment() {
|
|||||||
val fileName = "nats_certificate.zip"
|
val fileName = "nats_certificate.zip"
|
||||||
val downloadDirectory = "NATS"
|
val downloadDirectory = "NATS"
|
||||||
val file = downloadFile(url, requireContext(), fileName, downloadDirectory)
|
val file = downloadFile(url, requireContext(), fileName, downloadDirectory)
|
||||||
Toast.makeText(requireContext(), "NATS certificate Downloaded", Toast.LENGTH_SHORT).show()
|
Toast.makeText(
|
||||||
|
requireContext(),
|
||||||
|
"NATS certificate Downloaded",
|
||||||
|
Toast.LENGTH_SHORT
|
||||||
|
).show()
|
||||||
|
|
||||||
val unzipDirectoryPath = requireContext().getExternalFilesDir(null)?.absolutePath + "/$downloadDirectory"
|
val unzipDirectoryPath =
|
||||||
|
requireContext().getExternalFilesDir(null)?.absolutePath + "/$downloadDirectory"
|
||||||
unzip(file.absolutePath, unzipDirectoryPath)
|
unzip(file.absolutePath, unzipDirectoryPath)
|
||||||
Toast.makeText(requireContext(), "NATS certificate Extracted", Toast.LENGTH_SHORT).show()
|
Toast.makeText(
|
||||||
|
requireContext(),
|
||||||
|
"NATS certificate Extracted",
|
||||||
|
Toast.LENGTH_SHORT
|
||||||
|
).show()
|
||||||
}
|
}
|
||||||
|
|
||||||
is Result.Error -> {
|
is Result.Error -> {
|
||||||
response.exception.let { message ->
|
response.exception.let { message ->
|
||||||
Toast.makeText(
|
Toast.makeText(
|
||||||
@@ -459,7 +469,12 @@ class HomeFragment : Fragment() {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun downloadFile(responseBody: ResponseBody, context: Context, fileName: String, downloadDirectory: String): File {
|
private fun downloadFile(
|
||||||
|
responseBody: ResponseBody,
|
||||||
|
context: Context,
|
||||||
|
fileName: String,
|
||||||
|
downloadDirectory: String,
|
||||||
|
): File {
|
||||||
// Ensure the download directory exists
|
// Ensure the download directory exists
|
||||||
val fileDir = File(context.getExternalFilesDir(null), downloadDirectory)
|
val fileDir = File(context.getExternalFilesDir(null), downloadDirectory)
|
||||||
if (!fileDir.exists()) {
|
if (!fileDir.exists()) {
|
||||||
@@ -480,8 +495,6 @@ class HomeFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private fun unzip(zipFilePath: String, destDirectory: String) {
|
private fun unzip(zipFilePath: String, destDirectory: String) {
|
||||||
val destDir = File(destDirectory)
|
val destDir = File(destDirectory)
|
||||||
if (!destDir.exists()) {
|
if (!destDir.exists()) {
|
||||||
@@ -542,7 +555,8 @@ class HomeFragment : Fragment() {
|
|||||||
try {
|
try {
|
||||||
val db = Firebase.firestore
|
val db = Firebase.firestore
|
||||||
// Ensure deviceId is not null or empty
|
// Ensure deviceId is not null or empty
|
||||||
val deviceId = sharedPreference.getString(Constants.DEVICE_ID, "").takeIf { it!!.isNotBlank() }
|
val deviceId =
|
||||||
|
sharedPreference.getString(Constants.DEVICE_ID, "").takeIf { it!!.isNotBlank() }
|
||||||
?: throw IllegalStateException("Device ID is missing or blank.")
|
?: throw IllegalStateException("Device ID is missing or blank.")
|
||||||
|
|
||||||
val deviceRef = db.collection("devices").whereEqualTo("deviceId", deviceId)
|
val deviceRef = db.collection("devices").whereEqualTo("deviceId", deviceId)
|
||||||
@@ -550,13 +564,17 @@ class HomeFragment : Fragment() {
|
|||||||
deviceRef.get()
|
deviceRef.get()
|
||||||
.addOnSuccessListener { documentSnapshot ->
|
.addOnSuccessListener { documentSnapshot ->
|
||||||
if (!documentSnapshot.isEmpty) {
|
if (!documentSnapshot.isEmpty) {
|
||||||
val deviceData = documentSnapshot.documents[0].toObject(DeviceData::class.java)
|
val deviceData =
|
||||||
|
documentSnapshot.documents[0].toObject(DeviceData::class.java)
|
||||||
deviceData?.let { data ->
|
deviceData?.let { data ->
|
||||||
val username = data.username
|
val username = data.username
|
||||||
val password = data.password
|
val password = data.password
|
||||||
val natsToken = data.natsToken
|
val natsToken = data.natsToken
|
||||||
// Log for debugging
|
// Log for debugging
|
||||||
Log.d("fetchDeviceCredentials", "Username: $username, Password: $password")
|
Log.d(
|
||||||
|
"fetchDeviceCredentials",
|
||||||
|
"Username: $username, Password: $password"
|
||||||
|
)
|
||||||
// Save credentials in SharedPreferences
|
// Save credentials in SharedPreferences
|
||||||
with(sharedPreference.edit()) {
|
with(sharedPreference.edit()) {
|
||||||
putString("username", username)
|
putString("username", username)
|
||||||
|
|||||||
@@ -127,7 +127,6 @@ class DiagnosticsActivity : AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fun onErrorReported(msg: String) {
|
fun onErrorReported(msg: String) {
|
||||||
Toast.makeText(this, msg, Toast.LENGTH_SHORT).show()
|
Toast.makeText(this, msg, Toast.LENGTH_SHORT).show()
|
||||||
if (!isFinishing) onBackPressed()
|
if (!isFinishing) onBackPressed()
|
||||||
|
|||||||
@@ -61,7 +61,6 @@ class DigitalCardFragment : Fragment() {
|
|||||||
binding.blood.text = "Blood Group: ${testDetails?.bloodGroup}"
|
binding.blood.text = "Blood Group: ${testDetails?.bloodGroup}"
|
||||||
binding.sicklecell.text =
|
binding.sicklecell.text =
|
||||||
"Sickle-Cell: ${DataHolder.hemoCubeTestData?.prdClassification.toString()}"
|
"Sickle-Cell: ${DataHolder.hemoCubeTestData?.prdClassification.toString()}"
|
||||||
|
|
||||||
}
|
}
|
||||||
// Update the UI with the fetched details
|
// Update the UI with the fetched details
|
||||||
val originalDateFormat = SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault())
|
val originalDateFormat = SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault())
|
||||||
|
|||||||
@@ -134,7 +134,6 @@ class HemoCubeFragment : Fragment() {
|
|||||||
checkAndStartProcess()
|
checkAndStartProcess()
|
||||||
it.visibility = View.GONE
|
it.visibility = View.GONE
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sharedPreferences.getString(Constants.USER_ID, "").toString() == "ADMIN") {
|
if (sharedPreferences.getString(Constants.USER_ID, "").toString() == "ADMIN") {
|
||||||
@@ -361,6 +360,20 @@ class HemoCubeFragment : Fragment() {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun loadDACValues() {
|
||||||
|
hemoCubeViewModel.progressBar.postValue(true)
|
||||||
|
(activity as HemocubeActivity).mService.sendAndListenToHemoCube(
|
||||||
|
HemoCubeCommands.LOAD_DAC_VALUES,
|
||||||
|
object : UsbServiceListener {
|
||||||
|
override fun onUsbRead(data: ByteArray?) {
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onUsbError(e: Exception?) {
|
||||||
|
hemoCubeViewModel.progressBar.postValue(false)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
fun handleUsbData(stringData: String) {
|
fun handleUsbData(stringData: String) {
|
||||||
if (stringData.contains("#")) {
|
if (stringData.contains("#")) {
|
||||||
isTestOngoing = true
|
isTestOngoing = true
|
||||||
@@ -373,6 +386,7 @@ class HemoCubeFragment : Fragment() {
|
|||||||
when {
|
when {
|
||||||
resultData.contains("SNE") && this.testStatusCode < TestStatus.CONFIG_COMPLETED.code -> {
|
resultData.contains("SNE") && this.testStatusCode < TestStatus.CONFIG_COMPLETED.code -> {
|
||||||
processV2HardwareId(resultData)
|
processV2HardwareId(resultData)
|
||||||
|
loadDACValues()
|
||||||
}
|
}
|
||||||
|
|
||||||
(resultData.contains("SN") && !resultData.contains("SNS") && !resultData.contains("SNE") && resultData.length >= 15) && this.testStatusCode < TestStatus.CONFIG_COMPLETED.code -> {
|
(resultData.contains("SN") && !resultData.contains("SNS") && !resultData.contains("SNE") && resultData.length >= 15) && this.testStatusCode < TestStatus.CONFIG_COMPLETED.code -> {
|
||||||
@@ -392,6 +406,17 @@ class HemoCubeFragment : Fragment() {
|
|||||||
fetchResult()
|
fetchResult()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
(resultData.contains("#RS") && this.testStatusCode < TestStatus.EPROM_ADC_RETRIEVAL_STARTED.code) -> {
|
||||||
|
this.testStatusCode = TestStatus.EPROM_ADC_RETRIEVAL_STARTED.code
|
||||||
|
hemoCubeViewModel.messages.postValue("EPROM ADC Fetch")
|
||||||
|
}
|
||||||
|
|
||||||
|
(resultData.contains("#RC") && this.testStatusCode < TestStatus.EPROM_ADC_RETRIEVAL_COMPLETED.code) -> {
|
||||||
|
this.testStatusCode = TestStatus.EPROM_ADC_RETRIEVAL_COMPLETED.code
|
||||||
|
hemoCubeViewModel.messages.postValue("EPROM ADC Loaded")
|
||||||
|
showStartBufferButton()
|
||||||
|
}
|
||||||
|
|
||||||
resultData.contains("#BS") && this.testStatusCode < TestStatus.BUFFER_STARTED.code -> {
|
resultData.contains("#BS") && this.testStatusCode < TestStatus.BUFFER_STARTED.code -> {
|
||||||
hemoCubeViewModel.messages.postValue(getString(R.string.buffer_started))
|
hemoCubeViewModel.messages.postValue(getString(R.string.buffer_started))
|
||||||
this.testStatusCode = TestStatus.BUFFER_STARTED.code
|
this.testStatusCode = TestStatus.BUFFER_STARTED.code
|
||||||
@@ -642,10 +667,6 @@ class HemoCubeFragment : Fragment() {
|
|||||||
|
|
||||||
if (!hardwareId.isNullOrBlank()) {
|
if (!hardwareId.isNullOrBlank()) {
|
||||||
updateDeviceId(hardwareId)
|
updateDeviceId(hardwareId)
|
||||||
activity?.runOnUiThread {
|
|
||||||
binding.btnPlacebuffer.visibility = View.VISIBLE
|
|
||||||
}
|
|
||||||
hemoCubeViewModel.messages.postValue(getString(R.string.start))
|
|
||||||
} else {
|
} else {
|
||||||
hemoCubeViewModel.messages.postValue("Config error")
|
hemoCubeViewModel.messages.postValue("Config error")
|
||||||
}
|
}
|
||||||
@@ -659,6 +680,13 @@ class HemoCubeFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun showStartBufferButton() {
|
||||||
|
activity?.runOnUiThread {
|
||||||
|
binding.btnPlacebuffer.visibility = View.VISIBLE
|
||||||
|
}
|
||||||
|
hemoCubeViewModel.messages.postValue(getString(R.string.start))
|
||||||
|
}
|
||||||
|
|
||||||
fun extractV1HardwareId(input: String): String? {
|
fun extractV1HardwareId(input: String): String? {
|
||||||
val regex = Regex("SN (\\S+)")
|
val regex = Regex("SN (\\S+)")
|
||||||
val matchResult = regex.find(input)
|
val matchResult = regex.find(input)
|
||||||
|
|||||||
@@ -61,6 +61,7 @@ open class HemocubeActivity : AppCompatActivity() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private val connection = object : ServiceConnection {
|
private val connection = object : ServiceConnection {
|
||||||
override fun onServiceConnected(className: ComponentName, service: IBinder) {
|
override fun onServiceConnected(className: ComponentName, service: IBinder) {
|
||||||
val binder = service as UsbService.UsbServiceBinder
|
val binder = service as UsbService.UsbServiceBinder
|
||||||
@@ -81,7 +82,6 @@ open class HemocubeActivity : AppCompatActivity() {
|
|||||||
super.attachBaseContext(newBase)
|
super.attachBaseContext(newBase)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
binding = ActivityHemocubeBinding.inflate(layoutInflater)
|
binding = ActivityHemocubeBinding.inflate(layoutInflater)
|
||||||
@@ -125,7 +125,6 @@ open class HemocubeActivity : AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@SuppressLint("MutableImplicitPendingIntent")
|
@SuppressLint("MutableImplicitPendingIntent")
|
||||||
private fun requestUserPermission(manager: UsbManager, device: UsbDevice) {
|
private fun requestUserPermission(manager: UsbManager, device: UsbDevice) {
|
||||||
val mPendingIntent: PendingIntent
|
val mPendingIntent: PendingIntent
|
||||||
@@ -176,7 +175,6 @@ open class HemocubeActivity : AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fun onErrorReported(msg: String) {
|
fun onErrorReported(msg: String) {
|
||||||
Toast.makeText(this, msg, Toast.LENGTH_SHORT).show()
|
Toast.makeText(this, msg, Toast.LENGTH_SHORT).show()
|
||||||
if (!isFinishing) onBackPressed()
|
if (!isFinishing) onBackPressed()
|
||||||
|
|||||||
@@ -57,17 +57,11 @@ class JigFragment : Fragment(), IDcsSdkApiDelegate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun initScanner() {
|
private fun initScanner() {
|
||||||
//Setting up the SDK handler
|
|
||||||
sdkHandler = SDKHandler(requireContext())
|
sdkHandler = SDKHandler(requireContext())
|
||||||
//Registers a particular object which conforms to IDcsSdkApiDelegate interface as a receiver of SDK notifications.
|
|
||||||
sdkHandler!!.dcssdkSetDelegate(this)
|
sdkHandler!!.dcssdkSetDelegate(this)
|
||||||
//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)
|
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.
|
|
||||||
var notifications_mask = 0
|
var notifications_mask = 0
|
||||||
// We would like to subscribe to all barcode events
|
|
||||||
notifications_mask =
|
notifications_mask =
|
||||||
notifications_mask or DCSSDKDefs.DCSSDK_EVENT.DCSSDK_EVENT_BARCODE.value
|
notifications_mask or DCSSDKDefs.DCSSDK_EVENT.DCSSDK_EVENT_BARCODE.value
|
||||||
sdkHandler!!.dcssdkSubsribeForEvents(notifications_mask)
|
sdkHandler!!.dcssdkSubsribeForEvents(notifications_mask)
|
||||||
@@ -165,9 +159,7 @@ class JigFragment : Fragment(), IDcsSdkApiDelegate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun pullTrigger() {
|
private fun pullTrigger() {
|
||||||
// Check if the list is not empty before accessing its elements
|
|
||||||
if (mScannerInfoList.isNotEmpty()) {
|
if (mScannerInfoList.isNotEmpty()) {
|
||||||
// Only proceed if the scanner is not active
|
|
||||||
if (!mScannerInfoList[0].isActive) {
|
if (!mScannerInfoList[0].isActive) {
|
||||||
sdkHandler?.dcssdkEstablishCommunicationSession(mScannerInfoList[0].scannerID)
|
sdkHandler?.dcssdkEstablishCommunicationSession(mScannerInfoList[0].scannerID)
|
||||||
}
|
}
|
||||||
@@ -221,7 +213,6 @@ class JigFragment : Fragment(), IDcsSdkApiDelegate {
|
|||||||
// TODO("Not yet implemented")
|
// TODO("Not yet implemented")
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
|
||||||
override fun dcssdkEventImage(bytes: ByteArray?, i: Int) {}
|
override fun dcssdkEventImage(bytes: ByteArray?, i: Int) {}
|
||||||
|
|
||||||
override fun dcssdkEventVideo(bytes: ByteArray?, i: Int) {}
|
override fun dcssdkEventVideo(bytes: ByteArray?, i: Int) {}
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import com.hoho.android.usbserial.driver.UsbSerialDriver
|
|||||||
import com.hoho.android.usbserial.driver.UsbSerialPort
|
import com.hoho.android.usbserial.driver.UsbSerialPort
|
||||||
import com.hoho.android.usbserial.util.SerialInputOutputManager
|
import com.hoho.android.usbserial.util.SerialInputOutputManager
|
||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
|
|
||||||
class UsbService : Service() {
|
class UsbService : Service() {
|
||||||
private val binder = UsbServiceBinder()
|
private val binder = UsbServiceBinder()
|
||||||
private lateinit var mPort: UsbSerialPort
|
private lateinit var mPort: UsbSerialPort
|
||||||
@@ -43,6 +44,7 @@ class UsbService : Service() {
|
|||||||
override fun onNewData(data: ByteArray?) {
|
override fun onNewData(data: ByteArray?) {
|
||||||
listener?.onUsbRead(data)
|
listener?.onUsbRead(data)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onRunError(e: Exception?) {
|
override fun onRunError(e: Exception?) {
|
||||||
Log.e(TAG, "onRunError() called inside eventDrivenWrite()")
|
Log.e(TAG, "onRunError() called inside eventDrivenWrite()")
|
||||||
listener?.onUsbError(e)
|
listener?.onUsbError(e)
|
||||||
@@ -51,6 +53,7 @@ class UsbService : Service() {
|
|||||||
})
|
})
|
||||||
usbIoManager.start();
|
usbIoManager.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
fun disconnect() {
|
fun disconnect() {
|
||||||
if (isUsbConnected) {
|
if (isUsbConnected) {
|
||||||
mPort.close()
|
mPort.close()
|
||||||
@@ -58,6 +61,7 @@ class UsbService : Service() {
|
|||||||
Log.d(TAG, "My Usb disconnected:: ${mPort.driver}")
|
Log.d(TAG, "My Usb disconnected:: ${mPort.driver}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun eventDrivenWrite(command: TestRightCommands, listener: UsbServiceListener) {
|
fun eventDrivenWrite(command: TestRightCommands, listener: UsbServiceListener) {
|
||||||
this.listener = listener
|
this.listener = listener
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -82,7 +82,6 @@ class TrueHemeViewModel @Inject constructor(
|
|||||||
|
|
||||||
val uploadLogs = MutableLiveData<Result<UploadLogsResponse>?>()
|
val uploadLogs = MutableLiveData<Result<UploadLogsResponse>?>()
|
||||||
|
|
||||||
|
|
||||||
// Get the device ID of the device you want to retrieve data for (e.g., the first device in the list)
|
// Get the device ID of the device you want to retrieve data for (e.g., the first device in the list)
|
||||||
|
|
||||||
private val _networkStatusLiveData = NetworkStatusLiveData(context)
|
private val _networkStatusLiveData = NetworkStatusLiveData(context)
|
||||||
@@ -90,7 +89,6 @@ class TrueHemeViewModel @Inject constructor(
|
|||||||
val allKitTestData = hemoCubeBufferDao.getAll()
|
val allKitTestData = hemoCubeBufferDao.getAll()
|
||||||
val deviceData = MutableLiveData<DeviceData?>()
|
val deviceData = MutableLiveData<DeviceData?>()
|
||||||
|
|
||||||
|
|
||||||
val networkStatusLiveData: LiveData<Boolean>
|
val networkStatusLiveData: LiveData<Boolean>
|
||||||
get() = _networkStatusLiveData
|
get() = _networkStatusLiveData
|
||||||
val deviceMessages = MutableLiveData<String?>()
|
val deviceMessages = MutableLiveData<String?>()
|
||||||
@@ -381,7 +379,6 @@ class TrueHemeViewModel @Inject constructor(
|
|||||||
hemoCubeDao.deleteById(id = userId)
|
hemoCubeDao.deleteById(id = userId)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private fun addResultTestToDbforbuffercheck(bufferCheckData: BufferCheckData) {
|
private fun addResultTestToDbforbuffercheck(bufferCheckData: BufferCheckData) {
|
||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
try {
|
try {
|
||||||
|
|||||||
Reference in New Issue
Block a user