|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object edu.nrao.sss.electronics.SignalSwitch
public class SignalSwitch
A device that can connect one of its inputs to one of its outputs and pass signals through that connection. Only one input may be connected to an output, and only one output may be connected to an input. The remaining inputs and outputs (collectively, "poles") are not connected to any outputs or inputs, respectively.
For simultaneously connecting a single input to many outputs
see the SignalManifold
class.
See also the SignalTransferSwitch
for a variation of a
switch that connects N inputs to N outputs simultaneously,
with each pole connected to exactly one other, complementary, pole.
Signals pass through switches without being altered.
The following examples were all taken from the EVLA Antenna Block Diagram:
4 inputs, 1 output | 2 inputs, 1 output (assuming left-to-right flow) |
1 input, 4 outputs | 1 input, 2 outputs (assuming left-to-right flow) |
Note that indexing for input and output poles follows the java convention of starting with zero, which is different than what is displayed in the diagrams above. In addition to referencing poles by index, clients may name the input and output poles and then select them by name. If a client names two poles of the same kind (input or output) identically, the pole returned by the select-by-name methods is indeterminate.
Version Info:
$Revision: 1198 $ |
$Date: 2008-04-02 18:59:31 -0600 (Wed, 02 Apr 2008) $ |
$Author: dharland $ (last person to modify) |
Method Summary | |
---|---|
void |
execute()
Executes the currently selected output pipe of this device. |
void |
executeFromStartOfChainUpTo(SignalProcessor firstUnexecutedDevice)
Retreats upstream from this processor to the source of the stream and executes that device(s), telling it to stop execution at firstUnexecutedDevice . |
void |
executeUpTo(SignalProcessor firstUnexecutedDevice)
Executes this device and all downstream devices up to, but not including, the firstUnexecutedDevice . |
int |
getIndexOfSelectedInput()
Returns the index of the currently selected input pole. |
int |
getIndexOfSelectedOutput()
Returns the index of the currently selected output pole. |
SignalPipe |
getInputPipe(int index)
Returns the index th input pipe of this device. |
String |
getName()
Returns the name of this switch. |
String |
getNameOfSelectedInput()
Returns the name of the currently selected input pole. |
String |
getNameOfSelectedOutput()
Returns the name of the currently selected output pole. |
List<String> |
getNamesOfInputPoles()
Returns the names of the input poles of this switch. |
List<String> |
getNamesOfOutputPoles()
Returns the names of the output poles of this switch. |
int |
getNumberOfInputPoles()
Returns the number of input poles on this switch. |
int |
getNumberOfOutputPoles()
Returns the number of output poles on this switch. |
SignalPipe |
getOutputPipe(int index)
Returns the index th output pipe of this device. |
SignalPipe |
getSelectedInput()
Returns the currently selected input pole. |
SignalPipe |
getSelectedOutput()
Returns the currently selected output pole. |
Signal |
getSignal()
Returns the signal provided by the currently selected input pipe of this device. |
Signal |
getSignal(SignalPipe outputPipe)
|
boolean |
hasInputNamed(String poleName)
Returns true if this switch has an input with the given name. |
boolean |
hasOutputNamed(String poleName)
Returns true if this switch has an output with the given name. |
static SignalSwitch |
makeMultiInputSwitch(String deviceName,
int numberOfInputPoles)
Creates and returns a new switch with a single output pole and the given number of input poles. |
static SignalSwitch |
makeMultiOutputSwitch(String deviceName,
int numberOfOutputPoles)
Creates and returns a new switch with a single input pole and the given number of output poles. |
void |
nameInputs(String... poleNames)
Assigns names to the input poles of this switch. |
void |
nameOutputs(String... poleNames)
Assigns names to the output poles of this switch. |
SignalPipe |
selectInput(int inputPole)
Sets this switch so that it uses the input pole at the given index. |
SignalPipe |
selectInput(String poleName)
Sets this switch so that it uses the input pole with the given name. |
SignalPipe |
selectOutput(int outputPole)
Sets this switch so that it uses the output pole at the given index. |
SignalPipe |
selectOutput(String poleName)
Sets this switch so that it uses the output pole with the given name. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static SignalSwitch makeMultiInputSwitch(String deviceName, int numberOfInputPoles)
Up to numberOfInputPoles
sources may be hooked to this
switch, but exactly one of them may be selected at any one time.
Initially, the 0th input is the selected input.
deviceName
- an optional name for this switch. If this value is null
a default name will be used in its place.numberOfInputPoles
- the number of connections available for signal sources.
public static SignalSwitch makeMultiOutputSwitch(String deviceName, int numberOfOutputPoles)
Up to numberOfOutputPoles
signal processors may be hooked to this
switch, but exactly one of them may be selected at any one time.
Initially, the 0th output is the selected output.
deviceName
- an optional name for this switch. If this value is null
a default name will be used in its place.numberOfOutputPoles
- the number of connections available for signal processors.
public String getName()
public int getNumberOfInputPoles()
public int getNumberOfOutputPoles()
public boolean hasInputNamed(String poleName)
poleName
- the potential name of an input pole of this switch.
public boolean hasOutputNamed(String poleName)
poleName
- the potential name of an output pole of this switch.
public void nameInputs(String... poleNames)
Note: this method does not check the number of names submitted against the number of input poles.
poleNames
- new names for the input poles of this switch.public void nameOutputs(String... poleNames)
Note: this method does not check the number of names submitted against the number of output poles.
poleNames
- new names for the output poles of this switch.public List<String> getNamesOfInputPoles()
The names are ordered according to the numerical order of the poles that they represent. For example, if the returned list is "Inky", "Blinky", "Pinky", and "Clyde", then the pole at index zero for this switch is named "Inky" and the pole at index three is "Clyde".
public List<String> getNamesOfOutputPoles()
The names are ordered according to the numerical order of the poles that they represent. For example, if the returned list is "Larry", "Curly", "Moe", "Shemp", and "Curly Joe", then the pole at index one for this switch is named "Curly" and the pole at index two is "Moe".
public SignalPipe selectInput(String poleName)
poleName
- the potential name of an input pole of this switch.
IllegalArgumentException
- if this switch has no input pole with the given name.public SignalPipe selectInput(int inputPole)
inputPole
- the index of the input pole to be connected to this switch's
selected output.
IndexOutOfBoundsException
- if inputPole
is < 0 or >= the number of input poles.public SignalPipe selectOutput(String poleName)
poleName
- the potential name of an output pole of this switch.
IllegalArgumentException
- if this switch has no output pole with the given name.public SignalPipe selectOutput(int outputPole)
outputPole
- the index of the output pole to be connected to this switch's
selected input.
IndexOutOfBoundsException
- if outputPole
is < 0 or >= the number of output poles.public SignalPipe getSelectedInput()
public SignalPipe getSelectedOutput()
public SignalPipe getInputPipe(int index)
index
th input pipe of this device.
A typical usage pattern for this method is:myFilter.getInputPipe(p).connectInputTo(mySource);
Indexing begins at zero.
index
th input pipe of this device.public SignalPipe getOutputPipe(int index)
index
th output pipe of this device.
A typical usage pattern for this method is:myFilter.getOutputPipe(p).connectOutputTo(myProcessor);
Indexing begins at zero.
index
th output pipe of this device.public int getIndexOfSelectedInput()
public int getIndexOfSelectedOutput()
public String getNameOfSelectedInput()
public String getNameOfSelectedOutput()
public Signal getSignal()
getSignal
in interface SignalSource
public Signal getSignal(SignalPipe outputPipe)
public void execute()
execute
in interface SignalProcessor
public void executeUpTo(SignalProcessor firstUnexecutedDevice)
SignalProcessor
firstUnexecutedDevice
.
See SignalProcessor.execute()
for more information about the linking
of processors.
executeUpTo
in interface SignalProcessor
firstUnexecutedDevice
- the first device downstream that is not to be executed.
If all downstream devices should be executed you may use a
null value here or call SignalProcessor.execute()
.public void executeFromStartOfChainUpTo(SignalProcessor firstUnexecutedDevice)
SignalProcessor
firstUnexecutedDevice
.
executeFromStartOfChainUpTo
in interface SignalProcessor
firstUnexecutedDevice
- the first device in a chain of processors that is not
to be executed.
If all devices should be executed you may use a
null value here.
The first unexecuted device should be downstream of this
device.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |