1 """Spec module
2
3 This module define the Spec class for emulating a kind of Spec interpreter in
4 a Python object
5 """
6
7 __author__ = 'Matias Guijarro'
8 __version__ = '1.0'
9
10 import SpecConnectionsManager
11 import SpecEventsDispatcher
12 import SpecCommand
13 import SpecWaitObject
16 """Spec objects provide remote Spec facilities to the connected client."""
17
18 @property
20 return self.__specVersion
21
22 - def __init__(self, specVersion = None, timeout = None):
23 """Constructor
24
25 Keyword arguments:
26 connection -- either a 'host:port' string pointing to a Spec version (defaults to None)
27 timeout -- optional connection timeout (defaults to None)
28 """
29 self.connection = None
30
31 if specVersion is not None:
32 self.connectToSpec(specVersion, timeout = timeout)
33 else:
34 self.__specVersion = None
35
36
53
54
56 if attr.startswith('__'):
57 raise AttributeError
58
59 return SpecCommand.SpecCommand(attr, self.connection)
60
62 """Return motors mnemonics and names list."""
63 if self.connection is not None and self.connection.isSpecConnected():
64 get_motor_mnemonics = SpecCommand.SpecCommand('local md[]; for (i=0; i<MOTORS; i++) { md[i][motor_mne(i)]=motor_name(i) }; return md', self.connection)
65
66 motorMne = get_motor_mnemonics()
67 motorList = [None]*len(motorMne)
68 for motor_index, motor_dict in motorMne.iteritems():
69 mne, name = motor_dict.items()[0]
70 motorList[int(motor_index)]={"mne": mne, "name": name }
71 return motorList
72 else:
73 return []
74
76 """Return motor mnemonics list."""
77 motorMneList = []
78 for motor_dict in self._getMotorsMneNames():
79 motorMneList.append(motor_dict["mne"])
80 return motorMneList
81
83 """Return motors names list."""
84 motorNamesList = []
85 for motor_dict in self._getMotorsMneNames():
86 motorNamesList.append(motor_dict["name"])
87 return motorNamesList
88
89
91 if self.connection is not None:
92 versionChannel = self.connection.getChannel('var/VERSION')
93
94 return versionChannel.read()
95
96
98 if self.connection is not None:
99 nameChannel = self.connection.getChannel('var/SPEC')
100
101 return nameChannel.read()
102