Added methods and members to store detailed test csv and log Data.
This commit is contained in:
@@ -12,6 +12,9 @@ import com.example.refactoredapp.domain.ResultCalculationWithMaxImpl
|
|||||||
import com.example.refactoredapp.domain.SaveRawData
|
import com.example.refactoredapp.domain.SaveRawData
|
||||||
import com.example.refactoredapp.domain.TestRightResultCalculation
|
import com.example.refactoredapp.domain.TestRightResultCalculation
|
||||||
import java.lang.Exception
|
import java.lang.Exception
|
||||||
|
import java.text.SimpleDateFormat
|
||||||
|
import java.util.*
|
||||||
|
import kotlin.collections.ArrayList
|
||||||
import kotlin.math.log10
|
import kotlin.math.log10
|
||||||
import kotlin.math.pow
|
import kotlin.math.pow
|
||||||
|
|
||||||
@@ -42,6 +45,7 @@ class TestRightViewModel : ViewModel() {
|
|||||||
|
|
||||||
val wavelengthToAbsorbance = ArrayList<ArrayList<Double>>()
|
val wavelengthToAbsorbance = ArrayList<ArrayList<Double>>()
|
||||||
|
|
||||||
|
val calculationVariableList = ArrayList<CalculationVariableForTest>()
|
||||||
|
|
||||||
fun mapDeviceConstants(string: String) {
|
fun mapDeviceConstants(string: String) {
|
||||||
Log.d(TAG, "mapDeviceConstants() called")
|
Log.d(TAG, "mapDeviceConstants() called")
|
||||||
@@ -71,13 +75,13 @@ class TestRightViewModel : ViewModel() {
|
|||||||
DataHolder.wavelengthToPixelArray.clear()
|
DataHolder.wavelengthToPixelArray.clear()
|
||||||
if (DataHolder.deviceConstant != null) {
|
if (DataHolder.deviceConstant != null) {
|
||||||
for (x in 1..Constants.TEST_RIGHT_TOTAL_PIXEL) {
|
for (x in 1..Constants.TEST_RIGHT_TOTAL_PIXEL) {
|
||||||
val index = x - 1
|
// val index = x - 1
|
||||||
val wavelength: Double =
|
val wavelength: Double =
|
||||||
(DataHolder.deviceConstant!!.a.toDouble() * (index.toDouble()
|
(DataHolder.deviceConstant!!.a.toDouble() * (x.toDouble()
|
||||||
.pow((3).toDouble()))) +
|
.pow((3).toDouble()))) +
|
||||||
(DataHolder.deviceConstant!!.b.toDouble() * (index.toDouble()
|
(DataHolder.deviceConstant!!.b.toDouble() * (x.toDouble()
|
||||||
.pow((2).toDouble()))) +
|
.pow((2).toDouble()))) +
|
||||||
(DataHolder.deviceConstant!!.c.toDouble() * index) +
|
(DataHolder.deviceConstant!!.c.toDouble() * x) +
|
||||||
(DataHolder.deviceConstant!!.d.toDouble())
|
(DataHolder.deviceConstant!!.d.toDouble())
|
||||||
|
|
||||||
DataHolder.wavelengthToPixelArray.add(wavelength)
|
DataHolder.wavelengthToPixelArray.add(wavelength)
|
||||||
@@ -94,6 +98,18 @@ class TestRightViewModel : ViewModel() {
|
|||||||
if (isReference) DataHolder.intensityReferenceArray.clear()
|
if (isReference) DataHolder.intensityReferenceArray.clear()
|
||||||
else intensitySampleArray.clear()
|
else intensitySampleArray.clear()
|
||||||
|
|
||||||
|
// Todo: Remove
|
||||||
|
var fileName: String =
|
||||||
|
"test_log_" + SimpleDateFormat("ddMMyyyy HHmmss").format(Date()) + ".txt"
|
||||||
|
fileName = if (isReference) {
|
||||||
|
"reference_$fileName"
|
||||||
|
} else {
|
||||||
|
"sample_$fileName"
|
||||||
|
}
|
||||||
|
saveLogTest(DataHolder.appFolderPath, fileName, isReference, fullString)
|
||||||
|
|
||||||
|
Log.d(TAG, fullString)
|
||||||
|
|
||||||
val listOfString = fullString.split("\n")
|
val listOfString = fullString.split("\n")
|
||||||
|
|
||||||
// Log.d(TAG, "inside mapIntensityValues() -> isReference = $isReference")
|
// Log.d(TAG, "inside mapIntensityValues() -> isReference = $isReference")
|
||||||
@@ -107,7 +123,7 @@ class TestRightViewModel : ViewModel() {
|
|||||||
/* Removing trailing spaces and "Buf" from the string then taking lhs & rhs of ':' */
|
/* Removing trailing spaces and "Buf" from the string then taking lhs & rhs of ':' */
|
||||||
val numbers = line.trim()
|
val numbers = line.trim()
|
||||||
.substring(3).split(":")
|
.substring(3).split(":")
|
||||||
Log.d(TAG, line)
|
// Log.d(TAG, line)
|
||||||
if (numbers.size >= 2) {
|
if (numbers.size >= 2) {
|
||||||
// val temp = ArrayList<Double>(2)
|
// val temp = ArrayList<Double>(2)
|
||||||
// temp.add(numbers[0].toDouble())
|
// temp.add(numbers[0].toDouble())
|
||||||
@@ -164,6 +180,7 @@ class TestRightViewModel : ViewModel() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
wavelengthToAbsorbance.clear()
|
wavelengthToAbsorbance.clear()
|
||||||
|
|
||||||
// Index pointing to last of the array
|
// Index pointing to last of the array
|
||||||
// var indexInIntensityArrays = intensityReferenceArray.size - 1
|
// var indexInIntensityArrays = intensityReferenceArray.size - 1
|
||||||
// for ((index,wavelength) in wavelengthToPixelArray.withIndex()) {
|
// for ((index,wavelength) in wavelengthToPixelArray.withIndex()) {
|
||||||
@@ -201,7 +218,16 @@ class TestRightViewModel : ViewModel() {
|
|||||||
temp.add(absorbance)
|
temp.add(absorbance)
|
||||||
wavelengthToAbsorbance.add(temp)
|
wavelengthToAbsorbance.add(temp)
|
||||||
|
|
||||||
// indexInIntensityArrays--
|
|
||||||
|
// Todo: Remove
|
||||||
|
val calculationVariableForTest = CalculationVariableForTest()
|
||||||
|
calculationVariableForTest.pixelNo = index + 1
|
||||||
|
calculationVariableForTest.invertedPixelNo = invertedPixelIndex+1 // 0-based indexing
|
||||||
|
calculationVariableForTest.wavelength = wavelength
|
||||||
|
calculationVariableForTest.I0 = i0
|
||||||
|
calculationVariableForTest.I = i1
|
||||||
|
calculationVariableForTest.absorbance = absorbance
|
||||||
|
calculationVariableList.add(calculationVariableForTest)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -222,8 +248,21 @@ class TestRightViewModel : ViewModel() {
|
|||||||
SaveRawData().saveCsv(folderPath, filename, wavelengthToAbsorbance)
|
SaveRawData().saveCsv(folderPath, filename, wavelengthToAbsorbance)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun saveCsvForTesting(folderPath: String, filename: String) {
|
||||||
|
SaveRawDataTest().saveCsv(folderPath, filename, calculationVariableList)
|
||||||
|
}
|
||||||
|
|
||||||
fun saveLog(appFolderPath: String, fileName: String) {
|
fun saveLog(appFolderPath: String, fileName: String) {
|
||||||
SaveRawData().saveLog(appFolderPath, fileName, calculationData)
|
SaveRawData().saveLog(appFolderPath, fileName, calculationData)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun saveLogTest(
|
||||||
|
appFolderPath: String,
|
||||||
|
fileName: String,
|
||||||
|
isReference: Boolean,
|
||||||
|
fullString: String
|
||||||
|
) {
|
||||||
|
SaveRawDataTest().saveLog(appFolderPath, fileName, isReference, fullString)
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user