00001 #ifndef ONLINEHISTOGRAMGENERATOR_H_ 00002 #define ONLINEHISTOGRAMGENERATOR_H_ 00003 00004 #include "SimObject.h" 00005 00006 #include <vector> 00007 00008 class OnlineHistogramGenerator : public SimObject 00009 { 00010 SIMOBJECT( OnlineHistogramGenerator, AdvancePhase::One ) 00011 public: 00012 OnlineHistogramGenerator(); 00013 00014 OnlineHistogramGenerator(unsigned numInputPorts, 00015 double minVal, 00016 double maxVal, 00017 unsigned numBins = 10, 00018 unsigned samplingTime = 1); 00019 00020 virtual ~OnlineHistogramGenerator(); 00021 00022 virtual int nAnalogInputPorts() const; 00023 00024 virtual int nAnalogOutputPorts() const; 00025 00026 virtual PortType outputPortType(port_t p) const; 00027 00028 virtual PortType inputPortType(port_t p) const; 00029 00030 virtual int reset( double dt ); 00031 00032 virtual int advance( AdvanceInfo const& ai); 00033 00035 virtual double getAnalogOutput(analog_port_id_t port = 0) const; 00036 00038 virtual void setAnalogInput(double value, analog_port_id_t port = 0); 00039 00040 protected: 00041 unsigned n_input_ports; 00042 00043 double min_val; 00044 double max_val; 00045 00046 unsigned num_bins; 00047 00048 unsigned sampling_time; 00049 00050 unsigned stepsToWait; 00051 00052 double bin_width; 00053 00054 std::vector<unsigned> input_counter; 00055 00056 std::vector<double> out_values; 00057 00058 }; 00059 00060 #endif /*ONLINEHISTOGRAMGENERATOR_H_*/