-
Notifications
You must be signed in to change notification settings - Fork 0
/
algconsecutivematches.py
82 lines (56 loc) · 2 KB
/
algconsecutivematches.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
class algconsecutivematches:
# constructor here
carId = 0
lastCarId = 0
matches = 0
CONSECUTIVE_MATCHES = 3
#define pulse boundary widths here. use some sort of dispatcher???
pulsewidths = {
'1': ()
}
def calc_pulse_widths():
pass
# look at the database and calc pulse widths based on the sample data I currently have
# or have a
def next(pulseWidth):
if lastCarId > 0:
lastCarId = carId
carId = getCarId(pulseWidth)
if carId == lastCarId:
matches += 1
if matches >= CONSECUTIVE_MATCHES:
return carId #confirmed carid
else:
return 0
def getCarId(pulseWidth):
pass
'''
overview
--------
sql query get list of samples
iterate through them. each sample has a known CarId, so we want to see if we can reliably match it
the algorithm will loop through each pulse in the sample, and feed the pulses one by one into the algorithm
until it comes up with a match
Then we compare the match to the recorded carId, and record the result in the database
We can test all algorithms in the same loop. Results stored in DB. We use separate code to tabulate the results.
pseudocode
----------
loop samples
test3inARow(listOfPulsesForOneSample)
testAverageAll(listOfPulsesForOneSample)
def test3inARow
for pulses
3inARowAlg(pulse)
#must behave in a serial way (like an iterator)
#Can a python function persist variables across calls????
# no. use a class
def 3inARowAlg(pulse)
if new
matches = 0
lastcarid = empty
carid = findcarid(pulse)
elif
lastcarid = carid
carid = findcarid(pulse)
#https://www.csestack.org/python-check-if-all-elements-in-list-are-same/
'''