24 #include "IDataBuffer.h" 44 initialize(time_step,factor_y,reserved_size,size);
59 void initialize(
float time_step,
float factor_y,
int reserved_size,
int size)
63 _reserved_size=reserved_size;
65 _data_y=
new int[reserved_size];
66 for(
int i=0;i<_size;i++)
73 if(size<=_reserved_size)
77 out<<F(
"Error: buffer size is too big")<<endln;
97 void Set(
unsigned int index,
float value)
101 out<<F(
"Error: index outside of array bounds: ")<<index<<endln;
104 _data_y[index]=(value*_factor_y);
112 void MinMax(
float &min_x,
float &max_x,
float &min_y,
float &max_y)
115 max_x=_time_step*_size;
116 min_y=_data_y[_size-1];
117 max_y=_data_y[_size-1];
118 for(
int i=0;i<_size;i++)
120 min_y=min(min_y,_data_y[i]);
121 max_y=max(max_y,_data_y[i]);
127 float X(
unsigned int index)
131 out<<F(
"Error: index outside of array bounds: ")<<index<<endln;
134 return _time_step*index;
137 float Y(
unsigned int index)
141 out<<F(
"Error: index outside of array bounds: ")<<index<<endln;
144 return _data_y[index]/_factor_y;
Buffer for sensor data. It is used by chart control.
Definition: TimeSerieBuffer.h:27
int * Y()
Returns point to vaues array. It is used for direct access to internal buffer.
Definition: TimeSerieBuffer.h:107
void MinMax(float &min_x, float &max_x, float &min_y, float &max_y)
Returns min and max value for buffer data.
Definition: TimeSerieBuffer.h:112
bool SetSize(int size)
Sets actual buffer size. It has to be less or equal to reserved_size.
Definition: TimeSerieBuffer.h:71
float X(unsigned int index)
Returns X that is calculated from index in buffer (see time_step parameter)
Definition: TimeSerieBuffer.h:127
void initialize(float time_step, float factor_y, int reserved_size, int size)
Initialize internal buffer.
Definition: TimeSerieBuffer.h:59
unsigned int StartIndex()
Returns start index in buffer. For this class is always 0.
Definition: TimeSerieBuffer.h:147
float SetTimeStep(float time_step)
Sets time interval between samples in buffer.
Definition: TimeSerieBuffer.h:83
float Y(unsigned int index)
Returns scaled value Y from buffer for specified index.
Definition: TimeSerieBuffer.h:137
unsigned int Size()
Returns buffer size.
Definition: TimeSerieBuffer.h:152
float SetFactorY(float factor_y)
Sets scale factor for mesaurements.
Definition: TimeSerieBuffer.h:88
void Set(unsigned int index, float value)
Puts value into buffer.
Definition: TimeSerieBuffer.h:97
TimeSerieBuffer(float time_step, float factor_y, int reserved_size, int size)
Constructor.
Definition: TimeSerieBuffer.h:42
TimeSerieBuffer(float time_step, float factor_y, int size)
Constructor.
Definition: TimeSerieBuffer.h:52