-
Notifications
You must be signed in to change notification settings - Fork 102
Expand file tree
/
Copy path_attributes.py.mako
More file actions
129 lines (93 loc) · 4.17 KB
/
_attributes.py.mako
File metadata and controls
129 lines (93 loc) · 4.17 KB
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
${template_parameters['encoding_tag']}
# This file was generated
<%
module_name = template_parameters['metadata'].config['module_name']
config = template_parameters['metadata'].config
%>\
import ${module_name}._converters as _converters
import hightime
class Attribute(object):
"""Base class for all typed attributes."""
def __init__(self, attribute_id):
self._attribute_id = attribute_id
class AttributeViInt32(Attribute):
def __get__(self, session, session_type):
return session._get_attribute_vi_int32(self._attribute_id)
def __set__(self, session, value):
session._set_attribute_vi_int32(self._attribute_id, value)
class AttributeViInt32TimeDeltaMilliseconds(Attribute):
def __get__(self, session, session_type):
return hightime.timedelta(
milliseconds=session._get_attribute_vi_int32(self._attribute_id)
)
def __set__(self, session, value):
session._set_attribute_vi_int32(
self._attribute_id,
_converters.convert_timedelta_to_milliseconds_int32(value).value,
)
class AttributeViInt64(Attribute):
def __get__(self, session, session_type):
return session._get_attribute_vi_int64(self._attribute_id)
def __set__(self, session, value):
session._set_attribute_vi_int64(self._attribute_id, value)
class AttributeViReal64(Attribute):
def __get__(self, session, session_type):
return session._get_attribute_vi_real64(self._attribute_id)
def __set__(self, session, value):
session._set_attribute_vi_real64(self._attribute_id, value)
class AttributeViReal64TimeDeltaSeconds(Attribute):
def __get__(self, session, session_type):
return hightime.timedelta(
seconds=session._get_attribute_vi_real64(self._attribute_id)
)
def __set__(self, session, value):
session._set_attribute_vi_real64(
self._attribute_id,
_converters.convert_timedelta_to_seconds_real64(value).value,
)
class AttributeViString(Attribute):
def __get__(self, session, session_type):
return session._get_attribute_vi_string(self._attribute_id)
def __set__(self, session, value):
session._set_attribute_vi_string(self._attribute_id, value)
class AttributeViStringRepeatedCapability(Attribute):
def __get__(self, session, session_type):
return session._get_attribute_vi_string(self._attribute_id)
def __set__(self, session, value):
session._set_attribute_vi_string(
self._attribute_id,
_converters.convert_repeated_capabilities_without_prefix(value),
)
class AttributeViBoolean(Attribute):
def __get__(self, session, session_type):
return session._get_attribute_vi_boolean(self._attribute_id)
def __set__(self, session, value):
session._set_attribute_vi_boolean(self._attribute_id, value)
class AttributeEnum(object):
def __init__(self, underlying_attribute_meta_class, enum_meta_class, attribute_id):
self._underlying_attribute = underlying_attribute_meta_class(attribute_id)
self._attribute_type = enum_meta_class
self._attribute_id = attribute_id
def __get__(self, session, session_type):
return self._attribute_type(
self._underlying_attribute.__get__(session, session_type)
)
def __set__(self, session, value):
if type(value) is not self._attribute_type:
raise TypeError(
"must be "
+ str(self._attribute_type.__name__)
+ " not "
+ str(type(value).__name__)
)
return self._underlying_attribute.__set__(session, value.value)
# nitclk specific attribute type
class AttributeSessionReference(Attribute):
def __get__(self, session, session_type):
# Import here to avoid a circular dependency when initial import happens
from ${module_name}.session import SessionReference
return SessionReference(session._get_attribute_vi_session(self._attribute_id))
def __set__(self, session, value):
session._set_attribute_vi_session(
self._attribute_id, _converters.convert_to_nitclk_session_number(value)
)