The document describes a wheel module service that initializes a priority variable, checks for pulse events from a wheel, and runs the wheel by starting and stopping a timer for wheel rotation and posting events to other modules when rotation starts or stops. It uses variables to track the wheel state and whether the first pulse has occurred.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
30 views1 page
Wheel
The document describes a wheel module service that initializes a priority variable, checks for pulse events from a wheel, and runs the wheel by starting and stopping a timer for wheel rotation and posting events to other modules when rotation starts or stops. It uses variables to track the wheel state and whether the first pulse has occurred.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1
Wheel Module (a simple service)
Module Variable: MyPriority
InitializeWheel Takes a priority number, returns true. Initialize the MyPriority variable with the passed in parameter. Post Event ES_Init to this service End of InitializeWheel (return True) CheckWheelEvents (This function is placed in "EventCheckers" module) Takes no parameters, returns true if an event posted Local ReturnVal = False, CurrentWheelState Static Local - LastWheelState =0 Set CurrentWheelState to state read from port pin If the CurrentInputState is different from the LastInputState and CurrentInputState is low Set ReturnVal = True Post Event Pulse to Wheel module End if Set LastWheelState to CurrentWheelState Return ReturnVal End of CheckWheelEvents RunWheel (implements the service for Wheel) Static variable FirstPulse = false; The EventType field of ThisEvent will be one of: Pulse, ES_TIMEOUT Returns ES_NO_EVENT If ThisEvent is Pulse Start timer for wheel rotation that expires in 2 seconds and posts to Wheel machine If FirstPulse is false Start timer 0 Post Event WheelRotationStarted to LaserCharging, LaserFire, and DDM modules Set FirstPulse as true End if End if If ThisEvent is ES_TIMEOUT from wheel rotation timer Post event WheelRotationStopped to LaserFire, LaserCharging and DDM Set FirstPulse to be false End if Return ES_NO_EVENT End of RunWheel