All Downloads are FREE. Search and download functionalities are using the official Maven repository.

main.com.enniovisco.checking.Checker.kt Maven / Gradle / Ivy

The newest version!
package com.enniovisco.checking

import com.enniovisco.space.*
import io.github.moonlightsuite.moonlight.core.formula.*
import io.github.moonlightsuite.moonlight.core.space.*
import io.github.moonlightsuite.moonlight.domain.*
import io.github.moonlightsuite.moonlight.formula.*
import io.github.moonlightsuite.moonlight.offline.monitoring.*
import io.github.moonlightsuite.moonlight.offline.signal.*
import io.github.moonlightsuite.moonlight.space.*
import java.util.function.Function

typealias Monitor = SpatialTemporalMonitoring
typealias Interpretation = Function>

/**
 *
 */
class Checker(
    private val grid: Grid,
    private val data: List>,
    elements: Map Boolean>
) {
    private val locationService = StaticLocationService(grid.model)

    private val signal = TraceBuilder(grid, data)
        .useMetadata()
        .useElements(elements)
        .build()

    private val dist = mapOf,
            DistanceStructure>>(
        Pair("all", Function { grid.distance() }),
        Pair("base", Function { grid.distance(1) })
    )

    val atoms = elems(elements.map { it.key })

    fun check(spec: Formula): SpatialTemporalSignal {
        if (data.isEmpty()) {
            throw IllegalArgumentException("Empty data passed for the trace.")
        }
        val m = Monitor(atoms, dist, BooleanDomain(), true)
        return m.monitor(spec).monitor(locationService, signal)
    }

    private fun elems(elems: List):
            Map>> {
        val atoms = mutableMapOf>>(
            "screen" to Function { Function { it[0] } }
        )
        for (i in elems.indices) {
            atoms[elems[i]] = Function { Function { it[i + 1] } }
        }
        return atoms
    }


}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy