Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Real Time Analysis

Posted on 2004-09-04
4
Medium Priority
?
273 Views
Last Modified: 2010-05-18
Hello,
I have a java simulation program which presents 75 records of data every 15 seconds. It then pauses for "x" seconds. And presents another 75 seconds of data, and so on... All this data is written to a data file "abc.dat".

Could somebody tell me how to analyze this file in real-time depending on when new data is available in the file "abc.dat"? I would like to do it preferably in Java. The analysis program should check "abc.dat" on regular intervals of time or a user defined interval of time.

Any help on this issue would be appreciated.

Thank you,
AS
0
Comment
Question by:singhanupam
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 3

Accepted Solution

by:
Gunt earned 1500 total points
ID: 11980946
You can start a timer that checks if the file timestamp changes every X amount of time (depending on your required level of granularity).

A good implementation of this, using the observer pattern can be found here http://www.rgagnon.com/javadetails/java-0214.html

Check the DataFileWatchDog class by the end of the page.
0
 
LVL 3

Expert Comment

by:JohnnyAffa
ID: 11984134
how much java do you know?
do you know about threads?  
do you know about files?
how and who is modifiying the abc.dat file?
how often will it need to be checked?
0
 

Author Comment

by:singhanupam
ID: 11989838
I have been using Java as a programming tool for my simulations. I could have used Fortran too, but I wanted to use Java instead. Lets see, I know a little about threads, but I have been using file handling efficiently.

The "abc.dat" is being created by my simulation tool which I have created in Java. 75 records are written to this file, then the program pauses for 15 seconds and then another 75 records are written and so on... Each record has a time stamp in increments of .25seconds.

The analysis file should check this "abc.dat" file based on user inputs. For example if the user specifies that he/she wants a 10second refresh rate, it should analyze all the precious data already in the file plus the latest 10 seconds of data. I hope I was able to explain the problem.

Thank you
0
 
LVL 2

Expert Comment

by:gen718
ID: 12036999
Use 2 threads; one thread to generate the data to be analyzed and the other to do the analysys. Use a work queue to pass data between them in some "Work" object. You can trigger the analysis thread to perform the analysis via a "Analyze" work object. The analysis thread caches the records and/or writes them to file.

The "Analyze" work object can be posted to the queue when you finish creating the 75 records or when the user specifies.

The analysis thread can reread the file if you wish or analyze the cache of records whenever it receives the "Analyze" work object trigger. An implementation of a thread-safe work queue can be found in Chan's Java Almanac Volume 1.

The "Analyze" work object can be derived from a generic "Work" object or simply implemented as a flag in the generic "Work" object. Up to you.

Just some thoughts on a possible implementation. As always, there are many possible solutions.

Hope this helps a bit :)


0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
In this post we will learn different types of Android Layout and some basics of an Android App.
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
This video teaches viewers about errors in exception handling.
Suggested Courses

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question