Removed
This commit is contained in:
@@ -15,9 +15,6 @@
|
|||||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||||
<uses-feature android:name="android.hardware.usb.host" />
|
<uses-feature android:name="android.hardware.usb.host" />
|
||||||
<uses-permission android:name="android.permission.USB_PERMISSION" />
|
<uses-permission android:name="android.permission.USB_PERMISSION" />
|
||||||
|
|
||||||
<uses-permission android:name="android.permission.USB_PERMISSION" />
|
|
||||||
|
|
||||||
<application
|
<application
|
||||||
android:name="com.example.hpostesting.HPOSTestingApplication"
|
android:name="com.example.hpostesting.HPOSTestingApplication"
|
||||||
android:allowBackup="true"
|
android:allowBackup="true"
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ object DataHolder {
|
|||||||
val wavelengthToPixelArray = ArrayList<Double>()
|
val wavelengthToPixelArray = ArrayList<Double>()
|
||||||
val intensityReferenceArray = ArrayList<Double>()
|
val intensityReferenceArray = ArrayList<Double>()
|
||||||
var selectedTest: UserData? = null
|
var selectedTest: UserData? = null
|
||||||
var SelectTestType: HemoCubeTestData? = null
|
var HomocubeTestType: HemoCubeTestData? = null
|
||||||
|
|
||||||
var kitSerial: String = ""
|
var kitSerial: String = ""
|
||||||
|
|
||||||
|
|||||||
@@ -18,5 +18,7 @@ data class HemoCubeTestData(
|
|||||||
var deviceSerialNumber: String = "",
|
var deviceSerialNumber: String = "",
|
||||||
var kitSerial: String = "",
|
var kitSerial: String = "",
|
||||||
var reportPath: String = "",
|
var reportPath: String = "",
|
||||||
var resultRatio: Double? = null
|
var resultRatio: Double? = null,
|
||||||
|
var led1: Double? = null,
|
||||||
|
var led2: Double? = null
|
||||||
)
|
)
|
||||||
@@ -68,8 +68,8 @@ class HemoCubeFragment : Fragment() {
|
|||||||
|
|
||||||
hemoCubeViewModel.networkStatusLiveData.observe(viewLifecycleOwner) { isNetworkAvailable ->
|
hemoCubeViewModel.networkStatusLiveData.observe(viewLifecycleOwner) { isNetworkAvailable ->
|
||||||
apply {
|
apply {
|
||||||
kitSerial = DataHolder.SelectTestType?.kitSerial
|
kitSerial = DataHolder.HomocubeTestType?.kitSerial
|
||||||
testTime = DataHolder.SelectTestType?.testTime
|
testTime = DataHolder.HomocubeTestType?.testTime
|
||||||
isOnline = isNetworkAvailable
|
isOnline = isNetworkAvailable
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -122,38 +122,46 @@ class HemoCubeFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun parseUsbData(data: String) {
|
||||||
|
val bufferPattern = """ok (Green|Blue) B Intensity: (\d+\.\d+)""".toRegex()
|
||||||
|
val samplePattern = """ok (Green|Blue) Intensity: (\d+\.\d+)""".toRegex()
|
||||||
|
val avgPattern = """ok Avg (Green|Blue): (\d+\.\d+)""".toRegex()
|
||||||
|
val resultPattern = """ok Result: (\d+\.\d+)""".toRegex()
|
||||||
|
|
||||||
private fun readUsbData() {
|
var greenBIntensity: Double? = null
|
||||||
// Perform USB data reading and parsing here
|
var blueBIntensity: Double? = null
|
||||||
val buffer = ByteArray(256) // Adjust the buffer size as per your data
|
var greenIntensity: Double? = null
|
||||||
val endpoint = usbDevice?.getInterface(0)?.getEndpoint(0)
|
var blueIntensity: Double? = null
|
||||||
|
var avgGreen: Double? = null
|
||||||
|
var avgBlue: Double? = null
|
||||||
|
var result: Double? = null
|
||||||
|
|
||||||
endpoint?.let {
|
for (line in data.split("\n")) {
|
||||||
val bytesRead = usbConnection?.bulkTransfer(it, buffer, buffer.size, TIMEOUT)
|
when {
|
||||||
if (bytesRead != null && bytesRead > 0) {
|
bufferPattern.matches(line) -> {
|
||||||
val usbData = String(buffer, 0, bytesRead, Charsets.UTF_8)
|
val (color, intensity) = bufferPattern.find(line)!!.destructured
|
||||||
val parsedData = parseUsbData(usbData)
|
if (color == "Green") greenBIntensity = intensity.toDouble()
|
||||||
displayValuesOnTextView(parsedData)
|
else blueBIntensity = intensity.toDouble()
|
||||||
} else {
|
}
|
||||||
// Handle USB data read error
|
samplePattern.matches(line) -> {
|
||||||
}
|
val (color, intensity) = samplePattern.find(line)!!.destructured
|
||||||
}
|
if (color == "Green") greenIntensity = intensity.toDouble()
|
||||||
}
|
else blueIntensity = intensity.toDouble()
|
||||||
|
}
|
||||||
private fun parseUsbData(data: String): Map<String, String> {
|
avgPattern.matches(line) -> {
|
||||||
val lines = data.split("\n")
|
val (color, avg) = avgPattern.find(line)!!.destructured
|
||||||
val parsedData = mutableMapOf<String, String>()
|
if (color == "Green") avgGreen = avg.toDouble()
|
||||||
|
else avgBlue = avg.toDouble()
|
||||||
for (line in lines) {
|
}
|
||||||
val labelAndValue = line.split(":")
|
resultPattern.matches(line) -> {
|
||||||
if (labelAndValue.size == 2) {
|
result = resultPattern.find(line)!!.destructured.component1().toDouble()
|
||||||
val label = labelAndValue[0].trim()
|
}
|
||||||
val value = labelAndValue[1].trim()
|
|
||||||
parsedData[label] = value
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return parsedData
|
Log.d("greenBuffer", greenBIntensity.toString())
|
||||||
|
Log.d("greenBuffer", blueIntensity.toString())
|
||||||
|
Log.d("greenBuffer", blueBIntensity.toString())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -166,8 +174,6 @@ class HemoCubeFragment : Fragment() {
|
|||||||
append("$label: $value\n")
|
append("$label: $value\n")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Display the complete data accumulated so far
|
|
||||||
fullReadOutput.append(resultText)
|
fullReadOutput.append(resultText)
|
||||||
textView.text = fullReadOutput.toString()
|
textView.text = fullReadOutput.toString()
|
||||||
}
|
}
|
||||||
@@ -181,6 +187,7 @@ class HemoCubeFragment : Fragment() {
|
|||||||
data?.let {
|
data?.let {
|
||||||
val stringData = String(it)
|
val stringData = String(it)
|
||||||
fullReadOutput.append(stringData)
|
fullReadOutput.append(stringData)
|
||||||
|
|
||||||
binding.tvSubtitle4.text = fullReadOutput
|
binding.tvSubtitle4.text = fullReadOutput
|
||||||
resultRatio = fullReadOutput.toString()
|
resultRatio = fullReadOutput.toString()
|
||||||
val data = parseUsbData(fullReadOutput.toString())
|
val data = parseUsbData(fullReadOutput.toString())
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ class HemoCubeViewModel @Inject constructor(
|
|||||||
) : ViewModel() {
|
) : ViewModel() {
|
||||||
var isServiceConnected = false
|
var isServiceConnected = false
|
||||||
val progressBar = MutableLiveData(false)
|
val progressBar = MutableLiveData(false)
|
||||||
val testDetails = DataHolder.SelectTestType
|
val testDetails = DataHolder.HomocubeTestType
|
||||||
val testDetailuser = DataHolder.selectedTest
|
val testDetailuser = DataHolder.selectedTest
|
||||||
private val _networkStatusLiveData = NetworkStatusLiveData(context)
|
private val _networkStatusLiveData = NetworkStatusLiveData(context)
|
||||||
val networkStatusLiveData: LiveData<Boolean>
|
val networkStatusLiveData: LiveData<Boolean>
|
||||||
|
|||||||
@@ -51,7 +51,7 @@
|
|||||||
android:id="@+id/tv_subtitle4"
|
android:id="@+id/tv_subtitle4"
|
||||||
style="@style/title2"
|
style="@style/title2"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="70dp"
|
||||||
android:layout_marginHorizontal="24dp"
|
android:layout_marginHorizontal="24dp"
|
||||||
android:layout_marginTop="16dp"
|
android:layout_marginTop="16dp"
|
||||||
android:hint="Result"
|
android:hint="Result"
|
||||||
|
|||||||
Reference in New Issue
Block a user