Skip to content

Integration in Coldwave

Coldwave Script does not operate in isolation—it is tightly integrated with the hardware and cloud services of the Coldwave platform. Integration is achieved through specialized function blocks that encapsulate the respective interfaces:

  • Bus blocks (e.g., CANopen, Modbus, digital I/O) connect field devices and signals.
  • The Coldwave Block provides a unified interface for telemetry and service-based communication (sending/reading values over the platform).

This chapter explains the core principles and the role of the Coldwave Block. Details of bus‑specific blocks are covered in their respective hardware manuals.

Integration Layers

Between scripts and physical signals, there are three layers:

  1. Hardware and Field Buses
    Devices on CANopen, Modbus, digital inputs/outputs, analog inputs, etc.

  2. Coldwave Abstraction (Services, Telemetry, Mapping)

    • Fieldbus signals are aggregated into logical properties/services.
    • Each service is uniquely identified (e.g., via UUID).
    • The platform handles transport, retries, persistence, and historical storage.
  3. Script Layer (Blocks and Variables)

    • Bus‑specific blocks represent devices or registers (CANopen PDOs, Modbus registers, digital I/O).
    • The Coldwave Block enables asynchronous SET/GET operations on telemetry and services.

Scripts operate exclusively on layer 3; layers 1 and 2 are handled by Coldwave modules and the backend.

The Coldwave Block (Telemetry, SET/GET)

The Coldwave Block is implemented in the VM as an asynchronous function block. It performs SET/GET operations on a service identified by a UUID.

Purpose

  • SET mode: explicitly send a value to a service (setpoint, actuator command).
  • GET mode: retrieve the current value from the platform.

The implementation ensures:

  • clean asynchronous execution (BUSY/ACK),
  • filtering/deduplication (repeated identical SET values are not re‑sent),
  • clear error reporting (invalid UUID, missing service, busy, etc.).

Inputs and Outputs (Conceptual Signature)

NameTypeMeaning
IDUINTIdentifier of the datapoint within the service
MODUINTSub‑address / modifier (channel, index, etc.)
INDWORDValue to send in SET mode
SRV_UUIDSTRINGUUID of the service ("550e8400-e29b-41d4-a716-446655440000")
ENBOOLBlock active only when TRUE
TRIGBOOLRising edge triggers request
MODEDINT0 = SET, 1 = GET

Outputs:

NameTypeMeaning
OUTANYReturned value in GET mode
BUSYBOOLTRUE while request is in progress
ACKBOOLTRUE for one cycle when request completes successfully
ERRINTError code (0 = OK; otherwise errno/platform code)

Internally, state is stored in CW_State, tracking last value, latch state, errors, async requests, etc.

SET Mode (MODE = 0)

  1. Rising edge on TRIG latches the IN value.
  2. If no request is active, an async SET request is started.
  3. On success, ACK = TRUE, and the last value is stored. Identical future values are suppressed.
  4. On error, ERR is set, value remains latched, retry on next cycle.

GET Mode (MODE = 1)

  • Rising edge triggers async GET request.
  • On success: OUT updated, ACK = TRUE, ERR = 0.
  • On error: ERR != 0, ACK = FALSE.

Example: SET to Platform

vb
DIM CW AS COLDWAVE_BLOCK

CONST TargetId  AS UINT   = 10
CONST TargetMod AS UINT   = 0
CONST SrvUuid   AS STRING = "550e8400-e29b-41d4-a716-446655440000"

CW(ID := TargetId, MOD := TargetMod, SRV_UUID := SrvUuid)

PROGRAM
    DIM value AS DINT = 42
    DIM doWrite AS BOOL

    IF SomeCondition THEN
        doWrite = TRUE
    ELSE
        doWrite = FALSE
    END IF

    CW(IN := value, EN := TRUE, TRIG := doWrite, MODE := 0)

    IF CW.ACK THEN
        PRINT "Value sent successfully."
    END IF

    IF CW.ERR <> 0 THEN
        PRINT "Error sending value, code=", CW.ERR
    END IF
END PROGRAM

Example: GET from Platform

vb
DIM CW AS COLDWAVE_BLOCK

CONST TargetId  AS UINT   = 20
CONST TargetMod AS UINT   = 0
CONST SrvUuid   AS STRING = "550e8400-e29b-41d4-a716-446655440000"

CW(ID := TargetId, MOD := TargetMod, SRV_UUID := SrvUuid)

PROGRAM
    DIM doRead AS BOOL
    doRead = TRUE

    CW(EN := TRUE, TRIG := doRead, MODE := 1)

    IF CW.ACK THEN
        PRINT "Current value:", CW.OUT
    END IF

    IF CW.ERR <> 0 THEN
        PRINT "Error reading value, code=", CW.ERR
    END IF
END PROGRAM

Interaction with Bus Blocks

Bus blocks expose signals both:

  • locally to scripts (IN/OUT, block fields),
  • and as Coldwave services available via the platform.

Two common patterns:

  1. Local logic, cloud only receives data
    Script logic runs on local I/O; Coldwave Block only mirrors data.

  2. Cloud‑configured parameters
    Values from the cloud adjust behavior of local logic (thresholds, modes, timers).

Service mapping is configured remotely in the Coldwave backend and depends on device definitions.