Compare commits
1 Commits
preprod-te
...
Add_new_de
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0b484fe421 |
@@ -139,8 +139,4 @@ dependencies {
|
|||||||
|
|
||||||
implementation "androidx.preference:preference-ktx:1.2.1"
|
implementation "androidx.preference:preference-ktx:1.2.1"
|
||||||
implementation 'io.nats:jnats:2.11.2'
|
implementation 'io.nats:jnats:2.11.2'
|
||||||
|
|
||||||
implementation("androidx.work:work-runtime-ktx:2.9.0")
|
|
||||||
|
|
||||||
implementation("io.nats:jnats:2.11.2")
|
|
||||||
}
|
}
|
||||||
@@ -18,7 +18,6 @@ object Constants {
|
|||||||
|
|
||||||
const val ACCESS_TOKEN = "accessToken"
|
const val ACCESS_TOKEN = "accessToken"
|
||||||
const val NATS_TOKEN = "natsToken"
|
const val NATS_TOKEN = "natsToken"
|
||||||
const val NATS_TOKEN_EXPIRE_DATE = "natsTokenExpireDate"
|
|
||||||
|
|
||||||
const val WRITE_TIMEOUT_MILLIS = 30000 // 30 sec
|
const val WRITE_TIMEOUT_MILLIS = 30000 // 30 sec
|
||||||
const val READ_TIMEOUT_MILLIS = 60000 // 1 min
|
const val READ_TIMEOUT_MILLIS = 60000 // 1 min
|
||||||
@@ -87,7 +86,47 @@ object Constants {
|
|||||||
"HCV-000-3007",
|
"HCV-000-3007",
|
||||||
"HCV-000-3008",
|
"HCV-000-3008",
|
||||||
"HCV-000-3009",
|
"HCV-000-3009",
|
||||||
"HCV-000-3010"
|
"HCV-000-3010",
|
||||||
|
"HPP1-0124-0001",
|
||||||
|
"HPP1-0124-0002",
|
||||||
|
"HPP1-0124-0003",
|
||||||
|
"HPP1-0124-0004",
|
||||||
|
"HPP1-0124-0005",
|
||||||
|
"HPP1-0124-0006",
|
||||||
|
"HPP1-0124-0007",
|
||||||
|
"HPP1-0124-0008",
|
||||||
|
"HPP1-0124-0009",
|
||||||
|
"HPP1-0124-0010",
|
||||||
|
"HPP1-0124-0011",
|
||||||
|
"HPP1-0124-0012",
|
||||||
|
"HPP1-0124-0013",
|
||||||
|
"HPP1-0124-0014",
|
||||||
|
"HPP1-0124-0015",
|
||||||
|
"HPP1-0124-0016",
|
||||||
|
"HPP1-0124-0017",
|
||||||
|
"HPP1-0124-0018",
|
||||||
|
"HPP1-0124-0019",
|
||||||
|
"HPP1-0124-0020",
|
||||||
|
"HPP1-0124-0021",
|
||||||
|
"HPP1-0124-0022",
|
||||||
|
"HPP1-0124-0023",
|
||||||
|
"HPP1-0124-0024",
|
||||||
|
"HPP1-0124-0025",
|
||||||
|
"HPP1-0124-0026",
|
||||||
|
"HPP1-0124-0027",
|
||||||
|
"HPP1-0124-0028",
|
||||||
|
"HPP1-0124-0029",
|
||||||
|
"HPP1-0124-0030",
|
||||||
|
"HPP1-0124-0031",
|
||||||
|
"HPP1-0124-0032",
|
||||||
|
"HPP1-0124-0033",
|
||||||
|
"HPP1-0124-0034",
|
||||||
|
"HPP1-0124-0035",
|
||||||
|
"HPP1-0124-0036",
|
||||||
|
"HPP1-0124-0037",
|
||||||
|
"HPP1-0124-0038",
|
||||||
|
"HPP1-0124-0039",
|
||||||
|
"HPP1-0124-0040"
|
||||||
)
|
)
|
||||||
|
|
||||||
const val password = "SMI@12345"
|
const val password = "SMI@12345"
|
||||||
@@ -243,6 +282,246 @@ object Constants {
|
|||||||
listOf(24500, 26250),
|
listOf(24500, 26250),
|
||||||
listOf(24500, 26250),
|
listOf(24500, 26250),
|
||||||
listOf(24500, 26250),
|
listOf(24500, 26250),
|
||||||
|
),
|
||||||
|
"HPP1-0124-0001" to listOf(
|
||||||
|
listOf(24500, 26250),
|
||||||
|
listOf(24500, 26250),
|
||||||
|
listOf(24500, 26250),
|
||||||
|
listOf(24500, 26250)
|
||||||
|
),
|
||||||
|
"HPP1-0124-0002" to listOf(
|
||||||
|
listOf(24500, 26250),
|
||||||
|
listOf(24500, 26250),
|
||||||
|
listOf(24500, 26250),
|
||||||
|
listOf(24500, 26250)
|
||||||
|
),
|
||||||
|
"HPP1-0124-0003" to listOf(
|
||||||
|
listOf(24500, 26250),
|
||||||
|
listOf(24500, 26250),
|
||||||
|
listOf(24500, 26250),
|
||||||
|
listOf(24500, 26250)
|
||||||
|
),
|
||||||
|
"HPP1-0124-0004" to listOf(
|
||||||
|
listOf(24500, 26250),
|
||||||
|
listOf(24500, 26250),
|
||||||
|
listOf(24500, 26250),
|
||||||
|
listOf(24500, 26250)
|
||||||
|
),
|
||||||
|
"HPP1-0124-0005" to listOf(
|
||||||
|
listOf(24500, 26250),
|
||||||
|
listOf(24500, 26250),
|
||||||
|
listOf(24500, 26250),
|
||||||
|
listOf(24500, 26250)
|
||||||
|
),
|
||||||
|
"HPP1-0124-0006" to listOf(
|
||||||
|
listOf(24500, 26250),
|
||||||
|
listOf(24500, 26250),
|
||||||
|
listOf(24500, 26250),
|
||||||
|
listOf(24500, 26250)
|
||||||
|
),
|
||||||
|
"HPP1-0124-0007" to listOf(
|
||||||
|
listOf(24500, 26250),
|
||||||
|
listOf(24500, 26250),
|
||||||
|
listOf(24500, 26250),
|
||||||
|
listOf(24500, 26250)
|
||||||
|
),
|
||||||
|
"HPP1-0124-0008" to listOf(
|
||||||
|
listOf(24500, 26250),
|
||||||
|
listOf(24500, 26250),
|
||||||
|
listOf(24500, 26250),
|
||||||
|
listOf(24500, 26250)
|
||||||
|
),
|
||||||
|
"HPP1-0124-0009" to listOf(
|
||||||
|
listOf(24500, 26250),
|
||||||
|
listOf(24500, 26250),
|
||||||
|
listOf(24500, 26250),
|
||||||
|
listOf(24500, 26250)
|
||||||
|
),
|
||||||
|
"HPP1-0124-0010" to listOf(
|
||||||
|
listOf(24500, 26250),
|
||||||
|
listOf(24500, 26250),
|
||||||
|
listOf(24500, 26250),
|
||||||
|
listOf(24500, 26250)
|
||||||
|
),
|
||||||
|
"HPP1-0124-0011" to listOf(
|
||||||
|
listOf(24500, 26250),
|
||||||
|
listOf(24500, 26250),
|
||||||
|
listOf(24500, 26250),
|
||||||
|
listOf(24500, 26250)
|
||||||
|
),
|
||||||
|
"HPP1-0124-0012" to listOf(
|
||||||
|
listOf(24500, 26250),
|
||||||
|
listOf(24500, 26250),
|
||||||
|
listOf(24500, 26250),
|
||||||
|
listOf(24500, 26250)
|
||||||
|
),
|
||||||
|
"HPP1-0124-0013" to listOf(
|
||||||
|
listOf(24500, 26250),
|
||||||
|
listOf(24500, 26250),
|
||||||
|
listOf(24500, 26250),
|
||||||
|
listOf(24500, 26250)
|
||||||
|
),
|
||||||
|
"HPP1-0124-0014" to listOf(
|
||||||
|
listOf(24500, 26250),
|
||||||
|
listOf(24500, 26250),
|
||||||
|
listOf(24500, 26250),
|
||||||
|
listOf(24500, 26250)
|
||||||
|
),
|
||||||
|
"HPP1-0124-0015" to listOf(
|
||||||
|
listOf(24500, 26250),
|
||||||
|
listOf(24500, 26250),
|
||||||
|
listOf(24500, 26250),
|
||||||
|
listOf(24500, 26250)
|
||||||
|
),
|
||||||
|
"HPP1-0124-0016" to listOf(
|
||||||
|
listOf(24500, 26250),
|
||||||
|
listOf(24500, 26250),
|
||||||
|
listOf(24500, 26250),
|
||||||
|
listOf(24500, 26250)
|
||||||
|
),
|
||||||
|
"HPP1-0124-0017" to listOf(
|
||||||
|
listOf(24500, 26250),
|
||||||
|
listOf(24500, 26250),
|
||||||
|
listOf(24500, 26250),
|
||||||
|
listOf(24500, 26250)
|
||||||
|
),
|
||||||
|
"HPP1-0124-0018" to listOf(
|
||||||
|
listOf(24500, 26250),
|
||||||
|
listOf(24500, 26250),
|
||||||
|
listOf(24500, 26250),
|
||||||
|
listOf(24500, 26250)
|
||||||
|
),
|
||||||
|
"HPP1-0124-0019" to listOf(
|
||||||
|
listOf(24500, 26250),
|
||||||
|
listOf(24500, 26250),
|
||||||
|
listOf(24500, 26250),
|
||||||
|
listOf(24500, 26250)
|
||||||
|
),
|
||||||
|
"HPP1-0124-0020" to listOf(
|
||||||
|
listOf(24500, 26250),
|
||||||
|
listOf(24500, 26250),
|
||||||
|
listOf(24500, 26250),
|
||||||
|
listOf(24500, 26250)
|
||||||
|
),
|
||||||
|
"HPP1-0124-0021" to listOf(
|
||||||
|
listOf(24500, 26250),
|
||||||
|
listOf(24500, 26250),
|
||||||
|
listOf(24500, 26250),
|
||||||
|
listOf(24500, 26250)
|
||||||
|
),
|
||||||
|
"HPP1-0124-0022" to listOf(
|
||||||
|
listOf(24500, 26250),
|
||||||
|
listOf(24500, 26250),
|
||||||
|
listOf(24500, 26250),
|
||||||
|
listOf(24500, 26250)
|
||||||
|
),
|
||||||
|
"HPP1-0124-0023" to listOf(
|
||||||
|
listOf(24500, 26250),
|
||||||
|
listOf(24500, 26250),
|
||||||
|
listOf(24500, 26250),
|
||||||
|
listOf(24500, 26250)
|
||||||
|
),
|
||||||
|
"HPP1-0124-0024" to listOf(
|
||||||
|
listOf(24500, 26250),
|
||||||
|
listOf(24500, 26250),
|
||||||
|
listOf(24500, 26250),
|
||||||
|
listOf(24500, 26250)
|
||||||
|
),
|
||||||
|
"HPP1-0124-0025" to listOf(
|
||||||
|
listOf(24500, 26250),
|
||||||
|
listOf(24500, 26250),
|
||||||
|
listOf(24500, 26250),
|
||||||
|
listOf(24500, 26250)
|
||||||
|
),
|
||||||
|
"HPP1-0124-0026" to listOf(
|
||||||
|
listOf(24500, 26250),
|
||||||
|
listOf(24500, 26250),
|
||||||
|
listOf(24500, 26250),
|
||||||
|
listOf(24500, 26250)
|
||||||
|
),
|
||||||
|
"HPP1-0124-0027" to listOf(
|
||||||
|
listOf(24500, 26250),
|
||||||
|
listOf(24500, 26250),
|
||||||
|
listOf(24500, 26250),
|
||||||
|
listOf(24500, 26250)
|
||||||
|
),
|
||||||
|
"HPP1-0124-0028" to listOf(
|
||||||
|
listOf(24500, 26250),
|
||||||
|
listOf(24500, 26250),
|
||||||
|
listOf(24500, 26250),
|
||||||
|
listOf(24500, 26250)
|
||||||
|
),
|
||||||
|
"HPP1-0124-0029" to listOf(
|
||||||
|
listOf(24500, 26250),
|
||||||
|
listOf(24500, 26250),
|
||||||
|
listOf(24500, 26250),
|
||||||
|
listOf(24500, 26250)
|
||||||
|
),
|
||||||
|
"HPP1-0124-0030" to listOf(
|
||||||
|
listOf(24500, 26250),
|
||||||
|
listOf(24500, 26250),
|
||||||
|
listOf(24500, 26250),
|
||||||
|
listOf(24500, 26250)
|
||||||
|
),
|
||||||
|
"HPP1-0124-0031" to listOf(
|
||||||
|
listOf(24500, 26250),
|
||||||
|
listOf(24500, 26250),
|
||||||
|
listOf(24500, 26250),
|
||||||
|
listOf(24500, 26250)
|
||||||
|
),
|
||||||
|
"HPP1-0124-0032" to listOf(
|
||||||
|
listOf(24500, 26250),
|
||||||
|
listOf(24500, 26250),
|
||||||
|
listOf(24500, 26250),
|
||||||
|
listOf(24500, 26250)
|
||||||
|
),
|
||||||
|
"HPP1-0124-0033" to listOf(
|
||||||
|
listOf(24500, 26250),
|
||||||
|
listOf(24500, 26250),
|
||||||
|
listOf(24500, 26250),
|
||||||
|
listOf(24500, 26250)
|
||||||
|
),
|
||||||
|
"HPP1-0124-0034" to listOf(
|
||||||
|
listOf(24500, 26250),
|
||||||
|
listOf(24500, 26250),
|
||||||
|
listOf(24500, 26250),
|
||||||
|
listOf(24500, 26250)
|
||||||
|
),
|
||||||
|
"HPP1-0124-0035" to listOf(
|
||||||
|
listOf(24500, 26250),
|
||||||
|
listOf(24500, 26250),
|
||||||
|
listOf(24500, 26250),
|
||||||
|
listOf(24500, 26250)
|
||||||
|
),
|
||||||
|
"HPP1-0124-0036" to listOf(
|
||||||
|
listOf(24500, 26250),
|
||||||
|
listOf(24500, 26250),
|
||||||
|
listOf(24500, 26250),
|
||||||
|
listOf(24500, 26250)
|
||||||
|
),
|
||||||
|
"HPP1-0124-0037" to listOf(
|
||||||
|
listOf(24500, 26250),
|
||||||
|
listOf(24500, 26250),
|
||||||
|
listOf(24500, 26250),
|
||||||
|
listOf(24500, 26250)
|
||||||
|
),
|
||||||
|
"HPP1-0124-0038" to listOf(
|
||||||
|
listOf(24500, 26250),
|
||||||
|
listOf(24500, 26250),
|
||||||
|
listOf(24500, 26250),
|
||||||
|
listOf(24500, 26250)
|
||||||
|
),
|
||||||
|
"HPP1-0124-0039" to listOf(
|
||||||
|
listOf(24500, 26250),
|
||||||
|
listOf(24500, 26250),
|
||||||
|
listOf(24500, 26250),
|
||||||
|
listOf(24500, 26250)
|
||||||
|
),
|
||||||
|
"HPP1-0124-0040" to listOf(
|
||||||
|
listOf(24500, 26250),
|
||||||
|
listOf(24500, 26250),
|
||||||
|
listOf(24500, 26250),
|
||||||
|
listOf(24500, 26250)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -23,7 +23,4 @@ interface HemoCubeDao {
|
|||||||
|
|
||||||
@Query("UPDATE hemo_cube_test_table SET localFlag = :newValue WHERE _id = :id")
|
@Query("UPDATE hemo_cube_test_table SET localFlag = :newValue WHERE _id = :id")
|
||||||
suspend fun updateFieldById(id: String, newValue: Boolean)
|
suspend fun updateFieldById(id: String, newValue: Boolean)
|
||||||
|
|
||||||
@Query("UPDATE hemo_cube_test_table SET molbioFlag = :newValue WHERE _id = :id")
|
|
||||||
suspend fun updateMolbioFlag(id: String, newValue: Boolean)
|
|
||||||
}
|
}
|
||||||
@@ -11,7 +11,7 @@ import com.example.hpostesting.data.model.patient.HemoCubeTestData
|
|||||||
import com.google.android.datatransport.runtime.dagger.Provides
|
import com.google.android.datatransport.runtime.dagger.Provides
|
||||||
import javax.inject.Singleton
|
import javax.inject.Singleton
|
||||||
|
|
||||||
@Database(entities = [UserData::class, HemoCubeTestData::class, DeviceData::class], version = 15, exportSchema = false)
|
@Database(entities = [UserData::class, HemoCubeTestData::class, DeviceData::class], version = 14, exportSchema = false)
|
||||||
@TypeConverters(Converters::class)
|
@TypeConverters(Converters::class)
|
||||||
abstract class MyDatabase : RoomDatabase() {
|
abstract class MyDatabase : RoomDatabase() {
|
||||||
abstract fun userDao(): UserDao
|
abstract fun userDao(): UserDao
|
||||||
|
|||||||
@@ -3,27 +3,27 @@ package com.example.hpostesting.data.model.molbioresult
|
|||||||
import com.example.hpostesting.data.model.patient.HemoCubeTestData
|
import com.example.hpostesting.data.model.patient.HemoCubeTestData
|
||||||
|
|
||||||
data class MolbioV2Result(
|
data class MolbioV2Result(
|
||||||
val age: Int? = 31,
|
val age: Int? = 0,
|
||||||
val analysisDate: String? = "",
|
val analysisDate: String? = "",
|
||||||
val analysisId: String? = "",
|
val analysisId: String? = "",
|
||||||
val analysisStatus: String? = "",
|
val analysisStatus: String? = "",
|
||||||
val analysisType: String? = "HPOS",
|
val analysisType: String? = "",
|
||||||
val analysisTypeMethod: String? = "",
|
val analysisTypeMethod: String? = "",
|
||||||
val bloodGroup: String? = "",
|
val bloodGroup: String? = "",
|
||||||
val coefficients: List<Int>? = listOf(22, 22),
|
val coefficients: List<Int>? = listOf(),
|
||||||
val collectionLocation: List<Any>? = listOf(),
|
val collectionLocation: List<Any>? = listOf(),
|
||||||
val collectionTime: String? = "",
|
val collectionTime: String? = "",
|
||||||
val collector: String? = "",
|
val collector: String? = "",
|
||||||
val curveFitting: String? = "Linear",
|
val curveFitting: String? = "",
|
||||||
val deviceName: String? = "HPOS",
|
val deviceName: String? = "",
|
||||||
val expiryTime: String? = "",
|
val expiryTime: String? = "",
|
||||||
val gender: String? = "",
|
val gender: String? = "",
|
||||||
val interpretation: String? = "",
|
val interpretation: String? = "",
|
||||||
val `operator`: String? = "",
|
val `operator`: String? = "",
|
||||||
val patientId: Int? = 4545,
|
val patientId: Int? = 0,
|
||||||
val pregnancy: Boolean? = false,
|
val pregnancy: Boolean? = false,
|
||||||
val rawData: HemoCubeTestData? = HemoCubeTestData(),
|
val rawData: HemoCubeTestData? = HemoCubeTestData(),
|
||||||
val recommendation: String? = "NA",
|
val recommendation: String? = "",
|
||||||
val sampleId: String? = "",
|
val sampleId: String? = "",
|
||||||
val sampleType: String? = "",
|
val sampleType: String? = "",
|
||||||
val sickleCellHistory: Boolean? = false,
|
val sickleCellHistory: Boolean? = false,
|
||||||
@@ -34,5 +34,5 @@ data class MolbioV2Result(
|
|||||||
val testType: String? = "",
|
val testType: String? = "",
|
||||||
val thresholds: String? = "",
|
val thresholds: String? = "",
|
||||||
val underMedication: Boolean? = false,
|
val underMedication: Boolean? = false,
|
||||||
val volume: Int? = 2
|
val volume: Int? = 0
|
||||||
)
|
)
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
package com.example.hpostesting.domain
|
|
||||||
|
|
||||||
import android.content.Context
|
|
||||||
import android.util.Log
|
|
||||||
import androidx.work.CoroutineWorker
|
|
||||||
import androidx.work.WorkerParameters
|
|
||||||
import kotlinx.coroutines.Dispatchers
|
|
||||||
import kotlinx.coroutines.delay
|
|
||||||
import kotlinx.coroutines.withContext
|
|
||||||
|
|
||||||
class CheckUpdateWorker(
|
|
||||||
context: Context,
|
|
||||||
workerParams: WorkerParameters
|
|
||||||
) : CoroutineWorker(context, workerParams) {
|
|
||||||
|
|
||||||
override suspend fun doWork(): Result = withContext(Dispatchers.IO) {
|
|
||||||
try {
|
|
||||||
for (i in 1..900){
|
|
||||||
delay(1000)
|
|
||||||
Log.d("Work for every second", "doWork: Running")
|
|
||||||
}
|
|
||||||
|
|
||||||
Result.success()
|
|
||||||
} catch (e: Exception) {
|
|
||||||
Result.failure()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,134 +0,0 @@
|
|||||||
package com.example.hpostesting.presentation
|
|
||||||
|
|
||||||
import android.util.Log
|
|
||||||
import com.example.hpostesting.presentation.dashboard.DashboardActivity
|
|
||||||
import io.nats.client.AuthHandler
|
|
||||||
import io.nats.client.Connection
|
|
||||||
import io.nats.client.Message
|
|
||||||
import io.nats.client.NKey
|
|
||||||
import io.nats.client.Nats
|
|
||||||
import io.nats.client.Options
|
|
||||||
import java.io.IOException
|
|
||||||
import java.nio.charset.StandardCharsets
|
|
||||||
import java.security.GeneralSecurityException
|
|
||||||
|
|
||||||
|
|
||||||
class NatsManager(datacollector: DashboardActivity) {
|
|
||||||
|
|
||||||
val TAG = "Nats Service"
|
|
||||||
var nc: Connection? = null
|
|
||||||
val datacollector = datacollector
|
|
||||||
var connect = false
|
|
||||||
|
|
||||||
fun connect() {
|
|
||||||
Log.d(TAG, "TRY TO CONNECT")
|
|
||||||
Thread {
|
|
||||||
|
|
||||||
val seedString = "SUAK5IDCMHY4T2WA2LHNXGICGHKR3TPJFNSP6AUQP523RLANO4PSR6IEYA"
|
|
||||||
val seedBytes = seedString.toCharArray()
|
|
||||||
|
|
||||||
val theNKey = NKey.fromSeed(seedBytes) // really should load from somewhere
|
|
||||||
|
|
||||||
val options = Options.Builder()
|
|
||||||
.server("nats://192.168.10.117:4222")
|
|
||||||
.authHandler(object : AuthHandler {
|
|
||||||
override fun getID(): CharArray? {
|
|
||||||
return try {
|
|
||||||
theNKey?.publicKey
|
|
||||||
} catch (ex: GeneralSecurityException) {
|
|
||||||
null
|
|
||||||
} catch (ex: IOException) {
|
|
||||||
null
|
|
||||||
} catch (ex: NullPointerException) {
|
|
||||||
null
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun sign(nonce: ByteArray): ByteArray? {
|
|
||||||
return try {
|
|
||||||
theNKey?.sign(nonce)
|
|
||||||
} catch (ex: GeneralSecurityException) {
|
|
||||||
null
|
|
||||||
} catch (ex: IOException) {
|
|
||||||
null
|
|
||||||
} catch (ex: NullPointerException) {
|
|
||||||
null
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun getJWT(): CharArray? {
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.build()
|
|
||||||
|
|
||||||
try {
|
|
||||||
nc = Nats.connect(options)
|
|
||||||
Log.d(TAG, "Connected to Nats server ${options.servers.first()}")
|
|
||||||
connect = true
|
|
||||||
datacollector.setConnect(true)
|
|
||||||
|
|
||||||
|
|
||||||
nc?.publish(
|
|
||||||
"server.hpos.HCV-000-3001.ping",
|
|
||||||
"ALIVE".toByteArray(StandardCharsets.UTF_8)
|
|
||||||
)
|
|
||||||
nc?.publish(
|
|
||||||
"server.hpos.HCV-000-3001.health",
|
|
||||||
"ALIVE".toByteArray(StandardCharsets.UTF_8)
|
|
||||||
)
|
|
||||||
Log.d(TAG, "Published msg server.hpos.HCV-000-3001.ping on topic Testing")
|
|
||||||
val d = nc?.createDispatcher { msg: Message? ->
|
|
||||||
println("PRITIMOI SARKAR $msg")
|
|
||||||
}
|
|
||||||
|
|
||||||
d?.subscribe("device.hpos.HCV-000-3001.update") { msg ->
|
|
||||||
val response = String(msg.data, StandardCharsets.UTF_8)
|
|
||||||
datacollector. setResponse(response)
|
|
||||||
println("Message received (up to 100 times): $response")
|
|
||||||
}
|
|
||||||
|
|
||||||
d?.subscribe("device.hpos.HCV-000-3001.uploadlogs") { msg ->
|
|
||||||
val response = String(msg.data, StandardCharsets.UTF_8)
|
|
||||||
datacollector.setResponse(response + "uPLOAD")
|
|
||||||
println("Message received (up to 100 times): $response")
|
|
||||||
}
|
|
||||||
|
|
||||||
d?.subscribe("device.hpos.HCV-000-3001.disable") { msg ->
|
|
||||||
val response = String(msg.data, StandardCharsets.UTF_8)
|
|
||||||
datacollector.setResponse(response)
|
|
||||||
println("Message received (up to 100 times): $response")
|
|
||||||
}
|
|
||||||
|
|
||||||
d?.subscribe("device.hpos.HCV-000-3001.updatecustomer") { msg ->
|
|
||||||
val response = String(msg.data, StandardCharsets.UTF_8)
|
|
||||||
datacollector.setResponse(response)
|
|
||||||
println("Message received (up to 100 times): $response")
|
|
||||||
}
|
|
||||||
|
|
||||||
d?.subscribe("device.hpos.HCV-000-3001.checkupdate") { msg ->
|
|
||||||
val response = String(msg.data, StandardCharsets.UTF_8)
|
|
||||||
datacollector.setResponse(response)
|
|
||||||
println("Message received (up to 100 times): $response")
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (exp: Exception) {
|
|
||||||
println(exp.printStackTrace())
|
|
||||||
connect = false
|
|
||||||
datacollector.setConnect(true)
|
|
||||||
}
|
|
||||||
}.start()
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
fun pub(topic: String, msg: String) {
|
|
||||||
nc?.publish(topic, msg.toByteArray(StandardCharsets.UTF_8))
|
|
||||||
Log.d(TAG, "Published msg ${msg} on topic ${topic}")
|
|
||||||
}
|
|
||||||
|
|
||||||
fun close() {
|
|
||||||
nc?.close()
|
|
||||||
Log.d(TAG, "Nats connection close")
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -2,7 +2,6 @@ package com.example.hpostesting.presentation.dashboard
|
|||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.util.Log
|
|
||||||
import android.view.Menu
|
import android.view.Menu
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
@@ -13,9 +12,7 @@ import androidx.navigation.ui.navigateUp
|
|||||||
import androidx.navigation.ui.setupActionBarWithNavController
|
import androidx.navigation.ui.setupActionBarWithNavController
|
||||||
import androidx.navigation.ui.setupWithNavController
|
import androidx.navigation.ui.setupWithNavController
|
||||||
import com.example.hpostesting.data.constant.LanguageManager
|
import com.example.hpostesting.data.constant.LanguageManager
|
||||||
import com.example.hpostesting.presentation.NatsManager
|
|
||||||
import com.google.android.material.navigation.NavigationView
|
import com.google.android.material.navigation.NavigationView
|
||||||
import com.google.android.material.progressindicator.LinearProgressIndicator
|
|
||||||
import com.google.android.play.core.appupdate.AppUpdateManager
|
import com.google.android.play.core.appupdate.AppUpdateManager
|
||||||
import com.google.android.play.core.appupdate.AppUpdateManagerFactory
|
import com.google.android.play.core.appupdate.AppUpdateManagerFactory
|
||||||
import com.google.firebase.appdistribution.FirebaseAppDistribution
|
import com.google.firebase.appdistribution.FirebaseAppDistribution
|
||||||
@@ -25,17 +22,11 @@ import dagger.hilt.android.AndroidEntryPoint
|
|||||||
import `in`.sminnovations.hpostesting.R
|
import `in`.sminnovations.hpostesting.R
|
||||||
import `in`.sminnovations.hpostesting.databinding.ActivityDashboardBinding
|
import `in`.sminnovations.hpostesting.databinding.ActivityDashboardBinding
|
||||||
|
|
||||||
open interface IDataCollector {
|
|
||||||
fun setConnect(connect: Boolean)
|
|
||||||
fun setResponse(response: String)
|
|
||||||
}
|
|
||||||
@AndroidEntryPoint
|
@AndroidEntryPoint
|
||||||
class DashboardActivity : AppCompatActivity(), IDataCollector {
|
class DashboardActivity : AppCompatActivity() {
|
||||||
|
|
||||||
private lateinit var appBarConfiguration: AppBarConfiguration
|
private lateinit var appBarConfiguration: AppBarConfiguration
|
||||||
private lateinit var binding: ActivityDashboardBinding
|
private lateinit var binding: ActivityDashboardBinding
|
||||||
var responses: String = ""
|
|
||||||
lateinit var nats: NatsManager
|
|
||||||
override fun attachBaseContext(newBase: Context?) {
|
override fun attachBaseContext(newBase: Context?) {
|
||||||
val languageCode = LanguageManager.getSavedLanguage(newBase!!)
|
val languageCode = LanguageManager.getSavedLanguage(newBase!!)
|
||||||
LanguageManager.setLocale(newBase, languageCode)
|
LanguageManager.setLocale(newBase, languageCode)
|
||||||
@@ -48,9 +39,6 @@ class DashboardActivity : AppCompatActivity(), IDataCollector {
|
|||||||
binding = ActivityDashboardBinding.inflate(layoutInflater)
|
binding = ActivityDashboardBinding.inflate(layoutInflater)
|
||||||
setContentView(binding.root)
|
setContentView(binding.root)
|
||||||
setSupportActionBar(binding.appBarDashboard.toolbar)
|
setSupportActionBar(binding.appBarDashboard.toolbar)
|
||||||
nats = NatsManager(this)
|
|
||||||
// nats.connect()
|
|
||||||
// nats.pub("server.hpos.HCV-000-3001.ping", "THIS IS A TEST MSG")
|
|
||||||
|
|
||||||
val drawerLayout: DrawerLayout = binding.drawerLayout
|
val drawerLayout: DrawerLayout = binding.drawerLayout
|
||||||
val navView: NavigationView = binding.navView
|
val navView: NavigationView = binding.navView
|
||||||
@@ -116,16 +104,4 @@ class DashboardActivity : AppCompatActivity(), IDataCollector {
|
|||||||
// Toast.makeText(this, "App Update: Success!", Toast.LENGTH_SHORT).show()
|
// Toast.makeText(this, "App Update: Success!", Toast.LENGTH_SHORT).show()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun setConnect(connect: Boolean) {
|
|
||||||
if(connect){
|
|
||||||
Log.i("NATS Connection", connect.toString())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun setResponse(response: String) {
|
|
||||||
|
|
||||||
responses = responses+response+"\n"
|
|
||||||
println(responses)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -142,7 +142,6 @@ class HomeFragment : Fragment() {
|
|||||||
private fun checkForTokenAndUpdate() {
|
private fun checkForTokenAndUpdate() {
|
||||||
val accessToken = sharedPreference.getString(Constants.ACCESS_TOKEN, "").toString()
|
val accessToken = sharedPreference.getString(Constants.ACCESS_TOKEN, "").toString()
|
||||||
val natsToken = sharedPreference.getString(Constants.NATS_TOKEN, "").toString()
|
val natsToken = sharedPreference.getString(Constants.NATS_TOKEN, "").toString()
|
||||||
val natsTokenExpireDate = sharedPreference.getString(Constants.NATS_TOKEN_EXPIRE_DATE, "").toString()
|
|
||||||
if (accessToken.isEmpty() && natsToken.isEmpty()) {
|
if (accessToken.isEmpty() && natsToken.isEmpty()) {
|
||||||
hemoCubeViewModel.login(createLoginRequestData())
|
hemoCubeViewModel.login(createLoginRequestData())
|
||||||
} else {
|
} else {
|
||||||
@@ -151,7 +150,6 @@ class HomeFragment : Fragment() {
|
|||||||
} else {
|
} else {
|
||||||
hemoCubeViewModel.checkUpdate(createCheckUpdateRequestData())
|
hemoCubeViewModel.checkUpdate(createCheckUpdateRequestData())
|
||||||
hemoCubeViewModel.uploadLogs()
|
hemoCubeViewModel.uploadLogs()
|
||||||
hemoCubeViewModel.startPeriodicCheckUpdate()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
hemoCubeViewModel.loginResponse.observe(viewLifecycleOwner) { response ->
|
hemoCubeViewModel.loginResponse.observe(viewLifecycleOwner) { response ->
|
||||||
@@ -240,7 +238,6 @@ class HomeFragment : Fragment() {
|
|||||||
with(sharedPreference.edit()) {
|
with(sharedPreference.edit()) {
|
||||||
putString(Constants.ACCESS_TOKEN, response.data.data?.accessToken)
|
putString(Constants.ACCESS_TOKEN, response.data.data?.accessToken)
|
||||||
putString(Constants.NATS_TOKEN, response.data.data?.deviceUser?.natsToken)
|
putString(Constants.NATS_TOKEN, response.data.data?.deviceUser?.natsToken)
|
||||||
putString(Constants.NATS_TOKEN_EXPIRE_DATE, response.data.data?.deviceUser?.natsTokenExpiry)
|
|
||||||
apply()
|
apply()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -135,20 +135,20 @@ class HemoCubeFragment : Fragment() {
|
|||||||
hemoCubeViewModel.fireBaseUpload.observe(viewLifecycleOwner) { result ->
|
hemoCubeViewModel.fireBaseUpload.observe(viewLifecycleOwner) { result ->
|
||||||
if (result == "Success") {
|
if (result == "Success") {
|
||||||
showToast(R.string.test_upload)
|
showToast(R.string.test_upload)
|
||||||
|
activity?.runOnUiThread {
|
||||||
|
binding.btnSubmit.visibility = View.GONE
|
||||||
|
val i = Intent(
|
||||||
|
requireContext().applicationContext,
|
||||||
|
DashboardActivity::class.java
|
||||||
|
)
|
||||||
|
startActivity(i)
|
||||||
|
}
|
||||||
hemoCubeViewModel.resultUpload.observe(viewLifecycleOwner) {
|
hemoCubeViewModel.resultUpload.observe(viewLifecycleOwner) {
|
||||||
when (it) {
|
when (it) {
|
||||||
is Result.Success -> {
|
is Result.Success -> {
|
||||||
it.data.data?.get(0)?.rawData?.let { it1 ->
|
it.data.data?.get(0)?.rawData?.let { it1 ->
|
||||||
hemoCubeViewModel.updateMolbioFlag(
|
hemoCubeViewModel.updateMolbioFlag(
|
||||||
it1._id)
|
it1._id)
|
||||||
activity?.runOnUiThread {
|
|
||||||
binding.btnSubmit.visibility = View.GONE
|
|
||||||
val i = Intent(
|
|
||||||
requireContext().applicationContext,
|
|
||||||
DashboardActivity::class.java
|
|
||||||
)
|
|
||||||
startActivity(i)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
is Result.Error -> {
|
is Result.Error -> {
|
||||||
|
|||||||
@@ -10,9 +10,6 @@ import androidx.lifecycle.LiveData
|
|||||||
import androidx.lifecycle.MutableLiveData
|
import androidx.lifecycle.MutableLiveData
|
||||||
import androidx.lifecycle.ViewModel
|
import androidx.lifecycle.ViewModel
|
||||||
import androidx.lifecycle.viewModelScope
|
import androidx.lifecycle.viewModelScope
|
||||||
import androidx.work.ExistingPeriodicWorkPolicy
|
|
||||||
import androidx.work.PeriodicWorkRequestBuilder
|
|
||||||
import androidx.work.WorkManager
|
|
||||||
import com.example.hpostesting.data.DataHolder
|
import com.example.hpostesting.data.DataHolder
|
||||||
import com.example.hpostesting.data.NetworkStatusLiveData
|
import com.example.hpostesting.data.NetworkStatusLiveData
|
||||||
import com.example.hpostesting.data.Result
|
import com.example.hpostesting.data.Result
|
||||||
@@ -36,7 +33,6 @@ import com.example.hpostesting.data.model.updates.CheckUpdateResponse
|
|||||||
import com.example.hpostesting.data.model.updates.DeviceUpdateRequest
|
import com.example.hpostesting.data.model.updates.DeviceUpdateRequest
|
||||||
import com.example.hpostesting.data.repository.DatabaseRepository
|
import com.example.hpostesting.data.repository.DatabaseRepository
|
||||||
import com.example.hpostesting.data.repository.Repository
|
import com.example.hpostesting.data.repository.Repository
|
||||||
import com.example.hpostesting.domain.CheckUpdateWorker
|
|
||||||
import com.example.hpostesting.domain.LogFileManager
|
import com.example.hpostesting.domain.LogFileManager
|
||||||
import dagger.hilt.android.lifecycle.HiltViewModel
|
import dagger.hilt.android.lifecycle.HiltViewModel
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
@@ -47,7 +43,6 @@ import okhttp3.ResponseBody
|
|||||||
import java.text.SimpleDateFormat
|
import java.text.SimpleDateFormat
|
||||||
import java.util.Calendar
|
import java.util.Calendar
|
||||||
import java.util.Locale
|
import java.util.Locale
|
||||||
import java.util.concurrent.TimeUnit
|
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
@HiltViewModel
|
@HiltViewModel
|
||||||
@@ -65,12 +60,6 @@ class HemoCubeViewModel @Inject constructor(
|
|||||||
private val sharedPreference: SharedPreferences =
|
private val sharedPreference: SharedPreferences =
|
||||||
context.getSharedPreferences("PREFERENCE_NAME", Context.MODE_PRIVATE)
|
context.getSharedPreferences("PREFERENCE_NAME", Context.MODE_PRIVATE)
|
||||||
|
|
||||||
private val workManager = WorkManager.getInstance(context)
|
|
||||||
|
|
||||||
// init {
|
|
||||||
// startPeriodicCheckUpdate()
|
|
||||||
// }
|
|
||||||
|
|
||||||
val deviceProvisionResponse = MutableLiveData<Result<DeviceProvisionResponse>>()
|
val deviceProvisionResponse = MutableLiveData<Result<DeviceProvisionResponse>>()
|
||||||
|
|
||||||
val loginResponse = MutableLiveData<Result<LoginResponse>>()
|
val loginResponse = MutableLiveData<Result<LoginResponse>>()
|
||||||
@@ -162,16 +151,6 @@ class HemoCubeViewModel @Inject constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun startPeriodicCheckUpdate() {
|
|
||||||
val periodicRequest = PeriodicWorkRequestBuilder<CheckUpdateWorker>(
|
|
||||||
repeatInterval = 1, repeatIntervalTimeUnit = TimeUnit.MINUTES
|
|
||||||
).build()
|
|
||||||
|
|
||||||
workManager.enqueueUniquePeriodicWork(
|
|
||||||
"checkUpdateWorker", ExistingPeriodicWorkPolicy.KEEP, periodicRequest
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun uploadLogs() = viewModelScope.launch {
|
fun uploadLogs() = viewModelScope.launch {
|
||||||
uploadLogs.postValue(Result.Loading())
|
uploadLogs.postValue(Result.Loading())
|
||||||
val logFile = logFileManager.createLogFile().let { file ->
|
val logFile = logFileManager.createLogFile().let { file ->
|
||||||
@@ -253,24 +232,7 @@ class HemoCubeViewModel @Inject constructor(
|
|||||||
Log.i("Testdb", "Data uploaded to Firestore successfully")
|
Log.i("Testdb", "Data uploaded to Firestore successfully")
|
||||||
fireBaseUpload.postValue("Success")
|
fireBaseUpload.postValue("Success")
|
||||||
testDetails.localFlag = true
|
testDetails.localFlag = true
|
||||||
uploadResult(
|
uploadResult(MolbioV2ResultRequest(listOf(MolbioV2Result(rawData = testDetails))))
|
||||||
MolbioV2ResultRequest(
|
|
||||||
listOf(
|
|
||||||
MolbioV2Result(
|
|
||||||
rawData = testDetails,
|
|
||||||
analysisId = testDetails._id,
|
|
||||||
analysisDate = testDetails.testTime,
|
|
||||||
analysisStatus = testDetails.classificationResult,
|
|
||||||
thresholds = Constants.BUFFER_INTENSITY_THRESHOLDS[testDetails.deviceId].toString(),
|
|
||||||
interpretation = testDetails.classificationResult,
|
|
||||||
testId = testDetails._id,
|
|
||||||
testTime = testDetails.testTime,
|
|
||||||
collectionTime = testDetails.testTime,
|
|
||||||
expiryTime = testDetails.testTime,
|
|
||||||
)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
hemoCubeDao.insertAll(testDetails)
|
hemoCubeDao.insertAll(testDetails)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -336,7 +298,7 @@ class HemoCubeViewModel @Inject constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun updateMolbioFlag(userId: String) = viewModelScope.launch {
|
fun updateMolbioFlag(userId: String) = viewModelScope.launch {
|
||||||
hemoCubeDao.updateMolbioFlag(id = userId, true)
|
hemoCubeDao.updateFieldById(id = userId, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun addUser(userData: HemoCubeTestData) = viewModelScope.launch {
|
fun addUser(userData: HemoCubeTestData) = viewModelScope.launch {
|
||||||
|
|||||||
Reference in New Issue
Block a user