MOOSE - Multiscale Object Oriented Simulation Environment
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
DiffAmp Class Reference

#include <DiffAmp.h>

+ Collaboration diagram for DiffAmp:

Public Member Functions

 DiffAmp ()
 
double getGain () const
 
double getOutput () const
 
double getSaturation () const
 
void minusFunc (double input)
 
void plusFunc (double input)
 
void process (const Eref &e, ProcPtr p)
 
void reinit (const Eref &e, ProcPtr p)
 
void setGain (double gain)
 
void setSaturation (double saturation)
 
 ~DiffAmp ()
 

Static Public Member Functions

static const CinfoinitCinfo ()
 

Protected Attributes

double gain_
 
double minus_
 
double output_
 
double plus_
 
double saturation_
 

Detailed Description

Definition at line 36 of file DiffAmp.h.

Constructor & Destructor Documentation

DiffAmp::DiffAmp ( )

Definition at line 147 of file DiffAmp.cpp.

147  :gain_(1.0), saturation_(DBL_MAX), plus_(0), minus_(0), output_(0)
148 {
149 }
double output_
Definition: DiffAmp.h:58
double minus_
Definition: DiffAmp.h:57
double gain_
Definition: DiffAmp.h:54
double saturation_
Definition: DiffAmp.h:55
double plus_
Definition: DiffAmp.h:56
DiffAmp::~DiffAmp ( )

Definition at line 150 of file DiffAmp.cpp.

150  {
151  ;
152 }

Member Function Documentation

double DiffAmp::getGain ( ) const

Definition at line 173 of file DiffAmp.cpp.

References gain_.

Referenced by initCinfo().

174 {
175  return gain_;
176 }
double gain_
Definition: DiffAmp.h:54

+ Here is the caller graph for this function:

double DiffAmp::getOutput ( ) const

Definition at line 183 of file DiffAmp.cpp.

References output_.

Referenced by initCinfo().

184 {
185  return output_;
186 }
double output_
Definition: DiffAmp.h:58

+ Here is the caller graph for this function:

double DiffAmp::getSaturation ( ) const

Definition at line 178 of file DiffAmp.cpp.

References saturation_.

Referenced by initCinfo().

179 {
180  return saturation_;
181 }
double saturation_
Definition: DiffAmp.h:55

+ Here is the caller graph for this function:

const Cinfo * DiffAmp::initCinfo ( )
static

Definition at line 51 of file DiffAmp.cpp.

References diffAmpCinfo, getGain(), getOutput(), getSaturation(), Neutral::initCinfo(), minusFunc(), output(), outputOut(), plusFunc(), process(), reinit(), setGain(), and setSaturation().

52 {
53  static ValueFinfo<DiffAmp, double> gain( "gain",
54  "Gain of the amplifier. The output of the amplifier is the difference"
55  " between the totals in plus and minus inputs multiplied by the"
56  " gain. Defaults to 1" ,
59  static ValueFinfo<DiffAmp, double > saturation( "saturation",
60  "Saturation is the bound on the output. If output goes beyond the +/-"
61  "saturation range, it is truncated to the closer of +saturation and"
62  " -saturation. Defaults to the maximum double precision floating point"
63  " number representable on the system." ,
66 
67  static ReadOnlyValueFinfo<DiffAmp, double> output( "outputValue",
68  "Output of the amplifier, i.e. gain * (plus - minus)." ,
71  // Dest messages
73 
74  static DestFinfo gainIn( "gainIn",
75  "Destination message to control gain dynamically.",
77 
78  static DestFinfo plusIn( "plusIn",
79  "Positive input terminal of the amplifier. All the messages connected"
80  " here are summed up to get total positive input.",
82 
83  static DestFinfo minusIn( "minusIn",
84  "Negative input terminal of the amplifier. All the messages connected"
85  " here are summed up to get total positive input.",
88  // Shared messages
90  static DestFinfo process( "process",
91  "Handles process call, updates internal time stamp.",
93  static DestFinfo reinit( "reinit",
94  "Handles reinit call.",
96  static Finfo* processShared[] =
97  {
98  &process, &reinit
99  };
100 
101  static SharedFinfo proc( "proc",
102  "This is a shared message to receive Process messages "
103  "from the scheduler objects."
104  "The first entry in the shared msg is a MsgDest "
105  "for the Process operation. It has a single argument, "
106  "ProcInfo, which holds lots of information about current "
107  "time, thread, dt and so on. The second entry is a MsgDest "
108  "for the Reinit operation. It also uses ProcInfo. ",
109  processShared, sizeof( processShared ) / sizeof( Finfo* )
110  );
111 
112 
113  static Finfo * diffAmpFinfos[] = {
114  &gain,
115  &saturation,
116  &output,
117  &gainIn,
118  &plusIn,
119  &minusIn,
120  outputOut(),
121  &proc
122  };
123  static string doc[] = {
124  "Name", "DiffAmp",
125  "Author", "Subhasis Ray, 2008, NCBS",
126  "Description", "A difference amplifier. "
127  "Output is the difference between the total plus inputs and the total "
128  "minus inputs multiplied by gain. Gain can be set statically as a field"
129  " or can be a destination message and thus dynamically determined by the"
130  " output of another object. Same as GENESIS diffamp object."
131  };
132  static Dinfo<DiffAmp> dinfo;
133  static Cinfo diffAmpCinfo(
134  "DiffAmp",
136  diffAmpFinfos,
137  sizeof(diffAmpFinfos)/sizeof(Finfo*),
138  &dinfo,
139  doc,
140  sizeof(doc)/sizeof(string)
141 );
142 
143  return &diffAmpCinfo;
144 }
void minusFunc(double input)
Definition: DiffAmp.cpp:158
double getGain() const
Definition: DiffAmp.cpp:173
Definition: Dinfo.h:60
void process(const Eref &e, ProcPtr p)
Definition: DiffAmp.cpp:188
void setGain(double gain)
Definition: DiffAmp.cpp:163
static SrcFinfo1< double > * output()
Definition: Arith.cpp:14
void plusFunc(double input)
Definition: DiffAmp.cpp:153
Definition: OpFunc.h:27
static const Cinfo * diffAmpCinfo
Definition: DiffAmp.cpp:146
double getOutput() const
Definition: DiffAmp.cpp:183
static const Cinfo * initCinfo()
Definition: Neutral.cpp:16
void reinit(const Eref &e, ProcPtr p)
Definition: DiffAmp.cpp:203
void setSaturation(double saturation)
Definition: DiffAmp.cpp:168
static SrcFinfo1< double > * outputOut()
Definition: DiffAmp.cpp:44
Definition: Cinfo.h:18
double getSaturation() const
Definition: DiffAmp.cpp:178
Definition: Finfo.h:12

+ Here is the call graph for this function:

void DiffAmp::minusFunc ( double  input)

Definition at line 158 of file DiffAmp.cpp.

References minus_.

Referenced by initCinfo().

159 {
160  minus_ += input;
161 }
double minus_
Definition: DiffAmp.h:57

+ Here is the caller graph for this function:

void DiffAmp::plusFunc ( double  input)

Definition at line 153 of file DiffAmp.cpp.

References plus_.

Referenced by initCinfo().

154 {
155  plus_ += input;
156 }
double plus_
Definition: DiffAmp.h:56

+ Here is the caller graph for this function:

void DiffAmp::process ( const Eref e,
ProcPtr  p 
)

Definition at line 188 of file DiffAmp.cpp.

References gain_, minus_, output(), output_, outputOut(), plus_, and saturation_.

Referenced by initCinfo().

189 {
190  double output = gain_ * (plus_ - minus_);
191  plus_ = 0.0;
192  minus_ = 0.0;
193  if ( output > saturation_ ) {
194  output = saturation_;
195  }
196  if ( output < -saturation_ ) {
197  output = -saturation_;
198  }
199  output_ = output;
200  outputOut()->send(e, output_);
201 }
double output_
Definition: DiffAmp.h:58
double minus_
Definition: DiffAmp.h:57
double gain_
Definition: DiffAmp.h:54
double saturation_
Definition: DiffAmp.h:55
double plus_
Definition: DiffAmp.h:56
static SrcFinfo1< double > * output()
Definition: Arith.cpp:14
static SrcFinfo1< double > * outputOut()
Definition: DiffAmp.cpp:44

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void DiffAmp::reinit ( const Eref e,
ProcPtr  p 
)

Definition at line 203 of file DiffAmp.cpp.

References minus_, output_, outputOut(), and plus_.

Referenced by initCinfo().

204 {
205  // What is the right thing to do?? Should we actually do a process step??
206  output_ = 0.0;
207  plus_ = 0.0;
208  minus_ = 0.0;
209  outputOut()->send(e, output_);
210 }
double output_
Definition: DiffAmp.h:58
double minus_
Definition: DiffAmp.h:57
double plus_
Definition: DiffAmp.h:56
static SrcFinfo1< double > * outputOut()
Definition: DiffAmp.cpp:44

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void DiffAmp::setGain ( double  gain)

Definition at line 163 of file DiffAmp.cpp.

References gain_.

Referenced by initCinfo().

164 {
165  gain_ = gain;
166 }
double gain_
Definition: DiffAmp.h:54

+ Here is the caller graph for this function:

void DiffAmp::setSaturation ( double  saturation)

Definition at line 168 of file DiffAmp.cpp.

References saturation_.

Referenced by initCinfo().

169 {
170  saturation_ = saturation;
171 }
double saturation_
Definition: DiffAmp.h:55

+ Here is the caller graph for this function:

Member Data Documentation

double DiffAmp::gain_
protected

Definition at line 54 of file DiffAmp.h.

Referenced by getGain(), process(), and setGain().

double DiffAmp::minus_
protected

Definition at line 57 of file DiffAmp.h.

Referenced by minusFunc(), process(), and reinit().

double DiffAmp::output_
protected

Definition at line 58 of file DiffAmp.h.

Referenced by getOutput(), process(), and reinit().

double DiffAmp::plus_
protected

Definition at line 56 of file DiffAmp.h.

Referenced by plusFunc(), process(), and reinit().

double DiffAmp::saturation_
protected

Definition at line 55 of file DiffAmp.h.

Referenced by getSaturation(), process(), and setSaturation().


The documentation for this class was generated from the following files: