Reference
TrainServices
States, alerts and joins of train data within a snapshot.
Usage context
| Module | Package | SDK source |
|---|---|---|
| Kotlin/JVM | fr.nimby.sdk | kotlin-client/src/main/kotlin/fr/nimby/sdk/TrainServices.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 fr.nimby.sdk.TrainState
import fr.nimby.sdk.TrainAlert
import fr.nimby.sdk.TrainRecordChoose 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.
TrainState
enum class TrainState {
Unknown,
Driving,
StationStop,
TimedStop,
Depot,
DispatchWait,
SignalWait,
Mothballed,
NotPresent,
Other
}Observed service state. null means unavailable; Unknown and Other are observed results, not missing data.
TrainState.Unknown
UnknownThe game reports an undetermined state.
TrainState.Driving
DrivingReported driving state; does not prove strictly positive speed.
TrainState.StationStop
StationStopReported station stop.
TrainState.TimedStop
TimedStopReported timed stop.
TrainState.Depot
DepotReported depot state.
TrainState.DispatchWait
DispatchWaitReported dispatch wait.
TrainState.SignalWait
SignalWaitReported signal wait; this field alone does not describe the signal rule.
TrainState.Mothballed
MothballedTrain mothballed according to the reported state.
TrainState.NotPresent
NotPresentTrain reported as not present; distinct from an object missing from the snapshot.
TrainState.Other
OtherObserved state not represented by another known enum value.
TrainAlert
enum class TrainAlert {
None,
LineClosed,
NoPath,
InvalidOrders,
Collision,
SignalWait,
ScheduleClosed,
DispatchTracksOccupied,
NoServices,
ServicesAlreadyAssigned,
Other
}Observed train alert. null means unavailable; None means no reported alert. An alert is not a priority.
TrainAlert.None
NoneNo reported alert.
TrainAlert.LineClosed
LineClosedReported closed line.
TrainAlert.NoPath
NoPathReported missing path.
TrainAlert.InvalidOrders
InvalidOrdersReported invalid orders.
TrainAlert.Collision
CollisionCollision reported by the game.
TrainAlert.SignalWait
SignalWaitSignal-wait alert.
TrainAlert.ScheduleClosed
ScheduleClosedReported closed schedule.
TrainAlert.DispatchTracksOccupied
DispatchTracksOccupiedDispatch tracks occupied according to the game.
TrainAlert.NoServices
NoServicesNo services available according to the game.
TrainAlert.ServicesAlreadyAssigned
ServicesAlreadyAssignedServices already assigned according to the game.
TrainAlert.Other
OtherOther observed alert code, not represented by known values.
TrainRecord
data class TrainRecord(val train: Train, val service: Service?, val details: TrainDetails?,
val positionStation: Station?, val locationStation: Station?, val stopStation: Station?,
val metadata: TrainMetadata? = null, val line: Line? = null)Joined train view within a snapshot. Missing records remain null; an unresolved station does not prove a train is outside stations.
TrainRecord.train
val train: TrainBasic train observation.
TrainRecord.service
val service: Service?Service joined by train identity, when available.
TrainRecord.details
val details: TrainDetails?Assignment/occupants joined by train identity, when available.
TrainRecord.positionStation
val positionStation: Station?Station of the geometric position track, when resolved.
TrainRecord.locationStation
val locationStation: Station?Service-location station when resolved; may differ from positionStation.
TrainRecord.stopStation
val stopStation: Station?Target-stop station when resolved; not necessarily current position.
TrainRecord.metadata
val metadata: TrainMetadata? = nullRich metadata for the same train, when requested and available.
TrainRecord.line
val line: Line? = nullService line joined from the requested catalogue.