Overview
To better understand User-Defined Functions, let’s create one using the LEO dataset from Tutorial 1. This function will use the camera_1.temperature Channel to convert the temperature from Celsius to Fahrenheit, allowing it to be reused consistently across a Calculated Channel and a Rule.Create a User-Defined Function
- In Sift’s homepage, click the User-Defined Functions tab.
- Click New Function.
- In the User-Defined Function name box, enter:
- User-Defined Function names must meet the following requirements:
- No spaces
- Must be 1 to 253 characters long
- Must start with a letter
- Use only letters, numbers, and underscores
- User-Defined Function names must meet the following requirements:
- Replace
fl(infl_tutorial_7_user_defined_function) with your initials. - In the Enter an expression box, enter the following:
- In this expression,
$1is a placeholder that refers to the first input Channel assigned to the function, in this case camera_1.temperature. Each input Channel can be assigned a data type, including- Number,
- String,
- Boolean, or
- their constant equivalents (Constant Number, Constant String, Constant Boolean).
- Constant types use fixed values defined in the function that do not change between evaluations, while non-constant types receive their values from Channels at the time the function is called.
- For this function,
$1is defined as a Number since camera_1.temperature is a numeric Channel.
- For this function,
- When a function needs to operate on more than one Channel, you can add additional inputs and reference them as
$2,$3, and so on.- For example, if you wanted to calculate the temperature difference between two cameras in the LEO dataset, you could add camera_1.temperature as
$1and camera_2.temperature as$2, and write the expression as$1 - $2.
- For example, if you wanted to calculate the temperature difference between two cameras in the LEO dataset, you could add camera_1.temperature as
- In this expression,
- In the Preview section, click Select Run to preview.
- In the Run name or description box, enter the name of the created Run in Tutorial 1.
- Click Next.
- In the Channel name list, select camera_1.temperature.
- Click Preview.
- Click Save.