Imt.Base C++ API V4.1.1.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
RuntimeTimer.h
Go to the documentation of this file.
1// (c) IMT - Information Management Technology AG, CH-9470 Buchs, www.imt.ch.
2//
3// ActiveParts (AP) and the corresponding Data Flow Framework (DFF) is invented and designed by Jakob Daescher.
4// ANY USE OF THIS CODE CONSTITUTES ACCEPTANCE OF THE TERMS OF THE COPYRIGHT NOTICE.
5// ===================================================================================================
6// COPYRIGHT NOTICE
7// ===================================================================================================
8// Copyright (C) 2005-2075, IMT Information Management Technology AG, 9470 Buchs, Switzerland
9// All rights reserved.
10// This code is proprietary software of IMT Information Management Technology AG (hereinafter: "IMT").
11// Proprietary software is computer software licensed under exclusive legal right of IMT.
12//
13// The licensee is given the irrevocable, perpetual, worldwide, non-exclusive right and license to use,
14// execute and reproduce the software in binary form within the licensed products.
15//
16// Redistribution and use in source forms, without modification, are permitted provided that the following conditions are met:
17// (1) Copying of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
18// (2) Copying of source code is only allowed for regulatory documentation and archiving purposes
19// (3) Redistributions in binary form must reproduce the above copyright notice,
20// this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
21//
22// IMT provide no reassurances that the source code provided does not infringe
23// any patent, copyright, or any other intellectual property rights of third parties.
24// IMT disclaim any liability to any recipient for claims brought against
25// recipient by any third party for infringement of that parties intellectual property rights.
26//
27// THIS SOFTWARE IS PROVIDED BY IMT AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
28// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
29// IN NO EVENT SHALL IMT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
30// OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCURE-MENT OF SUBSTITUTE GOODS OR SERVICES;
31// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
32// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
33// IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34// ===================================================================================================
35
36#ifndef IMT_BASE_DFF_RUNTIMETIMER_H
37#define IMT_BASE_DFF_RUNTIMETIMER_H
38
42
43namespace imt {
44namespace base {
45namespace dff {
46namespace runtime {
47
53
54public:
55
62
66 static constexpr TimerHandle TIMERHANDLE_INVALID {0};
67
72 static void initTimerModule(uint32_t initialTimeMs = 0);
73
81 static TimerHandle startOneShotTimer(RuntimeCore::CoreHandle const apHandle, TimerHandle timerToStart, uint32_t const timerTicksMs);
82
90 static TimerHandle startPeriodicTimer(RuntimeCore::CoreHandle const apHandle, TimerHandle timerToStart, uint32_t const intervalMs);
91
97 static TimerHandle updatePeriodicTimer(TimerHandle timerToUpdate, uint32_t const intervalMs);
98
103 static TimerHandle killTimer(TimerHandle timerToKill);
104
109 static void process1msTick();
110
116
122 static bool getIsRunningState(TimerHandle const timerToCheck);
123
127 // AXIVION Construct AutosarC++19_03-A9.6.1: Implementation does not rely on trivial layout.
128 struct TimeItem {
129
134
139
144
149
154
158 // AXIVION Next Line AutosarC++19_03-M2.10.1: Allowed usage, compatibility purposes
160
165 };
166
167private:
168
175 static TimerHandle createOneShotTimer(RuntimeCore::CoreHandle const apHandle, uint32_t const ticksMs);
176
183 static TimerHandle updateOneShotTimer(RuntimeCore::CoreHandle const apHandle, TimerHandle timerToUpdate, uint32_t const ticksMs);
184
195 static TimerHandle createTimer(RuntimeCore::CoreHandle const apHandle, uint32_t const ticksMs, uint32_t const intervalMs);
196
202 static TimeItem* findActiveTimer(TimerHandle const timerToSearch);
203
204 static TimeItem* s_pActiveTimerListHead;
205 // we need to have unique id's for both kind of timers (e.g. an executable uses one-shot and periodic timers)
206 static int16_t s_periodicTimerUniqueId;
207 static int16_t s_oneShotTimerUniqueId;
208 static uint32_t s_tickCountMs;
209};
210
211} // namespace runtime
212} // namespace dff
213} // namespace base
214} // namespace imt
215
216#endif // IMT_BASE_DFF_RUNTIMETIMER_H
Base class for a static class that disables construction, copy, assignment and move of instances.
Definition StaticClass.h:48
int16_t CoreHandle
A CoreHandle is used to identify an executable with a unique number (similar to a phone number).
Definition RuntimeCore.h:64
RuntimeTimer defines the basic Application Interface (API) to the timer part of the run to completion...
static uint32_t getTickCountMs()
Returns the tick count in milliseconds elapsed since system start.
static TimerHandle startOneShotTimer(RuntimeCore::CoreHandle const apHandle, TimerHandle timerToStart, uint32_t const timerTicksMs)
Starts or restarts the given one shot timer.
static void process1msTick()
Process the 1ms tick in order to fire active timers if they are expired.
static TimerHandle updatePeriodicTimer(TimerHandle timerToUpdate, uint32_t const intervalMs)
Update the intervalMs of an active periodic timer.
static bool getIsRunningState(TimerHandle const timerToCheck)
Returns if the timer is running.
int16_t TimerHandle
A TimerHandle is used to identify a timer with a unique number.
static constexpr TimerHandle TIMERHANDLE_INVALID
Constant which represents an invalid timer handle.
static TimerHandle startPeriodicTimer(RuntimeCore::CoreHandle const apHandle, TimerHandle timerToStart, uint32_t const intervalMs)
Starts a periodic timer.
static void initTimerModule(uint32_t initialTimeMs=0)
Initialize software timer module.
static TimerHandle killTimer(TimerHandle timerToKill)
Kill an existing timer.
This is a application specific file which is used to configure Imt.Base.Core.Math.
__int16 int16_t
Definition stdint.h:59
unsigned __int32 uint32_t
Definition stdint.h:64
uint32_t ticksMs
Ticks to down count in milliseconds.
uint32_t intervalMs
Interval for periodic time in milliseconds.
RuntimeCore::CoreHandle receiverHandle
Executable which receives time event.
TimerHandle identifier
TimeItem object identifier.