Signals

Signals are mainly used for inter-process communication or communication with external systems.

The system has 256 built-in signals, indexed from 0 to 255. Each signal can store a 32-bit integer value, ranging from -2147483648 to 2147483647.

After system restart, all signals will be reset to 0.

Set Signal

lebai:set_signal(index, value)
  • Parameters
    • index Signal index
    • value Signal value to set
JSON-RPC
// Request:
{ "jsonrpc": "2.0", "method": "set_signal", "params": [{"key": 0, "value": 0}], "id": 1 }
// Response:
{ "jsonrpc": "2.0", "result": {}, "id": 1 }

Set Multiple Signals

lebai:set_signals(index, values)
  • Parameters
    • index Signal index
    • values Signal values to set
Example Program
lebai:set_signals(1, {1,2,3})
JSON-RPC
// Request:
{ "jsonrpc": "2.0", "method": "set_signals", "params": [{"key": 0, "values": [1, 2, 3]}], "id": 1 }
// Response:
{ "jsonrpc": "2.0", "result": {}, "id": 1 }

Get Signal

value = lebai:get_signal(index)
  • Parameters

    • index. Signal index
  • Returns

    • Corresponding signal value
JSON-RPC
// Request:
{ "jsonrpc": "2.0", "method": "get_signal", "params": [{"key": 0}], "id": 1 }
// Response:
{ "jsonrpc": "2.0", "result": {"value": 0}, "id": 1 }

Get Multiple Signals

value = lebai:get_signals(index, len)
  • Parameters

    • index. Signal index
    • len. Number of signals to get
  • Returns

    • Corresponding signal values
JSON-RPC
// Request:
{ "jsonrpc": "2.0", "method": "get_signals", "params": [{"key": 0, "len": 3}], "id": 1 }
// Response:
{ "jsonrpc": "2.0", "result": {"values": [1, 2, 3]}, "id": 1 }

Add Signal Value

lebai:add_signal(index, value)

Increase the signal value at specified index. This operation is atomic. Overflow may occur.

  • Parameters
    • index Signal index
    • value Signal value to add
JSON-RPC
// Request:
{ "jsonrpc": "2.0", "method": "add_signal", "params": [{"key": 0, "value": 0}], "id": 1 }
// Response:
{ "jsonrpc": "2.0", "result": {}, "id": 1 }