04-13-2010 01:42 PM
Hi All
I am new to Labview hence need some help. I am trying to develop an application which reads some data from a Wireless Sensor Network (WSN). The WSN consists of base station connected to the USB port which recieves data from other sensor nodes. The data comes in a certain format. Node name, temperature reading, humidity reading etc. I want to read the data from the serial port and based on the Node name, i want to display the information for each node in a listbox connected to a subpanel . Therefor allowing the user to access the different nodes using a listbox. So if a new node is detected then a new vi is created for that node and added to the listbox and displayed in the subpanel. Or the user can acces the different nodes available by scrolling throught the listbox.
Since all the nodes have the same sensors on board i have decided to use a single . I can read the data using the serial port, parse the data to detect which node it is and also what the sensor readings are. I have created a template VI for the sensor node. and can create multiple subvi using the template.
The problem i am having is how to update the instances created using the template. Each instance of the template should have a unique number, how can i acces this number. Also how to keep the listbox updated. I Would be greatful if someone could help to solve this problem either by suggesting a new way of doing this or by pointing out what i could do to solve this problem.
Raza
04-13-2010 02:09 PM - edited 04-13-2010 02:13 PM
uraza2001 wrote:Hi All
...
The problem i am having is how to update the instances created using the template. Each instance of the template should have a unique number, how can i acces this number. Also how to keep the listbox updated. I Would be greatful if someone could help to solve this problem either by suggesting a new way of doing this or by pointing out what i could do to solve this problem.
Raza
This is the method my grandaughter approves of.
THe "Crtl Val.set" method updates the FP control AFTER the template is instaciated but BEFORE it is run.
Use queues for each template to get the data updates.
Ben
04-13-2010 02:10 PM
Could you just use "Save As" to save each instance of your vi's created and give each a unique name? Then you can modify each one separately.
04-14-2010 09:29 AM
Hi Ben
Many thanks for the reply, that is one cute and brainy grandughter you have Looking at the snapshot, how do you know which instance you are updating. The Logger Ref vi is taking the reference as the input. Is the reference stored in this vi ?
Do you have a simple example vi, which i could look at ?
I will look into queues to pass the reference for each instance.
Raza
04-14-2010 09:31 AM
Hi tbob
I am not sure how i can save each reference. Do you have any idea or example of how this is done ?
Many Thanks
Raza
04-14-2010 09:47 AM
Hi Ben
Just to add one more question, once you create a number of instances using a template which are running in the background, how would we be able to update these instances. Do we save the ref for each instace somewere ?
Many Thanks
Raza
04-14-2010 10:55 AM
If you are using Ben's method, you cannot save that instance. You have to re-create it every time. But once the code is written, it is done. No need to save the instance. Otherwise, you have create individual vi's and not use a template.
04-15-2010 07:47 AM
I use different methods depending on the situation...
For a bunch of background objects like the one I was starting in the above image, I create multiple queues for interacting with each one. THese queues are typically "Command" and "Response" and the message they exchange are determined by the app. SO in the above...
I open a new instance from a template and before I run it, I set the FP control so the template can find the queues it needs. In the above I am using LVOOP but inside the LVOOP private data are the required queues.
After setting the FP control that instance is started-up and it gets the queue info from the control.
Sorry, but posting code will get me fired. Pictures and words only.
Ben
04-16-2010 07:17 AM
Hi Ben
Many Thyanks for the information, i will look into it and hopefully will beable to come up with a solution. I will get in touch once i have got around this problem
Raza
04-16-2010 12:14 PM
Hi Ben
Sorry to bother you again, got a question...
For every node i will have an instance open using the template vit. I can save the names of each instance of the vit, for example "graph_template 617.vi" into an array. Is it possible it open the instance and update it ? Ive tried it once using the open Vi reference and i am getting Error 1004 vi not in memory. Is there a way around this. Or is this not possible
Many Thanks
Raza