Jump to content

Datatype Class


Recommended Posts

Hi All,
I am currently facing some challenges with my application for data acquisition and processing. Specifically, the data cluster in the system has grown quite large, making it difficult for me to manage, especially when I consider adding new features. I have heard that converting everything to a class is the best approach, but I am unable to find any suitable resources or examples for it. Most of the available information pertains to simple and uncomplicated data types. Can anyone please guide me towards the appropriate resources or provide an example?

 

Thank you,

P.S. The data cluster in question is the subject of my inquiry look like this:

image.png.76e7298b45991be3f40124b7755ecb41.png 
and this is the class I atempted:
image.png.518bf15c2f89d058be28249393e23bee.png

Link to comment
13 hours ago, Mahbod Morshedi said:

I have heard that converting everything to a class is the best approach

Not like this

image.png.126031e50b3790892d75ffe736af3228.png

13 hours ago, Mahbod Morshedi said:

, but I am unable to find any suitable resources or examples for it. Most of the available information pertains to simple and uncomplicated data types.

Because that is the goal; break down your complex and complicated data types into simple and uncomplicated ones.

For configuration data you could maintain the path to the storage location and load the data as needed.

  • Like 1
Link to comment
20 hours ago, LogMAN said:

break down your complex and complicated data types into simple and uncomplicated ones.

Break down your complex and complicated data types into a complex and complicated architecture. :P FTFY

Edited by ShaunR
  • Haha 2
Link to comment

Thank you both for your comments,

 

I undrersatnd that my dta organisaion is a mess here. however i use these almost every where and wanthet to use only one wire across. I am not sure if there is a better way to do that since that can programatically change or vis UI. That is why I wanted to use a class to help me with ubn and bbn of the cluster data.

Cheers,

Link to comment
25 minutes ago, Mahbod Morshedi said:

That is why I wanted to use a class to help me with ubn and bbn of the cluster data.

If you are going they way I think you are, all you will do is swap [un]bundles for VI's and add a lot of boiler plate. To be fair. You monster cluster isn't really that much of a monster-more like a tribble.

My advice (if you're not going to re-architect) would be just to split out the data from the config. Your All Scan data BG and HRS is actually an identical format so you could rationalise that into a single array which will make adding more of the same format easier (just add and index into the array-no need to modify the cluster to add more data). Everything else seems to be config data.

Link to comment

I would agree that it doesn't quite look "monsterly" but there seems to be some cross contamination between  simple configuration stuff and actual test specs or data results or whatever it is.

If you talk class it would only be an improvement if you start about taking these apart into more fine grained classes. Some manager class that then can contain the individual test classes. Otherwise you simply replace a somewhat unwieldy cluster through a similar unwieldy class. And that is no real improvement at all. A class simply is a cluster on some steroids anyhow. (Yes I know it is a sloppy statement but for many purposes it is quite accurate).

Edited by Rolf Kalbermatter
Link to comment
10 hours ago, ShaunR said:

If you are going they way I think you are, all you will do is swap [un]bundles for VI's and add a lot of boiler plate. To be fair. You monster cluster isn't really that much of a monster-more like a tribble.

My advice (if you're not going to re-architect) would be just to split out the data from the config. Your All Scan data BG and HRS is actually an identical format so you could rationalise that into a single array which will make adding more of the same format easier (just add and index into the array-no need to modify the cluster to add more data). Everything else seems to be config data.

I totally Agree and in fact i had that format originally. However, arrays gets rid of the cluster names and replace them wit the first item's name and for me keeping track was becoming difficult even with documentation. it was just easier to have the clusters that can have different name. I know that i could also use a simple enum for indexing but that would add an extra data that needed to add to my system.
I also have a duplicate of BG and HRS as an original data and manipulated data. This way when want i can revert back by replacing the data with the original.

I am very new to programming and do not have experience in data organisation and almost nothing about labVIEW classes and the NI documentation is just too simple and is not covering any real life application.
That is why I was asking for help.

Cheers,

 

 

Link to comment
11 hours ago, Mahbod Morshedi said:

I totally Agree and in fact i had that format originally. However, arrays gets rid of the cluster names and replace them wit the first item's name and for me keeping track was becoming difficult even with documentation. it was just easier to have the clusters that can have different name. I know that i could also use a simple enum for indexing but that would add an extra data that needed to add to my system.
I also have a duplicate of BG and HRS as an original data and manipulated data. This way when want i can revert back by replacing the data with the original.

I am very new to programming and do not have experience in data organisation and almost nothing about labVIEW classes and the NI documentation is just too simple and is not covering any real life application.
That is why I was asking for help.

Cheers,

Here is a List API. Seems complicated but it's a "managed" list with lots of features. Overkill for what you need but it demonstrates a point. You could use it for your data but then you'd have a dependency. I'm guessing you don't want dependencies at this point.

image.png.40ede3f01101eb9a862fee7a70617c96.png

You'll notice it has two items in the cluster - Name and Variant (variant is a general type and think of it as your Cluster). The important part is that it has a "Name". This is a poor replacement for the Cluster Name (functionally) but it does enable lookups, even by regular expressions. It serves a very similar purpose but operates at run-time instead of design time

The name is just a string label. It can be anything. Granted it's not as simple as an enum but it does give much more flexibility and doesn't require design time editing of the control to make changes. The tradeoff is complexity. Now you have a way of making a list behave like a database but you need specific functions to look up and return data.

This, from one of the list examples, returns all items with a numerical label:

image.png.6d909d0fbbad9bd6c4dd1f6ee3b6b7ad.png

Intuitively you will realise that having duplicate data is not very useful unless you can distinguish between the original and manipulated. Up until now you have used the Cluster with an unbundle which has served you well but are now finding that you need to edit the cluster every time you add new variant of your data. The label gives you that ability at run-time instead of design time with a small increase in complexity.

However. Your biggest issue is compartmentalization - separating config from data. Now. What if only the List (aka data array) wasn't tied to a particular data type? Then, by thinking carefully about the labels you use, you would be able to differentiate between the different data types, different devices and different configs

There are other ways to approach this. But from where you are at present I would suggest this way - at least until you are more confident with your abilities. The database I suggested earlier requires a different mind-set and classes are a huge learning curve. This is a modest step from where you are to where you want to be.

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.