AnyLogic
Expand
Font size

CraneProgram API

CraneProgram structure contains detailed information about the bridge's movement along the rails of the overhead crane. This information is organized in a list of consecutive movement tasks describing the movement of each crane's component (bridge, trolley, hook) separately as well as delay tasks that describe pauses between these separate movements. The movement tasks are executed in the order of being listed in the program. Each movement task describes the component's movement as an offset from the component's current position.

To create a new program and initiate the bridge's movement according to this program, you have to follow these steps:

  1. Declare a new CraneProgram structure:

    CraneProgram program = new CraneProgram();

  2. List the movement task and delay tasks in the order that describes the bridge's route from the starting point to the target point using the CraneProgram API. For example:

    program.moveBridge(2, METER);
    program.moveTrolley(1.5, METER);
    program.delay(15, SECOND);
    ...
  3. Call the bridge's function moveByProgram() and pass the created CraneProgram structure as the argument:

    bridge.moveByProgram(program);

To work with the CraneProgram structure you can use the following API:

Working with program
Function Description
CraneProgram appendProgram(CraneProgram program) Appends the program passed as the argument to the current program. All movement tasks listed in the given program will be attached in the same order after the last task of the current program.
program - a program that must be appended to the current program
CraneProgram clone() Creates a copy of the current program. The copy is editable.
CraneProgram() This function is used to declare a new program.
Components movement tasks
Function Description
CraneProgram moveBridge(double offset, LengthUnits units) Creates a command to move the bridge for a distance specified as an offset from the current position of the bridge in the given length measurement units.

offset — an offset from the current position of the bridge to the target point of this movement
units — a constant that defines the length units
CraneProgram moveTrolley(double offset, LengthUnits units) Creates a command to move the trolley for a distance specified as an offset from the current position of the trolley in the given length measurement units.

offset — an offset from the current position of the trolley to the target point of this movement
units — a constant that defines the length units
CraneProgram moveHook(double offset, LengthUnits units) Creates a command to move the hook for a distance specified as an offset from the current position of the hook in the given length measurement units.

offset — an offset from the current position of the hook to the target point of this movement
units — a constant that defines the length units
CraneProgram moveToPoint(Point destinationPx, double safeHeight, LengthUnits units) Creates a command to move all components (bridge, trolley, hook) to the specified point taking into account the specified safe height of the hook in the given length units. This command does not detail separate movements of each component.

destinationPx — target point in pixels
safeHeight — safe height that must be observed by the hook
units — a constant that defines the length units
CraneProgram moveComponentsConcurrently(double bridgeOffset, double trolleyOffset, double hookOffset, LengthUnits units) Creates a command to move all components (bridge, trolley, hook) concurrently, where each component moves for a specified offset in the given length measurement units.

bridgeOffset — an offset from the current bridge position to the target point of this movement
trolleyOffset — an offset from the current trolley position to the target point of this movement
hookOffset — an offset from the current hook position to the target point of this movement
units — a constant that defines the length units
Delay task
Function Description
CraneProgram delay(double delayTime, TimeUnits units) Creates a command to pause the movement of all components (bridge, trolley, hook) for a specified period of time in the given time units.

delayTime — a period of time during which the components (bridge, trolley, hook) will not move
units — a constant that defines the time units
How can we improve this article?