stella
Class CommandEvent

java.lang.Object
  extended by java.util.EventObject
      extended by util.rmi.RmiEvent
          extended by stella.MessageEvent
              extended by stella.CommandEvent
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
AcquireExposureAdapter, AutoFocusCcd, DarkCcd, DerotatorOffsetTelescope, DerotatorTelescope, DitherAuxiliary, EnvironmentConfig, ExposeAdapter, ExposeAuxiliary, ExposureAbortCcd, FindAdapter, FindAuxiliary, FitsCcd, FixedRotatorAdapter, FocusAdapter, FocusOffsetAdapter, FocusOffsetTelescope, FocusTelescope, FocusTest, FollowRoof, GeometryAuxiliary, GeometryCcd, GuidingExposureAdapter, MoveAuxiliary, MoveMirrorTelescope, MoveTelescope, OffsetTelescope, OffsetTest, PointingModelAdd, PointingModelSave, PointingModelTelescope, PointingOffsetsTelescope, PositionRoof, PositionTelescope, ScientificCcd, ScsAddressConfig, SelectFilterAdapter, SelectFilterCalibration, SelectModeCcd, SequenceFilterCalibration, SimpleCommand, StarCommand, StartExposingAuxiliary, StartGuidingAdapter, StartGuidingAuxiliary, StartWatchMaster, TestConfig

public abstract class CommandEvent
extends MessageEvent

The generic command event class. This class should not be used directly, merely subclasses of this class. Concrete subclasses should additionally implement the appropriate marker interface, like TelescopeCommand.

Concrete subclasses of this class will carry additional parameter.
Example:

   MOVE_TELESCOPE 1 965054152000 131.130.36.73 
   314.745655 -12.983457   
   
In the example above, computer 131.130.36.73 sends a position command 105 to 131.130.36.79.

See Also:
Serialized Form

Nested Class Summary
static class CommandEvent.Create
          Test.
 
Field Summary
static String COMMANDPACKAGE
          The package name of the commands to prepend to the class name.
static String JVIEWPACKAGE
          The package name of the commands to prepend to the class name.
static char TYPESEPARATOR
          The separator between the command name and the command server.
 
Fields inherited from class stella.MessageEvent
SEPCHAR
 
Fields inherited from class util.rmi.RmiEvent
localHost, sourceName
 
Fields inherited from class java.util.EventObject
source
 
Constructor Summary
protected CommandEvent(Object src, String type, long time)
          A fully qualified command.
 
Method Summary
static String classNameToTemplate(String cname)
          Converts a class name to the command string.
static CommandEvent createCommand(MessageBin bin)
          Creates a full command event from a message bin.
static CommandEvent createCommand(Object src, String template)
          Creates a new command event from a template string.
static CommandEvent createJCommand(Object src, String template)
          Creates a new jcommand event from a template string.
static String extractType(Class command)
          Converts a concrete command class to the class type as found in the command event header.
private static Constructor getConstructor(String cname)
          Tries to locate the class with the given name.
 int getExpectedAcknowledgeNumber()
          Returns the number of acknowledge evnets this command is expected to follow.
private static CommandEvent instantiateCommand(Constructor construct, Object src, String type, long time)
          Uses the argument constructor to instantiate a new command event class.
protected static String[] parseForStrings(String line)
          Parses a command line into an array of strings.
static String templateToClassName(String template)
          Converts a template name into a valid class name.
 
Methods inherited from class stella.MessageEvent
checkType, equals, equalTime, equalTime, fromAscii, getAllCommandLines, getExecuteGroupKey, getHead, getLine, getNr, getTime, getType, hashCode, isValid, parseFromSingleString, parseLine, readFromBufferedStream, setNr, setTime, setType, setValid, toString
 
Methods inherited from class util.rmi.RmiEvent
getHost, getSourceName, setSourceName
 
Methods inherited from class java.util.EventObject
getSource
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

COMMANDPACKAGE

public static final String COMMANDPACKAGE
The package name of the commands to prepend to the class name.

See Also:
Constant Field Values

JVIEWPACKAGE

public static final String JVIEWPACKAGE
The package name of the commands to prepend to the class name.

See Also:
Constant Field Values

TYPESEPARATOR

public static final char TYPESEPARATOR
The separator between the command name and the command server.

See Also:
Constant Field Values
Constructor Detail

CommandEvent

protected CommandEvent(Object src,
                       String type,
                       long time)
A fully qualified command.

Method Detail

createCommand

public static CommandEvent createCommand(MessageBin bin)
Creates a full command event from a message bin. Parsing of command lines is done.


createCommand

public static CommandEvent createCommand(Object src,
                                         String template)
Creates a new command event from a template string. No command line is set. Used for generating command events from a template. A CommandRendering instance is than needed to fill in the command line.


createJCommand

public static CommandEvent createJCommand(Object src,
                                          String template)
Creates a new jcommand event from a template string. No command line is set. Used for generating command events in GUI-based command casters.


extractType

public static String extractType(Class command)
Converts a concrete command class to the class type as found in the command event header. Use this method to reliably shift from command classes to command types.

Parameters:
command - A class object denoting a command class
Returns:
The command type linked to the command class.

classNameToTemplate

public static String classNameToTemplate(String cname)
Converts a class name to the command string. This method does not check if the provided class name refers to a true class. The class name is transformed into the template name by capitalizing all lower-case letters. If a capital letter is found and it is not the first character a TYPESEPARATOR is inserted right before this capital letter.


templateToClassName

public static String templateToClassName(String template)
Converts a template name into a valid class name. The valid class name is generated from the template in the following way:


parseForStrings

protected static String[] parseForStrings(String line)
Parses a command line into an array of strings. Returns an array of token number.


getConstructor

private static Constructor getConstructor(String cname)
Tries to locate the class with the given name. If the class is found, a Constructor which takes an object, a string, and a long as an argument is searched and returned if successful. If the class name does not point to a valid class definition, or no constructor with object, string, long can be found, null is returned.


instantiateCommand

private static CommandEvent instantiateCommand(Constructor construct,
                                               Object src,
                                               String type,
                                               long time)
Uses the argument constructor to instantiate a new command event class. The arguments to the constructor are also specified. If instantiation using the constructor fails for any reason null is returned.


getExpectedAcknowledgeNumber

public int getExpectedAcknowledgeNumber()
Returns the number of acknowledge evnets this command is expected to follow. Used for test case only. If not overriden, this method will return one.

Returns:
One.