-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdataref.py
88 lines (67 loc) · 2.1 KB
/
dataref.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
'''
Dataref handling
'''
from XPLMDataAccess import *
from XPLMUtilities import *
from XPLMPlugin import *
from XPLMDefs import *
class DataRef():
'''
X-Plane Dataref handler
'''
@classmethod
def get_xp_dataref(cls, name):
ref = XPLMFindDataRef(name)
if ref is None:
raise Exception("Dataref not '%s' found" % name)
else:
return ref
@classmethod
def get_i(cls, name):
return XPLMGetDatai(cls.get_xp_dataref(name))
@classmethod
def set_i(cls, name, value):
return XPLMSetDatai(cls.get_xp_dataref(name), value)
@classmethod
def get_f(cls, name):
return XPLMGetDataf(cls.get_xp_dataref(name))
@classmethod
def set_f(cls, name, value):
return XPLMSetDataf(cls.get_xp_dataref(name), value)
@classmethod
def get_d(cls, name):
return XPLMGetDatad(cls.get_xp_dataref(name))
@classmethod
def set_d(cls, name, value):
return XPLMSetDatad(cls.get_xp_dataref(name), value)
@classmethod
def get_vb(cls, name, limit = 256):
value = []
XPLMGetDatab(cls.get_xp_dataref(name), value, 0, limit)
return value
@classmethod
def get_string(cls, name, limit = 256):
a = cls.get_vb(name, limit)
return "".join(a)
@classmethod
def set_vb(cls, name, value):
return XPLMSetDatab(cls.get_xp_dataref(name), value, 0, len(value))
@classmethod
def set_string(cls, name, value):
cls.set_vb(name, map(ord, value))
@classmethod
def get_vi(cls, name, limit = 1000):
value = []
XPLMGetDatavi(cls.get_xp_dataref(name), value, 0, limit)
return value
@classmethod
def set_vi(cls, name, value):
return XPLMSetDatavi(cls.get_xp_dataref(name), value, 0, len(value))
@classmethod
def get_vf(cls, name, limit = 1000):
value = []
XPLMGetDataf(cls.get_xp_dataref(name), value, 0, limit)
return value
@classmethod
def set_vf(cls, name, value):
return XPLMSetDatavf(cls.get_xp_dataref(name), value, 0, len(value))