Jump to content

Building Lists of Queue References


Recommended Posts

Hey guys,

I'm faced with the challenge of having a plug-in type architecture where one of the primary plugins is responsible for listening to an FPGA DMA FIFO and placing the data extracted into a set of queues which can be obtained and then destroyed by any number of consumer VI's (in sequence, not simultaneously).

The way I've been doing this is to maintain a "database" of queue references encapsulated inside clusters, the database is maintainted inside an AE. So the input to the AE is of type "Data Queue Handle" which is a single element cluster of type "variant". The data queues created are loaded into these clusters and then added to an array inside the AE. To obtain a data queue, a consumer will search through the array for the variant type which matches the queue type it needs (the one that doesn't return an error when the cluster is passed into the "variant to data" block).

This is functional, but makes me feel icky for some reason. I would like to just pass the raw references into some sort of database, which can then be chosen by a simple Equal? comparison. I can't figure a way to do this inside an AE though, as you can't build an array of different data types and you couldn't have a single input to accept all possible Data Queues.

Maintaining clusters of clusters of clusters is impractical and even more icky.

So, to summarise the question. How would you construct a routing house type function for queue references, which can be searched by any function which knows the right command?

I guess I could manually maintain a Typedef of the different data queue types as they're added to the project, then simply talk through that type def. Hmmmm

  • Like 1
Link to comment

Dare I say it?

This is one of those cases where you would probably be better to go for a class and use the run-time polymorphism. That would allow you to have overrides for each en/dequeue type without having to worry about checking and casting and (assuming you only have one of each type) you wouldn't need a "database".

Link to comment

I would solve it with OO :-)

I would probably create a singleton DataBase Objects that handles and stores an array of Queue-Objects.

I would create a abstract Queue Objects, and in different sub classes I would store the specific LV Queue type.

This is how a UML diagram could look like:

post-941-0-15507500-1331867392.png

Link to comment

Hi Mikael,

That idea was something I was playing around with in a blank project. How would you handle the fact that only one VI should be able to "subscribe" to a queue at any given time. You can't just base it on the singleton lock out idea as there are other operations which might need to take place (such as adding a new queue ref to the "data base").

Link to comment

I'd use the singleton to mediate the subscription (in FindQueue()) and have it move the queue ref to a different array (or mark it in use, depending on how complex you want your data structure). Require that the subscriber call a ReleaseQueue() method through the singleton when it's done with the queue ref.

Link to comment

Hmmm, Ok, worth playing with. I think I'm about 80% of the way to what we're talking about with the AE (FGV) approach. If I turn it into a singleton as mentioned above (I'm pondering whether it can be done without LVOOP) it should work.

Link to comment

So, due to my inexperience with LVOOP, I'll just say what I've done so far in trying to recreate what you guys are saying, and you can tell me if I'm on the right track.

I've created a library for my singleton which contains a parent class called "Abstract Queue". The data of this class contains a generic queue reference (the default happens to be string). This class has child classes, I32 Queue, DBL Queue, etc. The library also has a VI called "Get Singleton Data Base.VI" set to private scope. This VI obtains a queue of type "Array of Abstract Queue" (it has to be an array to store as a database right?).

The parent class has a method "Add Queue" which takes an "Abstract Queue" and "Array of Abstract Queue" as input and uses the build array prim to add the former to the latter. I anticipate over-riding this method for each child class. Am I thinking of this right, or have I got turned around somewhere? Each child classes "Add Queue" method takes "I32 Queue" and "Array of Abstract Queue" (or equivalent) as input.

There will be a VI in the library which is called Add Queue or something similar, which will take call the Add Queue method (which is over-ridden for each child).

Things I'm worried about but haven't had a chance to test yet.

1) Does the typecasting dot which appears on the "build array" prim mean that the information contained in the child queue objects will be lost when it's built into the array of type "Abstract Class"?

Edited by AlexA
Link to comment

Hmmm, Ok, worth playing with. I think I'm about 80% of the way to what we're talking about with the AE (FGV) approach. If I turn it into a singleton as mentioned above (I'm pondering whether it can be done without LVOOP) it should work.

An AE is already a singleton (thats the whole point of them). It might also be worth noting that the AE is synonymous with class methods.

Link to comment

Like ShaunR hints at, the AE is basically a singleton, so it's entirely possible to do this without LVOOP. The only nicety that LVOOP adds (that I can think of) is dynamic dispatch, but I don't think that's integral to what you're doing.

The coercion dot can indicate a loss of data (think of DBL cast to I32, for example). The best and easiest way to check in your case is to coerce the type, then pull it back off the array and compare it against the uncoerced value.

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
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
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.