001 package cnslab.cnsnetwork; 002 003 import edu.jhu.mb.ernst.model.Synapse; 004 005 /*********************************************************************** 006 * Poisson input events, similar to InputEvent 007 * 008 * @version 009 * $Date: 2012-08-04 13:43:22 -0500 (Sat, 04 Aug 2012) $ 010 * $Rev: 104 $ 011 * $Author: croft $ 012 * @author 013 * Yi Dong 014 * @author 015 * David Wallace Croft 016 ***********************************************************************/ 017 public final class PInputEvent 018 implements Comparable<PInputEvent>, Cloneable 019 //////////////////////////////////////////////////////////////////////// 020 //////////////////////////////////////////////////////////////////////// 021 { 022 023 /** time of the input event */ 024 public double time; 025 026 /** the synapse data */ 027 public Synapse synapse; 028 029 /** the source of input id */ 030 public int sourceId; 031 032 //////////////////////////////////////////////////////////////////////// 033 //////////////////////////////////////////////////////////////////////// 034 035 public PInputEvent ( 036 final double time, 037 final Synapse synapse, 038 final int sourceId ) 039 //////////////////////////////////////////////////////////////////////// 040 { 041 this.time = time; 042 043 this.synapse = synapse; 044 045 this.sourceId = sourceId; 046 } 047 048 //////////////////////////////////////////////////////////////////////// 049 //////////////////////////////////////////////////////////////////////// 050 051 @Override 052 public Object clone ( ) 053 //////////////////////////////////////////////////////////////////////// 054 { 055 try 056 { 057 return super.clone ( ); 058 } 059 catch ( final CloneNotSupportedException cnse ) 060 { 061// TODO: Why catch the exception and return null? 062 063 System.err.println ( "Clone Abort." + cnse ); 064 065 return null; 066 } 067 } 068 069 @Override 070 public int compareTo ( final PInputEvent arg0 ) 071 //////////////////////////////////////////////////////////////////////// 072 { 073 if ( time < arg0.time ) 074 { 075 return -1; 076 } 077 078 if ( time > arg0.time ) 079 { 080 return 1; 081 } 082 083 final int 084 targetNeuronIndexThis 085 = synapse.getTargetNeuronIndex ( ), 086 targetNeuronIndexOther 087 = arg0.synapse.getTargetNeuronIndex ( ); 088 089 if ( targetNeuronIndexThis < targetNeuronIndexOther ) 090 { 091 return -1; 092 } 093 094 if ( targetNeuronIndexThis > targetNeuronIndexOther ) 095 { 096 return 1; 097 } 098 099 if ( sourceId < arg0.sourceId ) 100 { 101 return -1; 102 } 103 104 if ( sourceId > arg0.sourceId ) 105 { 106 return 1; 107 } 108 109 return 0; 110 } 111 112 113 @Override 114 public String toString ( ) 115 //////////////////////////////////////////////////////////////////////// 116 { 117 return new String ( 118 "time:" 119 + time 120 + " sourceId:" 121 + sourceId 122 + " " 123 + synapse ); 124 } 125 126 //////////////////////////////////////////////////////////////////////// 127 //////////////////////////////////////////////////////////////////////// 128 }