package llc.arma.ble.domain.model

import llc.arma.ble.domain.usecase.AccelScale
import llc.arma.ble.domain.usecase.AccelViewMode

sealed class Ble(
    val info: BleInfo
) {

    class Accelerometer(
        info: BleInfo,
        val state: BleState,
        val accelerometerState: AccelerometerState
    ): Ble(info) {

        sealed class History {

            data class Enabled(
                val scale: AccelScale,
                val mode: AccelViewMode,
                val detailed: Boolean
            ) : History()

            object Disabled : History()

        }

        data class WriteRequest(
            val tx: BleState.TX?,
            val saveHistory: History?,
            val historyInterval: Long?
        )

        sealed class HistoryPoint {

            class Vibration (
                val date: Long,
                val value: Float
            ) : HistoryPoint()

            class Accelerate (
                val date: Long,
                val x: Float,
                val y: Float,
                val z: Float
            ) : HistoryPoint()

            class Angle (
                val date: Long,
                val x: Float,
                val y: Float,
                val z: Float
            ) : HistoryPoint()

        }

        class MeasurePoint (
            val frequency: Long,
            val value: Float
        )

        data class AccelerometerState(
            val saveHistory: History,
            val historyInterval: Long
        )

    }

    class Beacon(
        info: BleInfo,
        val state: BleState
    ) : Ble(info){

        data class WriteRequest(
            val tx: BleState.TX?
        )

    }

    class Thermometer(
        info: BleInfo,
        val state: BleState,
        val thermometerState: ThermometerState
    ) : Ble(info) {

        class MeasurePoint(
            val date: Long,
            val value: Float
        )

        data class ThermometerState(
            val temperature: Float,
            val saveHistory: Boolean,
            val historyInterval: Long
        )

        data class WriteRequest(
            val tx: BleState.TX?,
            val saveHistory: Boolean?,
            val historyInterval: Long?
        )

    }

    data class BleState(
        val tx: TX
    ){

        enum class TX {
            MINUS_40, MINUS_20, MINUS_16, MINUS_12, MINUS_8, MINUS_4, ZERO, PLUS_3, PLUS_4
        }

    }

}