Hardware Reference
In-Depth Information
The Basic Analysis Program
To implement the state machine, enter the Python code in Listing 17-2 into a new ile,
analyseBirdDataBasic.py .
Listing 17-2 analyseBirdDataBasic.py
#!/usr/bin/env python
import sys
import datetime
#print a debug message if debugging is turned on
def debug(msg):
if DEBUG:
print msg
state=”IDLE”
#Constants
INNER_BEAM = 0
OUTER_BEAM = 1
BROKEN = 0
UNBROKEN = 1
DEBUG = True
outwardTimes = []
# loop over every line that is being piped into the program
for line in sys.stdin:
#ignore lines beginning#
if line.startswith('#'):continue
# remove the new line character
line = line.rstrip('\n')
#split the text at each comma. This creates
#the event array, with three items
event = line.split(',')
#store the first item in the sensor variable -- this
#is which beam (inner or outer)
sensor = int(event[0])
#store the type of the event in the eventType
#variable -- this is if the beam broke or unbroke
eventType = int(event[1])
continued
Search WWH ::




Custom Search