Page 2 of 2 FirstFirst 12
Results 21 to 40 of 40
  1. #21
    xana is offline Member
    Join Date
    Jul 2010
    Posts
    17
    Rep Power
    0

    Default

    ok.

    I have the class SerialComm to receive and operate the data from a serial port.

    i have also more classes.

    Maybe I should put the code that i have in the main in a new class.

  2. #22
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,902
    Rep Power
    25

    Default

    Or a new method in the class.

  3. #23
    cselic is offline Senior Member
    Join Date
    Apr 2010
    Location
    Belgrade, Serbia
    Posts
    278
    Rep Power
    5

    Default

    Java Code:
    public NewMain(SerialComm data){
            this.ValA = ValA;
            this.ValB = ValB;
            this.ResA = ResA;
            this.ResB = ResB;
            this.Res = Res;
        }
    Well it would be great if you will have as argument in your constructor variable that can initialize ValA, ValB, ..., Res. For example NewMain object that already exists, or some other object that can initialize values with getters.

    So my advice is
    public NewMain(SomeArgumentThatCanInitializeValues itsNameIsVar) {
    this.ValA = itsNameIsVar.ValA;
    ....
    this.Res = itsNameIsVar.Res;


    or initialize with getters or other functions that return values that can initialize your variables for example: this.ValA = itsNameIsVar.getValA();
    this.Res = itsNameIsVar.getRes();

  4. #24
    cselic is offline Senior Member
    Join Date
    Apr 2010
    Location
    Belgrade, Serbia
    Posts
    278
    Rep Power
    5

    Default

    Java Code:
    out1.printf("%s %n","#   Time [sec]  Posm[mBar]");
                    out1.printf("%s","    "+time);
                    out1.printf("%s %n","    "+Res);
    Why you are using in function printf " " + variable?
    I guess that's redundant to format your output in function that you are using for formating the output :D

  5. #25
    cselic is offline Senior Member
    Join Date
    Apr 2010
    Location
    Belgrade, Serbia
    Posts
    278
    Rep Power
    5

    Default

    I do not want to be rude but I think that it would be better for you to do not use serial port because that technology is obsolete.
    Serial ports today are on graveyard of technology.

    They are not in usage for at least 5-10 years from now.

  6. #26
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,902
    Rep Power
    25

    Default

    Tell that to the manufacturer of the equipment the OP is trying to support.

  7. #27
    xana is offline Member
    Join Date
    Jul 2010
    Posts
    17
    Rep Power
    0

    Default

    Ok.
    I'm developing a JAVA application that receives data from serial port by means of the class SerialComm. This class is in a package named txrx (it is the only class in this package, the others are in package ploter).
    I have other classes besides this, such as the class PolterView that are in a different package named ploter.

    I have already removed the code that I have in the main() to a new class named Writefile, in package ploter.

    Due to my inexperience in JAVA I have one problem:

    The method Write from the class WriteFile (package ploter) is called in the class SerialComm (package txrx). This is working.
    However, I need one value from the class PolterView (package ploter) that I need as a input data for the method Write.

    I wanted to know how I can access this value, that is in the class PolterView (package ploter), from the class SerialComm (package txrx) so that I can invocate the method.

    I don't know if I explain me well enough, but it is a little dificul to me explain my problem.

    Best regards

  8. #28
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,902
    Rep Power
    25

    Default

    how I can access this value
    You need a reference to the class that has the value.
    I don't know the structure of you classes to be able to suggest how that can be done.

  9. #29
    xana is offline Member
    Join Date
    Jul 2010
    Posts
    17
    Rep Power
    0

    Default

    Hello.

    I think nowthe problem with the classes is finally resolved. :D

    Thank you for all the advices.

    To obtain the system time I used System.currentTimeMillis(), but when I run the program the resulting data from this instruction is:

    Java Code:
    1280768127754
    Instead of the expected system time in seconds.

    Do anyone know why this is happening?

    Best regards

  10. #30
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,902
    Rep Power
    25

    Default

    What API doc did you read that says the time returned would be in seconds?
    Better go read it again. The suffix of the method name gives it away.

  11. #31
    xana is offline Member
    Join Date
    Jul 2010
    Posts
    17
    Rep Power
    0

    Default

    I presume that the method would return a time value (in millis of course). I didn't explain it well.

    I wanted a method that would give me the system time in seconds, but I didn't found one.

    So I used this method.

    But is it expected to receive this output?

  12. #32
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,902
    Rep Power
    25

    Default

    I wanted a method that would give me the system time in seconds
    A bit of math: millisec / 1000 = seconds

  13. #33
    xana is offline Member
    Join Date
    Jul 2010
    Posts
    17
    Rep Power
    0

    Default

    Thank you :o

    But I continue to have the same problem. The following example shows the resulting file:

    Java Code:
    #   Time[sec]  Posm[mBar] 
        1280771209    20.0000
    #   Time[sec]  Posm[mBar] 
        1280771211    20.0000
    Although I can se a change in the variable time, I don't know how to see the time from this.

  14. #34
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,902
    Rep Power
    25

    Default

    What format do you want the current time in?
    The Date class will capture the current time and can be used with other classes to display times in different formats. See SimpleDateFormat, Calendar and GregorianCalendar.

    Read the API doc and
    Search for those class names should give you sample code for various formats.

  15. #35
    xana is offline Member
    Join Date
    Jul 2010
    Posts
    17
    Rep Power
    0

    Default

    Ok. Thanks for the suggestion.

    I used Calendar. I think my problem is now resolved.

    I want just to thank everyone for all the help.

    Best regards

  16. #36
    xana is offline Member
    Join Date
    Jul 2010
    Posts
    17
    Rep Power
    0

    Default

    Hello again.

    I wanted to ask if it is possible to change the size of a chart in NetBeans?

    I haved designed a small size chart and now I increased his size and the box is the size I want but the chart itself remaind with the previous size.

    Did I something wrong?

    Best regards

  17. #37
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,902
    Rep Power
    25

    Default

    sorry, I don't know how to use your IDE.
    Perhaps if you posted the code for the problem you are having, someone could help.

  18. #38
    xana is offline Member
    Join Date
    Jul 2010
    Posts
    17
    Rep Power
    0

    Default

    I write for that no code. I only changed the chart window in the design part of the class.

    When I run it the window appeared as change it in the design part, but the actual chart appeared as I initially have it.

    I only change the design part I didn't change the code.

  19. #39
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default

    You have a new and different question, and so I recommend you post it in a new thread. You also may want to provide more information about your problem in this new post.

  20. #40
    cselic is offline Senior Member
    Join Date
    Apr 2010
    Location
    Belgrade, Serbia
    Posts
    278
    Rep Power
    5

    Default

    What type of chart?
    (Please open new thread for that question)

Page 2 of 2 FirstFirst 12

Similar Threads

  1. Replies: 8
    Last Post: 05-12-2010, 08:19 PM
  2. Replies: 1
    Last Post: 02-04-2010, 10:17 PM
  3. taking data from recent output file
    By sara12345 in forum New To Java
    Replies: 3
    Last Post: 01-06-2010, 12:48 AM
  4. Where i have to write the common data to jsp
    By trill in forum JavaServer Pages (JSP) and JSTL
    Replies: 1
    Last Post: 08-07-2007, 08:35 AM
  5. Replies: 1
    Last Post: 07-24-2007, 03:02 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •