IONode Library

The IONode functions provide getters for the inputs and setters for the outputs.

 

Import

There is no import line needed to use this library and its functions.

 

Functions

 

IONode.get_input

Usage: IONode.get_input(name)

Retrieves the value of last value for this tag. Note: If the trigger event does not contain this tag, the last value would be automatically retrieved from historic data.

  • Credit cost: 0
  • Parameters:
    • namestr Name of input to retrieve
  • Returns:
    • dict Input data structure. If the input data structure is from a Tag node (green), it will be of the form:
      {
      "observed_at": "2015-04-11T21:36:53.832111+00:00",
      "event_data": {
          "value": 60
      },
      "tag_name": "raw.bpm"
      }

      If the input data structure is from another Python Module, it will be of the form:

      {
      "observed_at": "2015-04-11T21:36:53.832111+00:00",
      "event_data": {
          "action": "Help Request",
          "sensor_id": "Kiosk_3",
          "type": "Kiosk"
      }
      }

      Note: here actionsensor_id and type are example event_data key names



IONode.get_inputs

Usage: IONode.get_inputs()

Retrieves all of the inputs.

  • Credit cost: 0
  • Parameters: None
  • Returns:
    • list All inputs, of the form:
      [
      {
      "observed_at": "2015-04-11T21:36:53.832111+00:00",
      "event_data": {
          "action": "Help Request",
          "sensor_id": "Kiosk_3",
          "type": "Kiosk"
      }
      },
      ...
      ]

      Note: here actionsensor_id and type are example event_data key names



IONode.get_event

Usage: IONode.get_event()

Retrieves the event data from the event that triggered the workflow.

  • Parameter: None
  • Returns:
    • list List of objects of event data that triggered the workflow
      {
      'trigger': 'data', 
      'not_trigger': 'data'
      }

 

IONode.get_event_id()

Usage: IONode.get_event_id()

Retrieves the event ID from the event that triggered the workflow.

  • Parameter: None
  • Returns:
    • long Event ID from the event that triggered the workflow.
      746741958693904384L

 

IONode.tag_name

Usage: IONode.tag_name(name)

Retrieves the name of a tag node.

  • Credit cost: 0
  • Parameters:
    • namestr Name of input from which to retrieve tag name, if it exists
  • Returns:
    • str Name of the tag, if the input is from a tag node. Otherwise returns None
      "raw.bpm"



IONode.set_output

Usage: IONode.set_output(namedataobserved_at=None, user)

Sets the output data. This is used to output a single event.

  • Credit cost: 0
  • Parameters:
    • namestr output name
    • datadict output data
    • observed_atstr ISO 8601 time string. If not specified (or None), the observed_at of the IONode object will be set to the trigger event's observed_at. Time zone must be specified.
    • userstr user to output the new event to. Optional. If not specified then event will output to the user that triggered the workflow.
  • Returns: None
  • Example Usage:
    IONode.set_output('out1', {"tag1": 1}, user="different_user")

    Output:

    IONode.set_output('out1', {"tag_name":10})



IONode.set_output_list

Usage: IONode.set_output_list(namedata)

Sets the output data as a list. This is used to output multiple events. It is an alternative to using IONode.add_to_output_list.

  • Credit cost: 0
  • Parameters:
    • namestr output name
    • datalist output data array of event objects
    • observed_atstr ISO 8601 time string. If not specified (or None), the observed_at of the IONode object will be set to the trigger event's observed_at. Time zone must be specified.
  • Returns: None
  • Example Usage:
    outputMsgList = []
    outputMsgList.append({"tag1":10})
    outputMsgList.append({"tag2":10})
    outputMsgList.append({"tag3":10})
    IONode.set_output_list('out1', outputMsgList)

Note: This example gives the same results as the example provided for IONode.add_to_output_list



IONode.add_to_output_list

Usage: IONode.add_to_output_list(namedataobserved_at=None)

Sets the output data as a list. This is used to output multiple events. It is an alternative to using IONode.set_output_list.

  • Credit cost: 0
  • Parameters:
    • namestr output name
    • datadict output data
    • observed_atstr ISO 8601 time string. If not specified (or None), the observed_at of the IONode object will be set to the trigger event's observed_at. Time zone must be specified.
  • Returns: None
  • Example Usage:
    IONode.add_to_output_list('out1', {"tag1":10})
    IONode.add_to_output_list('out1', {"tag2":10})
    IONode.add_to_output_list('out1', {"tag3":10})

Note: This example gives the same results as the example provided for IONode.set_output_list



IONode.is_trigger

Usage: IONode.is_trigger(name)

Checks if an IONode is a trigger. Note: This function will not return true if the IONode is a timer.

  • Credit cost: 0
  • Parameters:
    • namestr Name of input to check
  • Returns:
    • bool True if the input is from a tag node and triggered this workflow. Otherwise False
      True

 

Variables

 

IONode.event_timestamp

Usage: IONode.event_timestamp

The timestamp from the event that triggered the workflow.

  • Value:
    • str ISO-8601 timestamp for the event that triggered the workflow
      "2020-02-21T20:05:06.376Z"

 

 

Sample Code


A simple example of code to use IONode from python module:

# note: 'value' is the default name for any Tag input value
myvariable = IONode.get_input('in1')['event_data']['value']
myvariable = myvariable * 2

out_data = {}

# In the code below, the output dictionary is assigned a key name 'output_value' and 
# the value to output: 
#
# - if the output of this module is plugged directly into a Processed Stream output block
# a new Tag will be created in the Processed stream with the name 'output_value'.
#
# - if the output of this module is connected to another Python module, the 
# IONode.get_input() call will then be 'IONode.get_input('in#')['event_data']['output_value']
# This way it is possible to send multiple (key, value) pairs to a single output.

out_data['output_value'] = myvariable
IONode.set_output('out1', out_data)