fix pipeline

This commit is contained in:
Pritimay Sarkar
2024-02-16 09:48:20 +05:30
parent b3726d8a9b
commit 7986f22da1
3 changed files with 78 additions and 91 deletions

View File

@@ -157,20 +157,13 @@ class HomeFragment : Fragment() {
thresholds = Constants.BUFFER_INTENSITY_THRESHOLDS[userData.deviceId].toString(), thresholds = Constants.BUFFER_INTENSITY_THRESHOLDS[userData.deviceId].toString(),
interpretation = userData.classificationResult, interpretation = userData.classificationResult,
testId = userData._id, testId = userData._id,
<<<<<<< HEAD
testTime = "2024-02-08 16:33:56",//userData.testTime,
=======
testTime = "2024-02-08 16:33:56",//userData.testTime, testTime = "2024-02-08 16:33:56",//userData.testTime,
>>>>>>> origin/dev-Issue-Fix-Branch
collectionTime = "2024-02-08 16:33:56",//userData.testTime, collectionTime = "2024-02-08 16:33:56",//userData.testTime,
expiryTime = "2024-02-08 16:33:56"//userData.testTime, expiryTime = "2024-02-08 16:33:56"//userData.testTime,
) )
) )
<<<<<<< HEAD
} }
if (!userData.molbioFlag && isTokenAvailable && Constants.MOLBIO_INTEGRATION) { if (!userData.molbioFlag && isTokenAvailable && Constants.MOLBIO_INTEGRATION) {
=======
>>>>>>> origin/dev-Issue-Fix-Branch
userData.molbioFlag = true userData.molbioFlag = true
hemoCubeViewModel.uploadResult(resultList) hemoCubeViewModel.uploadResult(resultList)
} }

View File

@@ -65,11 +65,11 @@ class DiagnosticsFragment : Fragment() {
binding.btnSubmit.setOnClickListener { binding.btnSubmit.setOnClickListener {
binding.btnSubmit.visibility = View.GONE binding.btnSubmit.visibility = View.GONE
runDeviceDiagnostics() runDeviceDiagnostics()
val batteryLevel = diagnosticsViewModel.getBatteryLevel().toString() val batteryLevel = "" //diagnosticsViewModel.getBatteryLevel().toString()
val batteryCapacity = context?.let { diagnosticsViewModel.getBatteryCapacity(it).toString() } val batteryCapacity = "" //context?.let { diagnosticsViewModel.getBatteryCapacity(it).toString() }
val batteryMaxCapacity = context?.let { diagnosticsViewModel.getBatteryMaxCapacity(it).toString() } val batteryMaxCapacity = "" //context?.let { diagnosticsViewModel.getBatteryMaxCapacity(it).toString() }
val batteryTemperature = diagnosticsViewModel.getBatteryTemperature().toString() val batteryTemperature = "" //diagnosticsViewModel.getBatteryTemperature().toString()
val batteryVoltage = context?.let { diagnosticsViewModel.getBatteryVoltage(it).toString() } val batteryVoltage = "" // context?.let { diagnosticsViewModel.getBatteryVoltage(it).toString() }
val additionalDetails = AdditionalDetails( val additionalDetails = AdditionalDetails(
batteryLevel = batteryLevel, batteryLevel = batteryLevel,

View File

@@ -1,9 +1,5 @@
package com.example.hpostesting.presentation.diagnostics package com.example.hpostesting.presentation.diagnostics
import android.content.Context
import android.content.Intent
import android.content.IntentFilter
import android.os.BatteryManager
import androidx.lifecycle.MutableLiveData import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope import androidx.lifecycle.viewModelScope
@@ -11,8 +7,6 @@ import com.example.hpostesting.data.Result
import com.example.hpostesting.data.model.Response import com.example.hpostesting.data.model.Response
import com.example.hpostesting.data.model.devicediagnostics.DeviceDiagnosticsRequest import com.example.hpostesting.data.model.devicediagnostics.DeviceDiagnosticsRequest
import com.example.hpostesting.data.model.devicediagnostics.DeviceDiagnosticsResponse import com.example.hpostesting.data.model.devicediagnostics.DeviceDiagnosticsResponse
import com.example.hpostesting.data.model.deviceprovision.DeviceProvisionRequest
import com.example.hpostesting.data.model.deviceprovision.DeviceProvisionResponse
import com.example.hpostesting.data.model.diagnostics.DiagnosticsData import com.example.hpostesting.data.model.diagnostics.DiagnosticsData
import com.example.hpostesting.data.model.patient.DeviceData import com.example.hpostesting.data.model.patient.DeviceData
import com.example.hpostesting.data.repository.Repository import com.example.hpostesting.data.repository.Repository
@@ -22,8 +16,8 @@ import javax.inject.Inject
@HiltViewModel @HiltViewModel
class DiagnosticsViewModel @Inject constructor( class DiagnosticsViewModel @Inject constructor(
private val respository: Repository, private val repository: Repository,
context: Context, // context: Context,
) : ViewModel() { ) : ViewModel() {
var isServiceConnected = false var isServiceConnected = false
val progressBar = MutableLiveData(false) val progressBar = MutableLiveData(false)
@@ -32,10 +26,10 @@ class DiagnosticsViewModel @Inject constructor(
val deviceData = MutableLiveData<DeviceData?>() val deviceData = MutableLiveData<DeviceData?>()
val fireBaseUpload = MutableLiveData<String>() val fireBaseUpload = MutableLiveData<String>()
val deviceDiagnosticsResponse = MutableLiveData<com.example.hpostesting.data.Result<DeviceDiagnosticsResponse>>() val deviceDiagnosticsResponse = MutableLiveData<com.example.hpostesting.data.Result<DeviceDiagnosticsResponse>>()
private val batteryStatus: Intent? = // private val batteryStatus: Intent? =
IntentFilter(Intent.ACTION_BATTERY_CHANGED).let { ifilter -> // IntentFilter(Intent.ACTION_BATTERY_CHANGED).let { ifilter ->
context.registerReceiver(null, ifilter) // context.registerReceiver(null, ifilter)
} // }
fun addDiagnosticsDataToDb(data: DiagnosticsData) { fun addDiagnosticsDataToDb(data: DiagnosticsData) {
viewModelScope.launch { viewModelScope.launch {
try { try {
@@ -68,71 +62,71 @@ class DiagnosticsViewModel @Inject constructor(
} }
fun getBatteryLevel(): Float? { // fun getBatteryLevel(): Float? {
val batteryPct: Float? = batteryStatus?.let { intent -> // val batteryPct: Float? = batteryStatus?.let { intent ->
val level: Int = // val level: Int =
intent.getIntExtra( // intent.getIntExtra(
BatteryManager.EXTRA_LEVEL, // BatteryManager.EXTRA_LEVEL,
-1 // -1
) // )
val scale: Int = // val scale: Int =
intent.getIntExtra( // intent.getIntExtra(
BatteryManager.EXTRA_SCALE, // BatteryManager.EXTRA_SCALE,
-1 // -1
) // )
level * 100 / scale.toFloat() // level * 100 / scale.toFloat()
} // }
//
return batteryPct // return batteryPct
} // }
//
fun getBatteryTemperature(): Float? { // fun getBatteryTemperature(): Float? {
val batteryTemp: Float? = batteryStatus?.let { intent -> // val batteryTemp: Float? = batteryStatus?.let { intent ->
val temperature = intent.getIntExtra( // val temperature = intent.getIntExtra(
BatteryManager.EXTRA_TEMPERATURE, // BatteryManager.EXTRA_TEMPERATURE,
0 // 0
) // )
temperature.toFloat() / 10 // temperature.toFloat() / 10
} // }
//
return batteryTemp // return batteryTemp
} // }
//
fun getBatteryVoltage(context: Context): Float { // fun getBatteryVoltage(context: Context): Float {
val batteryIntent = // val batteryIntent =
context.registerReceiver( // context.registerReceiver(
null, // null,
IntentFilter(Intent.ACTION_BATTERY_CHANGED) // IntentFilter(Intent.ACTION_BATTERY_CHANGED)
) // )
val voltage = batteryIntent?.getIntExtra( // val voltage = batteryIntent?.getIntExtra(
BatteryManager.EXTRA_VOLTAGE, // BatteryManager.EXTRA_VOLTAGE,
0 // 0
) ?: 0 // ) ?: 0
//
// milli-volts to volts // // milli-volts to volts
return voltage.toFloat() / 1000 // return voltage.toFloat() / 1000
} // }
//
//
fun getBatteryCapacity(context: Context): Int { // fun getBatteryCapacity(context: Context): Int {
val batteryManager = // val batteryManager =
context.getSystemService(Context.BATTERY_SERVICE) as BatteryManager // context.getSystemService(Context.BATTERY_SERVICE) as BatteryManager
val currentCapacity = // val currentCapacity =
batteryManager.getIntProperty(BatteryManager.BATTERY_PROPERTY_CHARGE_COUNTER) // batteryManager.getIntProperty(BatteryManager.BATTERY_PROPERTY_CHARGE_COUNTER)
//
return currentCapacity // return currentCapacity
} // }
//
fun getBatteryMaxCapacity(context: Context): Float { // fun getBatteryMaxCapacity(context: Context): Float {
val batteryManager = context.getSystemService(Context.BATTERY_SERVICE) as BatteryManager // val batteryManager = context.getSystemService(Context.BATTERY_SERVICE) as BatteryManager
val designCapacity = // val designCapacity =
batteryManager.getIntProperty(BatteryManager.BATTERY_PROPERTY_CAPACITY) // batteryManager.getIntProperty(BatteryManager.BATTERY_PROPERTY_CAPACITY)
val currentCapacity = // val currentCapacity =
batteryManager.getIntProperty(BatteryManager.BATTERY_PROPERTY_CHARGE_COUNTER) // batteryManager.getIntProperty(BatteryManager.BATTERY_PROPERTY_CHARGE_COUNTER)
//
// Calculate the estimated maximum battery capacity in mAh // // Calculate the estimated maximum battery capacity in mAh
val maxCapacity = currentCapacity.toFloat() / designCapacity.toFloat() * 100 // val maxCapacity = currentCapacity.toFloat() / designCapacity.toFloat() * 100
//
return maxCapacity // return maxCapacity
} // }
} }