NRF SDK 0.9

Reference

TrainTypes · Kotlin/Native

Typed identifiers, read options and material characteristics.

Usage context

ModulePackageSDK source
Kotlin/Nativenimbykotlin/src/nimby/TrainTypes.kt

Public API for SDK 0.9.0-alpha.2. Each entry provides the Kotlin signature and its contract: what the value means, conditions of use and effects to understand. Choose imports from the module shown above.

Imports on this page
import nimby.TrainQuery
import nimby.TrainId
import nimby.LineId
import nimby.StationId
import nimby.TrackId
import nimby.TimetableId
import nimby.TimetableShiftId
import nimby.TagId
import nimby.VehicleModelId
import nimby.LineType
import nimby.Timetable
import nimby.Tag
import nimby.TrainCharacteristics
import nimby.VehicleModel
import nimby.TrainVehicle
import nimby.TrainObservation
import nimby.TrainLine
import nimby.TrainStation
import nimby.TrainLineStop
import nimby.TrainLinePlan

Choose a read and interpret its results

In a mod, use ToolContext.trains(query). In a JVM application, use game.trains.snapshot(query = query); selecting a train also requests its line plan. One query batches all trains: do not create a snapshot per train. Clock reads and targeted single-train reads are separate.

TrainQuery optionDefaultRequested data
includeServicetrueObserved state, service and assignment.
includeLocationstruePositions and required location references.
includeCharacteristicsfalseConfigured and current material profiles.
includeTimetablesfalseAvailable timetable information; implies includeService.
includeTagsfalseDeclared tags and inheritance references; implies includeLines.
includePassengersfalseObserved occupants, distinct from capacity.
includeLinesfalseLine catalog, including lines with no assigned train.
includeCompositionfalseOrdered vehicles of configured and current compositions and referenced models.
ValueUnit and contract
Train.speedMps / Train.speedKmhCurrent speed. Native: an unavailable measurement remains null. JVM: also check speedDefaulted before treating a fallback value as a measurement.
maximumSpeedMps / maximumSpeedKmhMaterial maximum speed, in m/s or km/h; distinct from current speed and the track speed limit.
lengthM / emptyMassKg / maximumAccelerationMps2Metres, kilograms, metres per second squared.
powerW / tractiveForceNWatts and newtons.
passengers / passengerCapacity / carCountOccupants, capacity and vehicle count: three distinct quantities.
configured / current / compositionIndependent profiles, without filling missing values from one another. Null composition: unknown or unrequested; empty list: observed empty composition.
predictedArrivalDelayUs / predictedArrivalDelaySecondsSigned estimate in microseconds or seconds; negative for predicted early arrival. Neither deadline age nor priority.
arrivalOffsetSeconds / departureOffsetSecondsValidated offsets in seconds from the line-plan origin. Do not convert them into a train’s absolute date.
arrivalTimeUs / departureTimeUs / dispatchRetryTimeUsMicroseconds from the simulation origin, not 1970. Use calendar helpers; dates remain null when the origin is unknown.
capturedAtMillis / ageMillisComputer UTC time / monotonic age when copying; distinct from the game calendar.

Typed identifiers are opaque. TimetableShiftId is unique only together with its TimetableId. LineType distinguishes only Depot and Other; no passenger/freight category is inferred. An unavailable timetable name remains null. Tags are labels without automatic priority; incomplete or cyclic inheritance remains unknown. VehicleModel.nameEnglish retains the English catalog name.

TrainVehicle describes a vehicle within a composition. The nimby.Vehicle type used in driving calculations is a different contract. Do not mix identically named classes from nimby and fr.nimby.sdk.

TrainQuery

nimby · class
data class TrainQuery(val includeService: Boolean = true, val includeLocations: Boolean = true,
    val includeCharacteristics: Boolean = false, val includeTimetables: Boolean = false,
    val includeTags: Boolean = false, val includePassengers: Boolean = false, val includeLines: Boolean = false,
    val includeComposition: Boolean = false)

Options for a train read. Request only the groups you need; options select data, not a subset of trains.

TrainQuery.includeService

nimby · val
val includeService: Boolean = true

Requests train state and service. Enabled by default; timetables also imply this read.

TrainQuery.includeLocations

nimby · val
val includeLocations: Boolean = true

Requests location data and related stations/tracks. Enabled by default. Timetables also imply these data; false does not guarantee their absence from a covering snapshot.

TrainQuery.includeCharacteristics

nimby · val
val includeCharacteristics: Boolean = false

Requests configured and current material characteristics separately. Disabled by default.

TrainQuery.includeTimetables

nimby · val
val includeTimetables: Boolean = false

Requests available assignments and timetable data; implies service and track/station data even when includeLocations is false. Does not invent names or future passing times.

TrainQuery.includeTags

nimby · val
val includeTags: Boolean = false

Requests train tags and the tag/line catalogue needed for joins; implies includeLines.

TrainQuery.includePassengers

nimby · val
val includePassengers: Boolean = false

Requests occupant count; independent of material capacity.

TrainQuery.includeLines

nimby · val
val includeLines: Boolean = false

Requests the line catalogue, including lines without assigned trains. Does not request tags by itself.

TrainQuery.includeComposition

nimby · val
val includeComposition: Boolean = false

Requests ordered vehicles and referenced models for configured and current compositions. The groups remain optional.

TrainId

nimby · class
data class TrainId(val value: Long)

Typed train identity copied from the game. Its type prevents joins between different objects; it encodes no business category for the mod.

TrainId.value

nimby · val
val value: Long

Opaque value to compare and pass unchanged; do not decode it or reuse it in another game.

LineId

nimby · class
data class LineId(val value: Long)

Typed line identity copied from the game. Its type prevents joins between different objects; it encodes no business category for the mod.

LineId.value

nimby · val
val value: Long

Opaque value to compare and pass unchanged; do not decode it or reuse it in another game.

StationId

nimby · class
data class StationId(val value: Long)

Typed station identity copied from the game. Its type prevents joins between different objects; it encodes no business category for the mod.

StationId.value

nimby · val
val value: Long

Opaque value to compare and pass unchanged; do not decode it or reuse it in another game.

TrackId

nimby · class
data class TrackId(val value: Long)

Typed track identity copied from the game. Its type prevents joins between different objects; it encodes no business category for the mod.

TrackId.value

nimby · val
val value: Long

Opaque value to compare and pass unchanged; do not decode it or reuse it in another game.

TimetableId

nimby · class
data class TimetableId(val value: Long)

Typed timetable identity copied from the game. Its type prevents joins between different objects; it encodes no business category for the mod.

TimetableId.value

nimby · val
val value: Long

Opaque value to compare and pass unchanged; do not decode it or reuse it in another game.

TimetableShiftId

nimby · class
data class TimetableShiftId(val timetableId: TimetableId, val value: Long)

Identity of a shift within its timetable. The value alone is not unique: compare timetableId and value together.

TimetableShiftId.timetableId

nimby · val
val timetableId: TimetableId

Timetable to which this shift belongs.

TimetableShiftId.value

nimby · val
val value: Long

Opaque shift key, unique only within timetableId.

TagId

nimby · class
data class TagId(val value: Long)

Typed tag identity copied from the game. Its type prevents joins between different objects; it encodes no business category for the mod.

TagId.value

nimby · val
val value: Long

Opaque value to compare and pass unchanged; do not decode it or reuse it in another game.

VehicleModelId

nimby · class
data class VehicleModelId(val value: Long)

Typed vehicle model identity copied from the game. Its type prevents joins between different objects; it encodes no business category for the mod.

VehicleModelId.value

nimby · val
val value: Long

Opaque value to compare and pass unchanged; do not decode it or reuse it in another game.

LineType

nimby · class
enum class LineType {
    Depot,
    Other
}

Classification limited to depot lines and other lines; no passenger/freight category is inferred.

LineType.Depot

nimby · enum-entry
Depot

Line identified as a depot line.

LineType.Other

nimby · enum-entry
Other

Observed non-depot line; its commercial category is not determined.

Timetable

nimby · class
data class Timetable(val id: TimetableId, val name: String? = null)

Timetable identified from a train assignment. This type does not contain a complete passing schedule.

Timetable.id

nimby · val
val id: TimetableId

Identity of the observed timetable.

Timetable.name

nimby · val
val name: String? = null

The SDK currently exposes timetable identity without resolving its name; null is not an empty name.

Tag

nimby · class
data class Tag(val id: TagId, val name: String?)

Classification label. Compare its identity; its name can change. No tag triggers automatic priority or regulation.

Tag.id

nimby · val
val id: TagId

Tag identity, independent of its label.

Tag.name

nimby · val
val name: String?

Observed name, possibly absent; do not use it as a stable key.

TrainCharacteristics

nimby · class
data class TrainCharacteristics(val maximumSpeedMps: Double?, val lengthM: Double?, val emptyMassKg: Double?,
    val passengerCapacity: Int?, val carCount: Int?, val maximumAccelerationMps2: Double?, val powerW: Double?, val tractiveForceN: Double?,
    val composition: List<TrainVehicle>? = null)

Copied material-profile characteristics in SI units. Each field can be unknown independently; neither current speed nor priority.

TrainCharacteristics.maximumSpeedMps

nimby · val
val maximumSpeedMps: Double?

Optional material speed limit in metres per second; distinct from measured speed and track limit.

TrainCharacteristics.lengthM

nimby · val
val lengthM: Double?

Material length in metres; null when not established.

TrainCharacteristics.emptyMassKg

nimby · val
val emptyMassKg: Double?

Empty mass in kilograms; does not represent loaded mass.

TrainCharacteristics.passengerCapacity

nimby · val
val passengerCapacity: Int?

Optional passenger capacity of this profile; distinct from current occupants.

TrainCharacteristics.carCount

nimby · val
val carCount: Int?

Optional vehicle count of this profile; do not infer capacity or length from this count alone.

TrainCharacteristics.maximumAccelerationMps2

nimby · val
val maximumAccelerationMps2: Double?

Declared maximum acceleration in metres per second squared; not measured acceleration.

TrainCharacteristics.powerW

nimby · val
val powerW: Double?

Optional declared power in watts; not observed electrical consumption.

TrainCharacteristics.tractiveForceN

nimby · val
val tractiveForceN: Double?

Optional declared tractive force in newtons.

TrainCharacteristics.composition

nimby · val
val composition: List<TrainVehicle>? = null

Vehicles in observed order. null: unknown or unrequested; empty list: observed empty composition. Repeated models are significant.

TrainCharacteristics.maximumSpeedKmh

nimby · val
val maximumSpeedKmh: Double?

maximumSpeedMps multiplied by 3.6; null remains null.

VehicleModel

nimby · class
data class VehicleModel(val id: VehicleModelId, val code: String?, val nameEnglish: String?, val sourceName: String?)

Model referenced by a composition. The catalogue is limited to observed models; it does not classify trains as passenger or freight.

VehicleModel.id

nimby · val
val id: VehicleModelId

Vehicle-model identity.

VehicleModel.code

nimby · val
val code: String?

Optional observed model code.

VehicleModel.nameEnglish

nimby · val
val nameEnglish: String?

English catalogue name; does not automatically follow the tool language.

VehicleModel.sourceName

nimby · val
val sourceName: String?

Optional model-source name reported by the catalogue.

TrainVehicle

nimby · class
data class TrainVehicle(val index: Int, val model: VehicleModel)

A vehicle at a specific position in a composition; several vehicles may share the same model.

TrainVehicle.index

nimby · val
val index: Int

Zero-based position in the observed composition.

TrainVehicle.model

nimby · val
val model: VehicleModel

Model associated with this vehicle; its labels can remain unknown.

TrainVehicle.modelId

nimby · val
val modelId: VehicleModelId

Model identity, equal to model.id.

TrainObservation

nimby · typealias
typealias TrainObservation = Train

Another name for Train, with the same properties and contracts; no additional copy or conversion.

TrainLine

nimby · typealias
typealias TrainLine = Line

Another name for Line, with the same properties and contracts; no additional copy or conversion.

TrainStation

nimby · typealias
typealias TrainStation = Station

Another name for Station, with the same properties and contracts; no additional copy or conversion.

TrainLineStop

nimby · typealias
typealias TrainLineStop = Stop

Another name for Stop, with the same properties and contracts; no additional copy or conversion.

TrainLinePlan

nimby · typealias
typealias TrainLinePlan = LinePlan

Another name for LinePlan, with the same properties and contracts; no additional copy or conversion.