calculation
Class CalculationControl

java.lang.Object
  extended by calculation.CalculationControl
All Implemented Interfaces:
CalculationInterface

public class CalculationControl
extends java.lang.Object
implements CalculationInterface

The Calculation -class maintains whole calculation package and the rest of this thread.

Version:
1
Author:
Potkuri -group

Field Summary
private  AirControl airControl
          Current instance of AirControl class.
private  BuildTree buildTree
          Current instance of BuildTree class.
private  DataCollection dataCollection
          Current instance of DataCollection class.
private  FileController fileController
          Current instance of FileController class.
private  boolean flagSystemTimer
          Flag for running.
private  Graph graph
          Current instance of Graph class.
private  int internalClock
          Clock which represents passed time.
private  Parameters parameters
          Current instance of Parameters class.
private  boolean testMode
          Test mode.
private  int timerUpdateAirSpace
          Counter for airspace.
private  int timerUpdateGraphics
          Counter for graphics.
private  int timerUpdateMap
          Counter for map.
private  int updateIntervalAirspace
          How often should Airspace be updated.
private  int updateIntervalGraphics
          How often should graphics be updated.
private  int updateIntervalMap
          How often should Weather map and graph be updated.
 
Constructor Summary
CalculationControl(DataCollection dataCollection)
          Construct Calculation -package and help classes, which are used when calculating weather, graph and paths for the Graphics -package.
 
Method Summary
 boolean runTimer()
          This method is called from Main-class after all classes are constructed.
 void setTestMode()
          This method sets the test mode on for JUnit tests.
 void setTimerFlag(boolean flag)
          Set timer's flag.
private  void startDelay()
          Method pauses this thread for a second.
private  boolean update()
          Method refresh system when thread comes back from sleep.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

airControl

private AirControl airControl
Current instance of AirControl class.


buildTree

private BuildTree buildTree
Current instance of BuildTree class.


dataCollection

private DataCollection dataCollection
Current instance of DataCollection class.


fileController

private FileController fileController
Current instance of FileController class.


flagSystemTimer

private boolean flagSystemTimer
Flag for running.


graph

private Graph graph
Current instance of Graph class.


internalClock

private int internalClock
Clock which represents passed time.


parameters

private Parameters parameters
Current instance of Parameters class.


testMode

private boolean testMode
Test mode. This variable is only for JUnit tests.


timerUpdateAirSpace

private int timerUpdateAirSpace
Counter for airspace.


timerUpdateGraphics

private int timerUpdateGraphics
Counter for graphics.


timerUpdateMap

private int timerUpdateMap
Counter for map.


updateIntervalAirspace

private int updateIntervalAirspace
How often should Airspace be updated.


updateIntervalGraphics

private int updateIntervalGraphics
How often should graphics be updated.


updateIntervalMap

private int updateIntervalMap
How often should Weather map and graph be updated.

Constructor Detail

CalculationControl

public CalculationControl(DataCollection dataCollection)
Construct Calculation -package and help classes, which are used when calculating weather, graph and paths for the Graphics -package.

Parameters:
dataCollection - Current instance of dataCollection class.
Method Detail

runTimer

public boolean runTimer()
This method is called from Main-class after all classes are constructed. It loops while flag is set true and keeps program running. With every loop we call update -method, which handles the rest of update -procedures. If update -procedure takes less than we update timer interval says, we put this thread sleep for a specific time.

Specified by:
runTimer in interface CalculationInterface
Returns:
boolean

setTestMode

public void setTestMode()
This method sets the test mode on for JUnit tests.


setTimerFlag

public void setTimerFlag(boolean flag)
Set timer's flag. Program keeps running while flag is true.

Specified by:
setTimerFlag in interface CalculationInterface
Parameters:
flag - Flag value.

startDelay

private void startDelay()
Method pauses this thread for a second. This ensures that graphic's thread get enough computer time.


update

private boolean update()
Method refresh system when thread comes back from sleep. AirSpace and Graphics updates in every round, weather map-, graph- and arrival tree more sparsely. Some calculation can be divided into smaller parts. This optimization is useful when it comes to heavy operations on the same round.

Returns:
succeed