79419177

Date: 2025-02-06 19:56:22
Score: 0.5
Natty:
Report link

After talking to a dev with more familiarity with INGEAR, I have the answer.

You can't, or at least not with this data structure.

What you need is to have a UDT array wrapped in a UDT with only a single value. The data structure would then look like this:

public struct STRUCT_B
{
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 10)]
    public STRUCT_A[] A_List;
}

and in the PLC, you would need to have the same hierarchy exist.

Furthurmore, you could spin through the results with the following:

        DTEncoding udtEnc = new DTEncoding();
        STRUCT_B result = (STRUCT_B )udtEnc.ToType(Testing, typeof(STRUCT_B));

        for(int x = 0; x < 10; x++)
        {
            if (result.A_List[x].Active == true)
            {
                Console.WriteLine(sample.A_List[x].Value);
            }
        }

Additionally, this behavior does not play well with Booleans as it is better to define the first byte of the struct if there are booleans present and then extract them.

Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: cszynkowski