Heisenware Docs
Go to websiteGet a demo
  • 👋Welcome
  • Getting started
  • Release Notes
    • v84 - Get in the flow
    • v83 - Beauty treatment
    • v82 — Fully distributed
    • v81 — Removing old cruft
    • v80 — Chicks on fire
    • v79 — Nothing is forever
    • v78 — Keep moving
    • v77 — More intelligence
    • v76 — Well cooked
  • Build & Deploy Apps
    • Overview
    • Flow Builder
      • Nodes (Functions)
        • Inputs
        • Trigger
        • Output
      • Function Extensions
        • Modifier
        • Filter
        • Error handler
        • Memorizer
      • Objects & Instances
      • Utilities
        • Basic Functions
        • PDF functions
        • Circular buffer
        • Timer
        • Counter
    • Integrations
      • Protocol Connectors
        • GraphQL
        • HTTP/REST
        • MQTT
        • OPC UA
          • Heidenhain PLCs with OPC UA
        • RS-232/485
        • Siemens S7
      • Data Connectors
        • File
        • Relational Database
        • Time Series Database (WIP)
      • API Connectors
        • OGC SensorThings API
        • Operating System
        • Zebra RFID IoT Connector
      • Agent / (Edge Connector)
      • Calling Custom Code
    • UI Builder
      • Input Widgets
        • Form
        • File Upload
        • Photo
        • Signature
        • Barcode / QR-Code (WIP)
        • Document Scan (WIP)
      • Display Widgets
        • Chart
        • Chat
        • Circular Gauge
        • Data Grid
        • Linear Gauge
        • Map
        • Media View
        • Progress Bar
        • Sparkline
        • Status Lamp
        • Toast
        • Value Box
        • Kanban Board
        • Data Tiles
        • Pie Chart
        • Sankey
      • Buttons
      • Text Box
      • Images
      • Icons
    • Communication Interfaces
      • Email Notifications
      • OPC UA Server
    • Data & File Storage
      • Internal InfluxDB
      • Internal PostgreSQL
      • File Server
    • App Appearance
      • Pages
      • In-App Navigation
      • Screens & Devices
      • Theming
    • Simulation & Testing
      • Simulating Events
      • Simulating Data
    • PDF Templates
    • RAG-based Chatbot
    • Deployment
  • Manage Apps
    • Overview
    • Manage Apps
      • General Settings
      • Users and Access
      • Distribution & Versioning
    • Manage Integrations
    • Manage Account
      • Account Structure
      • Members
      • Workspaces
  • TUTORIALS
    • Build Your First Heisenware App
  • Connect Heidenhain CNC with OPC UA Support
  • Related links
    • Website
    • Privacy policy
    • Imprint
Powered by GitBook
On this page
  • Returning the same value
  • Combine data into array
  • Merging objects
  • Appending to an array
  • Mapping a range
  • Adding a delay
  • Checking for true parameters
  • Converting JSON data to a string
  • Parsing JSON data
  • Merging arrays
  • Combine arrays
  • Group arrays
  • Renaming object keys
  • Memory
  • Trigger
  1. Build & Deploy Apps
  2. Flow Builder
  3. Utilities

Basic Functions

Last updated 6 days ago

Basic functions are essential for data processing and serve as the foundational components for developing business logic. To utilize the basic functions:

  1. Find the Functionality panel on the left-hand side of the screen

  2. Expand Utilities and then Basic Functions

  3. Drag the function you want to use into a section on the logic board

Returning the same value

The echo function returns the given input without modification. It can be utilized for intermediate processing within a workflow or for debugging purposes. Additionally, echo serves as a method to generate static input values within the application logic.

Combine data into array

With combine, you can add two or more arguments into an array structure. You can mix different types of data and manually write data into the input boxes. To combine more than two arguments, you need to add more input boxes.

To combine data into an array:

  1. Drag an output onto the first input box or write a static value into it.

  2. Repeat for the second input box.

  3. Optionally add more input boxes by clicking the + symbol next to the existing input boxes and repeat the first step for them.

  4. Trigger the function and check if the output matches your desired format.

Merging objects

mergeObjects can combine two or more objects into one.

To merge objects:

  1. To add more objects, click the + symbol next to the initial input box. This action will create a new input box for each additional object you want to add.

  2. Drag the object boxes onto the inputs in the order you want to add them together.

  3. Trigger the function and expand the output to see if it matches your desired format.

Appending to an array

The arrayPush function appends arrays or individual items to an existing array. To add items or arrays, include them as arguments. Manual static inputs are also supported.

To create a new array:

  1. Drag the array you want to extend onto the first input.

  2. Then drag the items individually into the further inputs, following the order you in which you want to add them.

  3. If necessary, simply add new input boxes by clicking the + icon after any existing input box.

  4. Trigger the function.

Mapping a range

The mapRange function transforms a numeric value from an original range to a target range, both of which are defined by the user. This utility allows for scaling of numbers to fit into different numerical contexts or representations.

To map a range:

  1. To enter a value for mapping, type it directly into the first input field or drag and drop an output value onto it.

  2. Define the ranges in the second input by writing the names of the corresponding variables with a colon, then a space and then the value.

  3. Hit enter for a line break and add the next value.

You may copy the code below and insert it into the input box, then define the ranges by replacing null with your values.

origMin: null
origMax: null
newMin: null
newMax: null

Adding a delay

The delay function allows you to postpone the propagation of a value in your application, providing greater control over when specific actions occur.

To configure a delay:

  1. The first input field specifies the ID for the delay timer. This ID is required and needs to be unique for each delay.

  2. Add a second input field to insert or link your value.

  3. Introduce a third input field and specify your desired delay in milliseconds (e.g., timeout: 5000 for a five second delay). If this field is omitted, a default of 1000 milliseconds (one second) is applied.

    • If you wish to trigger this delay with every input update, even when the value remains the same, click change in the Trigger section and select the appropriate operational mode.

Checking for true parameters

Checking for all true parameters

The truth value of the result is determined as follows:

  • Leaving a box blank, inserting NULL, 0 or false or having fewer boxes than the defined number of parameters will result in the output false.

  • Any other value in the input boxes will result in true

  • Additional boxes above the defined number of parameters will be ignored ONLY if they are empty. Otherwise, the output will be false.

How to apply the AND operation:

  1. Define the number of needed parameters in the first input box.

  2. Add the amount of necessary input boxes.

  3. Manually insert or link data.

Checking for one or more true parameters

Filling an input box with content other than leaving it empty, entering NULL, 0, or false is interpreted as true.

In contrast to areAllParamsTrue, you don't need to define the number of input boxes. Just follow these steps:

  1. Create however many input boxes you need.

  2. Manually insert or link values.

Converting JSON data to a string

jsonStringify automatically converts an input to a suitable JSON string. The input should be an object or an array. Subsequent input boxes after the first one are ignored.

Parsing JSON data

The jsonParse function can interpret JSON data from outputs, transforming them into objects that can be utilized in other functions.

NOTE: When manually specifying JSON in a function's input, it is automatically converted into an object. Therefore, explicitly converting it with this function is unnecessary.

Merging arrays

mergeArrays is a function designed to combine multiple arrays by nesting their elements one level deeper into a new array structure. It requires at least one array as input.

The function compares the lengths of the input arrays and creates a new array with the length matching the shortest input array. Elements from the original arrays are repositioned as sub-elements at their respective indices within this new array. Any elements beyond the length of the shortest input array are omitted in the output.

To merge arrays:

  1. Add input boxes as needed.

  2. Drag arrays from outputs onto the inputs or specify them manually.

Combine arrays

This function combines multiple arrays of objects into a single array of objects. Corresponding elements from each array are merged into a single object. Keys of object elements are suffixed by the array index using an underscore.

Group arrays

Groups arrays of objects based on specified keys and merges objects with the same group identifier.

Renaming object keys

The renameObjectKeys function is designed to modify the keys in an object based on a provided mapping. It requires two parameters:

  1. Source Object: The object whose keys need updating, containing original key-value pairs.

  2. Mapping Object: An object defining the new key names, with each property pairing a new key name with its corresponding old key name newKey: oldKey.

Remember to write each mapping in a new line by hitting enter.

For source objects with variable key names, you can drag a dynamic key mapping object into the second input to adapt accordingly.

Memory

A memory function, also called memorizer, is functionally equivalent to an echo function set to trigger on its own input update. The moment the input changes, the output is updated as well.

Trigger

A trigger function is a function with no input, consisting of a trigger and an output. Like the memorizer, it can be dragged onto the canvas directly from the toolbar. This function can be used to trigger another function or a widget action that doesn't need an input, or to print out the timestamp of the trigger.

Drag your value onto the to ensure this delay is activated whenever the input value is modified.

To execute a logical operation across multiple variables, you can utilize the areAllParamsTrue function. It returns true when and only if every provided input evaluates to true.

Trigger the function or create a by linking.

The isOneOrMoreParamTrue function operates using a logical operation, in contrast to using a logical AND operation. This function returns true if at least one of its given parameters is true.

Trigger the function or create a by linking.

Trigger the function or create a to run this every time an input array changes.

Trigger
AND
OR
conditional trigger
conditional trigger
conditional trigger
Adding a string and an object into an array
Merging of two Objects
Attaching an item to an array
Mapping value 5.5 from range 0 to 10 to range 0 to 100
A delay with a timer of 5 seconds
Logical AND over three different values
Logical OR with two inputs
Hello World example for object to JSON
Extended Hello World example for JSON to object
Merging of two array with differing lengths
Combining two arrays
Renaming keys in an object