Skip to main content

Rail Deck is being prepared for an invitation-only Alpha. Check current availability

Developer documentation

Speed limits and operating rules

Preview the speed envelope and explanation for a chosen locomotive and train.

Source 0.1.0 Private source package

How the calls fit together

A policy preview explains the current decision. It does not reserve authority, claim driving control or submit a speed command.

JavaScript examples

Supply your configured client. Each call awaits a decoded result; errors pass to your caller. These identifiers and values are fictional. Use selected development records and review every change before running it. Opening this page sends no API requests.

See the complete TypeScript workflow · Explore the Node starter

operatingPolicy.previewLocomotive

Previews the resolved operating policy for one layout locomotive.

const result = await client.operatingPolicy.previewLocomotive(
  "account 1",
  "layout 1",
  "loco 1",
  {
    "trainFormationId": "formation 1",
    "requestedSpeedPercent": 75,
    "requestedDirection": "forward"
  }
);
TypeScript parameters and return type
accountId · required
RailDeckIdentifier

Account that owns the layout.

layoutId · required
RailDeckIdentifier

Layout containing the locomotive.

locomotiveId · required
RailDeckIdentifier

Locomotive whose policy should be previewed.

input · required
PreviewRailDeckLocomotiveOperatingPolicyInput

Requested speed, optional direction, and optional train formation.

Returns Promise<RailDeckLocomotiveOperatingPolicyPreview>.

Example evidence: Retained SDK transport fixture.

Download all TypeScript method examples

JavaScript calls and TypeScript downloads are checked through the real SDK using local response fixtures. This verifies the calls and decoding for those fixtures.

Handle errors and uncertain outcomes

Choose another feature

The complete TypeScript workflow

Follow how the calls fit together, including the review and recovery steps. Supply your configured client and explicitly selected development records. Importing the download performs no requests; mutations are never retried automatically.

import type { RailDeckDirectIntegrationClient as Client } from '@raildeck/frontend-sdk/direct-integration';

/**
 * Read handling evidence and preview a chosen train’s requested speed.
 * @param client - Configured client; the caller owns current authority.
 * @param accountId - Authorised account for this workflow.
 * @param layoutId - Explicitly selected layout within the account.
 * @param locomotiveId - Explicitly selected locomotive.
 * @param trainId - Explicitly selected saved train.
 * @param input - Reviewed input for this operation.
 * @returns An explanation of the current policy, without claiming control or sending speed.
 */
export async function reviewTrainSpeedPolicy(
  client: Client,
  accountId: string,
  layoutId: string,
  locomotiveId: string,
  trainId: string,
  input: Omit<Parameters<Client['operatingPolicy']['previewLocomotive']>[3], 'trainFormationId'>,
) {
  const handling = await client.trainFormations.getHandlingProfile(accountId, trainId);
  const policy = await client.operatingPolicy.previewLocomotive(accountId, layoutId, locomotiveId, {
    ...input, trainFormationId: trainId,
  });
  return { handling, policy };
}
Download TypeScript example

Information reviewed .