SE-631
Real-Time System Design and Implementation

Lab Assignment 5
(Due Monday, March
26)
Create
a project which controls the motion and lights of the train in our
real-time lab according to the following specification:
-
The train starts at speed
4, lights on.
-
The motion of the
train is controlled by the four push buttons:
-
Each time PB1 is
pushed, the train speed is incremented by 2, but the maximum speed
of the train is 10. When the train reaches the maximum speed,
pushing PB1 has no impact to the system.
-
Each time PB2 is
pushed, the train speed is decremented by 2, but the minimum speed
of the train is 4. When the train reaches
the minimum speed, pushing PB2
has no impact to the system.
-
Pushing
PB3 will reverse the moving direction of the train. For example,
when the train is
moving at speed 6 heading west, if
you push PB3, then the
train will stop and then restart to move
heading east at speed 6.
-
When PB4 is pushed, the train should move towards one of the three
stoppers and park in front of the stopper without hitting it.
-
The train lights
turn on and off alternatively every 4 seconds.
-
Spawn
three tasks in your implementation: the first task (motionHandler)
handles motion control commands, the second task (lightsHandler)
turns lights on and off, and the third task (controller)
collects control signals from PB1 -- PB4 and sends corresponding
control commands to
motionHandler through message queues.
-
The function call
LocoSet()
should be protected by a semaphore.
On the due day,
each team needs to demo the project to the class in the lab.
|