Link Search Menu Expand Document

Data Types

Libertas IDE will automatically analyze the Thing-App source code in supported programming languages to automatically generate Thing-App schemas (metadata).

A schema is a tree structure that contains the following data:

  • Any publicly exposed function can be a Thing-App Function.
  • A Thing-App Function may have arguments (parameters) as task config data. Although a function without any argument is allowed, it is not common.
  • Each argument is a tree-data representation of the data structure.

Each node on the argument schema tree has a type.

Primitive Types

A “primitive type” is a simple type.

  • Boolean - Has two possible values; true or false.
  • Number - A number that could be an integer or a floating-point.
  • String - A string value. An empty string with 0 lengths is allowed by default unless otherwise constrained.
  • Enumeration - Internally, it is an integer. If Enumeration has n items, the value range is [0, n-1].
  • DateTime - Combination of a date and time. Internally, its value is the number of seconds from Unix Epoch. A floating point is allowed with at least a millisecond of precision.
  • TimeOnly - Seconds from midnight. Internally, its value is a number. Floating-point is allowed with at least a millisecond of precision.
  • Device - A logical device. A device represents an endpoint of a physical device. Internally, it is an integer number of a device’s internal ID.
  • LanDevice - A 3rd party Wi-Fi/Ethernet. Internally, it is an integer number of the device’s internal ID. The system keeps track of the IP of a LAN device. For example, if an API initiates a TCP connection to a LAN device, the system will automatically use the IP address it knows.
  • VirtualDevice - A Thing-App emulated logical device. Internally, it is an integer number of the device’s internal ID.
  • User - A Libertas Hub user or a user group. Internally, it is an integer number of a user (or user group) ID.
  • Action - An action is similar to an Scene Action. An action combines a thing and an operation on the object. For example, if the device is a dimmer, the action is dimmer + level + transition time. Unlike Scene Actions, the Thing-App Task Action does NOT have wait options.

Enumeration Type

The enumeration type must be given the list of names.

Enumeration

Enumeration can be translated into any other display language, for example, Chinese.

Enumeration

Complex Types

The system has only two complex types: List (array) and Table (struct).

  • List (array) - A list represents an array of homogeneous types, i.e., all items in a list must have the same type.
  • Table (struct/class) - A table is a struct or class, a collection of key-value pairs. The key is the name; the value may be of any type.

Nullable / Optional

A data node can be optional or nullable, except for array elements. An array element cannot have a “null” value.

The value of a nullable type can be a special “null” value or a native value of the underlying type.

“null” is a special value in JSON. It is also a special value in language bindings. In Typescript, it is called “undefined.” In Rust, it is an Optional type.

Even though a nullable type can be defined in the source code in Libertas, it is not a “real” type in generated schema, where it is represented as the underlying type with a “nullable attribute.”

Programing Language Bindings

Libertas Thing-App can have direct language bindings to all popular programming languages. We chose Typescript and Rust as the programming frontends. Following the language-binding rules to define data structures used as public function arguments is important.

Libertas IDE will automatically analyze the Thing-App source code in supported programming languages to automatically generate Thing-App schemas (metadata).

Libertas Type Typescript Rust
Boolean boolean bool
Number number ‘i8, u8, i16, u16, i32, u32, i64, u64, i128, u128, f64’
String string String
Enumeration enum enum with repr macro such as #[repr(u8)]
DateTime declare type LibertasDateTime = number; type LibertasDateTime = u64
TimeOnly declare type LibertasTimeOnly = number; type LibertasTimeOnly = u32
Device declare type LibertasLanDevice = number; type LibertasDevice = u32
Lan Device declare type LibertasLanDevice = number; type LibertasLanDevice = u32
Virtual Device declare type LibertasVirtualDevice = number; type LibertasVirtualDevice = u32
User declare type LibertasUser = number; type LibertasUser = u32
Action declare type LibertasAction = number; type LibertasAction = u32
List [] Vec<T>
Table declare class struct
Nullable ? Option<T>

Function Signature

The function schema contains the function name and the schemas of each argument. It is referred to as the function signature.

Signature Editor

Libertas Signature Editor is a GUI tool included in the Libertas Studio IDE.

Developers use the signature editor to edit the Thing-App schemas further.

  • The schema tree is automatically generated from the source code for strongly typed languages such as Typescript and Rust. The Tree structure and the type of each node can not be modified
    • Developers can edit the attributes of each schema node
    • Developers can perform localized translation of the UI, such as editing the text string of each node to be displayed on the UI
  • For dynamically typed languages like Lua, developers must manually edit the argument schema trees.

Now, Lua is NO LONGER the recommended programming language for Libertas Studio. We encourage all developers to use Typescript or Rust (upcoming) to write Thing-Apps.

Read Signature Editor for the “Light Show Demo.”

Signature Editor

Thing-App UI Optimization

Combined with Attributes, data types can be optimized on Thing-App UI (e.g., Smartphone).

Time Multi Enum

Work in Progress

Libertas is a work in progress. New data types may be introduced in the future.