@@ -27,7 +27,6 @@ public class LEDSubsystemTest {
27
27
private final int LENGTH = 31 ;
28
28
private final int MIDDLE_START = 11 ;
29
29
private final int MIDDLE_END = 21 ;
30
- private LEDSubsystem m_ledSubsystem ;
31
30
32
31
private LEDStrip m_ledStrip1 ;
33
32
@@ -46,28 +45,24 @@ public void setup() {
46
45
// Create LED strip objects
47
46
m_ledStrip1 = new LEDStrip (new LEDStrip .Hardware (m_leds1 ));
48
47
49
- // Create LEDSubsystem object
50
- m_ledSubsystem = LEDSubsystem .getInstance ();
51
-
52
48
// Set LED strip for subsystem
53
- m_ledSubsystem .setLEDStrip (m_ledStrip1 );
49
+ LEDSubsystem . getInstance () .setLEDStrip (m_ledStrip1 );
54
50
}
55
51
56
52
@ AfterEach
57
53
public void close () {
58
- m_ledSubsystem .close ();
59
- m_ledSubsystem = null ;
54
+ LEDSubsystem .getInstance ().close ();
60
55
}
61
56
62
57
@ Test
63
58
@ Order (1 )
64
59
@ DisplayName ("Test if robot can set LED strip to single static solid color" )
65
60
public void solidFull () {
66
61
// Set LED pattern
67
- m_ledSubsystem .set (LEDPattern .solid (LEDStrip .TEAM_COLOR ), LEDStrip .Section .FULL );
62
+ LEDSubsystem . getInstance () .set (LEDPattern .solid (LEDStrip .TEAM_COLOR ), LEDStrip .Section .FULL );
68
63
69
64
// Run LED subsystem loop
70
- m_ledSubsystem .getDefaultCommand ().execute ();
65
+ LEDSubsystem . getInstance () .getDefaultCommand ().execute ();
71
66
72
67
Color ledBuffer [] = new Color [LENGTH ];
73
68
for (int i = 0 ; i < ledBuffer .length ; i ++) ledBuffer [i ] = m_ledStrip1 .getBuffer ().getLED (i );
@@ -82,11 +77,11 @@ public void solidFull() {
82
77
@ DisplayName ("Test if robot can set LED strip start section independently" )
83
78
public void startSection () {
84
79
// Set LED pattern
85
- m_ledSubsystem .set (LEDPattern .solid (Color .kRed ), Section .START );
86
- m_ledSubsystem .set (LEDPattern .solid (LEDStrip .TEAM_COLOR ), Section .MIDDLE , Section .END );
80
+ LEDSubsystem . getInstance () .set (LEDPattern .solid (Color .kRed ), Section .START );
81
+ LEDSubsystem . getInstance () .set (LEDPattern .solid (LEDStrip .TEAM_COLOR ), Section .MIDDLE , Section .END );
87
82
88
83
// Run LED subsystem loop
89
- m_ledSubsystem .getDefaultCommand ().execute ();
84
+ LEDSubsystem . getInstance () .getDefaultCommand ().execute ();
90
85
91
86
// Verify LED pattern
92
87
for (int i = 0 ; i < MIDDLE_START ; i ++)
@@ -100,11 +95,11 @@ public void startSection() {
100
95
@ DisplayName ("Test if robot can set LED strip middle section independently" )
101
96
public void middleSection () {
102
97
// Set LED pattern
103
- m_ledSubsystem .set (LEDPattern .solid (Color .kRed ), Section .MIDDLE );
104
- m_ledSubsystem .set (LEDPattern .solid (LEDStrip .TEAM_COLOR ), Section .START , Section .END );
98
+ LEDSubsystem . getInstance () .set (LEDPattern .solid (Color .kRed ), Section .MIDDLE );
99
+ LEDSubsystem . getInstance () .set (LEDPattern .solid (LEDStrip .TEAM_COLOR ), Section .START , Section .END );
105
100
106
101
// Run LED subsystem loop
107
- m_ledSubsystem .getDefaultCommand ().execute ();
102
+ LEDSubsystem . getInstance () .getDefaultCommand ().execute ();
108
103
109
104
Color ledBuffer [] = new Color [LENGTH ];
110
105
for (int i = 0 ; i < ledBuffer .length ; i ++) ledBuffer [i ] = m_ledStrip1 .getBuffer ().getLED (i );
@@ -123,11 +118,11 @@ public void middleSection() {
123
118
@ DisplayName ("Test if robot can set LED strip end section independently" )
124
119
public void endSection () {
125
120
// Set LED pattern
126
- m_ledSubsystem .set (LEDPattern .solid (Color .kRed ), Section .END );
127
- m_ledSubsystem .set (LEDPattern .solid (LEDStrip .TEAM_COLOR ), Section .START , Section .MIDDLE );
121
+ LEDSubsystem . getInstance () .set (LEDPattern .solid (Color .kRed ), Section .END );
122
+ LEDSubsystem . getInstance () .set (LEDPattern .solid (LEDStrip .TEAM_COLOR ), Section .START , Section .MIDDLE );
128
123
129
124
// Run LED subsystem loop
130
- m_ledSubsystem .getDefaultCommand ().execute ();
125
+ LEDSubsystem . getInstance () .getDefaultCommand ().execute ();
131
126
132
127
// Verify LED pattern
133
128
for (int i = 0 ; i < MIDDLE_END ; i ++)
@@ -141,13 +136,13 @@ public void endSection() {
141
136
@ DisplayName ("Test if robot can override subsystem LED control" )
142
137
public void ledOverride () {
143
138
// Set LED pattern
144
- m_ledSubsystem .set (LEDPattern .solid (Color .kBlue ), Section .FULL );
139
+ LEDSubsystem . getInstance () .set (LEDPattern .solid (Color .kBlue ), Section .FULL );
145
140
146
141
// Request LED override
147
- m_ledSubsystem .startOverride (LEDPattern .solid (LEDStrip .TEAM_COLOR ));
142
+ LEDSubsystem . getInstance () .startOverride (LEDPattern .solid (LEDStrip .TEAM_COLOR ));
148
143
149
144
// Run LED subsystem loop
150
- m_ledSubsystem .getDefaultCommand ().execute ();
145
+ LEDSubsystem . getInstance () .getDefaultCommand ().execute ();
151
146
152
147
// Verify LED pattern
153
148
for (int i = 0 ; i < LENGTH ; i ++)
@@ -156,10 +151,10 @@ public void ledOverride() {
156
151
assertEquals (LEDStrip .TEAM_COLOR , m_ledStrip1 .getBuffer ().getLED (i ));
157
152
158
153
// End LED override
159
- m_ledSubsystem .endOverride ();
154
+ LEDSubsystem . getInstance () .endOverride ();
160
155
161
156
// Run LED subsystem loop
162
- m_ledSubsystem .getDefaultCommand ().execute ();
157
+ LEDSubsystem . getInstance () .getDefaultCommand ().execute ();
163
158
164
159
// Verify LED pattern
165
160
for (int i = 0 ; i < LENGTH ; i ++)
0 commit comments