Вы находитесь на странице: 1из 7

Pseudo Code for EventCheckers.

c
FUNCTION: strobe_rise_check Takes nothing, returns boolean Initialize char LastPinState to 0 Initialize char CurrentPinSTate Initialize ReturnVal to False Set CurrentPinState tot STROBE_PIN if CurrentPinState does not equal LastPinState and CurrentPinState is 1 Initialize event ThisEvent, set type to ES_STROBE_RISE and parameter to 1 run PostCommunication with ThisEvent set ReturnVal to true Set LastPinState to CurrentPinState Return ReturnVal

FUNCTION: strobe_fall_check Takes nothing, returns boolean Initialize char LastPinState to 0 Initialize char CurrentPinSTate Initialize ReturnVal to False Set CurrentPinState tot STROBE_PIN if CurrentPinState does not equal LastPinState and CurrentPinState is 0 Initialize event ThisEvent, set type to ES_STROBE_FALL and parameter to 1 run PostCommunication with ThisEvent set ReturnVal to true Set LastPinState to CurrentPinState Return ReturnVal

FUNCTION: ack_rise_check Takes nothing, returns boolean Initialize char LastPinState to 0 Initialize char CurrentPinSTate Initialize ReturnVal to False Set CurrentPinState tot ACK_PIN 1

if CurrentPinState does not equal LastPinState and CurrentPinState is 0 Initialize event ThisEvent, set type to ES_ACK_RISE and parameter to 1 run PostCommunication with ThisEvent set ReturnVal to true Set LastPinState to CurrentPinState Return ReturnVal

FUNCTION: start_button_check takes nothing, returns boolean Initialize Initialize Initialize Initialize Initialize Initialize char LastPinSTate to 1 char LastLEDState to LOW char CurrLEDState char CurrentPinState ReturnVal to false timer 0 at rate 30

if LastLEDState is LOW set CurrLEDState to HIGH else set CurrLEDState to LOW Set IR_LED_PIN to CurrLEDState Set CurrentPinSTate to BUTTON_PIN if CurrentPinState does not equal LastPinState and CurrentPinState is 0 Initialize event ThisEvent, set type to ES_START_BUTTON_PRESS and parameter to 1 run PostHardWare with ThisEvent set ReturnVal to true Set LastPinSTate to CurrentPinSTate Set LastLEDState to CurrLEDState return ReturnVal

FUNCTION: checkStartButtons Takes nothing, returns boolean Initialize ButtonPinSTate to BUTTON_PIN if ButtonPinState is LOW return True 2

else return False

FUNCTION: Flame_IRSensor_check Takes nothing, returns boolean Initialize static char LastPinState to 0 Initialize unsigned char CurrentPinSTate Initialize ReturnVal to False Set CurrentPinSTate to FLAME_IR_SENSOR_PIN if CurrentPinState does not equal LastPinState and CurrentPinState is 0 Initialize event ThisEvent, set type to ES_TORCHIR_DETECT and parameter to TORCH run PostHardWare with ThisEvent set ReturnVal to true Set LastPinState to CurrentPinSTate Return ReturnVal

FUNCTION: checKFlameIRSensorsS Takes nothing, returns boolean Initialize FlamePinSTate to FLAME_IR_SENSOR_PIN if FlamePinState is 0 return True else return False

FUNCTION: Hades_IRSensor_check Takes nothing, returns boolean Initialize static char LastPinState to 0 Initialize unsigned char CurrentPinSTate Initialize ReturnVal to False Set CurrentPinSTate to HADES_IR_SENSOR_PIN if CurrentPinState does not equal LastPinState and CurrentPinState is 0 Initialize event ThisEvent, set type to ES_HADESIR_DETECT and parameter to HADES run PostHardWare with ThisEvent set ReturnVal to true 3

Set LastPinState to CurrentPinSTate Return ReturnVal

FUNCTION: checkHadesIRSensorsS Takes nothing, returns boolean Initialize HadesPinSTate to HADES_IR_SENSOR_PIN if HadesPinState is 0 return True else return False

FUNCTION: checkJoystickEvents Takes nothing, returns boolean Initialize static int LastPinState to 0 Initialize static boolean forward to False Initialize unsigned char CurrentPinSTate Initialize ReturnVal to False Initialize event JoystickEvent Set CurrentPinSTate to JOYSTICK_PIN if CurrentPinState does Set CurrentPinState else if CurrentPinSTate Set CurrentPinState else set CurrentPinState

not equal LastPinState and CurrentPinState is less than JOYSTICK to SLOW is greater than JOYSTICK_MAX to FAST to OFF

if CurrentPinSTate does not equal LastPinSTate if CurrentPinSTate is OFF Set JoystickEvent event type to OFF and parameter to CurrentPinState Run PostHardWare with JoystickEvent set ReturnVal to True else Set JoystickEvent eventType to ES_JOYSTICK_CHANGE and parameter to CurrentPinSta Run PostHardWare with JoystickEvent set ReturnVal to True Set LastPinState to CurrentPinSTate Return ReturnVal 4

FUNCTION: checKJoystickHigh Takes nothing, returns boolean Initialize CurrentPinState to JOYSTICK_PIN if CurrentPinState is greater than JOYSTICK_BUT return True else return False

FUNCTION: checkActuatorEvents Takes nothing, returns nothing Initialize static int LastPinState to MIDDLE Initialize int CurrentPinState Initialize boolean ReturnVal to False Initialize event ActuatorEvent Set CurrentPinState to read ACTUATOR_PIN if CurrentPinState is less set CurrentPinState to else if CurrentPinState is set CurrentPinState to else set CurrentPinSTate to than the actuator min START greater than actuator max End MIDDLE

if CurrentPinState does not equal LastPinSTate if CurrentPinState is START set ActuatorEvent event type to ES_END_OF_STATE run PostGame with ActuatorEvent set ReturnVal to True else if CurrentPinState is END set ActuatorEvent event type to ES_BEGINNING_OF_STATE run PostGame with ActuatorEvent run PostActuators with ActuatorEvent set ReturnVal to True Set LastPinState to CurrentPinState Return ReturnVal

FUNCTION: checkActuatorEvents2 5

Takes nothing, returns nothing Initialize static int LastPinState to MIDDLE Initialize int CurrentPinState Initialize boolean ReturnVal to False Initialize event ActuatorEvent Set CurrentPinState to read ACTUATOR_PIN2 if CurrentPinState is less set CurrentPinState to else if CurrentPinState is set CurrentPinState to else set CurrentPinSTate to than the actuator min START greater than actuator max End MIDDLE

if CurrentPinState does not equal LastPinSTate if CurrentPinState is START set ActuatorEvent event type to ES_END_OF_STATE run PostGame with ActuatorEvent set ReturnVal to True else if CurrentPinState is END set ActuatorEvent event type to ES_BEGINNING_OF_STATE run PostGame with ActuatorEvent run PostActuators with ActuatorEvent set ReturnVal to True Set LastPinState to CurrentPinState Return ReturnVal

FUNCTION: checkActuatorReset Takes nothing, returns boolean Initialize int CurrentPinSTate and CurrentPinSTate2 Initialize boolean ReturnVal to False Initialize event ActuatorEvent Set CurrentPinState to read ACTUATOR_PIN Set CurrentPinState2 to read ACTUATOR_PIN2

if CurrentPinState is less than Actuator max and CurrentPinSTate 2 is less than Actuator set ActuatorEvent event type to ES_MOTOR_RESTARTING and parameter to 1 run PostGame with ActuatorEvent set ReturnVal to True else set ActuatorEvent event type to ES_MOTOR_RESTARTED and parameter to 1 6

run PostGame with ActuatorEvent set ReturnVal to True Return ReturnVal

FUNCTION: tape_sensor_check Takes nothing, returns boolean Initialize event AccessBadgeEvent Initialize static boolean AccessBadgeIn to False if the tape sensor pin0 is 1 and tape sensor pin1 is 0 and AccessBadgeIn is False Set AccessBadgeEvent event type to ES_ACCESS_BADGE_ON and parameter to 0 run PostGame with AccessBadgeEvent set AccessBadgeIn to True else if AccessBadgein is True if the tape sensor pin0 is not 1 or tape sensor pin1 is not 0 Set AccessBadgeEvent event type to ES_ACCESS_BADGE_OFF and parameter to 0 run PostGame with AccessBadgeEvent set AccessBadgeIn to True Return AccessBadgeIn

Вам также может понравиться