-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrangeTimer_Model.c
51 lines (44 loc) · 1.2 KB
/
rangeTimer_Model.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
#include <string.h>
#include <stdbool.h>
#include <unistd.h>
#include "rangeTimerModelClass.h"
static void setTimer (rangeTimerModel_t *this, int *timer);
static void initTimer (rangeTimerModel_t *this);
static void countTimer (rangeTimerModel_t *this);
const rangeTimerModel_t rangeTimerModelInitValue = {
0,
false,
&setTimer,
&initTimer,
&countTimer,
};
static void setTimer (rangeTimerModel_t *this, int *timer)
{
this->timer = timer;
this->countEnable = true;
}
static void initTimer (rangeTimerModel_t *this)
{
this->timer = rangeTimerModelInitValue.timer;
this->countEnable = false;
}
static void countTimer (rangeTimerModel_t *this)
{
if (this->countEnable == true) {
if (this->timer) {
(*this->timer)--;
}
}
sleep (1);
}
void rangeTimerModel_Constructor (rangeTimerModel_t *this)
{
this->timer = rangeTimerModelInitValue.timer;
this->countEnable = rangeTimerModelInitValue.countEnable;
this->pSetTimer = rangeTimerModelInitValue.pSetTimer;
this->pInitTimer = rangeTimerModelInitValue.pInitTimer;
this->pCountTimer = rangeTimerModelInitValue.pCountTimer;
}