How-To Guides
Analytics Guides

Use the Simple Window Function

6min

You can use the Simple Window function to output a simple moving window. In the FIFO (first in, first out) algorithm, the first data point that enters the window is the first to be processed and removed as new data points come in. This function takes a single value as inputs.

User Scenario

Review the following scenario for the Simple Window function. Then, you will simulate PLC data and calculate the trend in the data.

In a manufacturing setting, the Simple Window function is used to analyze the real-time performance of a specific machine component. As new data points representing the component's performance are generated, the Simple Window function processes the data in a FIFO (first in, first out) manner, allowing the engineers to monitor the immediate impact of any changes or adjustments made to the component. This helps in quick identification of any anomalies or deviations from expected performance, facilitating timely maintenance or intervention.

Step 1: Add a Device

Follow the steps to Connect a Device and configure the following parameters:

  • Device Type: Simulator
  • Driver Name: Generator
  • Enable Alias Topics: Select the checkbox.

Step 2: Add Tags

After connecting the device, add the following tag. See Add Tags to learn more.

Tag 1: input1

  • Name: Select S - Random value generator
  • Value Type: Select float64
  • Polling Interval: Enter 1
  • Tag Name: Enter input1

Step 3: Create Analytics Flows

You can now create the analytics flows using data from the device and tag you previously created.

To create an analytics flow with the Simple Window Processor function:

  1. In Litmus Edge, navigate to Analytics.
  2. On the analytics canvas, click Add processor. The Create a processor dialog box displays.

    The Add processor option
    The Add processor option
    
  3. Select DataHub Subscribe.
  4. In the Topic field, click the Search icon, select the device you previously created, and then select the alias topic for the input1 tag.

    Create a Processor dialog box
    Create a Processor dialog box
    
  5. Click Save.
  6. Click Add processor again and select the  Simple Window processor. The Edit a Processor dialog box appears.
    • Value Type: This parameter specifies the type of incoming value. For example, if our input1 tag generates float64 values and we want int values for our window, we can select int from the drop-down menu.
    • Order: This parameter specifies the desired order of output window.
      • Oldest -> Newest
      • Newest -> Oldest
    • Window Size: This parameter specifies the window in which the values will be observed.
    • Click Save.

      Document image
      
  7. Connect the DataHub Subscribe processor (tag: input1) to the Simple Window processor with a wire and use the events connection.
  8. On the analytics canvas, click Save. The configured analytics flows should look like the following:
Document image


Step 4: View Output of Processor

Click the View icon in the Simple Window processor to view the output values.

The output shows a window of size 10 holding the incoming values from our input1 tag.

Output of Simple Windowprocessor
Output of Simple Windowprocessor