04-17-2013 03:04 PM
Hi!
My project is to build a test system consisting of several instruments to measure voltage, current and other stuff at the same time.
My idea was to do it like this (simplified)..
Main (the decision maker)
Module 1 (Controls communication with multimeter 1)
Module 2 (Controls communication with multimeter 2 - same type as multimeter 1)
I communicate between the modules with events, of course i want to be able to distinguish between events from Module 1 and 2.
So I start coding.. I complete Module 1 and it basically consist of a while loop with an event structure and some instrument VIs, and a data cluster that along with other stuff contains references to incoming and outgoing events. All fine I thought.
Now i want to do Module 2.. and my thought was to just use the same VI but another instrument address and all would be fine.. but no no.. any one see my problem yet? Otherwise keep reading 🙂
If it runs at all, I can't separate from witch module a message is comming from, since they use the same event references. Okidoki, I just make two different top level VIs in each module and use all instrument VIs in module 2 from module 1... but no no.. again.., since i generate all outgoing events in the instrument VIs and also all VIs in the module use the data cluster which include the event references i have to copy all VIs and change them to make Module 2... this can't be right, that is why i'm here 🙂
Possibilities!
1. I copy module 1 for each instrument of that type and change the data cluster to match that module = loads of VIs doing exactly the same = not right..
2. I use a case structure to separate between the different types = few VIs but not scalable, i have to add a case in each VI if I add an instrument = not right...
Neither of this is the right way to do it... how can I solve this?
/Peter
04-17-2013 03:33 PM
Just quickly from the top of my head, I would make the instrument controller a reentrant VI (preallocate clones) and pass in an enum, string, numeric, whatever to tell the VI what its "address" is. Now for your commands you make a cluster. One element of the cluster is the "address" and the rest of the cluster is your data/command. So when a command is recieved, the instrument controller checks the address. If it matches its given address, it reacts. Otherwise it just ignores it.
I've seen some good examples of this concept, just not sure where to find them right now.