-
Notifications
You must be signed in to change notification settings - Fork 20
/
ChipReader.py
62 lines (50 loc) · 2.01 KB
/
ChipReader.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
import JChip
import RaceResult
import Ultra
import WebReader
import MyLapsServer
class ChipReader:
JChip, RaceResult, Ultra, WebReader, MyLaps = tuple( range(5) ) # Add new options at the end.
Choices = (_('JChip/Impinj/Alien'), _('RaceResult'), _('Ultra'), _('WebReader'), _('MyLaps'))
def __init__( self ):
self.chipReaderType = None
self.reset()
def reset( self, chipReaderType=None ):
if self.chipReaderType is not None:
JChip.StopListener()
RaceResult.StopListener()
Ultra.StopListener()
WebReader.StopListener()
MyLapsServer.StopListener()
self.chipReaderType = (chipReaderType or ChipReader.JChip)
if self.chipReaderType == ChipReader.RaceResult:
self.StartListener = RaceResult.StartListener
self.GetData = RaceResult.GetData
self.StopListener = RaceResult.StopListener
self.CleanupListener = RaceResult.CleanupListener
self.IsListening = RaceResult.IsListening
elif self.chipReaderType == ChipReader.Ultra:
self.StartListener = Ultra.StartListener
self.GetData = Ultra.GetData
self.StopListener = Ultra.StopListener
self.CleanupListener = Ultra.CleanupListener
self.IsListening = Ultra.IsListening
elif self.chipReaderType == ChipReader.WebReader:
self.StartListener = WebReader.StartListener
self.GetData = WebReader.GetData
self.StopListener = WebReader.StopListener
self.CleanupListener = WebReader.CleanupListener
self.IsListening = WebReader.IsListening
elif self.chipReaderType == ChipReader.MyLaps:
self.StartListener = MyLapsServer.StartListener
self.GetData = MyLapsServer.GetData
self.StopListener = MyLapsServer.StopListener
self.CleanupListener = MyLapsServer.CleanupListener
self.IsListening = MyLapsServer.IsListening
else: # self.chipReaderType == ChipReader.JChip:
self.StartListener = JChip.StartListener
self.GetData = JChip.GetData
self.StopListener = JChip.StopListener
self.CleanupListener = JChip.CleanupListener
self.IsListening = JChip.IsListening
chipReaderCur = ChipReader()