Skip to main content

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

Developer documentation

Track power

Read and deliberately change a controller’s track-power scope.

Source 0.1.0 Private source package

How the calls fit together

Read current power evidence before an operator decision. An accepted power request is not a confirmed physical outcome.

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

system.getTrackPower

Loads the latest known track-power state for a layout.

const result = await client.system.getTrackPower(
  "account-1",
  "layout-1",
  {}
);
TypeScript parameters and return type
accountId · required
RailDeckIdentifier

Account that owns the layout.

layoutId · required
RailDeckIdentifier

Layout to inspect.

requestOptions · optional
RailDeckRequestControlOptions

Caller-owned cancellation signal and timeout; these controls never authorise an automatic mutation retry.

Returns Promise<RailDeckTrackPowerResponse>.

Example evidence: Retained SDK transport fixture.

system.setTrackPower

Sets track power for one controller and track scope.

const result = await client.system.setTrackPower(
  "account 1",
  "layout-1",
  {
    "controllerId": "controller-1",
    "track": "main",
    "state": "on"
  },
  {}
);
TypeScript parameters and return type
accountId · required
RailDeckIdentifier

Account that owns the layout.

layoutId · required
RailDeckIdentifier

Layout to control.

input · required
SetRailDeckTrackPowerInput

Controller, track, state, and optional emergency mode.

requestOptions · optional
RailDeckRequestControlOptions

Caller-owned cancellation signal and timeout; these controls never authorise an automatic mutation retry.

Returns Promise<RailDeckTrackPowerCommandResponse>.

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 current track-power evidence for an explicit operator decision.
 * @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 signal - Caller-owned cancellation signal.
 * @returns Current scoped evidence, not a promise about the physical track.
 */
export async function readPowerBeforeDecision(
  client: Client,
  accountId: string,
  layoutId: string,
  signal: AbortSignal,
) {
  return client.system.getTrackPower(accountId, layoutId, { signal, timeoutMs: 15_000 });
}

/**
 * Request power off only when the operator explicitly invokes this helper.
 * @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 controllerId - Explicitly selected command station.
 * @param track - Selected track output; this helper only requests power off.
 * @param signal - Caller-owned cancellation signal.
 * @returns Request acceptance; inspect subsequent state before claiming power is physically off.
 */
export async function switchReviewedTrackOff(
  client: Client,
  accountId: string,
  layoutId: string,
  controllerId: string,
  track: string,
  signal: AbortSignal,
) {
  return client.system.setTrackPower(accountId, layoutId, {
    controllerId, track, state: 'off',
  }, { signal, timeoutMs: 15_000 });
}
Download TypeScript example

Information reviewed .