Comparing two elapsed timer readings

Hi everyone,
I'm a new user of Labview, so I'm teaching myself as I go along really. I've come up against a problem though. I'm trying to compare two timer readings from elapsed timers. Eventually I am hoping to swap these timers for a pair of light beams inputted through a DAQ chassis. Initially though I wanted to get the content of my program correct, without having to have the equipment connected to my laptop.
I have attached my progress so far, apologies if my query has an obvious solution. As I say I'm a bit of an beginner! How would I take the two elasped timers log the times found off the timers, compare which one has a greater value and consequently start a new timer depending on this. I would then like to log this time in data form.
I've tried to compare the two elasped timers with greater than booleans etc but I cant seem to get it to work?
As I say I hope to use this idea in a time gate sort of application where depending on which light beam is broken first depends on which timer is started. Hope my explanation is clear.
Any help is much appreciated,
Thanks very much!
Attachments:
FYP.vi ‏15 KB

PT-
Looking at your code you have a few problems that you will need to address.  Read the LabVIEW help section titled "Caveats and Recommendations when Using Events in LabVIEW."  You have some latching booleans controls that are incorrectly placed.  The terminals should be in the event case that handles the value change event.  
Why two event structures?  One structure is a better Idea you can handle all your events with 1 loop (and avoid stopping the loops independantly- this can lead to a condition where the vi becomes unresponsive.
The lower loop compares the start times to two different timestamps.  This is introducing potential errors since there is timing relationship between the calls to the system timer.  and the lower case structures are rather insane- in english they resolve to "if started return how long its been since started else return 0"  Check the NI website there is a CLD practice exam solution (Car Wash) that has a pretty good example and discussion of using the elapsed timer express vi.  It might point you in a better direction than where you are going.
Why not use the time terminals in the event structure?  thats the time the event fired.  But, you might want the time the event was handled I don't Know-  (hint-comment your code and write SOMETHING in the vi documentation.  Eventually you'll be writing more complex code so start developing good habits now)  (good habits--)  
Come on back when you've looked at some of the examples and I'ld be glad to help you more.  
Jeff

Similar Messages

  • Comparing two dates+times [bash]

    To compare two dates+times* in bash I have always used date +%s and compared the resulting strings.  Is there a better way to do it?  Thanks.
    * As in "is date+time Y after date+time X?"

    Years ago I wrote a bash script to build a thumbnail gallery webpage for a local directory structure of torrents.  For each torrent, it created the thumbnail of an image with the same name, scraped torrents to get seeders/leechers, parsed a text file of urls and added links below the image with special favicons for commonly linked sites.
    That was a hassle, and I have been afraid to look at the script since I stopped using it.  But the page it produced was pretty sweet.
    Most of the scripts I write are a bit more down-to-earth than that though.
    Last edited by alphaniner (2012-04-25 18:50:02)

  • Comparing two date/times

    I need to be able to compare two times:
    1. I need top get the current time e.g 13:15
    2. I then need to work out how many minutes exist bewteen the above time and 17:00 the previous day
    So if the current time was 17:00 Mon
    then the number of minutes to 17:00 Sun would be 24hrs x 60 = 1440 Minutes ( I need this time )
    Any help would be great

    Try this:
    import java.util.*;
    public class timeDif {
       public static void main(String[] args) {
          Date yesterday=new Date(102,3,1,17,0,0);  // year,month-1,day,hour,minute,second
          Date today=new Date();  // get the current date/time
          long diff=(today.getTime()-yesterday.getTime())/60000;   // getTime() returns times in miliseconds
          System.out.println("time diff in minutes is "+diff);
    }V.V.

  • DB Time much higher compared to (Elapsed time * CPU)

    11.2.0.2 on Linux x86 64-bit, Single Instance
    AWR shows
    CPUs : 16
    Cores : 8
    Sockets : 2
    Begin Snap: 10-Jan-12 01:00:17
    End Snap: 10-Jan-12 02:00:40
    Elapsed: 60.38 (mins)
    DB Time: 1,627.47 (mins)
    My understanding is that (Elapsed * CPUs) is an upper bound for DB Time. DB Time is much higher though (60.38 * 16 = 966.08).

    Databases are rarely single user systems.
    My understanding is that (Elapsed * CPUs) is an upper bound for DB TimeNo, this isn't correct. That's the maximum CPU time you have.
    DB_TIME gives you the amount of time spent by active sessions actively working or actively waiting.
    DB_TIME/ELAPSED_TIME gives you a figure of Average Active Sessions - i.e. on average you have 26 active sessions over this period.
    If you think about it, if you have a 60 minute report and you have 1 user actively working or actively waiting, your elapsed time would be 60 minutes, maximum cpu time on 16 cpus is 960 minutes your db time would be 60 minutes.
    Double the number of active users to 2, elapsed time still 60 minutes, max cpu time still 960 minutes, db time 120.
    Double the number of active users to 4, elapsed time still 60 minutes, max cpu time still 960 minutes, db time 240.
    Mulitply the number of active by 10 to 40, elapsed time still 60 minutes, max cpu time still 960 minutes, db time 2400.
    Of course, you're unlikely to have 40 users who are constantly active for 60 minutes, but you get the picture.
    Edited by: Dom Brooks on Jan 10, 2012 10:54 AM
    Reworded

  • Comparing two Calendar dates

    No question. Just a comment with code example.
    Yesterday I was having issues comparing two Calendar dates. They looked equal in my println statement, but they failed the test. The solution evaded my cafeine intensified brain for hours. Then it hit me. Print out the time in milliseconds and see if the numbers were the same. Nope. Why?
    The problem was that in the real world, you get dates from all over the place, not just cooked up for a text book example. (Don't you just hate those text book examples in their unrealistic world?) Anyway, I was getting a date from an HTML form and a data from a database and comparing the two once I had converted them both to a Calendar object. This seemed a reasonable choice.
    Well, the java.sql.Date that the Oracle driver returned which was converted to a java.util.Date was fine. I ran this into a Calendar with the call calS.setTime(dbDate). The form date was split into fields and put into a difference Calendar obj with the call calF.set(fYear, fMonth, fDay, 0, 0, 0). This too seemed reasonable. Then a call to calS.equls(calF) resulted in a false even though the actual dates were in fact the same.
    The problem was with the time. The java.sql.Date (calS) had a time of 00:00:00 which was fine. The calendar from the form also had 00:00:00 for a time since I initialized it with zeros. Hummmmm. Now what? As mentioned before, I decided to print out the actuall time in milliseconds and that gave me my answer. The two calendars were off by only milliseconds, but that's why. You see, the equals method of Calendar compares two dates/time in milliseconds. You can see this in the source for yourself. It's not difficult to read at all. Download and open the api source file, src.zip, and locate Calendar.java in the java.util directory.
    The fix was to add calF.set(Calendar.MILLISECOND, 0) and calS.set(Calendar.MILLISECOND, 0) to zero out the milliseconds in each Calendar object. That did the trick. Here's example code of the problem (test1) and the solution (test2). I tried to simulate as close to real world as possible. If you have a better solution or I've made some error, please let me know. I'm always looking for better ways.
    Main.java
    import java.util.Calendar;
    import java.util.Date;
    import java.text.SimpleDateFormat;
    public class Main {
        private int fYear = 2003;
        private int fMonth = 3;  // march
        private int fDay = 14;
        public static void main(String[] args) {
            Main main = new Main();
            main.test1();
            main.test2();
        public void test1() {
            SimpleDateFormat df = new SimpleDateFormat();
            // get the date from the form
            Calendar calF = Calendar.getInstance();
            calF.set(fYear, fMonth-1, fDay, 0, 0, 0);  // month starts at 0 - so march would be 2
            System.out.println("From form date:     [" + df.format(calF.getTime()) + "] [" + calF.getTimeInMillis() + "]");
            // simulate other activity in the app
            try {
                Thread.sleep(5000);
            catch (Exception ex) {
                ex.printStackTrace();
            // get the Date from the shared object which comes from a database (java.sql.Date)
            // the return is java.util.Date
            // convert to a Calendar
            SharedObject so = new SharedObject();
            Date myDate = so.getTheDate();
            Calendar calS = Calendar.getInstance();
            calS.setTime(myDate);
            System.out.println("Shared Object date: [" + df.format(calS.getTime()) + "] [" + calS.getTimeInMillis() + "]");
            // compare the two calendars for equality
            if (calS.equals(calF)) {
                System.out.println("The same");
            else {
                System.out.println("NOT the same");
        public void test2() {
            SimpleDateFormat df = new SimpleDateFormat();
            // get the date from the form
            Calendar calF = Calendar.getInstance();
            calF.set(fYear, fMonth-1, fDay, 0, 0, 0);
            calF.set(Calendar.MILLISECOND, 0);  // the magic bean
            System.out.println("From form date:     [" + df.format(calF.getTime()) + "] [" + calF.getTimeInMillis() + "]");
            // simulate other activity in the app
            try {
                Thread.sleep(5000);
            catch (Exception ex) {
                ex.printStackTrace();
            // get the Date from the shared object which comes from a database (java.sql.Date)
            // the return is java.util.Date
            // convert to a Calendar
            SharedObject so = new SharedObject();
            Date myDate = so.getTheDate();
            Calendar calS = Calendar.getInstance();
            calS.setTime(myDate);  // just to be safe
            calF.set(Calendar.MILLISECOND, 0);
            System.out.println("Shared Object date: [" + df.format(calS.getTime()) + "] [" + calS.getTimeInMillis() + "]");
            // compare the two calendars for equality
            if (calS.equals(calF)) {
                System.out.println("The same");
            else {
                System.out.println("NOT the same");
    SharedObject.java
    public class SharedObject {
        public java.util.Date getTheDate() {
            java.util.Date d = null;
            try {
                java.sql.Date s = java.sql.Date.valueOf("2003-3-14");  // this march is converted internally
                d = (java.util.Date)s;
            catch (Exception ex) {
                ex.printStackTrace();
            return d;
    } The output
    From form date:     [3/14/03 12:00 AM] [1047621600296]
    Shared Object date: [3/14/03 12:00 AM] [1047621600000]
    NOT the same
    From form date:     [3/14/03 12:00 AM] [1047621600000]
    Shared Object date: [3/14/03 12:00 AM] [1047621600000]
    The same

    So your post boils down to the fact that Calendar's set(year, month, day, hour, minute, second) method doesn't change the milliseconds fraction?
    Given that there is this method, I guess it would be nice if there was a method that simultaneously set all fields, but the API does state:
    Previous values of other fields are retained. If this is not desired, call clear() first.

  • How can I compare two collections at the same time? (View two grid views)

    I have two collections containing some of the same images. (My Nikon D70 did not put an end-of-file on some images. I recovered them into a different collection.) Now I want to display both collections side-by-side in grid view. I will select those images in the "recovered" collection that correspond to the bad images in the "main" collection, add the ratings etc, and move just these to another collection.
    It is extremely frustrating to have to bounce back and forth between collections, remembering each image one by one and selecting it in the "recovered" collection. (The image names are not preserved in the "recovered" collection -- I have to go by what the image looks like.)
    LightRoom allows me to compare photos in the compare view. I want to compare collections in two grid views.

    CaptureTheLight,
    you have ran into a situation when you have to compare two sets of images and now you're wondering how come Lightroom doesn't have such "obviously necessary" functionality? But you have to admit it, this is not such a common situation in a photographer's workflow recovers broken files and tries to compare them against themselves. I think it's a pretty specific feature you need. Still, Lightroom has enough powerful tools for editing and sorting images.
    For example...
    You could just put them all - "main" and "recovered" - into a single collection or into the Quick Collection. Label the entire "recovered" collection with, say, red and sort by capture time. Now you'll have everything side by side, ordered chronologically. The "recovered" images will stay next to the "main" images since their capture time will be the same, and they will also stand out since they have the red label.
    Make the thumbnails bigger and set up the grid view so it tints the thumbnail cell are tinted with the label color. Now, you can go quickly through them visually checking labeled vs unlabeled.

  • Comparing the creation time of two jars.

    Hi,
    My requirement is that i need to compare the creation time of two of the jars and see which one of the jar is the latest.
    I did it using the following code i get the output in the form of strings so i cant compare them to find which one is the latest.
    import java.io.*;
    import java.util.*;
    public class FileTest {
         public static void main(String args[]) {
              File devbuild = new File(
                        "\\\\devspace\\dev$\\ReleaseEng\\DEVbuilds\\tw_enterprise\\build\\jboss\\Oracle\\Twelibrary.jar");
              File local = new File(
                        "D:\\jboss-4.2.1.GA\\server\\TWEServer\\Twelibrary.jar");
              Calendar now = Calendar.getInstance();
              int currtime = now.get(Calendar.HOUR_OF_DAY);
              int maxtime = 18;
              System.out.println("Before the while loop");
              while (currtime < maxtime) {
                   System.out.println("Inside the while loop");
                   if (devbuild.exists()) {
                        try {
                             // get runtime environment and execute child process
                             Runtime systemShell = Runtime.getRuntime();
                             BufferedReader br1 = new BufferedReader(
                                       new InputStreamReader(new FileInputStream(devbuild)));
                             BufferedReader br2 = new BufferedReader(
                                       new InputStreamReader(new FileInputStream(local)));
                             Process output = systemShell.exec("cmd /c dir " + devbuild);
                             Process output1 = systemShell.exec("cmd /c dir " + local);
                             // open reader to get output from process
                             BufferedReader br = new BufferedReader(
                                       new InputStreamReader(output.getInputStream()));
                             BufferedReader br3 = new BufferedReader(
                                       new InputStreamReader(output1.getInputStream()));
                             String out = "";
                             String out1 = "";
                             String line = null;
                             String line1 = null;
                             int step = 1;
                             int step1 = 2;
                             while ((line = br.readLine()) != null) {
                                  if (step == 6) {
                                       out = line;
                                  step++;
                             } // display process output
                             while ((line1 = br3.readLine()) != null) {
                                  if (step1 == 6) {
                                       out1 = line1;
                                  step1++;
                             try {
                                  out = out.replaceAll(" ", "");
                                  out1 = out1.replaceAll(" ", "");
                                  System.out.println("CreationDate: "
                                            + out.substring(0, 10));
                                  System.out.println("CreationTime: "
                                            + out.substring(10, 16) + "m");
                                  System.out.println("CreationDate: "
                                            + out1.substring(0, 10));
                                  System.out.println("CreationTime: "
                                            + out1.substring(10, 16) + "m");
                             } catch (StringIndexOutOfBoundsException se) {
                                  System.out.println("File not found");
                             //Long modifiedtime = devbuild.lastModified();
                             //long oldtime = old.lastModified();
                             int devbuilddate = Integer.parseInt(out.substring(0, 10));
                             int devbuildtime = Integer.parseInt(out.substring(10, 16));
                             int localbuilddate = Integer.parseInt(out1.substring(0, 10));
                             int localbuildtime = Integer.parseInt(out1.substring(10, 16));
                             if (devbuilddate >= localbuilddate && devbuildtime >= localbuildtime) {
                                  System.out.println("The Build date is Later than the one i am having--->");
                                  System.exit(6);
                             } else {
                                  System.exit(0);
                        } catch (Exception e) {
                             e.printStackTrace();
                   if (currtime > maxtime) {
                        System.exit(5);
    How can i do it?
    Can anyone help me out in this.
    Thanks,
    Kavipriya.

    Hi Clap,
    Thanks for ur reply. Let me say you the scenario clearly. We are in the process of automating some of the process. We have builds running daily night and our automation will run using that build.
    Currently the build which is getting generated does have manifest in it. For our automation framework we cant suggest adding the manifest. Which will not be agreed.
    Our automation will be checking till 10.am. to check whether the build is ready if not it will come out of the loop. If the build is avaialble within 10 then it will take the build and see whetehr the creation date and time of the build and the one i am having locally or different. If diff it will see whether the build generated is latest than the one i am having.
    If it so then the process will run.
    So hope you got my issue.

  • How to compare two different characteristics at the same time in polestar

    Hi Gurus,
    I would like to analyse the e fashion universe in polestar with comparison of previous year product line with current year product line at the same time.
    is there any way to do that we can compare two years of the product line sales revenue at the same time with comparison chart like 2003 T shirts vs 2002 T shirts 
    in polestar we can compare the two measures at the same time but i want to compare the sales revenue of product lines of two years in a comparison chart at the same time.
    Regards and thanks
    Abid Paul

    Hi Stratos,
    I am actually able to compare the Measures  but i want the comparison between the two different characteristics like this year  productline  vs last year productline at the same time with say one measure like sales revenue or any other.
    Is it possible to compare the both and it should represent in the chart as well at the same time.
    In the polestar i can compare three measures at the same time but i want to compare characteristics like year  2009 productline VS 2008 productline with one measure say sales revenue.
    I would really appreciate if you could help me out.
    Regards and thanks
    Abid

  • How to get one elapsed time for two loops OR MORE

    I'm calculating the time spent to maintain a value "elapsed time" for 2 things(A and B) differents,what to change in order to have 1 "elapsed time" not 2 ,so the value of "elapsed time" is caculated the moment the user maintain the value of A and B
    Attachments:
    item n4 complet.vi ‏3850 KB

    My VI is already attached
    Elapsed time 2 is calculated when the user starts the test of "variometre",maintien 3 when the user keeps the pointer of the variometre in 7 for 10 seconds
    Elapsed time  is calculated when the user starts the test of"horizon artificiel",maintien 2 when the user keeps the pointer of the horizon in 30 for 10 seconds.
    that's good if i wanna each test alone,but now the complication of this one is to maintain the 2 values 7 of the variometre and 30 of the horizon in the same time during 10 secs.that's why i want to have just 1 elapsed time and 1 maintien,because the the 2 tests will run on parallel then the elapsed time must start and when the user realises the 2 conditions in the same time,the maintien must begin counting.
    Attachments:
    item n4 complet.vi ‏3850 KB

  • Same sqlID with different  execution plan  and  Elapsed Time (s), Executions time

    Hello All,
    The AWR reports for two days  with same sqlID with different  execution plan  and  Elapsed Time (s), Executions time please help me to find out what is  reason for this change.
    Please find the below detail 17th  day my process are very slow as compare to 18th
    17th Oct                                                                                                          18th Oct
    221,808,602
    21
    2tc2d3u52rppt
    213,170,100
    72,495,618
    9c8wqzz7kyf37
    209,239,059
    71,477,888
    9c8wqzz7kyf37
    139,331,777
    1
    7b0kzmf0pfpzn
    144,813,295
    1
    0cqc3bxxd1yqy
    102,045,818
    1
    8vp1ap3af0ma5
    128,892,787
    16,673,829
    84cqfur5na6fg
    89,485,065
    1
    5kk8nd3uzkw13
    127,467,250
    16,642,939
    1uz87xssm312g
    67,520,695
    8,058,820
    a9n705a9gfb71
    104,490,582
    12,443,376
    a9n705a9gfb71
    62,627,205
    1
    ctwjy8cs6vng2
    101,677,382
    15,147,771
    3p8q3q0scmr2k
    57,965,892
    268,353
    akp7vwtyfmuas
    98,000,414
    1
    0ybdwg85v9v6m
    57,519,802
    53
    1kn9bv63xvjtc
    87,293,909
    1
    5kk8nd3uzkw13
    52,690,398
    0
    9btkg0axsk114
    77,786,274
    74
    1kn9bv63xvjtc
    34,767,882
    1,003
    bdgma0tn8ajz9
    Not only queries are different but also the number of blocks read by top 10 queries are much higher on 17th than 18th.
    The other big difference is the average read time on two days
    Tablespace IO Stats
    17th Oct
    Tablespace
    Reads
    Av Reads/s
    Av Rd(ms)
    Av Blks/Rd
    Writes
    Av Writes/s
    Buffer Waits
    Av Buf Wt(ms)
    INDUS_TRN_DATA01
    947,766
    59
    4.24
    4.86
    185,084
    11
    2,887
    6.42
    UNDOTBS2
    517,609
    32
    4.27
    1.00
    112,070
    7
    108
    11.85
    INDUS_MST_DATA01
    288,994
    18
    8.63
    8.38
    52,541
    3
    23,490
    7.45
    INDUS_TRN_INDX01
    223,581
    14
    11.50
    2.03
    59,882
    4
    533
    4.26
    TEMP
    198,936
    12
    2.77
    17.88
    11,179
    1
    732
    2.13
    INDUS_LOG_DATA01
    45,838
    3
    4.81
    14.36
    348
    0
    1
    0.00
    INDUS_TMP_DATA01
    44,020
    3
    4.41
    16.55
    244
    0
    1,587
    4.79
    SYSAUX
    19,373
    1
    19.81
    1.05
    14,489
    1
    0
    0.00
    INDUS_LOG_INDX01
    17,559
    1
    4.75
    1.96
    2,837
    0
    2
    0.00
    SYSTEM
    7,881
    0
    12.15
    1.04
    1,361
    0
    109
    7.71
    INDUS_TMP_INDX01
    1,873
    0
    11.48
    13.62
    231
    0
    0
    0.00
    INDUS_MST_INDX01
    256
    0
    13.09
    1.04
    194
    0
    2
    10.00
    UNDOTBS1
    70
    0
    1.86
    1.00
    60
    0
    0
    0.00
    STG_DATA01
    63
    0
    1.27
    1.00
    60
    0
    0
    0.00
    USERS
    63
    0
    0.32
    1.00
    60
    0
    0
    0.00
    INDUS_LOB_DATA01
    62
    0
    0.32
    1.00
    60
    0
    0
    0.00
    TS_AUDIT
    62
    0
    0.48
    1.00
    60
    0
    0
    0.00
    18th Oct
    Tablespace
    Reads
    Av Reads/s
    Av Rd(ms)
    Av Blks/Rd
    Writes
    Av Writes/s
    Buffer Waits
    Av Buf Wt(ms)
    INDUS_TRN_DATA01
    980,283
    91
    1.40
    4.74

    The AWR reports for two days  with same sqlID with different  execution plan  and  Elapsed Time (s), Executions time please help me to find out what is  reason for this change.
    Please find the below detail 17th  day my process are very slow as compare to 18th
    You wrote with different  execution plan, I  think, you saw plans. It is very difficult, you get old plan.
    I think Execution plans is not changed in  different days, if you not added index  or ...
    What say ADDM report about this script?
    As you know, It is normally, different Elapsed Time for same statement in different  day.
    It is depend your database workload.
    It think you must use SQL Access and SQl Tuning advisor for this script.
    You can get solution for slow running problem.
    Regards
    Mahir M. Quluzade

  • Cost in explain plan vs elapsed time

    hi gurus,
    i have two tables with identical data volume(same database/schema/tablespace) and the only difference between these two is, one partitioned on a date filed.
    statistics are up to date.
    same query is executed against both tables, no partition pruning involved.
    select ....... from non-partitioned
    execution plan cost=92
    elapsed time=117612
    select ... from partitioned
    execution plan cost=3606
    elapsed time=19559
    though plan cost of query against non-partitioned is quite less than partitioned, elapsed time in v$sqlarea is higher than partitioned.
    what could be the reason please?
    thanks,
    charles
    Edited by: user570138 on May 6, 2010 6:54 AM

    user570138 wrote:
    if elapsed time value is very volatile(with the difference in explain plan cost) , then how can i compare the performance of the query?Note that the same query with same execution plan and same data can provide different execution times - and due to a number of factors. The primary one being that the first time the query is executed, it performs physical I/O and loads the data into the buffer cache - where the same subsequent query finds this data via cheaper and faster logical I/O in the cache.
    in my case i want to compare the performance change before and after table partitioning.Then look at the actual utilisation cost of the query and not (variant) elapsed execution time. The most expensive operation on a db platform is typically I/O. The more I/O, the slower the execution time.
    I/O can be decreased in a number of ways. The usual approach in the database environment is to provide better or alternative data structures, in order to create more optimal I/O paths.
    So instead of using a hash table and separate PK b+tree index, using an index organised table. Instead of a single large table with indexes, a partitioned table with local indexes. Instead of joining plain tables, joining tables that have been clustered. Etc.
    In most cases, when done correctly, these physical data structure changes do not even impact the application layer. The SQL and code in this layer should be blissfully unaware of the physical structure changes done to improve performance.
    Likewise, changes in the logical layer (data model changes) can also improve performance. This of course does impact the application layer - and requires a proper design and implementation in the physical layer. Often proper data modeling is overlooked and flaws in it is attempted to be fixed by hacking the physical layer.
    my aim is to measure the query performance improvements, if any, by partitioning an existing tableWhy not measure current I/O before an operation, and then after the operation - and use the difference to determine the amount of I/O performed by that operation?
    This can be implemented in a start/stop watch fashion (instead of measuring time, measuring I/O) using the v$sesstat virtual performance view.

  • Help with quit function and elapsed time function.

    I have this annoying assignment game here and I am almost finished with it. I got two problems, the first is that the quit function partly works it quits from the game but it is giving me a "Guess is to high" message. I've tried so many things but nothing seems to work.
    The other problem is that the elapsed time " *(long f = System.currentTimeMillis()/1000;)* " starts to count before you actually write something for example if you run the program without writing something for 5 minutes, the highscore list will show your time you finished the game + these 5 minutes.
    If somebody could give me a hint or could explain to me how I could fix these problems I would be very thankful.
    import java.util.*;
    class Game  {
         public static void main(String[] arg) {
              int RAN,Entered_number=0,count=0;
              String guess1[] = new String[1];
              int guess2[] = new int[1];
              int time[] = new int[1];
              String NP1[];
              int NP2[];
              int NP3[];
              int j=0;
              Scanner scan=new Scanner(System.in);
              Scanner kb = new Scanner(System.in);
              Random myRandomizer = new Random();
              RAN= Math.abs(myRandomizer.nextInt() % 1000) + 1;
              System.out.println("\t\t\t"+"Hello and welcome to this guessing game!");
              System.out.println("\t\t\t"+"Start guessing, it's a number between 1 and 1000...");
              System.out.print("--------------------------------------------------");
              System.out.println("-----------------------------");
              System.out.println("please enter your number:");
              String control="";//control is just a name for the variable. it's used to read in the whole line if you have written something that is not a number.
              String name="";
              String answer="";
              boolean okgame=true;//is used so that you can play the game as long as the variable okgame is true.
              long f = System.currentTimeMillis()/1000;
              while((Entered_number!=RAN) && okgame)//controls if the number is different then RAN and that okgame is true.
                   System.out.print(RAN);
                   System.out.print(">");
                   if(scan.hasNextInt())//checks in advance that what you have written is a number, if so then it can read it as Entered_number.
                        Entered_number=scan.nextInt();
                   else
                        control=scan.nextLine();//Reads int the whole line to control what has been written in.
                        if(control.equalsIgnoreCase("quit"))//if control is = quit, then compare to will return 0.
                             okgame=false; //if you have written quit okgame, you put in false to quit the game.
                             // Entered_number=0;//initiates entered_number all over again to show message stupid guess i wont count that.
                   if(okgame)//as long as okgame is true it will show the result otherwise you go to else to show that the game is finished.
                        if((Entered_number>RAN)&&(Entered_number>=1)&&(Entered_number<=1000))
                             System.out.println("Guess is too high!");
                             count++;
                        else if((Entered_number<RAN)&&(Entered_number>=1)&&(Entered_number<=1000))
                             System.out.println("Guess is too low!");
                             count++;
                        else if((Entered_number>1000)||(Entered_number<1))
                             System.out.println("Stupid guess! I won't count that...");
                        else if (Entered_number==RAN)
                             long p = System.currentTimeMillis()/1000;
                             count++;
                             System.out.println("****Guess is CORRECT!");
                             System.out.print("****You guessed it in"+" "+count+" guesses and ");
                             System.out.print(p - f);
                             System.out.println(" seconds.");
                             System.out.println("please enter your name:");
                             System.out.print(">");
                             name=kb.next();
                             System.out.println("Do you want to play again ?(y/n)"); 
                             System.out.print(">");
                             answer=kb.next();
                             if(answer.equalsIgnoreCase("n"))
                                  System.out.println("**** The game is over.");
                                  okgame=false;
                             if(answer.equalsIgnoreCase("y"))
                                  Random myRandom = new Random();
                                  RAN = Math.abs(myRandom.nextInt() % 1000) + 1;
                                  System.out.println("current high score list:");
                                  long ttime = p-f;
                                  int ta = (int)ttime;
                                  j++;
                                  if (j > 1){
                                       NP1 = new String[j];
                                       NP2 = new int[j];
                                       NP3 = new int[j];
                                       for (int n = 1; n < j; n++){
                                            NP1[n-1] = guess1[n-1];
                                            NP2[n-1] = guess2[n-1];
                                            NP3[n-1] = time[n-1];
                                       NP1[j-1] = name;
                                       NP2[j-1] = count;
                                       NP3[j-1] = ta;
                                       guess1 = new String[j];
                                       guess1 = NP1;
                                       time = new int[j];
                                       guess2 = new int[j];
                                       guess2 = NP2; 
                                       time = NP3;
                                       for (int w = 1; w < guess2.length; w++) {
                                            for (int x = 1; x < guess2.length; x++) {
                                                 if (guess2[x] < guess2[x-1]) {
                                                      int z4, z5,z6,z7;
                                                      String z2, z3;
                                                      z4 = guess2[x];
                                                      z5 = guess2[x-1];
                                                      guess2[x] = z5;
                                                      guess2[x-1] = z4;
                                                      z2 = guess1[x];
                                                      z3 = guess1[x-1];
                                                      guess1[x] = z3;
                                                      guess1[x-1] = z2;
                                                      z6 = time[x];
                                                      z7 = time[x-1];
                                                      time[x] = z7;
                                                      time[x-1] = z6;
                                       for (int al = 1; al < time.length; al++) {
                                            for (int o = 1; o < time.length; o++) {
                                                 if (guess2[o] == guess2[o-1]) {
                                                      if (time[o] < time[o-1]) {
                                                           int z4, z5, z6 ,z7;
                                                           String z2, z3;
                                                           z2 = guess1[o]; z3 = guess1[o-1];
                                                           z4 = guess2[o]; z5 = guess2[o-1];
                                                           z6 = time[o]; z7 = time[o-1];
                                                           guess1[o] = z3; guess1[o-1] = z2;
                                                           guess2[o] = z5; guess2[o-1] = z4;
                                                           time[o] = z7; time[o-1] = z6;
                                  else {
                                       guess1[j-1] = name;
                                       guess2[j-1] = count;
                                       time[j-1] = ta;
                                  System.out.println("Number\t\tName\t\tHigh Score\tTime (Seconds)");
                                  System.out.println("------\t\t----\t\t----------\t--------------");
                                  for (int h = 0; h < j; h++) {
                                       System.out.println(" " + (h+1) + "\t\t" + guess1[h] + "\t\t" + guess2[h] + "\t\t" + time[h]);
                                  System.out.println("");
                                  System.out.println("Start guessing, it's a number between 1 and 1000...");
                             count=0;
    //-----------------------------------------------------------------------------------------------------------------------------------------------------PS I'm not done with the comments yet so that could be a little confusing for you guys =P
    Thanks!
    /chill

    else {
                                       guess1[j-1] = name;
                                       guess2[j-1] = count;
                                       time[j-1] = ta;
                                  System.out.println("Number\t\tName\t\tHigh Score\tTime (Seconds)");
                                  System.out.println("------\t\t----\t\t----------\t--------------");
                                  for (int h = 0; h < j; h++) {
                                       System.out.println(" " + (h+1) + "\t\t" + guess1[h] + "\t\t" + guess2[h] + "\t\t" + time[h]);
                                  System.out.println("");
                                  System.out.println("Start guessing, it's a number between 1 and 1000...");
                                                                                               f=System.currentTimeMillis()/1000;////////////include this line here
                             count=0;
                   }

  • Data Logging Elapsed Time

    I have a program that monitors a pressure reading from a transducer.  The initial readings are logged at 10 second intervals until the pressure is increased by a set value and the logging interval increases to 100 points per second.  Currently, when I graph the data, the elapsed time on the x-axis is inaccurate because the computer doesn't know when the 10 second stopped and the 100 points per second began.  Is there a way to keep track of the time the points are being logged?  Some sort of method of having the elapsed time between points logged so this can be used to create the x-axis?
    Thanks in Advance!!
    LabVIEW 2012 - Windows 7
    CLAD

    Hello,
    It sounds like you'd like to have two plots on the same graph, but the x-axis scale and values are different for your two plots.  You can control how data is plotted to a waveform graph by bundling the array of data you are plotting with an x0 (initial value) and a delta-x (distance between samples).  The order for the bundle (into a cluster of course) should be, x0 value, delta-x value, y-array of data.
    I have attached an example to illustrate this by allowing you to change the x0 and delta-x for two plots dynamically (the Generate Sine Pattern.vi is used as a subVI, where the other is the top level VI); I think this is exactly what you are looking for!
    I hope this helps!
    Best Regards,
    JLS
    Best,
    JLS
    Sixclear
    Attachments:
    Example1.zip ‏28 KB

  • How to use elapsed time function with state machine in Lab VIEW

    Hello
    I've been trying to use state machine with elapsed time function in order to sequentially start and stop my code. The arrangement is to start the code for 1 minute then stop for 5 minutes. I've attached the code, the problem is when I place the elapsed time function out of the while loop it doesn't work, on the other hand when I place it inside the loop it does work but it doesn't give the true  signal to move to the next state. 
    Could you please have a look to my code and help me to solve this issue.
    Regards 
    Rajab
    Solved!
    Go to Solution.
    Attachments:
    daq assistance thermocouple(sate machine raj).vi ‏436 KB

    Rajab84 wrote:
    Thanks apok for your help
    even with pressing start it keeps running on wait case 
    could you please explain the code for me, the use of Boolean crossing, increment , and equal functions 
    Best Regards 
    Rajab 
    OK..I modded the example to stop after 2 cycles. Also recommend taking the free online LabVIEW tutorials.
    run vi. case statement goes to "initialize", shift registers are initialized to their constants. goto "wait"
    "start"= false, stay in current state. If true, transition to "1 min" case
    reset elapsed timer with True from shift register(counter starts at zero)."time has elapsed"=false, stay in current state(1 min). If true, goto "5min" case
    reset elapsed timer with True from shift register of previous case(counter starts at zero)."time has elapsed"=false, stay in current state(5 min). If true, goto "1min" case. Also, bool crossing is looking for "true-false" from "5 min" compare function to add cycle count.
    Once cycle count reaches 2, stop while loop.... 
    Attachments:
    Untitled%202[1].vi ‏42 KB

  • How to compare date and time together

    Hi,
    How to compare Date and Time together?
    For example in a database table there are two fields rundate and runtime.  I want to compare these two with perticular date and time in the program.  Like, I want to pull all the records where the records's date and time are less than a perticular date and time in the program.
    Hope the question is clear...
    Thanks.
    Kavita

    Hi Kavita
    There is no as such Date and Time Comparision FM in Standard SAP  But You can define your own like this
    <b>FUNCTION ZAV4_COMPAREDATETIME.
    ""Lokale Schnittstelle:
    *"  IMPORTING
    *"     REFERENCE(DATE1) TYPE  DATS
    *"     REFERENCE(TIME1) TYPE  TIMS
    *"     REFERENCE(DATE2) TYPE  DATS
    *"     REFERENCE(TIME2) TYPE  TIMS
    *"  EXPORTING
    *"     VALUE(TWOISMORETOPICAL) TYPE  C
      twoismoretopical = ''.
      if date2 > date1.
        twoismoretopical = 'X'.
      else.
         if date2 = date1 and time2 > time1.
           twoismoretopical = 'X'.
         endif.
      endif.
    ENDFUNCTION.</b>
    Regards
    Mithlesh

Maybe you are looking for

  • Curve crashes after upgrade to OS 4.5.0.81

    Curve crashes after upgrade to OS 4.5.0.81  Ever since I upgraded to the T-Mobile handheld OS 4.5.0.81, my Curve crashes several times a day down to a black screen. I can't power back up on battery -- I have to plug in to an AC source, then power bac

  • Wonder if the external USB Superdrive works on AppleTV?

    Was just wondering if the external Superdrive option for the Macbook Air works with the USB on the AppleTV. So that you could watch dvd's. Anyone that knows this?

  • Ran out of disk space - 1TB drive

    I've run out of disk space for back up with my 1 TB drive I use for TM. The key reason is because of the HD files I am using for my home movies not to mention the media I have been buying off of iTunes. I have an unused 500GB drive. Can I somehow cre

  • Blank video uploads to YouTube (bug?)

    Hello - I'm uploading my video to YouTube. It did it absolutely fine the first time, but then I noticed a bad edit so tweaked and re-uploaded.It uploaded a completely black video. Sound was fine, and the length remains correct; but twice it uploaded

  • Value pass to Smartform when Print/Preview

    Hi, I've a custom print program and smartform. All my selecting data codes are in Smartform. How do I let Smartform knows whether I'm doing a preview or print? What values should I pass into Smartform? I'd like to achieve something as follows:- IF pr