NRF Guide

Référence

ModControl

Baux de recette, commandes temporaires et réponses du mod.

Contexte d’utilisation

ModulePackageSource SDK
Kotlin/JVMfr.nimby.sdkkotlin-client/src/main/kotlin/fr/nimby/sdk/ModControl.kt

Signatures extraites de la version 0.8.0-alpha.1. Les paramètres, leurs valeurs par défaut et les propriétés de constructeur sont conservés. Les corps des méthodes ne font pas partie de cette référence.

ControlOperation

fr.nimby.sdk · class
enum class ControlOperation(val code: Int) {
Status(0), Acquire(1), Renew(2), Release(3), ForceSignal(4), RestoreSignal(5),
    Train(6), RestoreTrain(7), Setting(8), RestoreSetting(9), Clear(10), ReadSignal(11), ReadTrain(12)
}

Protocol values only; aspect codes and setting indices belong to the mod.

TrainControlMode

fr.nimby.sdk · class
enum class TrainControlMode(val code: Int) {
SpeedLimit(0), PhysicalClearance(1), Stop(2)
}

TrainControlState

fr.nimby.sdk · class
enum class TrainControlState {
Absent, AwaitingExit, Active, Completed, Cancelled
}

ControlRequest

fr.nimby.sdk · class
data class ControlRequest(
    val operation: ControlOperation, val owner: Long = 0, val generation: Long = 0,
    val leaseMillis: Int = 0, val objectId: Long = 0, val exitSignal: Long = 0,
    val speedMps: Double = 0.0, val mode: TrainControlMode = TrainControlMode.SpeedLimit,
    val releaseByRear: Boolean = false, val value: Int = 0, val settingIndex: Int = 0
)

ControlResponse

fr.nimby.sdk · class
data class ControlResponse(
    val capabilities: Int, val generation: Long, val remainingMillis: Long,
    val signalCount: Int, val trainCount: Int, val settingCount: Int,
    val active: Int, val aspect: Int, val reason: Int,
    val speedMps: Double, val exitSignal: Long, val detail: String
)

Counts describe requested overlays. ReadSignal reads the last evaluated decision; ReadTrain.active is [TrainControlState.ordinal], not a permission.

ModControlSession

fr.nimby.sdk · class
class ModControlSession : AutoCloseable

Explicit recipe lease. No background renewals and no automatic retries. Expiration relinquishes temporary overrides. After a transport failure, inspect status and observations before deciding on another mutation. Construction réservée au SDK : utilisez la fonction de création ou le contexte fourni.

ModControlSession.modId

fr.nimby.sdk · val
val modId: String

ModControlSession.owner

fr.nimby.sdk · val
val owner: Long

ModControlSession.generation

fr.nimby.sdk · val
val generation: Long

ModControlSession.renew

fr.nimby.sdk · fun
@Synchronized fun renew(leaseMillis: Int = 5000) = send(ControlOperation.Renew) { it.copy(leaseMillis = leaseMillis) }

ModControlSession.forceSignal

fr.nimby.sdk · fun
@Synchronized fun forceSignal(signal: Long, aspect: Int) = send(ControlOperation.ForceSignal) { it.copy(objectId = signal, value = aspect) }

ModControlSession.restoreSignal

fr.nimby.sdk · fun
@Synchronized fun restoreSignal(signal: Long) = send(ControlOperation.RestoreSignal) { it.copy(objectId = signal) }

ModControlSession.setSetting

fr.nimby.sdk · fun
@Synchronized fun setSetting(signal: Long, index: Int, value: Boolean) = send(ControlOperation.Setting) {

ModControlSession.restoreSetting

fr.nimby.sdk · fun
@Synchronized fun restoreSetting(signal: Long, index: Int) = send(ControlOperation.RestoreSetting) { it.copy(objectId = signal, settingIndex = index) }

ModControlSession.constrainTrain

fr.nimby.sdk · fun
        exitSignal: Long = 0, releaseByRear: Boolean = false) = send(ControlOperation.Train) {

ModControlSession.restoreTrain

fr.nimby.sdk · fun
@Synchronized fun restoreTrain(train: Long) = send(ControlOperation.RestoreTrain) { it.copy(objectId = train) }

ModControlSession.readSignal

fr.nimby.sdk · fun
@Synchronized fun readSignal(signal: Long) = send(ControlOperation.ReadSignal) { it.copy(objectId = signal) }

ModControlSession.readTrain

fr.nimby.sdk · fun
@Synchronized fun readTrain(train: Long) = send(ControlOperation.ReadTrain) { it.copy(objectId = train) }

ModControlSession.clear

fr.nimby.sdk · fun
@Synchronized fun clear() = send(ControlOperation.Clear)

ModControlSession.close

fr.nimby.sdk · fun
@Synchronized override fun close()