While Loop in Gantt Chart Value

the problem is in the "createDataset" method whereby i want to do a while loop where i can check the data inside the database that i just inserted. after that i want to pass in all the data that is needed to generate the Gantt Chart. can anyone help me on this?
thanks
package ericTest;
import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.text.ParseException;
import java.util.StringTokenizer;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.Calendar;
import java.util.Date;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.JFreeChart;
import org.jfree.data.category.IntervalCategoryDataset;
import org.jfree.data.gantt.Task;
import org.jfree.data.gantt.TaskSeries;
import org.jfree.data.gantt.TaskSeriesCollection;
import org.jfree.data.time.SimpleTimePeriod;
import org.jfree.ui.ApplicationFrame;
import org.jfree.ui.RefineryUtilities;
import com.db4o.Db4o;
import com.db4o.ObjectContainer;
import com.db4o.ObjectSet;
public class GanttDemo3 extends ApplicationFrame {
   public GanttDemo3(final String title) {
        super(title);
        final IntervalCategoryDataset dataset = createDataset();
        final JFreeChart chart = createChart(dataset);
        // add the chart to a panel...
        final ChartPanel chartPanel = new ChartPanel(chart);
        chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
        setContentPane(chartPanel);
         public final static String filename = "C:\\KLGCC Mock Up.yap";
         private static ObjectContainer db;
         private static String day;
         private static String month;
         private static String year;
         private static String task;
         private static String startDate;
         private static String endDate;
         private static String startDay;
         private static String startMonth;
         private static String startYear;
         public static int startDay1;
         public static int startMonth1;
         public static int startYear1;
         public static String endDay;
         public static String endMonth;
         public static String endYear;
         public static int endDay1;
         public static int endMonth1;
         public static int endYear1;
         DataInputStream dis = null;
         String fileRecord = null;
         public void storeData() throws IOException{
              new File(filename).delete();
              db = Db4o.openFile(filename);
                   File f = new File("C:\\KLGCC Mock Up.txt");
                   FileReader fis = new FileReader(f);
                   BufferedReader bis = new BufferedReader(fis);
                   while((fileRecord = bis.readLine()) != null){
                             StringTokenizer st = new StringTokenizer(fileRecord,",");
                             task = st.nextToken();
                             startDate = st.nextToken();
                             endDate = st.nextToken();
                             System.out.println(task+ " - " +startDate+ " - " +endDate);
                             Country c = new Country(task, startDate, endDate);
                             db.set(c);               
                   db.close();
         public void storeStartDate() throws ParseException{
              db = Db4o.openFile(filename);
              Country c = new Country();
              ObjectSet result = db.get(c);
              while(result.hasNext()){
                   Country obj = (Country)result.next();
                   String sDate = obj.getStartDate();
                   StringTokenizer str = new StringTokenizer(sDate, "/");
                   startMonth = str.nextToken();
                   startDay = str.nextToken();
                   startYear = str.nextToken();
                   System.out.println(startYear);
                   int startMonth1 = Integer.parseInt(startMonth);
                   int startDay1 = Integer.parseInt(startDay);
                   int startYear1 = Integer.parseInt(startYear);
                   //startMonth1 = startMonth1 + 1;
                   ArrayList<Integer> startDay2 = new ArrayList<Integer>();
                   startDay2.add(startDay1);
                   ArrayList<Integer> startMonth2 = new ArrayList<Integer>();
                   startMonth2.add(startMonth1);
                   ArrayList<Integer> startYear2 = new ArrayList<Integer>();
                   startYear2.add(startYear1);
                   System.out.println("Heloo" +startDay2+ "/" +startMonth2+ "/" +startYear2);
              db.close();          
    public void storeEndDate() throws ParseException{
              db = Db4o.openFile(filename);
              Country c = new Country();
              ObjectSet result = db.get(c);
              while(result.hasNext()){
                   Country obj = (Country)result.next();
                   String sEndDate = obj.getEndDate();
                   StringTokenizer str1 = new StringTokenizer(sEndDate, "/");
                   endMonth = str1.nextToken();
                   endDay = str1.nextToken();
                   endYear = str1.nextToken();
                   int endMonth1 = Integer.parseInt(endMonth);
                   int endDay1 = Integer.parseInt(endDay);
                   int endYear1 = Integer.parseInt(endYear);
                   ArrayList<Integer> endDay2 = new ArrayList<Integer>();
                   endDay2.add(startDay1);
                   ArrayList<Integer> endMonth2 = new ArrayList<Integer>();
                   endMonth2.add(endMonth1);
                   ArrayList<Integer> endYear2 = new ArrayList<Integer>();
                   endYear2.add(endYear1);
                   System.out.println("END" +endDay2+ "/" +endMonth2+ "/" +endYear2);
              db.close();
    public static IntervalCategoryDataset createDataset() {
         final TaskSeries s1 = new TaskSeries("Scheduled");
         //Country chart = new Country();
         ArrayList ar = new Arraylist;
         Iterator it = ar.iterator();
         while it.hasNext();{
         s1.add(new Task("abc",
               new SimpleTimePeriod(date(startDay1, startMonth1, startYear1),
                                    date(endDay1, endMonth1, endYear1))));
                final TaskSeriesCollection collection = new TaskSeriesCollection();
        collection.add(s1);
        return collection;
     * Utility method for creating <code>Date</code> objects.
     * @param day  the date.
     * @param month  the month.
     * @param year  the year.
     * @return a date.
    private static Date date(final int day, final int month, final int year) {
        final Calendar calendar = Calendar.getInstance();
        calendar.set(year, month, day);
        final Date result = calendar.getTime();
        return result;
     * Creates a chart.
     * @param dataset  the dataset.
     * @return The chart.
    private JFreeChart createChart(final IntervalCategoryDataset dataset) {
        final JFreeChart chart = ChartFactory.createGanttChart(
            "Gantt Chart Demo",  // chart title
            "Task",              // domain axis label
            "Date",              // range axis label
            dataset,             // data
            true,                // include legend
            true,                // tooltips
            false                // urls
//        chart.getCategoryPlot().getDomainAxis().setMaxCategoryLabelWidthRatio(10.0f);
        return chart;   
    public static void main(final String[] args) throws IOException, ParseException
        final GanttDemo3 demo = new GanttDemo3("Gantt Chart Demo 1");
        demo.storeData();
        demo.storeStartDate();
        demo.storeEndDate();
        demo.pack();
        RefineryUtilities.centerFrameOnScreen(demo);
        demo.setVisible(true);
}

sorry. i know it's kinda blurr.
i did some modification on this part of the code
public static IntervalCategoryDataset createDataset() {
         final TaskSeries s1 = new TaskSeries("Scheduled");
         //Country chart = new Country();
         ArrayList ar = new ArrayList();
         for (Iterator it = ar.iterator(); it.hasNext();)
         s1.add(new Task(task,
               new SimpleTimePeriod(date(startDay1, startMonth1, startYear1),
                                    date(endDay1, endMonth1, endYear1))));
         System.out.println(task);
        final TaskSeriesCollection collection = new TaskSeriesCollection();
        collection.add(s1);
        return collection;
         }the problem is the gantt chart after i have generated couldn't come out any value. is it because i never executed some methods?
thanks

Similar Messages

  • Sir i am using datasocket read ,i am communicating with java but my problem is that bcz im using while loop to see if value has changed my labview consumes all the processors time ,sir i want a event like thing so that while loop is not in continuous loop

    sir i have given lot of effort but i am not able to solve my problem either with notifiers or with occurence fn,probably i do not know how to use these synchronisation tools.

    sir i am using datasocket read ,i am communicating with java but my problem is that bcz im using while loop to see if value has changed my labview consumes all the processors time ,sir i want a event like thing so that while loop is not in continuous loopHi Sam,
    I want to pass along a couple of tips that will get you more and better response on this list.
    1) There is an un-written rule that says more "stars" is better than just one star. Giving a one star rating will probably eliminate that responder from individuals that are willing to anser your question.
    2) If someone gives you an answer that meets your needs, reply to that answer and say that it worked.
    3) If someone suggests that you look at an example, DO IT! LV comes with a wonderful set of examples that demonstate almost all of the core functionality of LV. Familiarity with all of the LV examples will get you through about 80% of the Certified LabVIEW Developer exam.
    4) If you have a question first search the examples for something tha
    t may help you. If you can not find an example that is exactly what you want, find one that is close and post a question along the lines of "I want to do something similar to example X, how can I modify it to do Y".
    5) Some of the greatest LabVIEW minds offer there services and advice for free on this exchange. If you treat them good, they can get you through almost every challenge that can be encountered in LV.
    6) If English is not your native language, post your question in the language you favor. There is probably someone around that can help. "We're big, we're bad, we're international!"
    Trying to help,
    Welcome to the forum!
    Ben
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

  • How can I make a while loop wait for input boolean?

    Hi.
    I'm trying to control a robotic arm with labview for my undergrad dissertation, and I have a decent polar coordinate control panel made, but there is one problem; it checks for changes in the coordinates every five seconds, while I want it to only check on the touch of a button (ie, go!, I've changed your coordinates!). The changes are calculated with a while loop comparing the last value of theta, x and z in a while loop with the current one. I can't find a way of putting that into a case structure. If there is a way of making the while loop progress at the push of a button, I think it would work. The VI's attached below.
    Thanks in advance for any help.
    Cathal Scanlon
    ps, sorry about the mess, I'm going to reorganise the while loop into 2 if I can get the control button working.
    Message Edited by CatScan on 02-08-2007 02:45 PM
    Attachments:
    Polar coord assignment1.vi ‏142 KB

    Have you tried using an event structure? To use one, right click on the structure to add an event. Set the event as whatever button you wish to monitor and set the event to "Value Change". If you put this inside a while loop any time the button is pressed, the event structure will run the contents inside the loop. There are a number of options to have the event structure activate.
    *** Warning! I'm probably the last guy you want answering your labVIEW questions, but I figured I might be able to help.

  • What is the best way   for writing cursors in while loops

    i just chage my flatform from visual foxpro to sql
    for every report part using query analyser i have to make report on any tables
    suppose : - mastempno wise report
    so i heve to use cursor or store procedure in while loop
    for searching in transaction table
    so sometime i get confunsion of using cursors two times in while loop for fetching the values
    so help me for writing some simple codes for using cusrors in while loop while can fetch all values in transaction table

    Is this what u r looking for
    A Simple Cursor Example Which gives all records
    from Employee table
    Declare
    Cursor Emp is
    Select Empno,Ename
    FRom Employee;
    Begin
    For x in Emp Loop
    :block.empname := x.ename;
    End Loop;
    End;
    Regards,
    Ashutosh

  • Stop dependant while loops with 1 button

    Hi,
    I am developing a utility that allows a user to configure up to 2 devices (both use same driver with a different board number), click initialize, which then brings up a file dialog and displays arrays for the data to be collected and some error messages for each measurement.  The user then clicks the Start/Stop button to begin collecting and logging data.  Currently i have a Wait(ms) block to allow the user to set often the measurement should be made.  Currently the Start/Stop button allows collection to be started, paused, and started again.  My problem is trying to have a master stop button that should stop all loops immediately when it is pressed.
    I tried using a global variable for the stop button, but the measurement and logging while loop doesnt stop until after the wait(ms) block times out.  Can anyone give suggestions.  If i need to restructure the VI into different loops, I can do that.  I just want to understand the right way to program something like this.
    The VIs are attached.  I removed the device specific measurement VI so that anyone can open the vis and run them to see how it works.
    Attachments:
    2Devices_withoutMeasurementVI.vi ‏112 KB
    BuildOutput.vi ‏27 KB
    stopGlobal.vi ‏5 KB

    Ok.  I had a chance to take a look at your code and I think you don't quite understand the concept of "dataflow".  Let me see if I can help.
    First of all...when I refer to your upper structure, I am referring to the first while loop, sequence structure, and subsequent while loops.  When I refer to your lower structure, I am referring to the while loop containing the event structure.  Just so we get our terminology straight.
    I believe that you are under the illusion that your upper structure contains three parallel while loops.  It does not.  It contains three SERIAL while loops.  There is dataflow dependency between the while loops.  The sequence structure requires data that is not available until the first while loop has finished executing, so the sequence structure cannot start executing until the first while loop has terminated.
    The second while loop requires inputs from the first frame of the sequence structure (which, by the way, you don't need and should get rid of...the sequence structure, I mean), so it cannot start executing until the first frame of the sequence structure has terminated.  The third while loop requires inputs from the second while loop...so, again, the third while loop cannot run until the second while loop has finished executing.
    Now, for your stop button.  You have that global stopping all three loops.  So here's what is happening in your program:
    Your program starts.  The first while loop executes in parallel with the loop which contains the event structure.
    At some point you press the "stop" button.  Both the first while loop and the loop containing the event structure finish executing.
    The first frame of your sequence structure executes.
    The second frame of your sequence structure executes.  The second while loop reads the "stop" value from the global, so it executes once and then finishes.
    The third while loop starts executing.  Again, the loop reads the "stop" value from the global, so it executes once and then finishes.
    Then your program terminates.
    You need to restructure your program, because right now it doesn't make any sense at all.  Your block diagram would benefit from some serious tidying up as well, your wiring is a mess.  I suggest you look into a state machine architecture for this program.

  • Problem with two parallel While loops

    I have a serious problem with controlling two parallel While Loop. Here is the deal:
    I have written a VI to send a series of commands called Cycle through Serial Port to a custom hardware. One of these commands is setting motor pressure by sending it's command and changing it's voltage. After setting desired pressure I have to read and control motor pressure, again through serial port in a parallel loop. There is a Pressure Sensor in system and I can obtain current's motor pressure by sending a command and receiving pressure value. In the first While loop I send some commands to hardware including Pressure Setting Command trough a state machine. In the second While Loop I read pressure value and then decide to increase motor voltage or decrease  it. Now the problem is in communicating these two loops. In cycle after "Init" state when state reaches "Pressure 2 Bar" motor voltage will increase. Meanwhile I have to control this voltage in parallel While Loop. As you can see I used Local Variable to communicate between these two loops. The problem is that loops are not synchronized. Specially when I switch to "Pressure 3.8 Bar" state during cycle running control loop (second while) is still working based on "Pressure 2 Bar" state not 3.8 bar. Because of this motor pressure goes to 3.8 bar for a sec (becuase of  "Pressure 3.8 Bar" state) and comes back to 2 bar (because the second while still has not gotten that new state,most probably cause of all the delays in the loop)  and after couple seconds it goes back to 3.8 bar.
    I really don’t know what to do. Is there a way to fix this? Or I should consider a better way to do this?
    I went through Occurrence Palette but couldnt figure out how to embed that in the VI. 
    Sorry for my poor English. I attached VI and it's subVIs as a LLB file. I can explain more details if somebody wants. 
    Attachments:
    QuickStartCycle.llb ‏197 KB

    I make it a point to NEVER have a WAIT function inside a state machine.
    It sort of defeats the purpose, which I define as "Examine current state; decide whether you've met the conditions to advance to another state, then get out".
    For example, I have a single state machine VI controlling four identical instruments, via TCP connections.
    For some functions, that means issuing a command, waiting 60 seconds, then reading results.
    If I waited INSIDE the state machine, then it's tied up waiting on one device and cannot handle any others.
    Not a good plan.
    To handle this, I have a loop which calls the state machine.  After issuing the command, the state goes to "Waiting on Response", and there is a target time of 60 seconds from now.
    It's called over and over in that state, and each time merely compares NOW to the target time.  If NOW is past the target, then we read the results.
    the state machine can tell the caller when to call back; that's how I distinguish between an urgent need and nothing-to-do.
    By having the CALLER do the waiting, instead of the state machine itself, the state machine is free to handle another device, or do something else on the same device.
    You should be calling the state machine over and over and over anyway.  So, have the state machine "control the pressure" on every call, and THEN examine whatever state it's in.
    Steve Bird
    Culverson Software - Elegant software that is a pleasure to use.
    Culverson.com
    Blog for (mostly LabVIEW) programmers: Tips And Tricks

  • Making array while looping another array

    hi all,
    i have an array of int values.
    i need to make a list of another values while looping around the int values.
    but the values that are added to the list are objects
    can any one help me with the sample code in getting the list
    any ideas?
    regards and thanks in advance

    Double-posted
    http://forum.java.sun.com/thread.jspa?threadID=648140

  • Java 'while' Looping

    Write a program to read the bicycle wheel radius (a "double") the number of teeth on the front sprocket (an "int") and then to read repeatedly the number of teeth on a rear sprocket (an "int") and compute and print the effective radius until a value of zero is encountered.
    At every calculation except the first, print the ratio of the newly computed effective radius to the previous effective radius.
    MY problem is how i can use while loop in it to make it zero. well i m going to try different way to use while loop inside to get value zero and then get ratio to work. any help would be usefull.I m learning...as well so i will try just need guide line if its possible.
    Thanks all for reading
    public class BicycleGears {
    public static void main(String[] argv)
    double wheelRadius=0.0f;
    float eftRadius=0.0f;
    int frontSprocket=0;
    int rearSprocket=0;
    float pRadius=-0.0f;
    double eftRadius1;
    float ratio=0.00f;
    //Prompt and read the number;
    System.out.println ("Please enter the wheelRadius");
    wheelRadius = UserInput.readDouble();
    //produce an error message and end program
    if(wheelRadius <= 0)
    System.out.println("Error, invalid value");
    System.exit(0);
    //Prompt and read the number;
    System.out.println("Please enter the frontSprocket");
    frontSprocket = UserInput.readInt();
    //produce an error message and end program
    if(frontSprocket <= 0)
    System.out.println("Error, invalid value");
    System.exit(0);
    //Prompt and read the number
    System.out.println("Please enter the rearSprocket");
    rearSprocket = UserInput.readInt();
    //produce an error message and end program
    if (rearSprocket <= 0)
    System.out.println("Error, invalid value");
    System.exit(0);
    // calculation for radius
    eftRadius1 = (wheelRadius*frontSprocket)/rearSprocket;
    //print radius
    ----------------------------------error-----------------------------
    do {
    System.out.println("The effective radius for radius" + wheelRadius + "and sprockets" + frontSprocket + " and " + rearSprocket + " is " + eftRadius1 );
    } while (eftRadius1 > 0);
    System.out.println("The effective radius for radius" + wheelRadius + "and sprockets" + frontSprocket + " and " + rearSprocket + " is " + eftRadius1 );
    eftRadius1--;
    --------------------------error-----------------------------------------
    its work fine & run up to zero value But its start my calculation from E.g ( The effective radius for radius 27.5 and sprockets 55 and 23 is *65.77* Right ) But its give me result from here
    The effective radius for radius 27.5 and sprockets 55 and 23 is *42.77* ( Wrong ) till it go 0.
    } // end of main
    } // end class

    when i run i dont get any error thats the problem :)
    but only if some one run the code then they can understand my problem
    on above code my looping working fine but when i run, it give me wrong result. and Blue J dont give me any error..i asked teacher they said go & work out out yourself :( ...
    anyway i m working on it...but really thanks for your time man.
    ------------------------------------------My result which is wrong ----------------------------------------
    The effective radius for radius : 44.76087
    The effective radius for radius : 43.76087
    The effective radius for radius : 42.76087
    The effective radius for radius : 41.76087
    The effective radius for radius : 40.76087
    The effective radius for radius : 39.76087
    The effective radius for radius : 38.76087
    The effective radius for radius : 37.76087
    The effective radius for radius : 36.76087
    The effective radius for radius : 35.76087
    The effective radius for radius : 34.76087
    The effective radius for radius : 33.76087
    The effective radius for radius : 32.76087
    The effective radius for radius : 31.760872
    The effective radius for radius : 30.760872
    The effective radius for radius : 29.760872
    The effective radius for radius : 28.760872
    The effective radius for radius : 27.760872
    The effective radius for radius : 26.760872
    The effective radius for radius : 25.760872
    The effective radius for radius : 24.760872
    The effective radius for radius : 23.760872
    The effective radius for radius : 22.760872
    The effective radius for radius : 21.760872
    The effective radius for radius : 20.760872
    The effective radius for radius : 19.760872
    The effective radius for radius : 18.760872
    The effective radius for radius : 17.760872
    The effective radius for radius : 16.760872
    The effective radius for radius : 15.760872
    The effective radius for radius : 14.760872
    The effective radius for radius : 13.760872
    The effective radius for radius : 12.760872
    The effective radius for radius : 11.760872
    The effective radius for radius : 10.760872
    The effective radius for radius : 9.760872
    The effective radius for radius : 8.760872
    The effective radius for radius : 7.760872
    The effective radius for radius : 6.760872
    The effective radius for radius : 5.760872
    The effective radius for radius : 4.760872
    The effective radius for radius : 3.760872
    The effective radius for radius : 2.760872
    The effective radius for radius : 1.7608719
    The effective radius for radius : 0.7608719
    ratio is 0.23912811
    Please enter the Rear Sprocket
    -----------------------------------------------------------right code should give me result ----------------------------------------------
    The effective radius for radius : *65.77*
    The effective radius for radius : 64.65
    The effective radius for radius : 63.56 etc till i get zero value
    The effective radius for radius : 0.7608719 should be 0.00
    ratio is 0.23912811 how i hide ratio here i dont need show ration on first radius ( At every calculation except the first, print the ratio of the newly computed effective radius to the previous effective radius.)
    Please enter the Rear Sprocket
    I am trying to explain you. As such i dont get any error to run code..may b some calculation wrong or i m sure thats problem coming from looping. if you c first code i point error lines

  • Waveform charts slowed down control system while loop

    Hi
    In my application, I have control system which i acquire data, process and output the result. I placed some waveform charts in the while loop where i acquire data, process and output. This made while loop to miss data points( late). Is this because waveform charts store data as time passes?

    Waveform charts store data in a history buffer of configurable size. You can change it to a smaller number.
    What is the size of the history buffer?
    How many charts are you updating in your loop?
    What else is happening in your loop?
    How are you updating them (wire, local variable, value property, etc).
    How fast is your loop rate?
    Are your plots simple (thin lines) or fancy (e.g. large dots and thick lines)?
    Is autoscaling on or off?
    Are the charts set to "synchronous display" by accident?
    How many traces are on your chart?
    What is your LabVIEW version?
    What is your OS?
    Do you have overlapping elements on the front panel?
    Could you attach a simplified version of your code so we have a better idea what you're actually doing?
    LabVIEW Champion . Do more with less code and in less time .

  • Why writes LabVIEW only every 2 seconds the measured Value to a Excel (In a while loop with 100 ms tact)?

    Hi everybody,
    I use the myDAQ to measure speed, ampere, and voltage of a battery driven motor. (For Current measurement, i use a Sensor which outputs a 0-10 V signal). I placed all DAQ-Assitants in a while loop with a [Wait until next ms multiple] clock and set a value of 100 ms. I thougt, Labview will now write into my text file 10 times a second all values. In fact, as you can see in the attached text file, Labview only writes in a unsteady interval of 1-2 seconds a value, which is too less.
    The question: Did I do anything wrong, how can you create VI that writes you lets say 10 values a second into text file? Or is simply the DigitalMultimeter input of the myDAQ not able to sample a rate of 10 Hz? I couldn´t find any information in the specification handbook about the sample rate of the DMM?
    If anyone can help me would be great! Thanx a lot, Markus
    Attachments:
    Measure Speed+Current+Voltage into Excel.vi ‏175 KB
    Test7.txt ‏1 KB

    File I/O is not very efficient. I recommend that you do you file logging in a parallel task. Have one task do your data acquision. This task would then pass the data to be logged to the logging task via a queue. That way your file operations do not impact your data acquision. Also, express VIs are not very efficient. You would be better off accessing that directly using the DAQ VIs. The express VIs contain lots of steps that do not need to be done every time you call it such as initializing the device.
    Mark Yedinak
    "Does anyone know where the love of God goes when the waves turn the minutes to hours?"
    Wreck of the Edmund Fitzgerald - Gordon Lightfoot

  • How can I reset the value of an indicator in a while loop, from another synchronous while loop?

    I am running 2 synchronous while loops, one which is keep track of time, and the other is measuring periods. In the while loop that is measuring periods, I have a boolean indicator displaying whether the signal is on or off. My problem is that when the signal is off, the VI I use to measure the periods is waiting for the next signal, and displays the boolean value from the previous period measurement. While this VI is waiting, I want the indicator to display false and not the value from the last iteration of the loop.
    I am using LV 5.1 for MAC.

    Two things you can try:
    In preface to the first, the most common (perhaps ONLY) use of local variables should be in transferring data between parallel loops. This is a matter of discipline, and creates programs that are easier to understand, take less time and memory, and are just plain cleaner. Having said that, to transfer data between loops, use a local variable.
    Second solution: Instead of setting the value to false, just hide the indicator in question by using control references (property nodes for prev. version of LabVIEW). Control references are a great way to control items on a dialog or HMI screen.

  • How should I set up my VI so that I can use the linear fit coefficient data analysis program, when my values are coming from while loops within a sequence structure?

    I'm attempting to create a calibration program, using the printer port, and a Vernier Serial Box by modifying a calibration program designed for the serial box.
    There are six calibration points, and to collect them, I have it controlled by while loops so that the numbers are taken when a button is pushed, and this is inside a sequence structure so that I can get the six different points. I feed these numbers into two different arrays (for x and y values) and then try to use the linear coefficient analysis on these points, but the values for the slope and intercepts it returns are not correc
    t.
    If I cut out the array and coefficient analysis, and feed the same numbers in directly without the while loop and sequence structures, it produces the proper values... I don't know why the numbers it is producing are different, and I'd really like to know.
    Thanks,
    Karinne.

    I would use a data manager sub-vi that would be called by each from of the sequence structure that produced a data point. The data manager sub-vi could auto append new items or could place items in a specific entry of an array. Later on when you want to calculate the linear fit, call the sub-vi to return the array of values.
    Stu

  • How to use Boolean values from 2 different sources to stop a while loop?

    I am working on a program for homework that states E5.4) Using a single Whil eLoop, construct a VI that executes a loop N times or until the user presses a stop button. Be sure to include the Time Delay Exress Vi so the user has time to press the stop botton. 
    I am doing this right now but it seems as though I can only connect one thing to the stop sign on th while loop. It won't let me connect a comparision of N and the iterations as well as the stop button to the stop sign on the while loop. So how would I be able to structure it so that it stops if it receives a true Boolean value from either of the 2 sources (whichever comes first)? 
    Basically, I cannot wire the output of the comparison of N and iterations as well as the stop button to the stop button on the whlie loop to end it. Is there a solution?
    Thanks!
    Solved!
    Go to Solution.

    Rajster16 wrote:
    Using a single Whil eLoop, construct a VI that executes a loop N times or until the user presses a stop button. 
    Look in the boolean palette for something similar to the word hightlighted in red above.
    LabVIEW Champion . Do more with less code and in less time .

  • I currently have one input but need to run two loops. I cannot get the two while loops to run so that they both pick up the same data, they are both picking up alternate samples. How can I get them to both pick up all of the values?

    The system I am trying to create calculates a number of values based on an input. I need to make the calculations and display the values for an entire production run and for each hour. The only way I know to do this is to create two while loops, one looking at all the values that are received and one looking only at the values for hour long periods.
    Any help would be great.
    Thanks
    RossH

    Why do you think that you have to have two loops to accomplish this task? Why not use one loop and accumulate the same data into two data sets based on the two sets of criteria?

  • How can I build a table with the time values of a timer from a while loop

    Hi:
    I have a question concerning building a table:
    Every 100ms I read a value from a sensor (while loop with a timer). I would like to build a table with the actual time and the concerning value. For example:
    0msec         1V
    100msec     2V
    200msec     3V
    300msec     4V
    etc.
    If I use the Express VI for building a table, I always get the date and time, but I don't need the date and the time is in the following format: HH:MMS, which is nonsensical for me as I can't differentiate within msec. Can I change the format anywhere?
    Can I also save the table to a file or even to an Excelsheet? How can I do that?
    Thanks for your help!

    Hi Craig:
    thank you very much. To solve the mystery : ) :
    I want to drive a stepper motor with a specific frequency. To get the current degree value of the motor I would like to measure the current time (from the beginning of the move on). (With a formula I get the degree value out of the time)
    Concurrently I would like to get data from a torque sensor and from a pressure sensor. That's why I asked you about the time and the table. The measurement should start with the movement of the motor. How can I do that? Right now I have different block diagrams (different while loops) (see attachment) and I would like to put them in one.
    I haven't done the block diagram for the pressure sensor yet, so there is only the one for the torque sensor and the one for the motor.
    I also would like to set a mark in the table when the voltage value of an analog input gets under a specific threshold value. Is that possible?
    I'm sorry, I'm a novice in LabVIEW. But maybe you can help me.
    Thank you very much!
    Steffi
    Attachments:
    motor.vi ‏238 KB
    sensor.vi ‏59 KB

Maybe you are looking for