Reference
TrainTypes · Kotlin/Native
Typed identifiers, read options and material characteristics.
Usage context
| Module | Package | SDK source |
|---|---|---|
| Kotlin/Native | nimby | kotlin/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.
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.TrainLinePlanChoose 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 option | Default | Requested data |
|---|---|---|
| includeService | true | Observed state, service and assignment. |
| includeLocations | true | Positions and required location references. |
| includeCharacteristics | false | Configured and current material profiles. |
| includeTimetables | false | Available timetable information; implies includeService. |
| includeTags | false | Declared tags and inheritance references; implies includeLines. |
| includePassengers | false | Observed occupants, distinct from capacity. |
| includeLines | false | Line catalog, including lines with no assigned train. |
| includeComposition | false | Ordered vehicles of configured and current compositions and referenced models. |
| Value | Unit and contract |
|---|---|
| Train.speedMps / Train.speedKmh | Current speed. Native: an unavailable measurement remains null. JVM: also check speedDefaulted before treating a fallback value as a measurement. |
| maximumSpeedMps / maximumSpeedKmh | Material maximum speed, in m/s or km/h; distinct from current speed and the track speed limit. |
| lengthM / emptyMassKg / maximumAccelerationMps2 | Metres, kilograms, metres per second squared. |
| powerW / tractiveForceN | Watts and newtons. |
| passengers / passengerCapacity / carCount | Occupants, capacity and vehicle count: three distinct quantities. |
| configured / current / composition | Independent profiles, without filling missing values from one another. Null composition: unknown or unrequested; empty list: observed empty composition. |
| predictedArrivalDelayUs / predictedArrivalDelaySeconds | Signed estimate in microseconds or seconds; negative for predicted early arrival. Neither deadline age nor priority. |
| arrivalOffsetSeconds / departureOffsetSeconds | Validated offsets in seconds from the line-plan origin. Do not convert them into a train’s absolute date. |
| arrivalTimeUs / departureTimeUs / dispatchRetryTimeUs | Microseconds from the simulation origin, not 1970. Use calendar helpers; dates remain null when the origin is unknown. |
| capturedAtMillis / ageMillis | Computer 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
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
val includeService: Boolean = trueRequests train state and service. Enabled by default; timetables also imply this read.
TrainQuery.includeLocations
val includeLocations: Boolean = trueRequests 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
val includeCharacteristics: Boolean = falseRequests configured and current material characteristics separately. Disabled by default.
TrainQuery.includeTimetables
val includeTimetables: Boolean = falseRequests 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.includePassengers
val includePassengers: Boolean = falseRequests occupant count; independent of material capacity.
TrainQuery.includeLines
val includeLines: Boolean = falseRequests the line catalogue, including lines without assigned trains. Does not request tags by itself.
TrainQuery.includeComposition
val includeComposition: Boolean = falseRequests ordered vehicles and referenced models for configured and current compositions. The groups remain optional.
TrainId
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
val value: LongOpaque value to compare and pass unchanged; do not decode it or reuse it in another game.
LineId
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
val value: LongOpaque value to compare and pass unchanged; do not decode it or reuse it in another game.
StationId
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
val value: LongOpaque value to compare and pass unchanged; do not decode it or reuse it in another game.
TrackId
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
val value: LongOpaque value to compare and pass unchanged; do not decode it or reuse it in another game.
TimetableId
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
val value: LongOpaque value to compare and pass unchanged; do not decode it or reuse it in another game.
TimetableShiftId
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
val timetableId: TimetableIdTimetable to which this shift belongs.
TimetableShiftId.value
val value: LongOpaque shift key, unique only within timetableId.
TagId
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
val value: LongOpaque value to compare and pass unchanged; do not decode it or reuse it in another game.
VehicleModelId
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
val value: LongOpaque value to compare and pass unchanged; do not decode it or reuse it in another game.
LineType
enum class LineType {
Depot,
Other
}Classification limited to depot lines and other lines; no passenger/freight category is inferred.
LineType.Depot
DepotLine identified as a depot line.
LineType.Other
OtherObserved non-depot line; its commercial category is not determined.
Timetable
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
val id: TimetableIdIdentity of the observed timetable.
Timetable.name
val name: String? = nullThe SDK currently exposes timetable identity without resolving its name; null is not an empty name.
Tag
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
val id: TagIdTag identity, independent of its label.
Tag.name
val name: String?Observed name, possibly absent; do not use it as a stable key.
TrainCharacteristics
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
val maximumSpeedMps: Double?Optional material speed limit in metres per second; distinct from measured speed and track limit.
TrainCharacteristics.lengthM
val lengthM: Double?Material length in metres; null when not established.
TrainCharacteristics.emptyMassKg
val emptyMassKg: Double?Empty mass in kilograms; does not represent loaded mass.
TrainCharacteristics.passengerCapacity
val passengerCapacity: Int?Optional passenger capacity of this profile; distinct from current occupants.
TrainCharacteristics.carCount
val carCount: Int?Optional vehicle count of this profile; do not infer capacity or length from this count alone.
TrainCharacteristics.maximumAccelerationMps2
val maximumAccelerationMps2: Double?Declared maximum acceleration in metres per second squared; not measured acceleration.
TrainCharacteristics.powerW
val powerW: Double?Optional declared power in watts; not observed electrical consumption.
TrainCharacteristics.tractiveForceN
val tractiveForceN: Double?Optional declared tractive force in newtons.
TrainCharacteristics.composition
val composition: List<TrainVehicle>? = nullVehicles in observed order. null: unknown or unrequested; empty list: observed empty composition. Repeated models are significant.
TrainCharacteristics.maximumSpeedKmh
val maximumSpeedKmh: Double?maximumSpeedMps multiplied by 3.6; null remains null.
VehicleModel
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
val id: VehicleModelIdVehicle-model identity.
VehicleModel.code
val code: String?Optional observed model code.
VehicleModel.nameEnglish
val nameEnglish: String?English catalogue name; does not automatically follow the tool language.
VehicleModel.sourceName
val sourceName: String?Optional model-source name reported by the catalogue.
TrainVehicle
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
val index: IntZero-based position in the observed composition.
TrainVehicle.model
val model: VehicleModelModel associated with this vehicle; its labels can remain unknown.
TrainVehicle.modelId
val modelId: VehicleModelIdModel identity, equal to model.id.
TrainObservation
typealias TrainObservation = TrainAnother name for Train, with the same properties and contracts; no additional copy or conversion.
TrainLine
typealias TrainLine = LineAnother name for Line, with the same properties and contracts; no additional copy or conversion.
TrainStation
typealias TrainStation = StationAnother name for Station, with the same properties and contracts; no additional copy or conversion.
TrainLineStop
typealias TrainLineStop = StopAnother name for Stop, with the same properties and contracts; no additional copy or conversion.
TrainLinePlan
typealias TrainLinePlan = LinePlanAnother name for LinePlan, with the same properties and contracts; no additional copy or conversion.