Complex Data Type Parameters

Sepasoft MES Module Suite

A Complex Data Type Parameter is a flexible method for holding array data within a chart. They are created in the Start Block and can be accessed via scripting in the Script Block, and are also available for mapping connections in the Enclosing Chart, BAPI Action and RFM Action blocks. Data can be passed into and returned from charts by the chart execution functions here: system.mes.bc. The chart.getParameterValue() function will return a Complex Data Type Parameter object with several methods available for data manipulation.



Creating a Complex Data Type Parameter

Complex Data Type Parameters are created in the Start Block of any chart.

Create or Edit a New Data Type Parameter

Chart Parameters are created and edited in the Start Block's Start Properties pane:





Rules Regarding Complex Data Type Parameters

Information
  • Naming must conform to XML naming rules (see below).
  • Indexing starts at 1, so B[1] is the first element in the array B[1 to n].
  • To pass/read values to/from the entire array remove '[]' from the path used to address the array within the Complex Data Type Parameter.
  • To address specific elements within an array via an iterator, keep '[]' in the path.
  • Do not write a value to an element that doesn't already exist (must use the .append method of the Complex Data Type Parameter object to add a new element and their initial values to Complex Data Type Parameters).

To create a new Chart Parameter, click .

Configure the Chart Parameter using the Edit Parameter dialog box.


  1. Name the new parameter in Parameter Name (refer to naming rules above).
  2. Select the Complex Data Type radio button.
  3. Click on the name of your new parameter in the Complex Parameter Structure area.
  4. Click to add a row. Name it and select the Data Type in the Complex Node Editor area on the right. For an array instead of a list, select "Complex" from the Data Type drop-down. This will make this entry eligible for child elements.
  5. Complete the list or array as needed.
  6. Click Save to save the parameter (or Cancel to quit the edits).


Naming Rules

Information

Naming must conform to XML naming rules.

Element names:

  • Case-sensitive
  • Must start with a letter or underscore
  • Cannot start with the letters xml (or XML, or Xml, etc)
  • Can contain letters, digits, hyphens, underscores
  • Cannot contain spaces

Also:

  • Parameters must have unique names
  • Within a complex parameter, sibling nodes must have unique names

Object Functions

The chart.getParameterValue() function will return a Complex Data Type Parameter as a Pythonic object (dictionary, list, string, integer, real, etc., with type Date being represented in Ignition Date format). Therefore, the usual Python methods are available for data manipulation, such as:

.append()

Appends an element to a Pythonic List. Note that indexing begins at '1' instead of '0'.

Code Snippet

Code
list = chart.getParameterValue('@A/B[1]/C')
list.append('nine')
chart.setParameterValue('@A/B[1]/C', list)

Before

Code
<?xml version="1.0" encoding="UTF-8"?>
 <A>
    <B>
      <C>five</C>
      <C>six</C>
    </B>
    <B>
      <C>simple</C>
       <C>four</C>
    </B>
 </A>
    
   


After

Code
<?xml version="1.0" encoding="UTF-8"?>
 <A>
    <B>
      <C>five</C>
      <C>six</C>
      <C>nine</C>
    </B>
    <B>
      <C>simple</C>
      <C>four</C>
    </B>
 </A>

.remove()

Removes an element from a Pythonic List. Note that indexing begins at '1' instead of '0'.

Code Snippet

Code
list = chart.getParameterValue('@A/B[2]/C')
list.remove('four')
chart.setParameterValue('@A/B[2]/C', list)

Before

Code
<?xml version="1.0" encoding="UTF-8"?>
 <A>
    <B>
      <C>five</C>
      <C>six</C>
      <C>nine</C>
    </B>
    <B>
      <C>simple</C>
      <C>four</C>
    </B>
 </A>


After

Code
<?xml version="1.0" encoding="UTF-8"?>
 <A>
    <B>
      <C>five</C>
      <C>six</C>
      <C>nine</C>
    </B>
    <B>
      <C>simple</C>
    </B>
 </A>
   
   




Example 1

In this example chart, the Iteration Block, Decision Block and Aggregation Block have the ability to utilize Chart Parameters with 'Complex Array' parameter nodes created in the Start Block.



The following example showcases a typical Chart Parameter with complex array parameter nodes, named NestedArray, which is comprised of a root (NestedArrayRoot), a child element (A[ ] ) of type 'Complex Array', and an array of type 'Integer' (B[ ] as child of that. It is being fed a value from the calling button script. The chart iterates through each of the four A[ ] elements, and for each one, iterates through all four B[ ] elements.



Start Block

The root level of the Chart Parameter, NestedArray, is created by default. It is empty and requires one or more child elements to be useful.

Child element A[ ] is created as 'Complex Array' since the Array checkbox is checked. This creates an iterable series of empty array elements, starting at 0.

Child element B[ ] is created under A[ ] as data type 'Integer Array' (since the Array checkbox is checked) to hold data values. It is not set as type 'Complex Array' because that would make it an iterable series of empty array elements which would require at least one of its own child elements to hold data values.






Iteration Block: A Loop

This block loops through each instance of the empty complex array element node A[ ], starting with 0.

Note that there are two choices in the drop-down Array Path menu, one for each level of the array. The first is for the empty complex array element node, A[ ], and the second is for the integer array, B[ ]:




Array Path selection for "A Loop" Iteration Block



Script Block: A Loop

This script merely outputs the current value of A[ ] to the Ignition gateway Log. In this example, each instance of A[ ] contains a dictionary of that element's associated integer array, B[ ]:

A[0] → {'B' : [0, 1, 2]}
A[1] → {'B' : [10, 11, 12]}
A[2] → {'B' : [20, 21, 22]}



Log output for "A Loop" Script Block (in this example, for A[0])



Iteration Block: B Loop

This block loops through each instance of the integer array element B[ ] at the current instance of A[ ], starting with 0.

Note that there is no longer two choices in the drop-down Array Path menu. The empty complex array element node, A[ ], has already been claimed by the first Iteration Block, leaving only one remaining choice (the integer array, B[ ]).


Array Path selection for "B Loop" Iteration Block



Script Block: B Loop

This script merely outputs the current integer value of B[ ] at the current instance of A[ ], to the Ignition gateway Log. In this example, each instance of B[ ] contains a series of integers previously assigned by the button script:

A[0] / B[0] → 0
A[0] / B[1] → 1
A[0] / B[2] → 2

A[1] / B[0] → 10
A[1] / B[1] → 11
A[1] / B[2] → 12

A[2] / B[0] → 20
A[2] / B[1] → 21
A[2] / B[2] → 22



Log output for "B Loop" Script Block (in this example, for A[0])



Button Script

A window with a single Ignition Button component is used to:

  • Name the chart to be executed (Nested Iteration).
  • Assign integer values to each instance of integer array B[ ] in Chart Parameter NestedArray.
  • Pass in NestedArray and execute the chart Nested Iteration.




Ignition Button script on window


Log Output

The Ignition gateway Log records the output from the two Script Blocks that use logger commands to write out the current values of A[ ] and B[ ] per the nested chart execution sequence (remember: read from bottom upwards).








Sepasoft MES Module Suite