In the StreamBase expression language, function is a data type. This sample EventFlow module demonstrates three ways to apply an algorithm to data on a stream. Using Map operators, it converts temperature data in degrees Celsius to degrees Fahrenheit, by applying:
A function on a stream.
A global function defined as a constant.
An EventFlow expression.
StreamBase expression language functions can be defined as constant expressions or passed on a stream. As a StreamBase data type, functions return a declared data type, and can accept any other data type as arguments. In this sample, there is one double argument and a double result.
The Map operator UseGlobalExpression invokes a function that was defined as a constant on the EventFlow Editor's Definitions tab using thebutton. The Map operator UseFcnFromData applies a function added to the input stream by Map operator CreateFcn in a field named to_fahr. Map operator UseExpression evaluates an expression rather than a function to transform its input, and is included for comparison purposes.
In StreamBase Studio, import this sample with the following steps:
From the top-level menu, select→ .
to narrow the list of options.
Select the function sample from the Applications category.
StreamBase Studio creates a project for the sample.
In the Project Explorer view, open the sample you just loaded.
If you see red marks on a project folder, wait a moment for the project to load its features.
If the red marks do not resolve themselves after a minute, select the project, right-click, and select→ from the context menu.
function.sbappfile and click the Run button. This opens the SB Test/Debug perspective and starts the module.
Select the Manual Input tab.
Enter a value for a temperature in
celsiusinput stream and click .
Observe that the
temp_f_exproutput values are identical.
When done, press F9 or click the Terminate EventFlow Fragment button.
When you load the sample into StreamBase Studio, Studio copies the sample project's files to your Studio workspace, which is normally part of your home directory, with full access rights.
Load this sample in StreamBase Studio, and thereafter use the Studio workspace copy of the sample to run and test it, even when running from the command prompt.
Using the workspace copy of the sample avoids permission problems. The default workspace location for this sample is:
See Default Installation Directories for the default location of
studio-workspace on your system.