model
Class LightModel

java.lang.Object
  extended by model.LightModel

public class LightModel
extends Object

This is the main class for the Model part of the program. All communcations between the model and controller go through this class. Additionally, this class contains the current Show, ADMXDevice, and ChannelValues.


Constructor Summary
LightModel(ILightModelConnector _connector, ADMXDevice _dmxDevice, Show _show)
          This constructor instaniates the LightModel with a link to the connector, the current dmx device, and the default Show.
 
Method Summary
 void addCue(ACue cue)
          This method adds a new cue to the current show.
 boolean connect()
          This method will tell the view to the connect to the USBDMX.com device.
 void cueTransition(float oldCueNumber, float newCueNumber)
          This method will start a transition from the old cue to the new cue.
 void disconnect()
          This method will tell the model to disconnect from the current device, and switch to the dummy DMX device.
 Channel[] getChannels()
          This method will return an array of Channel objects for every channel with a non-zero value.
 Channel[] getChannelsForCue()
          This is a specilized form of getChannels() used when creating new cues.
 short getChannelValue(short address)
          This method returns the value of the given channel address.
 short[] getChannelValues(short[] addresses)
          This method will return the channel values for the given addresses.
 String[] getCueNames()
          This method will return an array containing the summary of every cue in the show.
 float getHighestCueNumber()
          This method will return the highest cue number in the show.
 void goToCue(float cueNumber)
          This method will move to a cue without a transition.
 void loadShow(String filename)
          This method will load the saved show back into the program.
 void resetFaderValues()
          This method will reset all the fader values to their defaults, and update the view to reflect this change.
 void saveShow(String filename)
          This method will save the current show to a file.
 void setChannelValue(Channel channel, float source)
          This method will set the channel value to the given value.
 void setChannelValues(Channel[] channels, float source)
          This method will set a series of channel values.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LightModel

public LightModel(ILightModelConnector _connector,
                  ADMXDevice _dmxDevice,
                  Show _show)
This constructor instaniates the LightModel with a link to the connector, the current dmx device, and the default Show.

Method Detail

getChannelValue

public short getChannelValue(short address)
This method returns the value of the given channel address.

Parameters:
address - The address whos value will be returned.
Returns:
The value of the given address.

getChannelValues

public short[] getChannelValues(short[] addresses)
This method will return the channel values for the given addresses.

Parameters:
addresses - The array of channel addresses.
Returns:
The array of channel values.

getChannels

public Channel[] getChannels()
This method will return an array of Channel objects for every channel with a non-zero value.

Returns:
The array of Channel objects for every channel with a non-zero value.

getChannelsForCue

public Channel[] getChannelsForCue()
This is a specilized form of getChannels() used when creating new cues. In addition to returning all channels with a non-zero value, it will also return channels with a hard-ducked fader value (-100).

Returns:
The array of Channel objects for cue creation.

setChannelValue

public void setChannelValue(Channel channel,
                            float source)
This method will set the channel value to the given value. The channelValues object will be updated, as will the dmxDevice, and then the view will be updated.

TODO: Change this method so an exception won't screw up the stored values.

Parameters:
channel - The Channel object with the new address, value pair.
source - An int representing the source of this channel value.

setChannelValues

public void setChannelValues(Channel[] channels,
                             float source)
This method will set a series of channel values. First, the channelValues object will be updated, then the channels changed on the dmxDevice. Finally, the view will be refreshed to represent the new values.

Parameters:
channels - The Channel objects with the new address, value pairs.
source - An int value representing the source of these channel values.

addCue

public void addCue(ACue cue)
This method adds a new cue to the current show. It will also update the view to reflect this change, and select this cue as the current cue.


resetFaderValues

public void resetFaderValues()
This method will reset all the fader values to their defaults, and update the view to reflect this change.


getCueNames

public String[] getCueNames()
This method will return an array containing the summary of every cue in the show.

TODO: Rename this method from getCueNames() to getCueSummaries()

Returns:
The string array constaining the summary of every cue in the show.

getHighestCueNumber

public float getHighestCueNumber()
This method will return the highest cue number in the show. This is used to select the default cue value when someone creates a new cue.

Returns:
The highest cue number in the show.

cueTransition

public void cueTransition(float oldCueNumber,
                          float newCueNumber)
This method will start a transition from the old cue to the new cue.

TODO: It appears this method is no longer necessary.

Parameters:
oldCueNumber - The number of the cue to transition away from.
newCueNumber - The number of the cue to transition to.

goToCue

public void goToCue(float cueNumber)
This method will move to a cue without a transition.

Parameters:
cueNumber - The cue number to go to.

connect

public boolean connect()
This method will tell the view to the connect to the USBDMX.com device.

TODO: This method needs to be redone so that the user can select what device they want to connect to.

Returns:
This method will return true if the model sucsessfully connected to the device, and false otherwise.

disconnect

public void disconnect()
This method will tell the model to disconnect from the current device, and switch to the dummy DMX device.


saveShow

public void saveShow(String filename)
This method will save the current show to a file.

Parameters:
filename - The file name and path to save the show to.

loadShow

public void loadShow(String filename)
This method will load the saved show back into the program. After loading the show, it will update the view and channel values to reflect this change.

Parameters:
filename - The file name and path to load the show from.