0
|
1
|
|
2 class DMX(list):
|
|
3 """the signal that goes on a real-life dmx wire. it's up to 512
|
|
4 un-named channels each with a 8-bit value on each channel. this type
|
|
5 is useful for a DMXOut node or DMXLevelDisplay node. the channels are
|
|
6 stored in a python list where the first channel is at index 0. the
|
|
7 first channel in dmx terminology would be called channel 1."""
|
|
8
|
|
9 def __init__(self,dmxlevels):
|
|
10 if len(dmxlevels)>512:
|
|
11 raise TypeError("DMX objects can't have more than 512 channels")
|
|
12 list.extend(dmxlevels) # list.__init__ did't work right
|
|
13
|
|
14 def append(self,level):
|
|
15 if len(self)==512:
|
|
16 raise TypeError("DMX objects can't have more than 512 channels")
|
|
17 list.append(self,level)
|
|
18
|
|
19 def extend(self,levels):
|
|
20 if len(self)+len(levels)>512:
|
|
21 raise TypeError("DMX objects can't have more than 512 channels")
|
|
22 list.extend(self,levels)
|
|
23
|
|
24 def __setslice__(self,i,j,seq):
|
|
25 newlength = len(self)-(max(0,j)-max(0,i))+len(seq)
|
|
26 # we could check if newlength>512, but any length-changing slice is
|
|
27 # probably wrong for this datatype
|
|
28 if newlength!=len(self):
|
|
29 raise NotImplementedError("Different-length setslice would disturb DMX channels")
|
|
30 list.__setslice__(self,i,j,seq)
|
|
31
|