@@ -60,28 +60,28 @@ private static final class PropertyPublisher implements AutoCloseable {
6060 try {
6161 switch (event .propertyKind ) {
6262 case kBoolean :
63- m_booleanValueEntry = table .getBooleanTopic (name ).getEntry (false );
64- m_booleanValueEntry .setDefault (event .value != 0 );
63+ booleanValueEntry = table .getBooleanTopic (name ).getEntry (false );
64+ booleanValueEntry .setDefault (event .value != 0 );
6565 break ;
6666 case kEnum :
67- m_choicesTopic = table .getStringArrayTopic (infoName + "/choices" );
67+ choicesTopic = table .getStringArrayTopic (infoName + "/choices" );
6868 // fallthrough
6969 case kInteger :
70- m_integerValueEntry = table .getIntegerTopic (name ).getEntry (0 );
71- m_minPublisher = table .getIntegerTopic (infoName + "/min" ).publish ();
72- m_maxPublisher = table .getIntegerTopic (infoName + "/max" ).publish ();
73- m_stepPublisher = table .getIntegerTopic (infoName + "/step" ).publish ();
74- m_defaultPublisher = table .getIntegerTopic (infoName + "/default" ).publish ();
75-
76- m_integerValueEntry .setDefault (event .value );
77- m_minPublisher .set (CameraServerJNI .getPropertyMin (event .propertyHandle ));
78- m_maxPublisher .set (CameraServerJNI .getPropertyMax (event .propertyHandle ));
79- m_stepPublisher .set (CameraServerJNI .getPropertyStep (event .propertyHandle ));
80- m_defaultPublisher .set (CameraServerJNI .getPropertyDefault (event .propertyHandle ));
70+ integerValueEntry = table .getIntegerTopic (name ).getEntry (0 );
71+ minPublisher = table .getIntegerTopic (infoName + "/min" ).publish ();
72+ maxPublisher = table .getIntegerTopic (infoName + "/max" ).publish ();
73+ stepPublisher = table .getIntegerTopic (infoName + "/step" ).publish ();
74+ defaultPublisher = table .getIntegerTopic (infoName + "/default" ).publish ();
75+
76+ integerValueEntry .setDefault (event .value );
77+ minPublisher .set (CameraServerJNI .getPropertyMin (event .propertyHandle ));
78+ maxPublisher .set (CameraServerJNI .getPropertyMax (event .propertyHandle ));
79+ stepPublisher .set (CameraServerJNI .getPropertyStep (event .propertyHandle ));
80+ defaultPublisher .set (CameraServerJNI .getPropertyDefault (event .propertyHandle ));
8181 break ;
8282 case kString :
83- m_stringValueEntry = table .getStringTopic (name ).getEntry ("" );
84- m_stringValueEntry .setDefault (event .valueStr );
83+ stringValueEntry = table .getStringTopic (name ).getEntry ("" );
84+ stringValueEntry .setDefault (event .valueStr );
8585 break ;
8686 default :
8787 break ;
@@ -94,18 +94,18 @@ private static final class PropertyPublisher implements AutoCloseable {
9494 void update (VideoEvent event ) {
9595 switch (event .propertyKind ) {
9696 case kBoolean -> {
97- if (m_booleanValueEntry != null ) {
98- m_booleanValueEntry .set (event .value != 0 );
97+ if (booleanValueEntry != null ) {
98+ booleanValueEntry .set (event .value != 0 );
9999 }
100100 }
101101 case kInteger , kEnum -> {
102- if (m_integerValueEntry != null ) {
103- m_integerValueEntry .set (event .value );
102+ if (integerValueEntry != null ) {
103+ integerValueEntry .set (event .value );
104104 }
105105 }
106106 case kString -> {
107- if (m_stringValueEntry != null ) {
108- m_stringValueEntry .set (event .valueStr );
107+ if (stringValueEntry != null ) {
108+ stringValueEntry .set (event .valueStr );
109109 }
110110 }
111111 default -> {
@@ -117,91 +117,91 @@ void update(VideoEvent event) {
117117 @ Override
118118 public void close () {
119119 try {
120- if (m_booleanValueEntry != null ) {
121- m_booleanValueEntry .close ();
120+ if (booleanValueEntry != null ) {
121+ booleanValueEntry .close ();
122122 }
123- if (m_integerValueEntry != null ) {
124- m_integerValueEntry .close ();
123+ if (integerValueEntry != null ) {
124+ integerValueEntry .close ();
125125 }
126- if (m_stringValueEntry != null ) {
127- m_stringValueEntry .close ();
126+ if (stringValueEntry != null ) {
127+ stringValueEntry .close ();
128128 }
129- if (m_minPublisher != null ) {
130- m_minPublisher .close ();
129+ if (minPublisher != null ) {
130+ minPublisher .close ();
131131 }
132- if (m_maxPublisher != null ) {
133- m_maxPublisher .close ();
132+ if (maxPublisher != null ) {
133+ maxPublisher .close ();
134134 }
135- if (m_stepPublisher != null ) {
136- m_stepPublisher .close ();
135+ if (stepPublisher != null ) {
136+ stepPublisher .close ();
137137 }
138- if (m_defaultPublisher != null ) {
139- m_defaultPublisher .close ();
138+ if (defaultPublisher != null ) {
139+ defaultPublisher .close ();
140140 }
141- if (m_choicesPublisher != null ) {
142- m_choicesPublisher .close ();
141+ if (choicesPublisher != null ) {
142+ choicesPublisher .close ();
143143 }
144144 } finally {
145145 Reference .reachabilityFence (m_videoListener );
146146 }
147147 }
148148
149- BooleanEntry m_booleanValueEntry ;
150- IntegerEntry m_integerValueEntry ;
151- StringEntry m_stringValueEntry ;
152- IntegerPublisher m_minPublisher ;
153- IntegerPublisher m_maxPublisher ;
154- IntegerPublisher m_stepPublisher ;
155- IntegerPublisher m_defaultPublisher ;
156- StringArrayTopic m_choicesTopic ;
157- StringArrayPublisher m_choicesPublisher ;
149+ BooleanEntry booleanValueEntry ;
150+ IntegerEntry integerValueEntry ;
151+ StringEntry stringValueEntry ;
152+ IntegerPublisher minPublisher ;
153+ IntegerPublisher maxPublisher ;
154+ IntegerPublisher stepPublisher ;
155+ IntegerPublisher defaultPublisher ;
156+ StringArrayTopic choicesTopic ;
157+ StringArrayPublisher choicesPublisher ;
158158 }
159159
160160 private static final class SourcePublisher implements AutoCloseable {
161161 SourcePublisher (NetworkTable table , int sourceHandle ) {
162- this .m_table = table ;
163- m_sourcePublisher = table .getStringTopic ("source" ).publish ();
164- m_descriptionPublisher = table .getStringTopic ("description" ).publish ();
165- m_connectedPublisher = table .getBooleanTopic ("connected" ).publish ();
166- m_streamsPublisher = table .getStringArrayTopic ("streams" ).publish ();
167- m_modeEntry = table .getStringTopic ("mode" ).getEntry ("" );
168- m_modesPublisher = table .getStringArrayTopic ("modes" ).publish ();
169-
170- m_sourcePublisher .set (makeSourceValue (sourceHandle ));
171- m_descriptionPublisher .set (CameraServerJNI .getSourceDescription (sourceHandle ));
172- m_connectedPublisher .set (CameraServerJNI .isSourceConnected (sourceHandle ));
173- m_streamsPublisher .set (getSourceStreamValues (sourceHandle ));
162+ this .table = table ;
163+ sourceUriPublisher = table .getStringTopic ("source" ).publish ();
164+ descriptionPublisher = table .getStringTopic ("description" ).publish ();
165+ connectedPublisher = table .getBooleanTopic ("connected" ).publish ();
166+ streamsPublisher = table .getStringArrayTopic ("streams" ).publish ();
167+ modeEntry = table .getStringTopic ("mode" ).getEntry ("" );
168+ modesPublisher = table .getStringArrayTopic ("modes" ).publish ();
169+
170+ sourceUriPublisher .set (makeSourceValue (sourceHandle ));
171+ descriptionPublisher .set (CameraServerJNI .getSourceDescription (sourceHandle ));
172+ connectedPublisher .set (CameraServerJNI .isSourceConnected (sourceHandle ));
173+ streamsPublisher .set (getSourceStreamValues (sourceHandle ));
174174
175175 try {
176176 VideoMode mode = CameraServerJNI .getSourceVideoMode (sourceHandle );
177- m_modeEntry .setDefault (videoModeToString (mode ));
178- m_modesPublisher .set (getSourceModeValues (sourceHandle ));
177+ modeEntry .setDefault (videoModeToString (mode ));
178+ modesPublisher .set (getSourceModeValues (sourceHandle ));
179179 } catch (VideoException ignored ) {
180180 // Do nothing. Let the other event handlers update this if there is an error.
181181 }
182182 }
183183
184184 @ Override
185185 public void close () throws Exception {
186- m_sourcePublisher .close ();
187- m_descriptionPublisher .close ();
188- m_connectedPublisher .close ();
189- m_streamsPublisher .close ();
190- m_modeEntry .close ();
191- m_modesPublisher .close ();
192- for (PropertyPublisher pp : m_properties .values ()) {
186+ sourceUriPublisher .close ();
187+ descriptionPublisher .close ();
188+ connectedPublisher .close ();
189+ streamsPublisher .close ();
190+ modeEntry .close ();
191+ modesPublisher .close ();
192+ for (PropertyPublisher pp : properties .values ()) {
193193 pp .close ();
194194 }
195195 }
196196
197- final NetworkTable m_table ;
198- final StringPublisher m_sourcePublisher ;
199- final StringPublisher m_descriptionPublisher ;
200- final BooleanPublisher m_connectedPublisher ;
201- final StringArrayPublisher m_streamsPublisher ;
202- final StringEntry m_modeEntry ;
203- final StringArrayPublisher m_modesPublisher ;
204- final Map <Integer , PropertyPublisher > m_properties = new HashMap <>();
197+ final NetworkTable table ;
198+ final StringPublisher sourceUriPublisher ;
199+ final StringPublisher descriptionPublisher ;
200+ final BooleanPublisher connectedPublisher ;
201+ final StringArrayPublisher streamsPublisher ;
202+ final StringEntry modeEntry ;
203+ final StringArrayPublisher modesPublisher ;
204+ final Map <Integer , PropertyPublisher > properties = new HashMap <>();
205205 }
206206
207207 private static final AtomicInteger m_defaultUsbDevice = new AtomicInteger ();
@@ -253,40 +253,40 @@ public void close() throws Exception {
253253 SourcePublisher publisher = m_publishers .get (event .sourceHandle );
254254 if (publisher != null ) {
255255 // update the description too (as it may have changed)
256- publisher .m_descriptionPublisher .set (
256+ publisher .descriptionPublisher .set (
257257 CameraServerJNI .getSourceDescription (event .sourceHandle ));
258- publisher .m_connectedPublisher .set (true );
258+ publisher .connectedPublisher .set (true );
259259 }
260260 }
261261 case kSourceDisconnected -> {
262262 SourcePublisher publisher = m_publishers .get (event .sourceHandle );
263263 if (publisher != null ) {
264- publisher .m_connectedPublisher .set (false );
264+ publisher .connectedPublisher .set (false );
265265 }
266266 }
267267 case kSourceVideoModesUpdated -> {
268268 SourcePublisher publisher = m_publishers .get (event .sourceHandle );
269269 if (publisher != null ) {
270- publisher .m_modesPublisher .set (getSourceModeValues (event .sourceHandle ));
270+ publisher .modesPublisher .set (getSourceModeValues (event .sourceHandle ));
271271 }
272272 }
273273 case kSourceVideoModeChanged -> {
274274 SourcePublisher publisher = m_publishers .get (event .sourceHandle );
275275 if (publisher != null ) {
276- publisher .m_modeEntry .set (videoModeToString (event .mode ));
276+ publisher .modeEntry .set (videoModeToString (event .mode ));
277277 }
278278 }
279279 case kSourcePropertyCreated -> {
280280 SourcePublisher publisher = m_publishers .get (event .sourceHandle );
281281 if (publisher != null ) {
282- publisher .m_properties .put (
283- event .propertyHandle , new PropertyPublisher (publisher .m_table , event ));
282+ publisher .properties .put (
283+ event .propertyHandle , new PropertyPublisher (publisher .table , event ));
284284 }
285285 }
286286 case kSourcePropertyValueUpdated -> {
287287 SourcePublisher publisher = m_publishers .get (event .sourceHandle );
288288 if (publisher != null ) {
289- PropertyPublisher pp = publisher .m_properties .get (event .propertyHandle );
289+ PropertyPublisher pp = publisher .properties .get (event .propertyHandle );
290290 if (pp != null ) {
291291 pp .update (event );
292292 }
@@ -295,15 +295,15 @@ public void close() throws Exception {
295295 case kSourcePropertyChoicesUpdated -> {
296296 SourcePublisher publisher = m_publishers .get (event .sourceHandle );
297297 if (publisher != null ) {
298- PropertyPublisher pp = publisher .m_properties .get (event .propertyHandle );
299- if (pp != null && pp .m_choicesTopic != null ) {
298+ PropertyPublisher pp = publisher .properties .get (event .propertyHandle );
299+ if (pp != null && pp .choicesTopic != null ) {
300300 try {
301301 String [] choices =
302302 CameraServerJNI .getEnumPropertyChoices (event .propertyHandle );
303- if (pp .m_choicesPublisher == null ) {
304- pp .m_choicesPublisher = pp .m_choicesTopic .publish ();
303+ if (pp .choicesPublisher == null ) {
304+ pp .choicesPublisher = pp .choicesTopic .publish ();
305305 }
306- pp .m_choicesPublisher .set (choices );
306+ pp .choicesPublisher .set (choices );
307307 } catch (VideoException ignored ) {
308308 // ignore (just don't publish choices if we can't get them)
309309 }
@@ -459,7 +459,7 @@ private static synchronized void updateStreamValues() {
459459 // Set table value
460460 String [] values = getSinkStreamValues (sink );
461461 if (values .length > 0 ) {
462- publisher .m_streamsPublisher .set (values );
462+ publisher .streamsPublisher .set (values );
463463 }
464464 }
465465 }
@@ -474,7 +474,7 @@ private static synchronized void updateStreamValues() {
474474 // Set table value
475475 String [] values = getSourceStreamValues (source );
476476 if (values .length > 0 ) {
477- publisher .m_streamsPublisher .set (values );
477+ publisher .streamsPublisher .set (values );
478478 }
479479 }
480480 }
0 commit comments