Welcome to our new forum
All users of the legacy CODESYS Forums, please create a new account at account.codesys.com. But make sure to use the same E-Mail address as in the old Forum. Then your posts will be matched. Close

Visualization - writing to an array using a variable for the index

2019-01-17
2019-01-18
  • Tim.Manning - 2019-01-17

    Hi,

    I am new to Visualization. I am using an OEM IDE, based on CodeSys 3.5.

    I am trying to use a Visualization Table to read and write data to a single row of 16 row array. The row to be displayed will be selected by setting a global variable, which will be used as the index. [NOTE: It's not possible to use a visualization local variable as an index to an array, the compiler throws an error]

    In the table properties, the 'Data array' is defined as 'Program_POU.arrayName[GVL_Var.arrayIndex]'

    For the column properties, I have selected 'Use template' and under the 'Template' -> 'Inputconfiguration', I have set 'OnMouseClick' to 'Write a Variable', and under 'Choose variable to edit', I have selected 'Use text output variable'.

    In the visualization, the table displays the data just fine. As I vary the 'arrayIndex' value, the correct row of the data array is displayed.

    However, I can't write to the data array. I click on the array cell, and the cell opens and allows me to type in the new value. However, when I press enter, no data is written to the array.

    I have tested this with a hard coded index, and it works just fine. However, it would be very inefficient for me to have to create 16 unique instances of this visualization, rather than create one and use a variable index.

    Is what I am doing supposed to be supported?

     
  • Tim.Manning - 2019-01-18

    I have tested this further and the issue seems to be with writing to an array of structures. If I write to an array of primitives (e.g., an array of INTs or REALs) everything works fine. However, writing to an array of structures, I can't write if the array index is a variable. I can write to an array of structures if the array index is fixed.

    See my test cases and results below.

    Am I doing something wrong, or is this a bug?

    I have tested this as follows:

    Test 1
    Type of Element = Text field
    Column = 'Use Template' -> 'InputConfiguration' -> 'On mouse click' -> 'Write variable'

    Case 1
    Text Variable = 'Program_POU.arrayName[GVL_Var.arrayIndex]' -

    Result - Read - SUCCESS
    Write - SUCCESS

    Case 2
    Text Variable = 'Program_POU.structName[GVL_Var.arrayIndex].structElement'

    Result - Read - SUCCESS
    Write - FAIL

    Case 3
    Text Variable = 'Program_POU.structName[1].structElement'

    Result - Read - SUCCESS
    Write - SUCCESS

    Test 2
    Type of Element = Table

    Case 1
    Data array = 'Program_POU.arrayName[GVL_Var.arrayIndex]'

    Column = 'Use Template'
    Text Variable = 'Program_POU.arrayName[GVL_Var.arrayIndex]'
    'InputConfiguration' -> 'On mouse click' -> 'Write variable'

    Result - Read - SUCCESS
    Write - SUCCESS

    Case 2
    Data array = 'Program_POU.structName[GVL_Var.arrayIndex]'

    Column = 'Use Template'
    Text Variable = 'Program_POU.structName[GVL_Var.arrayIndex].structElement'
    'InputConfiguration' -> 'On mouse click' -> 'Write variable'

    Result - Read - SUCCESS
    Write - FAIL

    Case 3
    Data array = 'Program_POU.structName[1]'

    Column = 'Use Template'
    Text Variable = 'Program_POU.structName[1].structElement'
    'InputConfiguration' -> 'On mouse click' -> 'Write variable'

    Result - Read - SUCCESS
    Write - SUCCESS

    Test 3
    Type of Element = Radio Button

    Case 1
    Variable = 'Program_POU.arrayName[GVL_Var.arrayIndex]'

    Result - Read - SUCCESS
    Write - SUCCESS

    Case 2
    Variable = 'Program_POU.structName[GVL_Var.arrayIndex].structElement'

    Result - Read - SUCCESS
    Write - FAIL

    Case 3
    Variable = 'Program_POU.structName[1].structElement'

    Result - Read - SUCCESS
    Write - SUCCESS

     

    Related

    Talk.ru: 1


Log in to post a comment.