Hello, welcome back.
In this lesson, we go going to see how to work with defense groups, I'm going to make a copy of one
of our old projects and then I'll just continue from there.
Before that, I'll just clear everything from the screen, OK, so we can select one of our old projects.
Let's see.
I can just select project, which is project number two.
Well, we can just make a copy of the latest one and clean it.
I'll copy this and then paste over here.
I call this events groups.
Scorpion, it's done open this.
This is may not see over here.
I'm going to clean everything we have, all our related code is going to be taken up.
So clean this and in here, I'll clean this as well.
And I explained why we're not creating new projects because we would have to include the the library
files.
OK, so this what we have.
OK, this what we have, so we're going to experiment with different groups, we're going to have two
tasks.
One task would set the event a bit and then the other one would read it.
Before that, we're going to define some bits for the two tasks.
So I'm going to come over here.
Over here, I have to delete these as well or define task one bit as.
It's zero and then task to bit us bit one, this simply means shift.
One, two bits, number zero, shift one to bits, number one.
OK, so once that is done, I'll come over here to create a new task.
Before that, I'm going to I'm going to bring our Ewart's in this program.
We don't have our you out in it, so we are going to transmit the data from you to check our experiment.
So I'll copy our UTX in its function and I'll call it in here.
Okay, and the first and will print this system initializing.
OK, just to make sure our Ewart's good, OK?
And we're going to declare an event group Hando at the top over here.
We're simply calling this X event group once we've declared a handover.
We're going to create the event group and store the handle store.
The handle returned into our handle variable.
Once this is done, we're going to create two tasks.
One is called the Bizet's, the other is called a bit Reede.
They both have the same priority and the same stack size.
OK, and we're going to have the task functions.
This once task function will be called X event setting task and this are the ones task function will
be called X event reading task.
So once we've done this, we simply start our search, the.
And we are familiar with the API already task that Schussler.
So now we have to implement the task functions, the first one event.
Team task going to have this and we're going to have our infinite loop here.
In here, we're going to define a delay amount in milliseconds, we're going to see 500 milliseconds
delay is simply CDMs to takes.
The value returned will be five hundred Emmis.
OK, so we're going to start off by delaying for 500 M is
over here and then we're going to print a message.
We're going to say.
Bit setting task is about to set Bitz zero, so we print this.
And then we go ahead to Cesspits Zero.
By using our function events group, Cesspits, remember, with zero corresponds to task one bit.
So we say event group Cesspits.
We passed the event group Hando here and then the bit we wish to set, which is task one bit bits.
Number zero here.
Okay.
Once that is done, we going to wait a bit, 500 times, and we're going to set for page one as well,
which is task to bit.
OK, so we just see we about to set and then we set about to set and then we said now are we going to
go to the event reader to ask?
A separate task of this task down here, we have the infinite loop.
And over here, we're going to define the bits to wait for currently our system has bits, has to bits.
We have the task one bit and the task to bits.
We can combine the bits using an operation so we define an event.
It's variable here called experts to wait for.
And we have two of them task one bit and task to bits.
So we use an operation to put them together and store them in a single variable.
OK, so now we are going to call X event group, wait for its function to wait for the bids and this
is going to return a value.
So this value that is returned is an event, but we have to start somewhere because of that.
I'm going to create this variable here that would hold the event group value and also I'm going to create
a delay here.
Of two hundred, Miss OK.
So now all we have to do is call our function event group Weetbix.
And this function here.
Takes as its first the event group, Hando, and this is the bits we are waiting for before declared
this, we are waiting for these bits, bits one and bits zero.
OK, and then.
This third argument here is known as the exclosure on exit, and this over here, if we said this to
true, then in a bit setting the value passed over here as bits to wait for will be cleared in the event
group before the event group occurs.
So we want to clear whatever was set.
So we said is true.
This next argument is whether we want to wait for all the bits or not.
So this one, if we said is to true all the bits, is what we are interested.
If we said this to be true, then the event event group, events group, which bits this function would
return when all the bits, when both tossed one bit into two bits are set.
But over here, we are saying false because we don't want all of them, we expect just one of them to
be said.
So if we said is to true, it would wait for all of them, both of them essentially, OK.
So this one here, this and if we want to read more, we can build our project and then go and read
about this function.
OK, even by highlighting that we have it here, the first argument here is the the events group handle.
The second argument is the bits to wait for over here.
We cannot see the rest, but let's double click and see.
Go to declaration.
OK, so the third argument is it's clear on exits, like we said, if we said it's true, then the bits
that were set will be cleared on exit.
What happened was that.
Open declaration.
And then the next one is.
Wait for orbit's whether we want to wait for orbit's or not, we say force and then amount of time to
wait.
And we said CDMs, we said Portsmouth's delay, OK?
So once that is done, we just continue, we find out which bits is set, so we say in any of the bits.
So since that's the case, then we have to use and if block to find out which of it.
So we're going to take the the retained value X group value here and perform on an operation.
So we're going to take this perform on an operation with task one bit.
If this is not equal to zero, meaning if it is if it is one, then we say bits reading task events,
bits zero is what we've just read.
Cos, you know, this is for task one.
I can put task one here.
Because the tasks have different, you know, numbers compared to the bits, so then we can do the same
thing for me to perform the same operation here.
Four bits, one story, which is four task to.
And then we can delay a bit, we can delay our 200 Emmis, OK?
So this is it now we're going to put the function prototypes out of TOPIA.
Okay, now let's build and see.
Click over here to build.
OK, the reason we get to this is we have to include events, group storage, because it's a new component
to want to use.
I'll come over here or Simms's was not open declaration.
And that we include events groups today over here.
No, I'll click and build.
It's built successfully.
Right, click over here.
See the bug US ASTM 32.
And then I'll click on events groups over here.
And then I'll say, OK.
And I'll click the switch.
Then I'll come over here to view our real time and then I'll click to run over here.
You can see.
We are and reading the events bit so over here.
So bit in task.
About two, said Spitz, one, and then bits reading task events, bits one set.
Which is for task two and then with a certain task about to set with zero, which reading task event
but zero set, which is for task one.
So this is a simple experiment just to show us how to set event bits and how to read them.
OK, so this is our basic event bit introduction.
This order is I'll see you in the next lesson.