React on Array's last Element arrival
Hello NI developers!
My VI reads data from board and fills array. As data acquisition speed is slower than VI performance I want VI react and perform action exactly when array gets it's last element. I don't want to use Stacked Sequence Structure, because there NEXT frame executes only when it gets all the data from previous frame and if I manipulate large amounts of data (i.e. Megabytes) it will be hanging somewhere in memory. I want to catch that moment when array filled with last element. Any advices how can I reach that?
Thank you in advance.
Message Edited by ACiDuser on 06-26-2008 08:17 AM
I want calculate transfer speed. CIN measures time that takes FOR Loop and sends it to LV. And I get this time with microsecond precision. I got an idea... Maybe I should use this Stacked Event Structure only for "Time" indicator.. and inside Check If it's not equal with 0 then - calculate speed!
Similar Messages
-
Lots of blank space when printing array with only last element printed
I have a slight problem I have been trying to figure it out for days but can't see where my problem is, its probably staring me in the face but just can't seem to see it.
I am trying to print out my 2 dimensional array outdie my try block. Inside the trying block I have two for loops in for the arrays. Within the second for loop I have a while to put token from Stringtokeniser into my 2 arrays. When I print my arrays in this while bit it prints fine however when I print outside the try block it only print the last element and lots of blank space before the element.
Below is the code, hope you guys can see the problem. Thank you in advance
import java.io.*;
import java.net.*;
import java.lang.*;
import java.util.*;
import javax.swing.*;
public class javaflights4
public static final String MESSAGE_SEPERATOR = "#";
public static final String MESSAGE_SEPERATOR1 = "*";
public static void main(String[] args) throws IOException
String data = null;
File file;
BufferedReader reader = null;
file = new File("datafile.txt");
String flights[] [];
//String flightdata[];
flights = new String[21][7];
int x = 0;
//flightdata = new String[7];
int y = 0;
try
reader = new BufferedReader(new FileReader(file));
//data = reader.readLine();
while((data = reader.readLine())!= null)
data.trim();
StringTokenizer tokenised = new StringTokenizer(data, MESSAGE_SEPERATOR1);
for(x = 0; x<=flights.length; x++)
for(y = 0; y<=flights.length; y++)
while(tokenised.hasMoreTokens())
//System.out.println(tokenised.nextToken());
flights [x] [y] = tokenised.nextToken();
//System.out.print("*"+ flights [x] [y]+"&");
System.out.println();
catch(ArrayIndexOutOfBoundsException e1)
System.out.println("error at " + e1);
catch(Exception e)
finally
try
reader.close();
catch(Exception e)
int i = 0;
int j = 0;
System.out.print(flights [j]);
//System.out.println();A number of problems.
First, I bet you see a lot of "error at" messages, don't you? You create a 21x7 array, then go through the first array up to 21, going through the second one all the way to 21 as well.
your second for loop should go to flights[x].length, not flights.length. That will eliminate the need for ArrayIndexOutOfBounds checking, which should have been an indication that you were doing something wrong.
Second, when you get to flights[0][0] (the very first iteration of the inner loop) you are taking every element from the StringTokenizer and setting flights[0][0] to each, thereby overwriting the previous one. There will be nothing in the StringTokenizer left for any of the other (21x7)-1=146 array elements. At the end of all the loops, the very first element in the array (flights[0][0]) should contain the last token in the file.
At the end, you only print the first element (i=0, j=0, println(flight[ i][j])) which explains why you see the last element from the file.
I'm assuming you have a file with 21 lines, each of which has 7 items on the line. Here is some pseudo-code to help you out:
count the lines
reset the file
create a 2d array with the first dimension set to the number of lines.
int i = 0;
while (read a line) {
Tokenize the line;
count the tokens;
create an array whose size is the number of tokens;
stuff the tokens into the array;
set flights[i++] to this array;
} -
How to display last element in a dynamic 1d array
hi..
i want to display the value of last element in a 1d dynamic array.../ i mean ..if i stop the vi run, i need to display the last element in the array..how can i do this?
and is there any way to use a button to start the vi...instead of using the Run button on the vi front panel??
Solved!
Go to Solution.Index array!. Use array size to determine the size of your array, subtract 1, feed that in the index terminal of Index Array.
You have to start the VI running somehow. It could be set to run when opened. Assuming what you want is a means to type values into a front panel, hit a GO button that you created on the front panel, then have the real part of the VI execute. You could use an event structure. Or put a while loop at the beginning with a small wait statement in side that basically just polls the GO button. When that button is pressed, the true boolean stops the while loop and allows the program to proceed to the main body of your program. -
Stopping while loop after last element of 2d array is passed through
I posted something similar to this before, but what I got didn't work. So this time I'll try to be more clear with what I am trying to do. What I have done is combine two 1d arrays into a 2d array, and am using it to run an experiment. I split the 2d array into a 1d array by column, and am trying to get the while loop that the array is in to stop after the last element of the array is indexed. I need to use a while loop because the array is constantly updating because the number of elements can be changed while the program is running. What I am having trouble with is getting the while loop to stop after the last element has run, because the last element is subject to change. Any ideas?
ThanksI am trying to run a measurement using labview to control different instruments. The program is suppossed tp work in that it runs a measurement for each current setpoint inputed, for 1 magnetic field setpoint. So for example, if the magnetic field setpoint is 8000 gauss, and the two current setpoints are .00001 amp, and .0001 amp, it will run the meauserement twice for the 2 current setpoints for each magnetic field setpoint. What I am trying to do is that sometimes, I might have to edit the magnetic field setpoints while the program is running. I am having trouble with refreshing the magnetic field setpoints, which allows the user to input a new magnetic field setpoint while it is running.
-
How to get the last element of a structure in a textfield in DesignStudio
Hello,
how can I get the last element of a structure within a bex query?
Within the structure we are working with dates that dynamically are buiId (input date - offsets for several months).
I have to show the last value in a single textfield within DesignStudio.
Regards
FrankHi Frank,
in DS 1.3 you can use forEach function to get the last element of BEx structure (or n-th element in general using if condition)
var array = DS_CROSSTAB1.getMembers("DHGY5D6XEFO1K45SB00BXFH7A",10);
var lastMember="";
array.forEach(function(element, index) {
lastMember = element.text;
TEXT_1.setText("Last structure element: "+lastMember); -
How to select the last elements in a string
Hi Guys
I am using UART RS232 protocol and i need to calculate the check sum. My data came in decimal and in the end it must be doubles to manipulate it. So my problem is, for example, the sum of all elemants is in decimal 1742 and in hex is 6CE and i wont only the last two elemants, CE that corresponds to 206 that is the result of my checksum. Can anyone help me?
Thanks
Solved!
Go to Solution.
Attachments:
String last elements.vi 9 KBThanks Syrpimp
My data came from HMI in decimal like the example that i show above. Each cell is a value. You used an array, but i think that i can't use it because it must be done automatically and the data field have variable length.
The UART protocol frame has a start frame field that corresponds to two ‘{‘ characters and an end frame field that corresponds to two ‘}’. Additionally, besides the data field, that has variable length, it has a byte that corresponds to the command type and another that is the checksum. The following table illustrates the protocol.
Bytes considered in checksum
Command Data
Start Frame
Cmd
(hex)
Data0
Data1
Data2
Data3
Data4
Data5
Data6
Data…
CHK SUM
End Frame
1 Byte CHK SUM (sum of all data bytes truncated to 1 byte)
Fig. 1 UART communication protocol template
I receive data like this:
123
123
160
54
111
103
110
108
107
109
108
108
100
100
100
100
0
0
1
4
5
0
0
0
0
0
0
7
96
1
0
0
0
0
0
10
51
1
0
0
51
1
1
23
12
0
206
125
125
I'm trying explain my doubt the best way i can and i thank you all. -
Hello all
I am having a string like this:
55.000000; 10.000000; 0.100000; 1.000000; 1.000000; 0.100000; 0.000000; 0.000000; 1.000000; 1.000000; 22.000000; 0.100000; 6144.000000;
The length of the string is not always same. What i want is to have the last element. i.e in this case 6144
One way is to get the string length and using string subset to get the last element. But for this, the length must be always constant.
Is there any other way to get the last element independant of the string length
thanks
Nghtcwrlr
********************Kudos are alwayzz Welcome !! ******************
Solved!
Go to Solution.Since you have the extra semicolon at the end, I actually grabbed the second-to-last element of the array after the spreadsheet string to array.
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
Attachments:
Get last element.png 13 KB -
How to remove only the last element of spreadsheet string
I use path to string option to store image path into database and while retrieving the string is again converted into path but it gives out an error as the output of array to spreadsheet string gives out a tab at the end which is unable for the IMAQ read file to recognise.but when i use the path of the image directly into IMAQ readfile the image is opened . so how to remove the tab only at the end of output of the spreadsheet string(whose length can vary)? I have also attached my program with this.
Attachments:
retrieve_images_from_DB.vi 65 KB
file_path_to_db_(images).vi 40 KB
create_table_for_images.vi 45 KBindhu wrote:
> Thanks for your reply!
> But my problem is to remove only the last element(which is a tab or an
> alphabet) from a spreadsheet string of any length.
If you just want to remove the last character of a string just use the
String Size function reduce the result by one and wire it together with
the string to the Split String function.
Rolf Kalbermatter
Rolf Kalbermatter
CIT Engineering Netherlands
a division of Test & Measurement Solutions -
Best Way To Build An Array Of Many Elements
Simple question for you LabVIEW experts: I want to build an array of many element for use in my code. The problem is I have 20 elements I need to insert into the "Build Array Function." This takes up much code space and is really not that clean. I was thinking of using a For Loop and use the iteration terminal as the index for each element. The For Loop would then use auto indexing and build this array for me.
Is there a more efficient way to do this? Thanks!hobby1 wrote:
Crossrulz, I was planning on handling it like this:
I have a total of 17 element I need to build an array from. Each case would include another element to be written to the array. Is this the correct way to handle this?
Thats one way to do it. Not nearly as efficient as using the Build Array, but it will work.
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines -
How to delete the last element of a collection without iterating it?
how to delete the last element of a collection without iterating it?
To add to jverd's reply, even if you could determine the last element, in some collections it is not guaranteed to always be the same.
From HashSet:
It makes no guarantees as to the iteration order of the set; in particular, it does not guarantee that the order will remain constant over time. -
Indexing array of references element by element
Hello,
I have a simple question. How do I go about indexing an array of references element by element? For example, when using a cluster reference, there is a property node called "controls [ ]" that we can pass into a for loop. For a normal array, "enable indexing" is usually automatically turned on when entering a for loop. Why is it that for an array of references, this is not the case? Thanks for the help.
Solved!
Go to Solution.
Attachments:
array_of_references.JPG 35 KBSince the Get Image is a method, it has to work on something, and that would be a picture control or indicator. (If you look at the Get Image Method for the array, you'll notice it only returns an image of the front panel object, so I think you'd just get a picture of the array as it looks on the FP).
So you'd send the picture to an indicator, then use the Get image method on that indicator immediately afterwards. See attached. I didn't try this out so I can't be sure it would work, but I think it would. But it would still be a major hack compared to just using the Picture to Pixmap VI.
Message Edited by Ravens Fan on 03-27-2009 01:03 AM
Attachments:
Array_of_References[1]_BD.png 12 KB -
JComboBox shows "Java Applet Window" as last element
Hey all,
I am having a problem with using JComboBox. When I use JComboBox and show it in a JDialog (popup window), the last element of the drop down (JComboBox) is "Java Applet Window". This element is, however, not selectable. I want to get rid fo the "Java Applet Window" in my dropdown.
This problem only happens when my applet opens up a JDialog that has the JComboBox, but does not happen when I add the JComboBox directly to the applet.
I've read around in other forums that this has to do with security. I understand the need to show that a popup window (JDialog) is an applet window so the user doesn't mistake it as one of the native windows. But, the JComboBox is not a whole 'nother window, so why does it feel the needs to add that last line to designate it as a "Java Applet Window?"
Thanks.
Nina.My apologies, I did not clarify myself in my question. Sorry that I created misunderstandings of the problem - as evident in the response in the previous post from himanshug.
I am using JDK 1.3.1
I must use an applet, but all my components are standalone. They can be ran as a standalone application. But for deployment, we are using applets. It's easier to do applets so clients can access via browser than deploy a whole application installation on 50 machines halfway across the world.
And no, there is no element in my list that says "Java Applet Window". When running my application standalone, the "Java Applet Window" does not appear as the last element in my drop down.
The "Java Applet Window" also does NOT appear when I add the drop down directly to the applet. It only appears when the drop down is in a JDialog that gets launched by an applet.
My problem: How to get rid of the "Java Applet Window" as it seems something is adding this to my dropdown. And it's not my code that is adding it.
Thanks. I am also up'ing the duke dollars for a solution to this to 15. -
"For explaination , like this
1 1 1 1 1 1 1 ....... to 640
+2 2 2 2 2 2 2 .......
+3 3 3 3 3 3 3 .......
=6 6 6 6 6 6 6 ....... this is the final 1D array of summed elements."
Appreciate the sample VI's but I can't open them ( I have Labview 5.01 )Here is Mikael solution, expanded to include rows and ready to use as a subVI. Now all is needed is the polymorphic version
www.vartortech.com
Attachments:
Sum_rows_or_colums.vi 25 KB -
hi! i just need a little help, i really dont need the whole program jus the important methods of it.
Searching Array of 50 elements out of the 50 Integer Value in your Array,
the user can enter a value & your program will display the specific
subscript/index that contain the value
All computation must be place in a method that returns a value.
.has to be the sorriest excuse for a student I've seen in a while
3 separate accounts at JavaWorld, all asking to be spoon-fed,
http://www.javaworld.com/javaforums/showflat.php?Cat=&Board=javabeginner&Number=26852&page=0&view=collapsed&sb=5&o=&fpart=1
http://www.javaworld.com/javaforums/showflat.php?Cat=&Board=javabeginner&Number=26884&page=0&view=collapsed&sb=5&o=&fpart=1
http://www.javaworld.com/javaforums/showflat.php?Cat=&Board=javabeginner&Number=26876&page=0&view=collapsed&sb=5&o=&fpart=1
now at least this account at Sun
@OP - your future is assured
[email protected] -
How to create array with "n" elements...
Hy, how can i create a array with "n" elements ?
i know, but the thing is: the other methode (which
one isn't developed fom me) needs an Object Array
(Object []) to work correctly...then take a look into the method toArray() of the Collection interface.
thats why i need this gay "object Array"....I think it would be wise to avoid that adjective in this context and meaning.
Maybe you are looking for
-
ITunes RIngtone Feature?
I followed the Apple Help instructions on how to create a ringtone for my iPhone by using a song purchased from iTunes. Every song that I bought could not be made into a ringtone. When I chose "create ringtone" a meassage appeared stating that "this
-
Status of message in case of file-xi-idoc scenario
In file2idoc scenario, i have 500 records, how to check the records reached or not (except SXMB_MONI & IDX5)?
-
Can a Flash movie be created in DW 6?
-
Embedding a call to an external system using a JavaScript?
Hello I just been given a widget to a new system ... with the words "Place the code below where you want to interface to the system" <script language="javascript" type="text/javascript" charset="utf-8" src="https://euro.FREDnet:8443/plesk-billing/app
-
Updat succesfull but fails in re-start...
update to 6.01 succesfull, but after closing new version and opening again firefox, the older version appears ! Then i get the message that an update is available, i download it and the story repearts himself...