ThermostatAgent

open class ThermostatAgent : Thread

Java counterpart of it.unibo.tuprolog.examples.solve.ThermostatAgentKt: a reactive agent whose control loop is a Prolog program, while its get_temp/1 sensor and push/1 actuator primitives are plain Java objects, showing how the :solve public API reads from Java (e.g. going through request.getUnificator().mgu(...) rather than the mgu extension available in Kotlin).

The agent runs as a Thread: its control logic is loaded from the bundled thermostat.pl resource (templated with the cold/hot thresholds passed to the constructor) and solved once via it.unibo.tuprolog.solve.Solver, printing whether the target temperature range was reached, the logic program failed, or an exception was raised.

Constructors

Link copied to clipboard
constructor(name: String, coldThreshold: Int, hotThreshold: Int, temperature: Int)

Properties

Link copied to clipboard
Link copied to clipboard
val MAX_PRIORITY: Int = 10
Link copied to clipboard
val MIN_PRIORITY: Int = 1
Link copied to clipboard
open var name: String
Link copied to clipboard
Link copied to clipboard
open val temperature: Int

Functions

Link copied to clipboard
open fun activeCount(): Int
Link copied to clipboard
Link copied to clipboard
open fun countStackFrames(): Int
Link copied to clipboard
open fun currentThread(): Thread
Link copied to clipboard
open fun dumpStack()
Link copied to clipboard
open fun enumerate(tarray: Array<Thread>): Int
Link copied to clipboard
Link copied to clipboard
open fun getId(): Long
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open fun holdsLock(p: Any): Boolean
Link copied to clipboard
open fun interrupt()
Link copied to clipboard
open fun interrupted(): Boolean
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
fun join(duration: Duration): Boolean
fun join(millis: Long)
Link copied to clipboard
open fun main(args: Array<String>)
Entry point spawning a ThermostatAgent with a cold threshold of 20, a hot threshold of 24, and a starting temperature of 30, then waiting for it to reach a stable temperature before the JVM exits.
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open fun onSpinWait()
Link copied to clipboard
fun resume()
Link copied to clipboard
open fun run()
Parses the templated thermostat.pl program, builds a solver registering get_temp/1 and push/1 under the libs.agency.thermostat library alias (with variable tracking enabled so bound variables remain visible), and solves the start/0 goal once, printing the outcome to standard output.
Link copied to clipboard
Link copied to clipboard
fun setPriority(newPriority: Int)
Link copied to clipboard
open fun sleep(millis: Long)
Link copied to clipboard
open fun start()
Link copied to clipboard
Link copied to clipboard
fun stop()
Link copied to clipboard
fun suspend()
Link copied to clipboard
fun threadId(): Long
Link copied to clipboard
open fun toString(): String
Link copied to clipboard
open fun yield()