forked from snoplus/smellie
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSmellieRS.py
91 lines (71 loc) · 2.68 KB
/
SmellieRS.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
83
84
85
86
87
88
89
90
91
# Written by Christopher Jones 9/01/2013 email:[email protected]
# This requires the LabJackPython Software that has been adapted to work for a Windows 7 64-bit machine
# Please Check the u12SMELLIE.py script for more details
import u12SMELLIE,time
d = u12SMELLIE.U12()
# Pulses the channel up bit on the LabJack
def ChannelUp():
#Raises D1
d.eDigitalOut(1,1)
#Lowers D1
d.eDigitalOut(1,0)
#Raises D1
d.eDigitalOut(1,1)
# Pulses the execute bit on the LabJack
def Execute():
#Raises D0
d.eDigitalOut(0,1)
#Lowers D0
d.eDigitalOut(0,0)
#Raises D0
d.eDigitalOut(0,1)
time.sleep(30) ##time for sepia to power up
#gets the channel displayed on the Fibre Switch
def GetDisplayChannel():
def invert(bit):
if (bit == 0):
bit = 1
return bit
elif(bit == 1):
bit = 0
return bit
else:
return "Invalid input"
channel = invert(d.eDigitalIn(2)) + 2.0*float(invert(d.eDigitalIn(3))) + 4.0*float(invert(d.eDigitalIn(4)))
return int(channel)
#gets the last execute channel on the Fibre Switch
def GetLastChannel():
def invert(bit):
if (bit == 0):
bit = 1
return bit
elif(bit == 1):
bit = 0
return bit
else:
return "Invalid input"
channel = invert(d.eDigitalIn(5)) + 2.0*float(invert(d.eDigitalIn(6))) + 4.0*float(invert(d.eDigitalIn(7)))
return int(channel)
# this function can be changed if necessary
def SetRSChannel(picked_channel):
if (picked_channel >= 6 or picked_channel < 0):
print "Fail: Pick a Valid Channel between 0-5 inclusive"
return 0
else:
current_display_channel = GetDisplayChannel()
while (picked_channel != current_display_channel):
ChannelUp()
current_display_channel = GetDisplayChannel()
return
# this checks to see if the laser channel switch execution is in progress (or not)
def CheckExe():
manual_execution_flag = d.eDigitalIn(8)
#Note: If the argument UpdateDigital=True then new values are sent
if (manual_execution_flag == 1):
print "Execution in Progress"
return
else:
print "No execution in Progress"
return
def help():
print "SmellieFS Commands include:\n - SetChannel(0-5)\n - GetLastChannel()\n - Execute()\n - GetDisplayChannel()\n - ChannelUp()\n - help()\n - CheckExe()\n Please see the LabJackPython module for more information https://github.com/labjack/LabJackPython"