-
Notifications
You must be signed in to change notification settings - Fork 0
/
tubes.py
96 lines (75 loc) · 2.5 KB
/
tubes.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
92
93
94
95
#!/usr/bin/env python
# -*- encoding: utf-8 -*-
# ./tubes.py
#
# (c) 2010-2012 Konstantin Sering, Nora Umbach, Dominik Wabersich
# <colorlab[at]psycho.uni-tuebingen.de>
#
# GPL 3.0+ or (cc) by-sa (http://creativecommons.org/licenses/by-sa/3.0/)
#
# content: (1) Tubes classes, which provide functions for working
# with the tubes.
#
# input: --
# output: --
#
# created 2010
# last mod 2013-01-01 10:52 KS
"""
The tubes class gives an easy interface to handle the tubes and CalibTubes
provides convenient methods to measure and calibrate the tubes.
"""
import devtubes
from colorentry import ColorEntry
# TODO: Paths
#from os import chdir, path
# chdir(path.dirname(self.__file__))
class Tubes(object):
"""
Gives high level access to the tubes.
This class hides all the hardware specifications and has no
dependencies on the eyeone module.
Example:
>>> tub = Tubes(dummy=True)
>>> tub.setVoltages((1000, 1000, 1000))
>>> tub.printNote()
<BLANKLINE>
Note:
The tubes must be switched on for at least four (!!) hours in
order to radiate a stable amount of light.
<BLANKLINE>
"""
def __init__(self, dummy=False):
"""
Initializes tubes object.
Contains an object with a method setVoltages. This method gets a
triple of integers and sets the voltages of the tubes. The devtubes
object takes care of all the hardware stuff.
Parameters:
dummy: *False* or True
If dummy=True no wasco runtime libraries will be loaded.
"""
self.devtub = devtubes.DevTubes(dummy=dummy)
def setVoltages(self, voltages):
"""
Sets tubes to given voltages.
If setVoltages gets an ColorEntry object, it extracts the voltages
from this object and sets the tubes accordingly.
WARNING: Don't set the tubes directly (e.g., via wasco), because
the change in voltage has to be smoothly. This prevents the
fluorescent tubes to accidentally give out.
"""
if isinstance(voltages, ColorEntry):
self.devtub.setVoltages(voltages.voltages)
else:
self.devtub.setVoltages(voltages)
def printNote(self):
"""
Prints a note, that states what is important, when you use the
tubes.
"""
print("""
Note:
The tubes must be switched on for at least four (!!) hours in order
to radiate a stable amount of light.
""")