From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
10-15-2021 09:42 AM
Hi All,
So I have a issue with a program I am writing, basically, there are a number of cameras on a local network, these cameras send out JSON data for the various parameters.
The number of cameras is unknown, so my code does a scan of the network, finds all the camera IP's and then starts getting JSON responses from them. As there is alot of data and due to the way the JSON library works, each response from a camera fills a cluster of various different data types, most of these parameters have options on what can be set which are put into arrays, some numeric parameters have max, min and increments instead.
What I wanted to do was fill an array with these response clusters from each camera, then display them on the front panel, but use the parameter option arrays for each to populate the String Combo boxes for the user to select during run-time.
After research, mostly on here, it appears this is not possible due to each cluster having to have the same "Strings[]" value (the options in the combo dropdown)
Does anyone have a good work around for this? as the number of data clusters in unknown i cant think of a better way to collect the data...
Hoping someone else has had the same issue as i presume this would be fairly commen when working with JSON data like this
Jon
10-16-2021 11:04 PM
One option I would consider would be an "array" of subpanels. You can't actually place a subpanel in an array, but it possible to fake it and then have multiple dynamic copies of the same VI, where each can have its own properties. You could even have different VIs, if your clusters are different enough.
Note that you would need to communicate with these VIs to pass them the relevant data. I would suggest using a framework you're comfortable with for communicating with multiple processes (Actor Framework, DQMH, Messenger Library, etc.) and do some tests on working with VIs with UIs in subpanels.
While you could make this into an XControl and have it take the array of clusters as the data type and communicate with the VIs, it's probably not worth it.
As for how to do it, the basic idea is to have one subpanel and inside that either have enough subpanels to cover what you need or move the VIs between subpanels as you scroll. See for example here and follow the links from there. I seem to also remember seeing someone have just two subpanels in a VI and then recursively use the second subpanel to contain all of the subsequent VIs.
10-17-2021 01:34 PM
Note that you can delay setting the Strings[] of your combo box until the "Mouse Down?" Event on the box. At that point you can determine which camera the User is trying to change, and fill the Strings[] with the options for that camera.
10-23-2021 10:16 AM
Hi Guys,
Thanks for the responses, I've got my code working well, but I'm having to populate my combo box strings locally inside the event structure, rather than in a subvi, which is a shame as it makes it a bit bulky and repetitive (I'm sure there is a better solution, I'm pretty sure I need to use message ques in my code, I had never used them before, going to have a play with them
If I update the strings in my data cluster in a submission I can't find any way to make it pass them through to the mainvi.
In the event (value changed) on the main data array, it takes the string arrays and uses property nodes which are linked to the front panel combo boxes to populate them, it's a bit clunky but functional
When I get back on my computer I will upload a screen shot, I'm sure someone will have a far better solution that doesn't require loads of repeated code in case structures
Thank you
10-24-2021 02:36 AM
You haven't showed your code, so it's not clear to me why you even have duplicated code, but you can probably select the relevant code and then select Edit>>Create SubVI. This will attempt to create a subVI from the selected code and because you have an implicitly linked property node, it should create a reference to the control, pass the value of that reference into the subVI and change the code in the subVI to use an explicitly linked property node.
Then, assuming the code is the same, you should be able to call that subVI in the other cases and you'll just need to create a reference to each relevant control and pass that into the subVI.
Since you say this entire thing was for an array of clusters, I would have expected that you would have only a single event for the array control, but then the tricky thing is detecting which element you clicked on (you need to use the pane coords from the event and then account for the array position, the size of the array element (which you can get with the position and bounds properties) and the index value of the array).
10-24-2021 12:57 PM - edited 10-24-2021 01:04 PM
For something like the OP described, I have used the combination of a Table Control and Text Ring to allow the user to select different values for a list of sensors that may not have all the same properties.
mcduff
A bit of work, but it ends up doing the job. See below for a list of DAQ where one DAQ has adjustable gain and the other does not.
10-24-2021 01:46 PM
Thanks for all the replies, and the table example you showed does look great! It would limit my soewhat on how I can layout the GUI front panel though, which might not be the end of the world, but flexability would be great. I have finally got back to my laptop so I can upload the section of my code that is causing me the headache.
Any ideas on how this can be made into a subvi would be gladly recieved! I'm sure i'm also not necessarily doing things correctly, I'm self taught in LabView so forgive my code!
Its basically an Array of Clusers, the number of clusters in the array is the number of cameras detected, so is dynamic, I cannot think of a way of dynamically displaying each cluster not knowing how many there are, AND having them with functional Combo Boxes
10-24-2021 02:29 PM
It's hard to offer advice without knowing all the details. Your VI as posted does not look scalable. Maybe the following pictures will help you formulate a UI. (Note I am self taught also, so take everything with a healthy dose of mistrust.)
(If you want the VI in a subVI use references and property nodes, like below. You will need to keep track of your references.)
Think about using subPanels, splitters, and other elements for your display. Below is a shot of a program that configures multiple DAQs.
Stuff like serial numbers, and properties can be hidden most of the time, the little arrow expands a splitter so one can see the properties of the DAQs.
When a DAQ is highlighted, the subPanel becomes active, see below.
When the task is active and highlighted, the subPanel changes again.
Like your cameras, there is a lot of information there, but it all doesn't have to be displayed at once, it can be broken down into groups to make your UI more presentable and easier to work with.
10-24-2021 02:54 PM
Hi,
That all looks great, I will have to have a play with subpanels, and splitters, I've not used them before
I did try using references to make a subvi to process the data, but I couldn't get it to pass the Strings[ ] parameters through from the combo boxes, and I ended up wasting so much time trying that I used property nodes locally in the main vi
The code I sent, more or less, sits withing the ZCAM Data Value Changed event, so when the data changes it updates the individual camera data cluster, as I said, it's pretty clunky and frustratingly not dynamically scalable
10-24-2021 03:07 PM
The Controls[] property gives generic references, you may have to use "to more specific class" like so
But since you may have nested clusters within clusters, you may have to index out the controls multiple times.