Skip to content

Variable System

Overview

The Variable System is a powerful feature that allows users to create, manage, and use dynamic values throughout the Ecubus Pro platform. Variables function like virtual signals flowing through the internal system, carrying information between different components and nodes. These virtual signals can be captured, transformed, and routed to create flexible and interconnected systems where changes in one area can automatically propagate to others. VarArch

Features

System Variables

System variables are pre-defined variables that provide real-time information about the system's performance and connected devices. These variables are automatically updated by the system and can be accessed but not modified directly by users.

Performance Monitoring Variables

The system provides performance monitoring variables that help track the application's event loop performance:

Variable IDDescriptionUnit
EventLoopDelay.minMinimum event loop delay - lower values indicate better performancems
EventLoopDelay.maxMaximum event loop delay - higher values indicate potential performance issuesms
EventLoopDelay.avgAverage event loop delay - a good balance between performance and stabilityms

These variables are essential for monitoring the responsiveness and performance of the application. High event loop delay values may indicate processing bottlenecks that could affect system responsiveness.

Device Statistics Variables

For each connected CAN device, the system automatically creates a set of statistics variables:

Variable ID PatternDescriptionUnit
Statistics.{deviceName}.BusLoadCurrent bus load for the specified device%
Statistics.{deviceName}.BusLoadMinMinimum bus load recorded%
Statistics.{deviceName}.BusLoadMaxMaximum bus load recorded%
Statistics.{deviceName}.BusLoadAvgAverage bus load%
Statistics.{deviceName}.FrameSentFreqFrequency of frames sentf/s
Statistics.{deviceName}.FrameRecvFreqFrequency of frames receivedf/s
Statistics.{deviceName}.FrameFreqOverall frame frequencyf/s

system var

User Variables

User variables are custom variables that you can create, modify, and delete based on your specific needs. These variables can be used across the application to store values, track states, and create dynamic workflows.

Supported Data Types

User variables support the following data types:

  • Number: Numerical values with optional min/max bounds and unit specification
  • String: Text values for storing names, messages, or any alphanumeric content
  • Array: Collections of values organized in a list format

Creating User Variables

To create a new user variable:

  1. Navigate to the User Variables tab in the Variable Manager
  2. Click the "Add Variable" button (file icon)
  3. Fill in the variable details:
    • Namespace: (Optional) Group your variables logically
    • Name: Unique identifier for the variable (letters, numbers, and underscores only)
    • Description: (Optional) Additional information about the variable's purpose
    • Data Type: Select Number, String, or Array
    • Initial Value: The starting value for the variable
    • For Number type:
      • Minimum: Optional lower bound
      • Maximum: Optional upper bound
      • Unit: Optional unit of measurement (e.g., "ms", "°C", "rpm")

User Variables InterfaceUsrVar

Example

Use Graph-Line to record BusLoad and FrameFreq

typescript
Util.OnKey('b', async () => {
  const pl = []
  const start = Date.now()
  for (let i = 0; i < 5000; i++) {
    const msg: CanMessage = {
      dir: 'OUT',
      data: Buffer.alloc(8).fill(i % 255),
      id: 1,
      msgType: {
        idType: CAN_ID_TYPE.STANDARD,
        brs: false,
        canfd: false,
        remote: false
      }
    }
    pl.push(output(msg))
  }
  await Promise.any(pl)
  const end = Date.now()
  console.log(`send ${pl.length} messages cost ${end - start}ms`)
})

busload