/
goodoutput.go
139 lines (120 loc) · 2.87 KB
/
goodoutput.go
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
130
131
132
133
134
135
136
137
138
139
package code
// GoodOutput indicates output status of the node
type GoodOutput uint8
// WithACN sets Output to transmit sACN
func (s GoodOutput) WithACN(enable bool) GoodOutput {
if enable {
return s | (1 << 0)
}
return s | (0 << 0)
}
// ACN indicates Output is selected to transmit sACN
func (s GoodOutput) ACN() bool {
return s&(1<<0) > 0
}
// WithLTP sets Merge Mode is LTP
func (s GoodOutput) WithLTP(enable bool) GoodOutput {
if enable {
return s | (1 << 1)
}
return s | (0 << 1)
}
// LTP indicates Merge Mode is LTP
func (s GoodOutput) LTP() bool {
return s&(1<<1) > 0
}
// WithOutput sets DMX output short detected on power up
func (s GoodOutput) WithOutput(enable bool) GoodOutput {
if enable {
return s | (1 << 2)
}
return s | (0 << 2)
}
// Output indicates DMX output short detected on power up
func (s GoodOutput) Output() bool {
return s&(1<<2) > 0
}
// WithMerging sets Output is merging ArtNet data
func (s GoodOutput) WithMerging(enable bool) GoodOutput {
if enable {
return s | (1 << 3)
}
return s | (0 << 3)
}
// Merging indicates Output is merging ArtNet data
func (s GoodOutput) Merging() bool {
return s&(1<<3) > 0
}
// WithText sets Channel includes DMX512 text packets
func (s GoodOutput) WithText(enable bool) GoodOutput {
if enable {
return s | (1 << 4)
}
return s | (0 << 4)
}
// Text indicates Channel includes DMX512 text packets
func (s GoodOutput) Text() bool {
return s&(1<<4) > 0
}
// WithSIP sets Channel includes DMX512 SIP’s
func (s GoodOutput) WithSIP(enable bool) GoodOutput {
if enable {
return s | (1 << 5)
}
return s | (0 << 5)
}
// SIP indicates Channel includes DMX512 SIP’s
func (s GoodOutput) SIP() bool {
return s&(1<<5) > 0
}
// WithTest sets Channel includes DMX512 test packets
func (s GoodOutput) WithTest(enable bool) GoodOutput {
if enable {
return s | (1 << 6)
}
return s | (0 << 6)
}
// Test indicates Channel includes DMX512 test packets
func (s GoodOutput) Test() bool {
return s&(1<<6) > 0
}
// WithData sets Data transmitted
func (s GoodOutput) WithData(enable bool) GoodOutput {
if enable {
return s | (1 << 7)
}
return s | (0 << 7)
}
// Data indicates Data transmitted
func (s GoodOutput) Data() bool {
return s&(1<<7) > 0
}
// String returns a string representation of GoodOutput
func (s GoodOutput) String() string {
acn, ltp, output, merging, text, sip, test, data := "no", "no", "no", "no", "no", "no", "no", "no"
if s.LTP() {
ltp = "yes"
}
if s.ACN() {
acn = "yes"
}
if s.Output() {
output = "yes"
}
if s.Merging() {
merging = "yes"
}
if s.Text() {
text = "yes"
}
if s.SIP() {
sip = "yes"
}
if s.Test() {
test = "yes"
}
if s.Data() {
data = "yes"
}
return "GoodOutput: OutputACN: " + acn + ", LTPMergeMode: " + ltp + ", OutputShort: " + output + ", Merging: " + merging + ", DMX512Text: " + text + ", DMX512SIP: " + sip + ", DMX512Test: " + test + ", DataSending: " + data
}