Sequences

Cryogenic application requires sequences for certain procedures (i.e. Evacuation). These sequences can be represented with a subset of flowchart Blocks: Process, Decision and Terminator. Cryo HMI Framework Controls implements this subset and joins them all together with a specialized Sequence Container that actually interfaces with the PLC code.

Blocks

Blocks are very simple controls with no important processing code inside of them. There are 3 blocks implemented, they all have the same interface, but their symbol and meaning are different:

  • Process: Also called activity. Once finished it goes to the next step.

  • Decision: Conditional operation that determines which one of the two paths the sequence will take.

  • Terminator: Indicates the beginning and ending of a sequence.

../_images/sequences_block_types.png

The 3 types of Blocks

All of them can be in any of 3 different states: Idle, Active and Finished

../_images/sequences_block_states.gif

States of a Sequence Block

  • Idle: The sequence has not yet reached this step. The box has a white background.

  • Active: The sequence is currently executing this step. The box background is animated between a white and a green background.

  • Finished: The step has already been finished. The box has a green background.

For further information about Flowchart and its Blocks check its wiki page

Blocks Interface

Common Blocks Interface Table

Name

Group

Description

Value

Common

String or Value that it’s being shown inside the block symbol.

BlockId

Common

Unique number that represents the ID of this block, no other block should have the same value. The number is shown on the upper left side of the Framework Control as S<BlockId>.

State

Common

INT value that represents the state of the device: Idle (0), Active (1) and Finished (2).

On Fill Color

Colors

Symbol Fill Color when it’s Finished

Off Fill Color

Colors

Symbol Fill Color when it’s Idle

Sequence Container

As the name suggests, Sequence Container Framework Control inherits the TE2000 Container capabilities.

As a plain container, it can group any child control. All child controls added are defined relative to the position of the container.

Sequence Containers also allow the user to interface with the PLC sequence by using a custom json-schema named Sequence Object . Check Sequence Container Interface for more information.

Note

There is a function block in CryoLib FB_CRYO_HMI_SEQUENCE that can interface directly with Sequence Container, but this is not covered in this manual.

The container will accept any type of control inside of it, but will only interact with Process, Decision and Terminator and only if they are direct childs of the container. Please check the section Example for more information.

Interface

Sequence Container has a specially defined Object as interface called Sequence. The interface is defined by a json-schema:

{
  "$schema": "http://json-schema.org/draft-04/schema",
  "definitions": {
    "TcHmi.Controls.CryoFramework.SequenceContainer": {
      "type": "object",
      "frameworkInstanceOf": "TcHmi.Controls.System.TcHmiControl",
      "frameworkControlType": "SequenceContainer",
      "frameworkControlNamespace": "TcHmi.Controls.CryoFramework"
    },
    "TcHmi.Controls.CryoFramework.Sequence": {
      "properties": {
        "arSequence": {
          "items": {
            "type": "integer"
          },
          "type": "array"
        },
        "bIsFinished": {
          "type": "boolean"
        }
      },
      "type": "object",
      "required":[
        "arSequence",
        "bIsFinished"
      ]
    }
  }
}

In summary, the Object Sequence is a structure that contains two attributes:

  • arSequence: Array of integer (BlockIds) values.

  • bIsFinished: Flag that signals if the sequence is still running.

The Sequence Object isthe only interface Object that needs to be linked with the PLC.

Sequence Container Interface Table

Name

Group

Description

Sequence.arSequence

Common

Array of numbers indicating Finished blocks. The last value of the array is the active block.

Sequence.bFinished

Common

If this value is true, the current active block is marked as finished.

Blocks and Container Logic

Every time the container gets an update of arSequence and bIsFinished, the following procedure is called:

## WARNING This is just a small representation of the actual code.

## sequenceBlocks is a dictionary of blocks with block_id as key

def SequenceUpdated(self, ar_sequence: List, is_finished: bool):
    ## All elements of sequence_blocks are put to Idle state
    for block_id in self.sequence_blocks:
        self.sequence_blocks[block_id].setState(State.IDLE)

    ## Take last value, which corresponds to the current processed block
    last_value = ar_sequence.pop()
    if is_finished:
        self.sequence_blocks[last_value].setState(State.FINISHED)
    else:
        self.sequence_blocks[last_value].setState(State.ACTIVE)

    ## Put all other valid blocks from the sequence array as Finished
    for block_id in ar_sequence:
        if block_id in self.sequence_blocks:
            self.sequence_blocks[block_id].setState(State.FINISHED)
        elif block_id > 0:
            ## Error logged to browser console
            error("SequenceID " + block_id + "not present in HMI sequence!")

Example

Let’s create a simple sequence for testing and understanding Sequences.

The Setup

  1. Add a Sequence Container, in this example, we also add borders so it’s easy to see its limits.

../_images/sequences_example_add_container.png
  1. Add a Sequence Blocks and give them unique BlockID, also add some text on their Value

../_images/sequences_example_add_blocks.png
  1. Use a simple line to connect all the vertical Blocks [0, 1, 2, 10, 11, 30].

../_images/sequences_example_add_line.png
  1. Add a rectangle to join Block S20 to the Rest of the diagram.

../_images/sequences_example_diagram.png

After following these steps, the setup is done.

Note

Steps 3 and 4 are only for cosmetic reasons, the line and the rectangle will not affect in any way the sequence behavior.

Testing a correct Sequence

Now that the sequence done, we will modify its Sequence attribute to see how it affects it.

  1. With the sequence container selected, click the attribute CommonSequence three doted box [...].

../_images/sequences_example_open_attribute.png
  1. A new box will appear, select bIsFinished and then deselect it (this is to avoid an error)

../_images/sequences_example_edit_properties.png
  1. Then press on the three doted box [...] on arSequence and a new menu will appear.

  2. This menu is to edit arSequence array. Press Add button and a new value will appear, make sure the value is 0.

../_images/sequences_example_edit_arSequence.png
  1. Close both modal windows and you should see how it affects the block with BlockId = 0. The block will blink between white and green colors signaling the user that this is the current step in the sequence.

../_images/sequences_example_1_block.gif

Figure inside red box with dashed outline is blinking

  1. Repeat step 3, 4 and 6. But this time add [1, 2] to the array. Make sure 2 is the last value of the array (at the end).

    ../_images/sequences_example_3_block.gif
  2. Repeat step 3, 4 and 6. But this time add [10, 30] to the array. Make sure 30 is the last value of the array (at the end). Notice how the blinking block is always the last one on the list, in this case, Block 30

    ../_images/sequences_example_5_block.gif
  3. Open again the Sequence Object (as Step 1), this time, only check the value bIsFinished. Now Block S30 will stop blinking

../_images/sequences_example_5_block_finished.png

This concludes the example, this should clear more or less how Sequences work.

Testing an incorrect Sequence

  1. Follow the steps of Testing a correct sequence until step 4.

  2. Add into arSequence the values [9, 20].

../_images/sequences_example_bad_sequence.gif
  1. Notice how Block S9 is green and S20 is blinking.

Warning

As shown in the example, Sequence Blocks and Container are only a meant to show the state of a Sequence of a PLC. No logic is present to make sure that the data is consistent, so if an error like this appear could mean that the PLC sequence is wrong, or the BlockId between the PLC and the HMI seuquence are not correctly aligned.