9 int m_TendencyBufferSize = 3;
10 const int TENDENCY_BUFFER_SIZE = 30;
21 int m_TickIntervalLastTick;
22 float m_TendencyBuffer[TENDENCY_BUFFER_SIZE];
23 int m_TendencyBufferWriteIterator;
26 bool m_FirstPass =
true;
29 PluginPlayerStatus m_ModulePlayerStatus;
39 m_TickInterval = 1000;
40 manager.RegisterItself(GetNotifierType(),
this);
43 bool IsTimeToTick(
int current_time)
45 return ( current_time > m_TickIntervalLastTick + m_TickInterval );
61 return this.ClassName() +
" Notifier";
69 void SetActive(
bool state )
72 if ( !state ) HideBadge();
75 void DisplayTendency(
float delta)
79 void AddToCyclicBuffer(
float value)
81 m_TendencyBuffer[m_TendencyBufferWriteIterator] = value;
82 m_TendencyBufferWriteIterator++;
83 if( m_TendencyBufferWriteIterator == m_TendencyBufferSize )
85 m_TendencyBufferWriteIterator = 0;
86 m_ShowTendency =
true;
90 float ReadFromCyclicBuffer(
int index)
92 int indx = m_TendencyBufferWriteIterator + index;
93 if( indx >= m_TendencyBufferSize)
95 indx = indx - m_TendencyBufferSize;
97 return m_TendencyBuffer[indx];
100 float GetDeltaAvaraged()
103 for(
int i = 0; i < m_TendencyBufferSize; i++)
105 values.Insert(ReadFromCyclicBuffer(i));
111 float values_sum = 0;
114 for(i = 0; i < values.Count(); i++)
116 float value = values.Get(i);
121 float sma = values_sum / m_TendencyBufferSize;
128 float tnd = sma - m_LastMA;
144 for(
int i = 0; i < values.Count() - 1; i++)
146 value1 = values.Get(i);
147 value2 = values.Get(i + 1);
148 float average = (value1 + value2) / 2;
149 values.Set(i, average);
150 values.Set(i + 1, average);
152 int index = values.Count() - 1;
153 values.Set(index, value2);
156 void OnTick(
float current_time)
164 m_TickIntervalLastTick = current_time;
166 AddToCyclicBuffer( GetObservedValue() );
167 if (m_ShowTendency) DisplayTendency( GetDeltaAvaraged() );
171 protected int CalculateTendency(
float delta,
float inctresholdlow,
float inctresholdmed,
float inctresholdhigh,
float dectresholdlow,
float dectresholdmed,
float dectresholdhigh)
185 protected eBadgeLevel DetermineBadgeLevel(
float value,
float lvl_1,
float lvl_2,
float lvl_3)
195 protected void DisplayBadge()
199 protected void HideBadge()
203 protected float GetObservedValue()