package llc.arma.ble.domain.usecase

import kotlinx.coroutines.flow.Flow
import llc.arma.ble.domain.Result
import llc.arma.ble.domain.common.BleException
import llc.arma.ble.domain.model.Ble
import llc.arma.ble.domain.repository.BleRepository
import javax.inject.Inject

class GetAccelerometerMeasureBySerialFlow @Inject constructor(
    private val bleRepository: BleRepository
) {

    operator fun invoke(
        serial: String,
        accelScale: AccelScale,
        accelMode: AccelViewMode,
        fftAxis: FftAxis,
        fftMode: FftViewMode,
        frequency: FftFrequency
    ): Flow<Result<Ble.Accelerometer.RealtimePoint, BleException>> {

        return bleRepository.getAccelerometerMeasureBySerialFlow(serial, accelScale, accelMode, fftAxis, fftMode, frequency)

    }

}

enum class AccelViewMode {
    ACCELERATION, PEAK_ACCELERATION, RMS, VIBRATION, ANGLE, ROTATIONS;

    companion object
}

enum class AccelScale(val k: Int) {

    S_2(2_000), S_4(4_000), S_8(8_000), S_16(16_000);

    companion object

}