Hardware Reference
In-Depth Information
Listing 17-3 continued
state = “WAITING_INWARD_I_CLEAR”
else:
debug (“timeout on waiting inward O Clear”)
state= “IDLE”
elif (state == “WAITING_INWARD_I_CLEAR”):
if (diffTime.seconds < 5):
if ((sensor==INNER_BEAM) and (eventType==UNBROKEN)):
state == “IDLE”
debug (str(eventTime)+” BIRD has returned”)
state = “IDLE”
else:
debug (“timeout on waiting inward I Clear”)
state= “IDLE”
# if we end up in any other state, then we generate
# an error
else:
debug (“error”)
raise ValueError, “unexpected input block state: “+state
#independent of state
#update the lastEventTime to be the value from this loop
#for next iteration of loop
lastEventTime = eventTime
Ensure that debugging is turned on (check that DEBUG=1 is set) and run the program by typ-
ing the following:
cat birddata.txt | python analyseBirdDataFiltered.py
Python will print the states of the state machine as it processes your bird data. he next step
is to visualise this data so that you can see trends about your bird behaviour.
Drawing a Graph
You may be familiar with using a spreadsheet to draw charts or graphs. LibreOice is a free
oice suite that runs on the Raspberry Pi. It contains the spreadsheet program Calc, which is
largely compatible with Microsoft Excel and Google Docs Spreadsheets. he most appropriate
Search WWH ::




Custom Search