Brett Fitzgerald

Greenhorn
+ Follow
since Mar 21, 2006
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Brett Fitzgerald

Hey everyone. I'm working on a project, involving a weather station updating a website. Currently, the site is online at http://www.weather.seniordesignprojects.com if you want to take a look for reference. Basically, there are three applets on that page. One displays some labels about the current weather (weather in my study, that is, with a fan blowing on the wind meter), and the other two are 24-hour history graphs of wind and temperature. I seem to have a problem displaying the two graphs. They are simply hand-made graphs used by drawing lines and such. It seems that one graph is always displayed twice, in both locations, and the other is displayed once, in it's proper location. The result is one location has both applets displaying on it. This happens in IE and Firefox. Does anyone know what causes this or what I can do to fix it? Thanks in advance!

Brett
18 years ago
Thanks to both of you for such a quick reply. I tried Ernest's method and it worked well. Paul, I'm planning on giving yours a shot as well. That will actually help me with the other program I'm writing, since I have a couple variable-time-length processes, but I need something else to happen every 30 seconds. Another use for threading, but this timer may make it much simpler. Again, thanks to you both!

Brett
18 years ago
I'm trying to write an applet that gets information from a file every 30 seconds and displays it to a series of labels. My code looks like this:

public class App extends Applet{
Label lblTimeStamp;
WeatherData data;
String path = "update.dat";

public void init(){
resize(300, 800);
setLayout(new FlowLayout());
setBackground(Color.black);
lblTimeStamp = new Label("lblTimeStamp");
lblTimeStamp.setAlignment(Label.CENTER);
lblTimeStamp.setFont(new Font("Serif", Font.BOLD, 12));
lblTimeStamp.setForeground(Color.red);

while(true){

try{
Thread.sleep(30000);
FileInputStream fs = new FileInputStream(path);
ObjectInputStream is = new ObjectInputStream(fs);
data = (WeatherData)is.readObject();
lblTimeStamp.setText(data.getTimeStamp().format(new Date()));
os.close();
}
catch(InterruptedException e){
}
catch(Exception err){
System.out.println(err);
}
}
}
}

I have a class defined called WeatherData that has the values that it's looking for. My problem is the point at which the Thread.sleep() is issued. I've tried moving it out of the while loop, and when the applet is run, it executes the Thread.sleep() statement before any other statement, except the resize(). No matter where I put Thread.sleep(), it runs first. When it is in the while loop, it executes once, then nothing else happens. Can anyone explain this to me? Thanks!

Brett Fitzgerald
18 years ago
Start off by starting both the 7 and the five minute timers. Flip each one as it runs out. End up by flipping the 7 minute timer 1 once, and the 5 minute twice. This generates 14 minutes total on the 7 minute timer, and 15 minutes on the five minute timer.

Once the second run of the 7 minute timer has elapsed (14 minutes into the process), start your stopwatch. The 3rd run of the 5 minute timer has 1 minute remaining at this point. Once this minute runs through, simply run the 5 minute timer three more times.

Brett
18 years ago
Joe, thanks. I don't know how I missed that thread, but it does answer my questions. I got another box that I'm puttting linux on, so I can try both methods.

Brett
18 years ago
I'm a fairly new java programmer, and I'm having some problems. I've done some reading in these forms on the internet. Here's my goal:
I have a device (a weather station) attached to my rs232 com port, and I'd like to read in the data being sent to my pc. I have no idea how to approach this.

This is what I've done: I've looked at that Sun Java API, but it appears that they have elminated windows suppport in version 3.0. I found out about the rxtx.org open source project, but after reading through this, I became thoroughly confused. Is figuring that out going to be my best option? What's the best way for a relativly new java programming to access data coming into a COM port in WindowsXP?

Thanks for your help!

Brett
18 years ago