ikayaki.squid
Class Magnetometer

java.lang.Object
  extended by ikayaki.squid.Magnetometer
All Implemented Interfaces:
SerialIOListener, EventListener

public class Magnetometer
extends Object
implements SerialIOListener

Offers an interface for controlling the magnetometer."

Author:
Aki Korpua

Field Summary
private  boolean measuring
           
private  Stack<String> messageBuffer
          Buffer for incoming messages, readed when needed.
private  int pollTimeout
           
private  SynchronousQueue<String> queue
          Synchronous queue for waiting result message from magnetometer
protected  SerialIO serialIO
          COM port for communication.
private  boolean waitingForMessage
           
 
Constructor Summary
Magnetometer()
          Creates a new magnetometer interface.
 
Method Summary
 void clearFlux(char axis)
          Clears flux counter for axis.
protected  void configure(char axis, char subcommand, char option)
          Used for configuring Magnetometer parameters.
protected  String getData(char axis, char command, String datavalues)
          Generic send message sender, use with caution and knowledge.
 char[] getFilters()
          Returns filter configurations for all axis.
 boolean[] getLoop()
          Returns if Loops have been opened on axes.
 char[] getRange()
          Returns range configurations for all axis.
 boolean[] getSlew()
          Returns Fast Slew options value.
 boolean isMeasuring()
           
 boolean isOK()
          Checks if connection is ok.
protected  void latchAnalog(char axis)
           
protected  void latchCounter(char axis)
           
 void pulseReset(char axis)
          Pulse reset (open then close) feedback loop for axis.
 double[] readData()
          Latches axes, reads counters and analog.
protected  void reset(char axis)
          Reset settings for axis.
protected  void resetCounter(char axis)
          Reset counter for axis.
 void serialIOEvent(SerialIOEvent event)
          Propagates serial port message event.
 void updateSettings()
          Checks which settings have changed and updates the magnetometer interface.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

messageBuffer

private Stack<String> messageBuffer
Buffer for incoming messages, readed when needed.


queue

private SynchronousQueue<String> queue
Synchronous queue for waiting result message from magnetometer


pollTimeout

private int pollTimeout

serialIO

protected SerialIO serialIO
COM port for communication.


waitingForMessage

private boolean waitingForMessage

measuring

private boolean measuring
Constructor Detail

Magnetometer

public Magnetometer()
             throws SerialIOException
Creates a new magnetometer interface. Opens connection to Magnetometer COM port (if its not open already) and reads settings from the Setting class.

Throws:
SerialIOException
Method Detail

updateSettings

public void updateSettings()
Checks which settings have changed and updates the magnetometer interface. This method will be called by the Squid class.


reset

protected void reset(char axis)
Reset settings for axis.

Parameters:
axis - 'X', 'Y', 'Z' or 'A' (all). All characters are in upper case.

resetCounter

protected void resetCounter(char axis)
Reset counter for axis.

Parameters:
axis - 'X', 'Y', 'Z' or 'A' (all). All characters are in upper case.

configure

protected void configure(char axis,
                         char subcommand,
                         char option)
Used for configuring Magnetometer parameters. See subcommand for usages.

Parameters:
axis - 'X', 'Y', 'Z' or 'A' (all). All characters are in upper case.
subcommand - The CONFIGURE subcommands follow:
"F" Set filter configuration. The data subfield sets the filter to the indicated range. The four possible data values are: "1" One Hertz Filter; 1 Hz "T" Ten Hertz Filter; 10 Hz "H" One hundred Hertz Filter; 100 Hz "W" Wide band filter; WB
"R" Set DC SQUID electronic range. The data subfield selects the range desired. The four possible data values are: "1" One time range; 1x "T" Ten times range; 10x "H" One hundred times range; 100x "E" Extended range; 1000x
"S" Set\reset the fast-slew option. Two data values are possible: "E" Enable the fast-slew; turn it on. "D" Disable the fast-slew; turn it off.
"L" This subcommand opens or closes the SQUID feedback loop or resets the analog signal to +/- 1/2 flux quantum about zero. The three possible data values are: "O" Open the feedback loop. (This command also zeros the flux counter) "C" Close the feedback loop. "P" Pulse-reset (open then close) the feedback loop. (This command also zeros the flux counter)
option - see data values from subcommands.

latchAnalog

protected void latchAnalog(char axis)
Parameters:
axis - 'X', 'Y', 'Z' or 'A' (all). All characters are in upper case.

latchCounter

protected void latchCounter(char axis)
Parameters:
axis - 'X', 'Y', 'Z' or 'A' (all). All characters are in upper case.

getData

protected String getData(char axis,
                         char command,
                         String datavalues)
Generic send message sender, use with caution and knowledge. Checks if commands are good.

Parameters:
axis - 'X', 'Y' or 'Z'. All characters are in upper case.
command - "D" Send back the analog data last captured with the LATCH command. The data field is not required.
"C" Send back the counter value last captured with the LATCH command. The data field is not required.
"S" Send back status. Various pieces of status can be sent by the magnetometer electronics.
datavalues - Datavalues one or more:
"A" Send back all status.
"F" Send back all filter status.
"R" Send back all range status.
"S" Send back slew status.
"L" Send back SQUID feedback loop status. Return feedback, waiting time?
Returns:
Returns data wanted, see command and datavalue

pulseReset

public void pulseReset(char axis)
Pulse reset (open then close) feedback loop for axis. Need to be done before measuring.

Parameters:
axis - 'X', 'Y', 'Z' or 'A' (all). All characters are in upper case.

clearFlux

public void clearFlux(char axis)
Clears flux counter for axis. Need to be done measuring.

Parameters:
axis - 'X', 'Y', 'Z' or 'A' (all). All characters are in upper case.

readData

public double[] readData()
Latches axes, reads counters and analog. Calculates data from them and returns them.

Returns:
Returns 3 double values in following order: (x,y,z)

isMeasuring

public boolean isMeasuring()

getFilters

public char[] getFilters()
Returns filter configurations for all axis.

Returns:
return filter values for all axis in order (x,y,z).
Values:
"1" One Hertz Filter; 1 Hz
"T" Ten Hertz Filter; 10 Hz
"H" One hundred Hertz Filter; 100 Hz
"W" Wide band filter; WB

getRange

public char[] getRange()
Returns range configurations for all axis.

Returns:
return filter values for all axis in order (x,y,z).
Values:
"1" One time range; 1x
"T" Ten times range; 10x
"H" One hundred times range; 100x
"E" Extended range; 1000x

getSlew

public boolean[] getSlew()
Returns Fast Slew options value.

Returns:
true if Fast Slew is on, false if not. In order (x,y,z).

getLoop

public boolean[] getLoop()
Returns if Loops have been opened on axes.

Returns:
return Loop status for all axis in order (x,y,z). Values true = on, false = off.

isOK

public boolean isOK()
Checks if connection is ok.

Returns:
true if ok.

serialIOEvent

public void serialIOEvent(SerialIOEvent event)
Description copied from interface: SerialIOListener
Propagates serial port message event.

Specified by:
serialIOEvent in interface SerialIOListener
Parameters:
event - the event that happened.