Solved

Real Time Analysis

Posted on 2004-09-04
4
270 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 500 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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

Suggested Solutions

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
The viewer will learn how to implement Singleton Design Pattern in Java.

696 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