CTRL-script: Working with struct having a mapping - direct access to mapping not working, DebugN() does not list content of mapping

Discussions about product bugs & problems!
Note: This is no replacement for the Official ETM Support!
2 posts • Page 1 of 1
kwiesinger
Posts:1
Joined: Mon Sep 05, 2016 11:33 am

CTRL-script: Working with struct having a mapping - direct access to mapping not working, DebugN() does not list content of mapping

Post by kwiesinger »

I have performed some tests if the CTRL-script can cope with c-structs having a mapping.

It seems, that basically c-structs are supported, but I've notices two issues:

1. Direct mapping manipulation via the struct-data is not working and causes an exception.
2. DebugN() does list the (primitive) data of the struct, but not the mapping content.

WinCC OA version: 3.14 64bit
Patches: P5
operating system: Windows7 64bit

Here is my test example:

Code: Select all

struct SStructData
{
  string   strAction;
  uint     uState;
  mapping  mDps;
};

struct SDpData
{
  string strName;
  string strType;
};

void main()
{
  SDpData myDp;
  myDp.strName = "NameX";
  myDp.strType = "TypeY";
  DebugTN( __LINE__ +" myDp:" );
  DebugN( myDp );
  
  SStructData myStructData;
  myStructData.strAction = "ON";
  myStructData.uState = 1;
  DebugTN( __LINE__ +" myStructData:" );
  DebugN( myStructData );
  DebugTN( __LINE__ +" myStructData.mDps:" );
  DebugN( myStructData.mDps );
  
  // Direct manipulation - not working
  try
  {
    myStructData.mDps[ myDp.strName ] = myDp;
  }
  catch
  {
    DebugN(getLastException());     
    DebugN(getErrorStackTrace(getLastException()));
  }
  DebugTN( __LINE__ +" myStructData:" );
  DebugN( myStructData );
  DebugTN( __LINE__ +" myStructData.mDps:" );
  DebugN( myStructData.mDps );
  
  // Indirect manipulation - working
  {
    mapping myMapTemp = myStructData.mDps;
    myMapTemp[ myDp.strName ] = myDp;
    myStructData.mDps = myMapTemp;
  }
  DebugTN( __LINE__ +" myStructData:" );
  // DebugN() at the struct does NOT list the content of the mapping
  DebugN( myStructData );
  DebugTN( __LINE__ +" myStructData.mDps:" );
  DebugN( myStructData.mDps );
}
And here the console output:

Code: Select all

WCCOAui1:2016.09.15 11:16:43.933["19 myDp:"]
WCCOAui1:[instance 000000000C20A6B0 of class SDpData
WCCOAui1:"strName" : "NameX"
WCCOAui1:"strType" : "TypeY"]
WCCOAui1:2016.09.15 11:16:43.933["25 myStructData:"]
WCCOAui1:[instance 000000000783B740 of class SStructData
WCCOAui1:"strAction" : "ON"
WCCOAui1:"uState" : 1
WCCOAui1:"mDps" : ]
WCCOAui1:2016.09.15 11:16:43.933["27 myStructData.mDps:"]
WCCOAui1:[mapping 0 items
WCCOAui1:]
WCCOAui1:[dyn_errClass 1 items
WCCOAui1:WCCOAui      (1), 2016.09.15 11:16:43.933, CTRL, WARNING,    78, Assignment to this expression impossible, myStructData.mDps
WCCOAui1:		Stacktrace:
WCCOAui1:		     1: main() at [Module: _QuickTest_ Panel: Test_KW1.pnl Script: Initialize]:33
WCCOAui1:]
WCCOAui1:[dyn_string 1 items
WCCOAui1:     1: "main() at [Module: _QuickTest_ Panel: Test_KW1.pnl Script: Initialize]:33"
WCCOAui1:]
WCCOAui1:2016.09.15 11:16:43.933["40 myStructData:"]
WCCOAui1:[instance 000000000783B740 of class SStructData
WCCOAui1:"strAction" : "ON"
WCCOAui1:"uState" : 1
WCCOAui1:"mDps" : ]
WCCOAui1:2016.09.15 11:16:43.933["42 myStructData.mDps:"]
WCCOAui1:[mapping 0 items
WCCOAui1:]
WCCOAui1:2016.09.15 11:16:43.933["51 myStructData:"]
WCCOAui1:[instance 000000000783B740 of class SStructData
WCCOAui1:"strAction" : "ON"
WCCOAui1:"uState" : 1
WCCOAui1:"mDps" : ]
WCCOAui1:2016.09.15 11:16:43.933["54 myStructData.mDps:"]
WCCOAui1:[mapping 1 items
WCCOAui1:         "NameX" : instance 000000000B42BF70 of class SDpData
WCCOAui1:"strName" : "NameX"
WCCOAui1:"strType" : "TypeY"
WCCOAui1:]
Best regards,
Klaus

mkoller
Posts:741
Joined: Fri Sep 17, 2010 9:03 am

Re: CTRL-script: Working with struct having a mapping - direct access to mapping not working, DebugN() does not list content of mapping

Post by mkoller »

ad 1: this is currently not implemented
ad 2: seems to be a bug in 3.14 which is already solved in 3.15 (note that struct/class are an experimental feature in 3.14)

2 posts • Page 1 of 1