model
Class ChannelValues

java.lang.Object
  extended by model.ChannelValues

public class ChannelValues
extends Object

This class stores all the current channel values. Additionally, it decides what the actual value of a channel will be when it is receiving values from multiple sources.

TODO: I need to rewrite this entire class using a numbered priority system. The current system does not allow enough flexibility for the power I want to have in the program. For now, this does work well, and until I have time to rewrite this entire portion of the program, I will leave it as it is.


Field Summary
static int CUE_SOURCE
          When a channel value is being changed, the channel source value is passed in with the method.
static int CUE_VALUE_MODE
          These modes relate to the status of specific channels at any given time.
static int DEFAULT_VALUE_MODE
          These modes relate to the status of specific channels at any given time.
static int FADER_SOURCE
          When a channel value is being changed, the channel source value is passed in with the method.
static int FADER_VALUE_MODE
          These modes relate to the status of specific channels at any given time.
static int SUBMASTER_SOURCE
          When a channel value is being changed, the channel source value is passed in with the method.
static int SUBMASTER_VALUE_MODE
          These modes relate to the status of specific channels at any given time.
 
Constructor Summary
ChannelValues(int _maxChannel)
          This constructor will create a new ChannelValue object with the set maximum number of channels.
 
Method Summary
 Channel[] getAllChannels()
          This will return the Channel objects for all channels up to the maxChannel value.
 int[] getAllChannelSources()
          This method will return the source for all channels through maxChannels.
 Channel getChannel(Channel channel)
          This method will return the Channel object for the given Channel object.
 Channel getChannel(short address)
          This method will return the channel object for a given address.
 Channel[] getChannels()
          This will return a Channel object for all channels with a non-zero value.
 Channel[] getChannels(Channel[] channels)
          This method will return Channel objects for the given channels.
 Channel[] getChannels(Channel[] channels, int source)
          This method will return a Channel object with the value from the given source for each given channel address.
 Channel[] getChannels(short[] addresses)
          This method will return Channel objects for the given addresses.
 Channel[] getChannelsForCue()
          This will return all the channel values for channels that either arn't zero, or have a fader value of -100.
 int getChannelSource(Channel channel)
          This method will return the priority of the address in the Channel object.
 int getChannelSource(short address)
          This method will return the source of the channel at the given address.
 int[] getChannelSources(Channel[] channels)
          This method will return the sources for the given channels.
 int[] getChannelSources(short[] addresses)
          This method will return the sources for the given channel addresses.
 int[] getChannelSources(short startAddress, short endAddress)
          This method will return the sources for the given range of addresses.
 short getChannelValue(Channel channel)
          This method will return the value of this channel.
 short getChannelValue(short address)
          This method will return the value of the channel at the given address.
 short[] getChannelValues(short[] addresses)
          This method will return the values for the given addresses.
 short[] getChannelValues(short startAddress, short endAddress)
          This method will return the channel values from the startAddress to the endAddress.
 Channel[] getCueChannels()
          This method will return the Channel objects for any channel with a non-zero cue value.
 Channel[] getCueChannels(Channel[] channels)
          This method will return the Channel objects for the given channels.
 short[] resetFaderValues()
          This method resets all the fader values back to their defaults.
 void updateChannel(Channel channel, int source)
          This method will update the value for the given address, value pair.
 void updateChannels(Channel[] channels, int source)
           
 void updateChannels(Channel[] channels, int[] sources)
          This method will update the value for a set of address, value pairs from the given sources.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FADER_SOURCE

public static final int FADER_SOURCE
When a channel value is being changed, the channel source value is passed in with the method. FADER_SOURCE is used when the channel value is from the virtual faders or keyboard.

See Also:
Constant Field Values

CUE_SOURCE

public static final int CUE_SOURCE
When a channel value is being changed, the channel source value is passed in with the method. CUE_SOURCE is used when the channel value is from a cue.

See Also:
Constant Field Values

SUBMASTER_SOURCE

public static final int SUBMASTER_SOURCE
When a channel value is being changed, the channel source value is passed in with the method. SUBMASTER_SOURCE is used when the channel value is from a submaster.

See Also:
Constant Field Values

DEFAULT_VALUE_MODE

public static final int DEFAULT_VALUE_MODE
These modes relate to the status of specific channels at any given time. This status decides what the color code around the channel will be. The DEFAULT_VALUE_MODE is utilized when a channel does not have any value assigned to it, and is simply the default vale of 0.

See Also:
Constant Field Values

FADER_VALUE_MODE

public static final int FADER_VALUE_MODE
These modes relate to the status of specific channels at any given time. This status decides what the color code around the channel will be. The FADER_VALUE_MODE is utilized when the value on this channel is manually set through the virual faders (or keyboard input).

See Also:
Constant Field Values

CUE_VALUE_MODE

public static final int CUE_VALUE_MODE
These modes relate to the status of specific channels at any given time. This status decides what the color code around the channel will be. The CUE_VALUE_MODE is utilized when the value on this channel is from the current cue.

See Also:
Constant Field Values

SUBMASTER_VALUE_MODE

public static final int SUBMASTER_VALUE_MODE
These modes relate to the status of specific channels at any given time. This status decides what the color code around the channel will be. The SUBMASTER_VALUE_MODE is utilized when the current value on this channel is from the submasters.

See Also:
Constant Field Values
Constructor Detail

ChannelValues

public ChannelValues(int _maxChannel)
This constructor will create a new ChannelValue object with the set maximum number of channels. It will instantiate all of the channel values to their defaults.

Parameters:
_maxChannel - The maximum number of channels for this setup.
Method Detail

updateChannel

public void updateChannel(Channel channel,
                          int source)
This method will update the value for the given address, value pair.

Parameters:
channel - The channel object with the address, value pair to be updated.
source - The source of the new channel value.

updateChannels

public void updateChannels(Channel[] channels,
                           int source)

updateChannels

public void updateChannels(Channel[] channels,
                           int[] sources)
This method will update the value for a set of address, value pairs from the given sources. The length of the channel and source arrays must be the same.

Parameters:
channels - The array of address, value pairs to be updated. This array must be the same length as the sources array.
sources - The array of sources for the updated channels. This array must be the same length as the channels array.

getChannelValue

public short getChannelValue(short address)
This method will return the value of the channel at the given address.

TODO: This is one of the methods that needs to be overhauled and replaced with a priority system to get rid fo the mess of if statements and special cases.

Parameters:
address - The address to return the value of.
Returns:
The value of the channel at address.

getChannelValue

public short getChannelValue(Channel channel)
This method will return the value of this channel.

Parameters:
channel - The Channel object with the address to retrieve the value for. Only channel.address will be used; the passed in value will be ignored.
Returns:
The value of the channel at the address.

getChannelSource

public int getChannelSource(short address)
This method will return the source of the channel at the given address. If a value has multiple sources, it will return them in order of priority.

TODO: This is the other method that needs to be redone with the priority system to replace this mess of if statements and special cases. For now, this works well and won't be changed until I'm ready to rewrite the whole class.

Parameters:
address - The address to return the source for.
Returns:
The source of the value at the given address.

getChannelSource

public int getChannelSource(Channel channel)
This method will return the priority of the address in the Channel object.

Parameters:
channel - The channel object to look up the source for. The value will be ignored and only the address used.

getChannel

public Channel getChannel(short address)
This method will return the channel object for a given address.

Parameters:
address - The address to return the channel object for.
Returns:
The Channel object for the given address.

getChannel

public Channel getChannel(Channel channel)
This method will return the Channel object for the given Channel object. The value of the given Channel object will be ignored, and only the address used.

Parameters:
channel - The channel to return the Channel object for.
Returns:
The channel object for the given channel.

getChannels

public Channel[] getChannels(short[] addresses)
This method will return Channel objects for the given addresses.

Parameters:
addresses - The array of addresses to return Channel objects for.
Returns:
The array of Channel for the addresses given.

getChannels

public Channel[] getChannels(Channel[] channels)
This method will return Channel objects for the given channels. Only the address is used from the given channels, the value is ignored.

Parameters:
channels - The channels to return Channel objects for.
Returns:
The array of Channel objects corresponding to the given channels.

getChannelValues

public short[] getChannelValues(short startAddress,
                                short endAddress)
This method will return the channel values from the startAddress to the endAddress. The returned values include both the startAddress value and endAddress value.

Parameters:
startAddress - The starting address for the values returned. This address will be included in the returned values.
endAddress - The ending address for the values returned. This address will be included in the returning values.
Returns:
The array of the channel values.

getChannelSources

public int[] getChannelSources(short startAddress,
                               short endAddress)
This method will return the sources for the given range of addresses. The returned range will include both the start and end addresses.

Parameters:
startAddress - The start address for the range of results. This address will be included in the results.
endAddress - The end address for the range of results. This address will be included in the results.
Returns:
The array of channel sources for the given address range.

getChannels

public Channel[] getChannels()
This will return a Channel object for all channels with a non-zero value.

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

getChannels

public Channel[] getChannels(Channel[] channels,
                             int source)
This method will return a Channel object with the value from the given source for each given channel address.

Parameters:
channels - The channels that you want the values from the given source for. Only the address parameter from these channels will the used, the value will be ignored.
source - The source to get the values from.
Returns:
The array containing the channel objects for the given channels with the value of that channel from the given source.

getChannelsForCue

public Channel[] getChannelsForCue()
This will return all the channel values for channels that either arn't zero, or have a fader value of -100. These values are used for dealing with cues.

Returns:
The array of Channel objects.

getAllChannels

public Channel[] getAllChannels()
This will return the Channel objects for all channels up to the maxChannel value.

Returns:
The array of all Channel objects up to the value of maxChannel.

getCueChannels

public Channel[] getCueChannels()
This method will return the Channel objects for any channel with a non-zero cue value. It will return the cue value for that channel.

Returns:
The array of Channel objects for channels with non-zero cue values.

getCueChannels

public Channel[] getCueChannels(Channel[] channels)
This method will return the Channel objects for the given channels. These channel objects will contain the cue values on those channels.

Parameters:
channels - The cue values for these channels will be returned. The value from these channels is ignored.
Returns:
The Channel objects for the given channels with the cue values.

getChannelValues

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

Parameters:
addresses - The addresses to return the values for.
Returns:
The array of channel values for the given addresses.

getChannelSources

public int[] getChannelSources(short[] addresses)
This method will return the sources for the given channel addresses.

Parameters:
addresses - The array of address to return the sources for.
Returns:
The array of channel sources corresponding to the given addresses.

getChannelSources

public int[] getChannelSources(Channel[] channels)
This method will return the sources for the given channels. Only the address is used from the given channel objects, the value is ignored.

Parameters:
channels - The channels to return the sources for.
Returns:
The array containing the sources for the given channels.

getAllChannelSources

public int[] getAllChannelSources()
This method will return the source for all channels through maxChannels.

Returns:
The array containing the sources for all channels.

resetFaderValues

public short[] resetFaderValues()
This method resets all the fader values back to their defaults.

Returns:
The addresses of the of the fader values that were changed.