package com.manalejandro.odb2bluetooth.data.database.entities

import androidx.room.ColumnInfo
import androidx.room.Entity
import androidx.room.ForeignKey
import androidx.room.Index
import androidx.room.PrimaryKey

/**
 * Entity representing an OBD signal (PID command) in the database
 */
@Entity(
    tableName = "obd_signals",
    foreignKeys = [
        ForeignKey(
            entity = Model::class,
            parentColumns = ["id"],
            childColumns = ["model_id"],
            onDelete = ForeignKey.CASCADE
        )
    ],
    indices = [Index("model_id")]
)
data class ObdSignal(
    @PrimaryKey(autoGenerate = true)
    val id: Int = 0,
    @ColumnInfo(name = "model_id")
    val modelId: Int,
    @ColumnInfo(name = "signal_id")
    val signalId: String,
    val name: String,
    val path: String?,
    val unit: String?,
    val description: String?,
    val header: String?,
    val command: String?,
    val frequency: Double?,
    @ColumnInfo(name = "min_value")
    val minValue: Double?,
    @ColumnInfo(name = "max_value")
    val maxValue: Double?
)

