ikayaki.squid
Class Squid

java.lang.Object
  extended by ikayaki.squid.Squid

public class Squid
extends Object

Offers an interface for controlling the SQUID system. Reads settings from the Settings class. Creates instances of the degausser, handler and magnetometer classes and offers handles for them.

Author:
Aki Korpua

Field Summary
private  Degausser degausser
          Instance of the degausser interface.
private  Handler handler
          Instance of the handler interface.
private static Squid instance
          Instance of the Squid interface.
private  Magnetometer magnetometer
          Instance of the magnetometer interface.
private  Project owner
          The project that is currently using the Squid, or null if no project is using it.
 
Constructor Summary
private Squid()
          Initializes the Squid interface.
 
Method Summary
 Degausser getDegausser()
          Returns an interface for controlling the degausser.
 Handler getHandler()
          Returns an interface for controlling the handler.
 Magnetometer getMagnetometer()
          Returns an interface for controlling the magnetometer.
 Project getOwner()
          Returns project that is currently using the Squid.
static Squid instance()
          Returns a reference to the Squid.
 boolean isOK()
          Checks whether all devices are working correctly.
 boolean setOwner(Project owner)
          Sets the owner of the Squid.
 void updateSettings()
          Checks which settings have changed and updates all the device interfaces.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

instance

private static Squid instance
Instance of the Squid interface.


owner

private Project owner
The project that is currently using the Squid, or null if no project is using it.


degausser

private Degausser degausser
Instance of the degausser interface.


handler

private Handler handler
Instance of the handler interface.


magnetometer

private Magnetometer magnetometer
Instance of the magnetometer interface.

Constructor Detail

Squid

private Squid()
       throws IOException
Initializes the Squid interface. Creates instances of Degausser, Handler and Magnetometer.

Throws:
IOException
Method Detail

instance

public static Squid instance()
                      throws IOException
Returns a reference to the Squid. If it has not yet been created, will create one.

Throws:
IOException

getDegausser

public Degausser getDegausser()
Returns an interface for controlling the degausser.

Returns:
Handler for Degausser if available

getHandler

public Handler getHandler()
Returns an interface for controlling the handler.

Returns:
Handler for Handler if available

getMagnetometer

public Magnetometer getMagnetometer()
Returns an interface for controlling the magnetometer.

Returns:
Handler for Magnetometer if available

updateSettings

public void updateSettings()
Checks which settings have changed and updates all the device interfaces. This method should be called when changes are made to the device parameters.

This method starts a worker thread that will update the settings. If the current project has a measurement running, the thread will keep on retrying until the measurement is finished. Multiple calls to this method within a short period of time will update the settings only once.


isOK

public boolean isOK()
Checks whether all devices are working correctly.

Returns:
true if everything is correct, otherwise false.

setOwner

public boolean setOwner(Project owner)
Sets the owner of the Squid. Only one project may have access to the Squid at a time. This method may be called only from the Project class.

Parameters:
owner - the project that will have exclusive access to the Squid. May be null.
Returns:
true if successful, false if the existing owner had a running measurement.

getOwner

public Project getOwner()
Returns project that is currently using the Squid.

Returns:
the project, or null if none is using the Squid.