1
00:00:00,720 --> 00:00:01,820
Hello, welcome back.

2
00:00:01,830 --> 00:00:08,310
And this lesson, we go in to see how to work with software timers, I'm going to make a copy of the

3
00:00:08,310 --> 00:00:11,850
Gatekeeper Task Project and paste it over here.

4
00:00:12,450 --> 00:00:15,720
And I'll call this working with software time as.

5
00:00:28,360 --> 00:00:29,700
They copy over here.

6
00:00:33,340 --> 00:00:36,610
Then expand this and then call.

7
00:00:37,890 --> 00:00:40,630
Then I'll look at it, I may not see fall over here.

8
00:00:41,170 --> 00:00:44,340
OK, so we're going to create two new tasks.

9
00:00:44,350 --> 00:00:49,770
So I'm going to clean all the artists related code from the project.

10
00:00:50,870 --> 00:00:57,070
OK, I've cleaned all the tasks we created, deletes the task functions as well.

11
00:00:59,720 --> 00:01:00,650
Of deleted them.

12
00:01:02,580 --> 00:01:03,240
And.

13
00:01:04,410 --> 00:01:05,930
Delete them from here as well.

14
00:01:09,700 --> 00:01:11,520
So we just have our project.

15
00:01:11,570 --> 00:01:16,950
Well, no more projects before we use time as we need to include time as to our projects.

16
00:01:16,960 --> 00:01:22,300
So I'll go to our Simms's always thought each fall by right clicking an open declaration.

17
00:01:23,020 --> 00:01:31,060
And over here I'm going to include time in storage so I can simply copy one of these and paste over

18
00:01:31,060 --> 00:01:32,380
here and change this word.

19
00:01:34,980 --> 00:01:35,760
To Taimur.

20
00:01:36,600 --> 00:01:41,450
Well, time is plural, it is required click here to be able to see how we are looking.

21
00:01:45,170 --> 00:01:51,950
OK, we're looking good, and then I'll come back here to our main function, so I'm going to declare

22
00:01:51,950 --> 00:01:52,820
the time up period.

23
00:01:52,820 --> 00:01:58,650
We're going to experiment with both the periodic timer and the one short timer.

24
00:01:59,390 --> 00:02:00,830
OK, I'll delete this.

25
00:02:00,830 --> 00:02:02,690
Excuse Hondo here.

26
00:02:02,690 --> 00:02:05,990
We don't need this, so we're going to have to puritz.

27
00:02:07,390 --> 00:02:07,960
OK.

28
00:02:09,630 --> 00:02:17,820
So we define in this we're going to see the one short time period should be four thousand.

29
00:02:18,780 --> 00:02:19,680
Milliseconds.

30
00:02:21,780 --> 00:02:25,010
I cuts this by mistake, sorry about that.

31
00:02:26,070 --> 00:02:26,520
So.

32
00:02:27,670 --> 00:02:33,070
The Winshaw time either period should be four thousand milliseconds because we are doing PDM, Static's

33
00:02:33,250 --> 00:02:37,620
and then our periodic timer issued whuppin every 500 Ms.

34
00:02:38,170 --> 00:02:42,490
OK, so that's the period to now.

35
00:02:42,490 --> 00:02:50,230
What we're going to do is we going to create a handle for our timer or our time is because we have two

36
00:02:50,230 --> 00:02:50,730
of them.

37
00:02:50,740 --> 00:02:57,090
We're going to have a handle for the want one short time as well as our periodic auto reload timer.

38
00:02:57,400 --> 00:03:04,690
And also we're going to create a variable to hold our time as that is whether the timer is started or

39
00:03:04,690 --> 00:03:05,050
not.

40
00:03:06,320 --> 00:03:14,060
We can start our variable in the base type, so we see a base type over here X time or one started,

41
00:03:14,060 --> 00:03:16,120
X time or two started OK.

42
00:03:16,700 --> 00:03:19,930
Once that is done, we're going to create over time to create over time.

43
00:03:20,120 --> 00:03:22,730
We use the X time to create function.

44
00:03:23,240 --> 00:03:29,350
The first argument of this function is a string just to let us know the name of this timer.

45
00:03:29,810 --> 00:03:32,510
The second argument is the the period.

46
00:03:32,990 --> 00:03:38,860
And the third argument is whether we want to said this as a one shot timer or not.

47
00:03:39,680 --> 00:03:42,680
And then the last after that, there's an argument.

48
00:03:43,840 --> 00:03:51,040
Where we can place a variable to start a timer timer ID, and then after that, the argument is.

49
00:03:52,230 --> 00:03:59,910
The callback function for the timer, so I'll come over here, we first got our first argument as the

50
00:03:59,910 --> 00:04:02,020
time we call in this one one shot.

51
00:04:02,550 --> 00:04:04,740
The second argument is the time up period.

52
00:04:07,420 --> 00:04:13,240
So the period before it is defined at the top, we gave it this value, but it wasn't your time.

53
00:04:13,840 --> 00:04:24,400
OK, so the next argument after this is the is whether we want this time to be a one short timer or

54
00:04:24,400 --> 00:04:29,020
an auto reload timer because we want this to be one shot, we're going to pass false over here.

55
00:04:29,380 --> 00:04:32,560
The next argument is the time of ID.

56
00:04:32,560 --> 00:04:33,850
We're not using time ID.

57
00:04:33,850 --> 00:04:34,570
So I'm going to pause.

58
00:04:34,570 --> 00:04:39,100
You hear the last argument is the callback function for the time.

59
00:04:39,100 --> 00:04:41,770
I just like our tasks of task functions.

60
00:04:41,990 --> 00:04:43,720
Our time is of callback functions.

61
00:04:43,900 --> 00:04:48,300
We're going to create a callback function called Pravy one short time, a callback.

62
00:04:48,310 --> 00:04:51,190
So I'm just put in the name here, OK?

63
00:04:56,350 --> 00:05:03,650
And of course, this time I will return to handle which we are storing in our X time X one short time

64
00:05:03,710 --> 00:05:04,090
handle.

65
00:05:04,390 --> 00:05:05,530
So I'm going to copy this.

66
00:05:06,590 --> 00:05:09,830
And then we create the auto reload version.

67
00:05:10,840 --> 00:05:18,460
So over here, we said this is going to be our auto reload or periodic timer, I'll call this auto reload

68
00:05:19,810 --> 00:05:23,580
and then the period for our auto reload we defined up here.

69
00:05:23,860 --> 00:05:33,040
So I copy this period and this time it's asking whether we want to want to make it one shot we want.

70
00:05:34,660 --> 00:05:41,260
So to phrase this properly, this parameter asks whether you want it to be auto reload or not.

71
00:05:42,040 --> 00:05:46,870
So over here, when we said force, we said we don't want auto reload.

72
00:05:46,880 --> 00:05:52,540
And since the all the other option is one shot, if you said to force, you are going to have a one

73
00:05:52,540 --> 00:05:53,260
shot timer.

74
00:05:53,530 --> 00:05:55,510
So over here we want auto reload.

75
00:05:55,520 --> 00:05:58,390
So we're going to set it to true this parameter.

76
00:06:01,300 --> 00:06:08,470
OK, and then after that, we have this argument, which is for the time, a Honda, and then we have

77
00:06:08,570 --> 00:06:16,420
this disco back where we have to put a TAMAKO box over here, we're going to use a kolba called PSV.

78
00:06:17,840 --> 00:06:22,670
Pravy, we can give it a name, auto reload time I Kobuk Pravy.

79
00:06:27,650 --> 00:06:32,300
Auto reload time, I call back like this.

80
00:06:33,220 --> 00:06:34,160
OK, so.

81
00:06:35,810 --> 00:06:42,320
Once we are done, we've created our time is now we have to start our time is.

82
00:06:43,840 --> 00:06:49,840
So to start the timer, we simply use the the time I start to function to do the.

83
00:06:52,170 --> 00:06:53,130
My computer does.

84
00:06:54,600 --> 00:06:59,460
I pressed a single key and then it's duplicated over 50 times.

85
00:07:02,350 --> 00:07:08,800
It could be that my computer is getting slow because I've turned off the fun so that it doesn't disturb

86
00:07:08,800 --> 00:07:17,470
the video, because when you're recording for long and your computer phone is on, you hear the the

87
00:07:17,470 --> 00:07:18,520
sound of the fun.

88
00:07:22,760 --> 00:07:24,650
OK, so the task function.

89
00:07:27,110 --> 00:07:30,470
All the the callback function for our time, as this one is called.

90
00:07:30,740 --> 00:07:33,890
So what we want to do is get the current time and print.

91
00:07:34,310 --> 00:07:37,540
We can get the time using the get count.

92
00:07:38,300 --> 00:07:42,470
So I'm going to create a local variable here called X Time Now.

93
00:07:44,130 --> 00:07:51,480
And then I'm going to get it current time and store it in this variable, so to get a time, we simply

94
00:07:51,480 --> 00:07:51,840
see.

95
00:07:52,810 --> 00:07:55,000
Get take count.

96
00:07:58,340 --> 00:08:05,840
So I obtain that and storage in this very well, and once we've done that, then we can go ahead to

97
00:08:05,840 --> 00:08:08,060
print this using our print.

98
00:08:09,270 --> 00:08:14,720
OK, so remember, Tamako back functions are different from our task functions.

99
00:08:15,290 --> 00:08:17,650
There shouldn't be an infinite loop here.

100
00:08:17,660 --> 00:08:18,860
We don't have it.

101
00:08:19,160 --> 00:08:21,950
If it's not, we don't have is not an optional thing.

102
00:08:22,100 --> 00:08:24,770
We we must make sure we don't put a while.

103
00:08:24,770 --> 00:08:25,600
One loop here.

104
00:08:26,210 --> 00:08:31,820
This is a callback function is supposed to run to completion his thoughts and then it completes.

105
00:08:32,360 --> 00:08:34,760
There's no one here, OK.

106
00:08:35,820 --> 00:08:37,020
So this is the.

107
00:08:38,650 --> 00:08:40,510
The Kobuk for our.

108
00:08:43,260 --> 00:08:50,430
One short timer, so a similar one for our auto reload timer is simply going to print the time just

109
00:08:50,430 --> 00:08:51,410
like we've done above.

110
00:08:51,810 --> 00:08:56,430
So we have P RV or to reload the time I call back, it gets the.

111
00:08:57,650 --> 00:09:00,650
Take account and then print it like this.

112
00:09:01,250 --> 00:09:05,720
OK, so once I've done this, I'm going to expose the prototypes.

113
00:09:05,720 --> 00:09:06,470
I'll copy this.

114
00:09:07,250 --> 00:09:09,310
I'll bring this to the top over here.

115
00:09:10,710 --> 00:09:15,390
And then I'll come down to get the auto reload.

116
00:09:17,060 --> 00:09:17,870
I'll this.

117
00:09:20,140 --> 00:09:21,820
And then put this over here.

118
00:09:22,890 --> 00:09:25,750
OK, let's see what we have.

119
00:09:25,990 --> 00:09:27,130
Click over here to build.

120
00:09:31,680 --> 00:09:34,590
We have two errors, what does A, C, P, R, v?

121
00:09:35,850 --> 00:09:36,780
Auto reload.

122
00:09:37,140 --> 00:09:46,020
OK, there's an anomaly here, I forgot the word or the letter T over here, so I'll click here to build.

123
00:09:50,130 --> 00:09:50,790
It's built in.

124
00:09:52,920 --> 00:09:54,390
OK, Canaro.

125
00:09:55,360 --> 00:09:56,130
And, um.

126
00:09:59,090 --> 00:10:01,790
We can right click over here.

127
00:10:02,540 --> 00:10:07,610
And run us estimate that it's you select this twenty three.

128
00:10:11,280 --> 00:10:12,660
And then I'll say, OK.

129
00:10:20,620 --> 00:10:21,070
OK.

130
00:10:22,490 --> 00:10:25,180
It's still working, so standard verified.

131
00:10:25,210 --> 00:10:28,240
OK, let's go to real time to see what we have.

132
00:10:29,540 --> 00:10:30,260
Here we are.

133
00:10:32,550 --> 00:10:36,710
I'm going to clear this up, I'm going to open our port again.

134
00:10:41,010 --> 00:10:43,140
Real time, it's not responding.

135
00:10:47,360 --> 00:10:50,340
OK, I'm going to close this in open again.

136
00:10:51,890 --> 00:10:52,590
Here we are.

137
00:10:53,330 --> 00:10:58,310
So like this in port, so I tell poetry to hear.

138
00:10:59,440 --> 00:11:01,690
And then this is how port.

139
00:11:03,820 --> 00:11:06,040
OK, still not responded.

140
00:11:06,490 --> 00:11:15,190
OK, now let's see where we could have an anomaly, we came over here, we created two times.

141
00:11:16,340 --> 00:11:22,010
And they've got a callback function as we started our scheduler, we didn't forget that.

142
00:11:23,930 --> 00:11:26,930
Did we start a time is the next time I start?

143
00:11:28,140 --> 00:11:30,000
We started both time as.

144
00:11:34,350 --> 00:11:40,680
Let's inspect our code, so we came over here, we created our timer, we stored the handle, the Winshaw

145
00:11:40,680 --> 00:11:44,680
timer here and over here, we created the auto reload.

146
00:11:44,730 --> 00:11:48,200
OK, but we stored the auto reload and one short handle.

147
00:11:48,660 --> 00:11:50,240
OK, this may be creating an error.

148
00:11:50,610 --> 00:11:54,000
So our our program is probably crushing around here.

149
00:11:54,750 --> 00:12:00,110
Um, so of course we have to change this because we made a copy of this one.

150
00:12:00,540 --> 00:12:04,020
We or I thought to change this the handle.

151
00:12:04,470 --> 00:12:09,420
So the auto reload will be stored in the auto reload handle over here.

152
00:12:09,750 --> 00:12:12,930
OK, let's run and see if this is what was causing us the issue.

153
00:12:13,710 --> 00:12:15,690
Click over here to build its Beurden.

154
00:12:16,900 --> 00:12:20,110
And it's done building, I'll click here to run.

155
00:12:21,540 --> 00:12:22,200
If I hear.

156
00:12:24,600 --> 00:12:27,180
And hoping to see.

157
00:12:28,630 --> 00:12:29,980
Eau Claire rootin.

158
00:12:33,330 --> 00:12:35,190
Waiting for the power connection.

159
00:12:41,950 --> 00:12:43,290
OK, there we go.

160
00:12:44,800 --> 00:12:47,200
Oh, we can see our timer running.

161
00:12:48,250 --> 00:12:56,560
OK, I'm going to post this right, we see that one short time, OK, and once that's.

162
00:12:57,700 --> 00:13:04,420
This time period, four thousand times, but we see that every 500 times auto reload time.

163
00:13:06,200 --> 00:13:13,100
Executed callback such that we have six thousand five hundred seven thousand seven thousand five hundred

164
00:13:13,100 --> 00:13:19,820
eight thousand, so it's working as expected, because this this is the period we defined that the author

165
00:13:19,820 --> 00:13:26,870
reload timer is 500 times every 500 M is issued execute its callback function, whereas we want the

166
00:13:26,870 --> 00:13:28,700
Winshaw time to execute.

167
00:13:28,700 --> 00:13:36,620
This was issued execute four thousand milliseconds after we started and that's what occurred over here.

168
00:13:37,790 --> 00:13:44,480
OK, so this order is with regards to our time is I'll see in the next lesson of a nice day.
