import { Observable, RepeatConfig } from 'rxjs'; import { MotionMasterClient } from './motion-master-client'; import { DeviceRef, ParameterValueType, PositionProfileConfig, TorqueProfileConfig, VelocityProfileConfig } from './types'; import { Cia402State, ModesOfOperation } from './cia402'; /** * Represents commands that correspond to functions in {@link MotionMasterClient} and {@link MotionMasterReqResClient}. */ export type MotionComposerFlowCommandType = 'delay' | 'download' | 'quickStop' | 'resetFault' | 'runPositionProfile' | 'runTorqueProfile' | 'runVelocityProfile' | 'setModesOfOperation' | 'transitionToCia402State' | 'upload'; /** * Represents the status of a command in the flow. * - 'failed': Command execution failed, e.g., failure to reset fault or reach the target profile. * - 'running': Command has started, emitted immediately upon execution. * - 'succeeded': Command executed successfully. */ export type MotionComposerFlowCommandStatus = 'failed' | 'running' | 'succeeded'; /** * Represents a command within a Motion Composer flow. * Commands are executed sequentially within a single flow. */ export interface MotionComposerFlowCommand { /** * Specifies the type of command, corresponding to a function in the client library. */ type: MotionComposerFlowCommandType; /** * Optional reference to a device. * Most commands refer to a device, except for cases like `delay`. */ deviceRef?: DeviceRef; /** * Device-specific configuration. * Interfaces extending this one will define the appropriate config type for the command. */ config?: any; /** * Device-specific result. * Not all commands return a result, but commands like `upload` provide a parameter value as the result. */ result?: any; /** * Current status of the command during Motion Composer execution. * If undefined, the command is in an idle state. This property should be excluded when serializing or storing the command in a file. */ status?: MotionComposerFlowCommandStatus; /** * A textual description of the status. * Typically used for the error message when the command has a failed status. */ statusMessage?: string; } /** * Represents a delay command in a Motion Composer flow. */ export interface MotionComposerFlowCommandDelay extends MotionComposerFlowCommand { type: 'delay'; config: { /** * Specifies the duration, in milliseconds, to wait before executing the next command. */ duration: number; }; } export interface MotionComposerFlowCommandDownload extends MotionComposerFlowCommand { type: 'download'; deviceRef: DeviceRef; config: { index: number; subindex: number; value: ParameterValueType; }; } export interface MotionComposerFlowCommandQuickStop extends MotionComposerFlowCommand { type: 'quickStop'; deviceRef: DeviceRef; } export interface MotionComposerFlowCommandResetFault extends MotionComposerFlowCommand { type: 'resetFault'; deviceRef: DeviceRef; } export interface MotionComposerFlowCommandRunPositionProfile extends MotionComposerFlowCommand { type: 'runPositionProfile'; deviceRef: DeviceRef; config: PositionProfileConfig; } export interface MotionComposerFlowCommandRunTorqueProfile extends MotionComposerFlowCommand { type: 'runTorqueProfile'; deviceRef: DeviceRef; config: TorqueProfileConfig; } export interface MotionComposerFlowCommandRunVelocityProfile extends MotionComposerFlowCommand { type: 'runVelocityProfile'; deviceRef: DeviceRef; config: VelocityProfileConfig; } export interface MotionComposerFlowCommandSetModesOfOperation extends MotionComposerFlowCommand { type: 'setModesOfOperation'; deviceRef: DeviceRef; config: { modesOfOperation: ModesOfOperation; }; } export interface MotionComposerFlowCommandTransitionToCia402State extends MotionComposerFlowCommand { type: 'transitionToCia402State'; deviceRef: DeviceRef; config: { state: Cia402State; }; } export interface MotionComposerFlowCommandUpload extends MotionComposerFlowCommand { type: 'upload'; deviceRef: DeviceRef; config: { index: number; subindex: number; }; result?: ParameterValueType; } export type MotionComposerFlowCommandUnion = MotionComposerFlowCommandDelay | MotionComposerFlowCommandDownload | MotionComposerFlowCommandQuickStop | MotionComposerFlowCommandResetFault | MotionComposerFlowCommandRunPositionProfile | MotionComposerFlowCommandRunTorqueProfile | MotionComposerFlowCommandRunVelocityProfile | MotionComposerFlowCommandSetModesOfOperation | MotionComposerFlowCommandTransitionToCia402State | MotionComposerFlowCommandUpload; /** * Represents a flow in Motion Composer. * Flows execute in parallel, while commands within each flow execute sequentially. * Flows can optionally repeat command execution a specified number of times or indefinitely. */ export interface MotionComposerFlow { /** * Optional name to distinguish between flows. * Typical examples include 'Left Wheel' and 'Custom Velocity Profile'. */ name?: string; /** * Specifies the number of times to repeat this flow, with an optional delay between each execution. * If undefined (default), the flow executes only once. */ repeat?: number | RepeatConfig; /** * A list of commands to execute sequentially. */ commands: MotionComposerFlowCommandUnion[]; } /** * Represents the entire Motion Composer. */ export interface MotionComposer { /** * A unique identifier for this Motion Composer, allowing it to be stored in permanent storage. */ id: string; /** * An optional name that describes the purpose or functionality of the Motion Composer. */ name?: string; /** * The timestamp indicating when this Motion Composer was created. */ createdAt?: number; /** * A list of flows to execute in parallel. */ flows: MotionComposerFlow[]; } /** * The MotionComposerRunner executes a Motion Composer data structure (file). * * Execution can be stopped, but this will only happen after the current command completes. * * The class maintains the `running` state. * * While executing, the observable returned by the `run` method emits the entire Motion Composer data structure, * including updated status for each command as it starts, succeeds, or fails. */ export declare class MotionComposerRunner { private client; /** * Indicates the running status of the Motion Composer as it executes and completes. */ running: boolean; /** * Emits on the `stop$` subject to halt the execution of the entire Motion Composer after ongoing commands complete. */ private stop$; constructor(client: MotionMasterClient); /** * Executes the provided Motion Composer. * Flows run in parallel, while commands within each flow are executed sequentially. */ run(motionComposer: MotionComposer): Observable; /** * Stops the currently executing Motion Composer. * All ongoing commands must complete before execution is halted. */ stop(): void; }