DCode

Covers Engine 2.0.0

Getting Started

Create and inspect a small DCode task and its calculated output.

Create this demo in a test project. It writes only docs_demo_* channels and does not need a hardware plugin.

Create the script

Open Scripts, create docs_demo.dcode, and enter:

task_periodic docs_demo_clock:
    task elapsed_seconds:
        |docs_demo_seconds| = elapsed_seconds

channel_calculation docs_demo_minutes:
    return |docs_demo_seconds| / 60

The task publishes elapsed time on a schedule. The calculation runs inline when docs_demo_seconds is committed and writes docs_demo_minutes.

Validate and activate

Save the script, use the editor’s validation/build diagnostics, and correct reported errors before activating it. Activation registers the task and calculation with the engine. Use the task’s Start control, or set docs_demo_clock_running to 1 from Channels if it is stopped.

Open Channels and search for docs_demo. While the task runs, seconds should advance and minutes should be seconds divided by 60. The interface updates on its telemetry interval, so it need not show every task iteration.

ChannelExpected behavior
docs_demo_secondsIncreasing active elapsed time while the task runs.
docs_demo_minutesDerived seconds / 60.
docs_demo_clock_running1 while running, 0 while stopped.
docs_demo_clock_target_frequencyRequested update rate in Hz.
docs_demo_clock_actual_frequencyMeasured rate; read-only.
docs_demo_clock_hold1 pauses the task while preserving state.

Stop the demo through its task control when finished. Closing the script tab does not stop it. Saving source edits also does not prove the running declaration was replaced; activate the edited version and inspect the build result.

Keep values between iterations

Use state for data owned by one task:

task_periodic docs_demo_counter:
    start:
        state.count = 0

    task elapsed_seconds:
        state.count = state.count + 1
        |docs_demo_count| = state.count

    end:
        print("Demo counter stopped")

start: initializes the run, task: repeats, and end: performs stop handling. A local variable declared in the task body is temporary for that invocation.

If it does not run

SymptomCheck
No task appearsActivation/build result and script errors.
Values remain stationaryRunning and hold controls.
Calculation output stays unchangedCalculation errors and whether a dependency is being updated.
A write is ignoredChannel authority and the current owner.
UI lags while diagnostics advanceTelemetry/display interval; compare with the engine’s actual frequency.

Continue with Periodic Tasks, Channel Calculations, or Events.