2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
5 // Licensed under the Flora License, Version 1.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://floralicense.org/license/
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an AS IS BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
18 * @file FUiEffects_EffectTimer.h
19 * @brief This is the header file for the _EffectTimer class
22 #ifndef FUI_EFFECTS_INTERNAL_EFFECTTIMER_H_
23 #define FUI_EFFECTS_INTERNAL_EFFECTTIMER_H_
26 #include <FBaseSysLog.h>
27 #include <FSysSystemTime.h>
28 #include <FUiEffectsTypes.h>
30 namespace Tizen { namespace Ui { namespace Effects
35 * @brief Class for effect timer
40 : public Tizen::Base::Runtime::Timer
49 * @param [in] _type Set type of this timer
52 _EffectTimer(void): __effectID(-1), __timeout(-1), __t1(-1), __countGreater(0), __count(0)
58 * Timer Initialisation
62 * @param [in] TimerEventListener OnTimerExpired event listener
63 * @param [in] _effectID id of effect assigned to this timer
64 * @param [in] _timeout A __timeout interval in milliseconds
67 result Construct(Tizen::Base::Runtime::ITimerEventListener &TimerEventListener, long effectID, int timeout)
69 __effectID = effectID;
71 return Tizen::Base::Runtime::Timer::Construct(TimerEventListener);
75 * Gets Id of Effect assigned to this timer
79 * @return EffectIDType Effect id
81 long GetEffectIdType(void)
87 * Stores current system time for next realtime interval calculation
91 * @see _EffectTimer::CalculationTimeStep
95 Tizen::System::SystemTime::GetTicks(__t1);
108 void Start(int t = 0)
112 Timer::Start(__timeout);
124 * Increases the variable count means a number of calling function OnTimerExpired
144 if (__countGreater != 0)
146 int c = (int)(__countGreater * 1.f / __count * 100);
147 SysLog(NID_UI_EFFECT, "Timer timeout for effect with %i ID is greater than a threshold in %i%% of cases.", __effectID, c);
149 Tizen::Base::Runtime::Timer::Cancel();
155 * Resets and then starts. Use this method for first run
170 * Precise realtime interval calculation.
176 float CalculationTimeStep(void)
178 const long long t0 = __t1;
179 Tizen::System::SystemTime::GetTicks(__t1);
183 if (sub > 3*__timeout)
186 if (__countGreater == 0)
188 SysLogException(NID_UI_EFFECT, E_TIMEOUT, "Timer timeout for effect with %i ID is too small! Your device is too slow for specified timeout. You may increase the timer time.", __effectID);
197 long __effectID; /**< id of parent effect */
198 int __timeout; /**< period in milliseconds */
199 long long __t1; /**< internal use */
204 } } } // Tizen::Ui::Effects
206 #endif //FUI_EFFECTS_INTERNAL_EFFECTTIMER_H_