Distributed Control & Automation Framework (DCAF)

cancel
Showing results for 
Search instead for 
Did you mean: 

DCAF Arrays of Strings

Solved!
Go to solution

Hello,

 

I'm new to DCAF so I apologise if this is something straightforward. However, I have encountered my first issue.

 

I have a custom module with an 'Array of String' Processing Result.

 

I wish to display this on a UI reference module.

 

I am yet to have any success.

 

This is using the standard engine and configuration editor.

 

My hunch is that this is something to do with initialisation as if you try to 'replace array elements' into an empty string you won't have much luck!. (These next thoughts could be a red-herring though...) 

 

Therefore my thought is that maybe I need to set defaults for my channel tag and engine tag to ensure it isn't initialised with an empty array.

If I probe 'read default value Array of String', I can see that the channel tag from my module has the default I assigned but the engine tag has no default value (just an empty array). This surely means that the swap operations fail when trying to write to the engine data table?

 

A workaround could be to just use a delimited string but I would like to know where I am going wrong.

Any help is much appreciated!

Nick
0 Kudos
Message 1 of 6
(5,388 Views)
Solution
Accepted by topic author niNickC

Hi niNickC,

 

If the Array of Strings is a Processing Result you would want to initialize it somewhere. It this is running on an embedded system it could be a good idea initializing the array in init and then just doing Array Replaces. 

 

I just created a simple static module and the array is populating just fine. I am not connecting this to the UI module yet but the data is moving correctly within the engine. This is what I have in the user process.vi (see file attached). For simplicity I initialize in the first call. The other case just has a replace.

 

Would you be able to attach a simplified version of your module that reproduces the issue?

 

Cheers,

Andres GJ

 

 

 

 

 

 

Message 2 of 6
(5,351 Views)

Hi

You don't mention, but 2D arrays are not supported. I once mapped to a 2D control and it broke the UI being updated.  Also check all labels on your UI are unique. 

Regards

Nick

0 Kudos
Message 3 of 6
(5,343 Views)

Hi Nick,

 

As a sanity check, I set up a project that reads an array of strings from a UI ref module, then writes it back again. It works for all the cases I tried, such as changing array sizes and empty arrays. There's no issue with tags/channels defaulting to empty either.

 

Could you post the custom module?

 

We had a problem on some modules we wrote with wiring a for loop with an array coming in and out, but not checking the array dimensions coming in. One of the arrays was empty, so the for loop didn't excecute. That's the only time I can remember seeing something similar.

 

Matt

0 Kudos
Message 4 of 6
(5,330 Views)

Thanks everyone for your support.

When I probe the 'Data Allocations' output from the module runtime init, you can clearly see an initialised array:

 

Allocations 1.png

 

However, when I probe the Result Allocation in the process method, the array is uninitialised so the replace array inside the data table function fails...

 

Allocations 2.png

Process VI.png

I have attached my module.

Many Thanks

 

Nick

Nick
0 Kudos
Message 5 of 6
(5,317 Views)

Ok so using 'first call' to initialise as AGJ_CR suggested seems to have fixed the problem.

 

Thank you!

 

However, this is quite counter-intuitive to me, why did it not work inside the init function?

Nick
0 Kudos
Message 6 of 6
(5,309 Views)