forked from RTTrP/RTTrP-v2.4.2.0
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy paththirdParty_lighting.py
102 lines (81 loc) · 3.38 KB
/
thirdParty_lighting.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
96
97
98
99
100
101
102
import struct
import RTTrP
class RTTrPL():
def __init__(self, header):
self.rttrp_head = header
self.data = header.data
class Packet():
# Generic packet information, each module contains this data, which
# is used to help determine how to proceed with data extraction
def __init__(self, data, intSig, fltSig):
self.pkType = data[0]
self.intSig = intSig
self.fltSig = fltSig
self.data = data[1:]
class LightingOutputModule(Packet):
def __init__(self, data, intSig, fltSig):
super().__init__(data, intSig, fltSig)
if (hex(self.intSig) == "0x4154"):
(self.size, self.sequenceNumber, self.actionType, self.holdTime, self.numUniverses) = \
struct.unpack("!HfBfH", self.data[0:13])
elif (hex(slef.intSig) == "0x5441"):
(self.size, self.sequenceNumber, self.actionType, self.holdTime, self.numUniverses) = \
struct.unpack("HfBfH", self.data[0:13])
self.data = self.data[13:]
def printModule(self):
print("=============Lighting Output Module==============")
print("Packet Type : ", hex(self.pkType))
print("Packet Size : ", self.size)
print("Sequence Number : ", self.sequenceNumber)
if (hex(self.actionType) == "0x01"):
print("Action : Snapshot")
elif (hex(self.actionType) == "0x00"):
print("Action : Update")
else:
print("Action : Unknown")
print("Hold Time : ", self.holdTime)
print("Num of Universes : ", self.numUniverses)
#Snapshots contain universe(s)
class UniverseModule(Packet):
def __init__(self, data, intSig, fltSig):
super().__init__(data, intSig, fltSig)
if (hex(self.intSig) == "0x4154"):
(self.size, self.universeID, self.numSpots) = struct.unpack("!HHH", self.data[0:6])
elif (hex(slef.intSig) == "0x5441"):
(self.size, self.universeID, self.numSpots) = struct.unpack("HHH", self.data[0:6])
self.data = self.data[6:]
def printModule(self):
print("=============Universe Module==============")
print("Packet Type : ", hex(self.pkType))
print("Packet Size : ", self.size)
print("Universe ID : ", self.universeID)
print("Num of Spots : ", self.numSpots)
#Universes contain spot(s)
class SpotModule(Packet):
def __init__(self, data, intSig, fltSig):
super().__init__(data, intSig, fltSig)
if (hex(self.intSig) == "0x4154"):
(self.size, self.spotID, self.spotOffset, self.numChannels) = struct.unpack("!HHHH", self.data[0:8])
elif (hex(slef.intSig) == "0x5441"):
(self.size, self.spotID, self.spotOffset, self.numChannels) = struct.unpack("HHHH", self.data[0:8])
self.data = self.data[8:]
def printModule(self):
print("=============Spot Module==============")
print("Packet Type : ", hex(self.pkType))
print("Packet Size : ", self.size)
print("Spot ID : ", self.spotID)
print("Num of Channels : ", self.numChannels)
#Spots contain channel(s)
class ChannelModule(Packet):
def __init__(self, data, intSig, fltSig):
super().__init__(data, intSig, fltSig)
if (hex(self.intSig) == "0x4154"):
(self.channelOffset, self.xFade, self.channelValue) = struct.unpack("!HHB", self.data[0:6])
elif (hex(slef.intSig) == "0x5441"):
(self.channelOffset, self.xFade, self.channelValue) = struct.unpack("HHB", self.data[0:6])
self.data = self.data[6:]
def printModule(self):
print("=============Channel Module==============")
print("Packet Type : ", hex(self.pkType))
print("CHannel : ", self.channelOffset)
print("Value : ", self.channelValue)