9 int m_TendencyBufferSize = 3;
10 const int TENDENCY_BUFFER_SIZE = 30;
14 int m_TickIntervalLastTick;
15 float m_TendencyBuffer[TENDENCY_BUFFER_SIZE];
16 int m_TendencyBufferWriteIterator;
19 bool m_FirstPass =
true;
21 PluginPlayerStatus m_ModulePlayerStatus;
29 m_TickInterval = 1000;
30 manager.RegisterItself(GetNotifierType(),
this);
33 bool IsTimeToTick(
int current_time)
35 return (current_time > m_TickIntervalLastTick + m_TickInterval);
50 return this.ClassName() +
" Notifier";
67 void DisplayTendency(
float delta);
69 void AddToCyclicBuffer(
float value)
71 m_TendencyBuffer[m_TendencyBufferWriteIterator] = value;
72 m_TendencyBufferWriteIterator++;
73 if (m_TendencyBufferWriteIterator == m_TendencyBufferSize)
75 m_TendencyBufferWriteIterator = 0;
76 m_ShowTendency =
true;
80 float ReadFromCyclicBuffer(
int index)
82 int indx = m_TendencyBufferWriteIterator + index;
83 if ( indx >= m_TendencyBufferSize)
85 indx = indx - m_TendencyBufferSize;
88 return m_TendencyBuffer[indx];
91 float GetDeltaAvaraged()
94 for (
int i = 0; i < m_TendencyBufferSize; i++)
96 values.Insert(ReadFromCyclicBuffer(i));
101 for (i = 0; i < values.Count(); i++)
103 float value = values.Get(i);
107 float sma = valuesSum / m_TendencyBufferSize;
114 float tnd = sma - m_LastMA;
124 for (
int i = 0; i < values.Count() - 1; i++)
126 value1 = values.Get(i);
127 value2 = values.Get(i + 1);
128 float average = (value1 + value2) / 2;
129 values.Set(i, average);
130 values.Set(i + 1, average);
133 int index = values.Count() - 1;
134 values.Set(index, value2);
137 void OnTick(
float current_time)
139 m_TickIntervalLastTick = current_time;
145 DisplayTendency(GetDeltaAvaraged());
149 protected int CalculateTendency(
float delta,
float inctresholdlow,
float inctresholdmed,
float inctresholdhigh,
float dectresholdlow,
float dectresholdmed,
float dectresholdhigh)
152 if (delta > inctresholdlow)
154 if (delta > inctresholdmed)
156 if (delta > inctresholdhigh)
158 if (delta < dectresholdlow)
160 if (delta < dectresholdmed)
162 if (delta < dectresholdhigh)
int CalculateTendency(float delta, float inctresholdlow, float inctresholdmed, float inctresholdhigh, float dectresholdlow, float dectresholdmed, float dectresholdhigh)