00001 #ifndef ONLINEAVERAGER_H_ 00002 #define ONLINEAVERAGER_H_ 00003 00004 #include "SimObject.h" 00005 00006 #include <cmath> 00007 00008 class OnlineAverager : public SimObject 00009 { 00010 SIMOBJECT( OnlineAverager, AdvancePhase::One ) 00011 public: 00012 OnlineAverager(); 00013 00014 OnlineAverager(unsigned numInputPorts); 00015 00016 virtual ~OnlineAverager(); 00017 00018 virtual int nAnalogInputPorts() const; 00019 00020 00021 virtual int nAnalogOutputPorts() const; 00022 00023 00024 virtual PortType outputPortType(port_t p) const; 00025 00026 virtual PortType inputPortType(port_t p) const; 00027 00028 virtual int reset( double dt ); 00029 00030 virtual int advance( AdvanceInfo const& ai); 00031 00032 00034 virtual double getAnalogOutput(analog_port_id_t port = 0) const; 00035 00037 virtual void setAnalogInput(double value, analog_port_id_t port = 0); 00038 00040 double mean; 00041 00043 double std; 00044 00045 protected: 00046 unsigned n_input_ports; 00047 00048 double sum; 00049 double sum2; 00050 00051 }; 00052 00053 #endif /*ONLINEAVERAGER_H_*/