Ramp Down

Description

This object is a digital to analog converter and is being used to map a given time (in ms) into a block of 4096 and count down.

The objects will now stop running once input parameters are changed.


App Builder Object


Source Code

function execute() { switch (trigger) { case TRIGGERS.SYSTEM_ASYNC: { if (context.counter > 0 && context.state) { context.counter -= context.segment; if (context.counter <= 0) { return [0]; } sleep(100, true); return [context.counter]; } break; } case 0: { cancelSleep(); context.totalTime = inPorts[1].value; context.splitTime = context.totalTime / 100; context.segment = 4096 / context.splitTime; context.counter = 4096; context.state = true; sleep(100,true ); return [context.counter]; } case 2: // reset { context.state = false; cancelSleep(); context.counter = 4096; return [context.counter]; } default: break; } return []; }

Examples

Example

Initialize

Time (ms)

Step width (s)

Example

Initialize

Time (ms)

Step width (s)

1

Trigger

4096

1 for 4096

2

Trigger

8192

0.5 for 4096

3

Trigger

5000

0.8192 for 4096


In Ports

Position

Name

Message Type

Description

Position

Name

Message Type

Description

1

Start

Trigger

This port is being used to start the 'Ramp Down' object.

2

Time (Ms)

Number

This port is being used to receive a time for the 'Ramp Down' object.

3

Reset

Trigger

This port is being used to reset the 'Ramp Down' object.


Out Ports

Position

Name

Message Type

Description

Position

Name

Message Type

Description

1

Out

Analog

This port releases the counting down from the given time in a block of 4096 steps.


Properties

Name

Description

Name

Description

Object Name

The name on the object on the canvas.

Show Code View

The switch to turn on code view for the Code Object.

Duplicate Code into custom Code Object