edu.nrao.sss.electronics
Class SignalSampler

java.lang.Object
  extended by edu.nrao.sss.electronics.SignalSampler
All Implemented Interfaces:
SignalProcessor, SignalSource

public class SignalSampler
extends Object
implements SignalProcessor, SignalSource

A device that samples a signal to create a DigitalSignal.

Version Info:

$Revision: 1269 $
$Date: 2008-05-05 14:39:39 -0600 (Mon, 05 May 2008) $
$Author: dharland $ (last person to modify)

Since:
2007-11-02
Author:
David M. Harland

Constructor Summary
SignalSampler(String deviceName, int numberOfBitsPerSample, Frequency samplesPerSecond)
          Creates a new sampler that produces signals with the given properties.
 
Method Summary
 void eraseSignalMemory()
          Erases this device's memory of its most recent execution.
 void execute()
          Runs this device on the signal received from its input pipe and then executes the processor connected to its output pipe, if any.
 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.
 SignalPipe getInputPipe()
          Returns the input pipe of this device.
 Signal getMostRecentInput()
          Returns a copy of the input signal most recently processed by this device.
 DigitalSignal getMostRecentOutput()
          Returns a copy of the output signal most recently produced by this device.
 String getName()
          Returns the name of this device.
 SignalPipe getOutputPipe()
          Returns the output pipe of this device.
 Signal getSignal()
          Returns a copy of the signal produced by the most recent execution of this device.
 DigitalSignal sample(Signal input)
          Creates and returns a new signal that is the result of applying this sampler to the given input signal.
 void setName(String newName)
          Sets the name of this device.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SignalSampler

public SignalSampler(String deviceName,
                     int numberOfBitsPerSample,
                     Frequency samplesPerSecond)
Creates a new sampler that produces signals with the given properties.

Parameters:
deviceName - an optional name for this sampler. If this value is null a default name will be used in its place.
numberOfBitsPerSample - the number of bits in one sample of a digital signal produced by this device.
samplesPerSecond - the number of samples of a signal taken per second by this device.
Method Detail

setName

public void setName(String newName)
Sets the name of this device.

If newName is null or the empty string (""), the request to change the name will be denied and the current name will remain in place.

Parameters:
newName - an optional name for this sampler.

getName

public String getName()
Returns the name of this device.

Returns:
the name of this device.

getInputPipe

public SignalPipe getInputPipe()
Returns the input pipe of this device. A typical usage pattern for this method is:
 mySampler.getInputPipe().connectInputTo(mySource);

Returns:
the input pipe of this device.

getOutputPipe

public SignalPipe getOutputPipe()
Returns the output pipe of this device. A typical usage pattern for this method is:
 mySampler.getOutputPipe().connectOutputTo(myProcessor);

Returns:
the output pipe of this device.

getMostRecentInput

public Signal getMostRecentInput()
Returns a copy of the input signal most recently processed by this device. If this processor has never been executed, or if the input signal it processed most recently was null, the returned value will be null.

Returns:
the input signal most recently sent into this sampler.

getMostRecentOutput

public DigitalSignal getMostRecentOutput()
Returns a copy of the output signal most recently produced by this device. If this processor has never been executed, or if the input signal it processed most recently was null, the returned value will be null.

Returns:
the output signal most recently produced by this sampler.

eraseSignalMemory

public void eraseSignalMemory()
Erases this device's memory of its most recent execution.

See Also:
getMostRecentInput(), getMostRecentOutput(), getSignal()

getSignal

public Signal getSignal()
Returns a copy of the signal produced by the most recent execution of this device. If this device has never been run, or if the input signal it processed most recently was null, the returned value will be null.

The returned signal may be safely cast to a DigitalSignal.

Specified by:
getSignal in interface SignalSource
Returns:
the signal provided by this device.

execute

public void execute()
Runs this device on the signal received from its input pipe and then executes the processor connected to its output pipe, if any. Both the input signal and the output produced by sampling it are remembered by this sampler and are available via the getMostRecentInput() and getMostRecentOutput() methods.

Specified by:
execute in interface SignalProcessor

executeUpTo

public void executeUpTo(SignalProcessor firstUnexecutedDevice)
Description copied from interface: SignalProcessor
Executes this device and all downstream devices up to, but not including, the firstUnexecutedDevice. See SignalProcessor.execute() for more information about the linking of processors.

Specified by:
executeUpTo in interface SignalProcessor
Parameters:
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().

executeFromStartOfChainUpTo

public void executeFromStartOfChainUpTo(SignalProcessor firstUnexecutedDevice)
Description copied from interface: SignalProcessor
Retreats upstream from this processor to the source of the stream and executes that device(s), telling it to stop execution at firstUnexecutedDevice.

Specified by:
executeFromStartOfChainUpTo in interface SignalProcessor
Parameters:
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.

sample

public DigitalSignal sample(Signal input)
Creates and returns a new signal that is the result of applying this sampler to the given input signal.

This sampler alters the analog signal in the same way that a mixer connected to a local oscillator that is tuned to a frequency equal to that of the sampling frequency of this mixer would.

Note that the input signal and this sampler are not affected by calls to this method. In other words this sampler will not remember the input signal sent in or the output signal produced. This is in contrast to a call to the execute() methods.

Parameters:
input - the signal to be sampled.
Returns:
a new digital signal that is the result of applying this sampler to input.


Copyright © 2009. All Rights Reserved.