001 package edu.nrao.sss.electronics; 002 003 /** 004 * A signal processor that does not propagate its signal. 005 * <p> 006 * <b>Version Info:</b> 007 * <table style="margin-left:2em"> 008 * <tr><td>$Revision: 1198 $</td></tr> 009 * <tr><td>$Date: 2008-04-02 18:59:31 -0600 (Wed, 02 Apr 2008) $</td></tr> 010 * <tr><td>$Author: dharland $ (last person to modify)</td></tr> 011 * </table></p> 012 * 013 * @author David M. Harland 014 * @since 2007-11-07 015 */ 016 public class SignalProcessorSink 017 implements SignalProcessor 018 { 019 private Signal signal; 020 private SignalPipe inputPipe; 021 022 //============================================================================ 023 // OBJECT CREATION 024 //============================================================================ 025 026 /** 027 * Creates a new sink that has no source. 028 */ 029 public SignalProcessorSink() 030 { 031 signal = null; 032 inputPipe = SignalPipe.makeAndWeldOutputTo(this); 033 } 034 035 //============================================================================ 036 // 037 //============================================================================ 038 039 /** 040 * Returns the input pipe of this device. 041 * A typical usage pattern for this method is:<pre> 042 * mySink.getInputPipe().connectInputTo(mySource);</pre> 043 * 044 * @return the input pipe of this device. 045 */ 046 public SignalPipe getInputPipe() 047 { 048 return inputPipe; 049 } 050 051 /** 052 * Returns a copy of the signal most recently sent to this sink. 053 * If this the chain leading to this sink has never been executed, 054 * or if that execution produced a <i>null</i> signal, 055 * the returned value will be <i>null</i>. 056 * 057 * @return the signal most recently sent to this sink. 058 */ 059 public Signal getMostRecentSignal() 060 { 061 return signal; 062 } 063 064 /** 065 * Erases this device's memory of its most recent execution. 066 * @see #getMostRecentSignal() 067 */ 068 public void eraseSignalMemory() 069 { 070 signal = null; 071 } 072 073 //============================================================================ 074 // INTERFACE SignalProcessor 075 //============================================================================ 076 077 /** Does nothing. */ 078 public void execute() { } 079 080 /** Does nothing. */ 081 public void executeUpTo(SignalProcessor firstUnexecutedDevice) { } 082 083 public void executeFromStartOfChainUpTo(SignalProcessor firstUnexecutedDevice) 084 { 085 inputPipe.executeFromStartOfChainUpTo(firstUnexecutedDevice); 086 087 signal = inputPipe.getSignal(); 088 } 089 }