|
1 | 1 | package org.strykeforce.thirdcoast.telemetry; |
2 | 2 |
|
3 | 3 | import com.ctre.phoenix.motorcontrol.can.TalonSRX; |
4 | | -import java.util.Collection; |
5 | | -import java.util.Collections; |
6 | | -import java.util.LinkedHashSet; |
7 | | -import java.util.Optional; |
8 | | -import java.util.Set; |
9 | | -import javax.inject.Inject; |
10 | | -import javax.inject.Singleton; |
11 | 4 | import org.slf4j.Logger; |
12 | 5 | import org.slf4j.LoggerFactory; |
| 6 | +import org.strykeforce.thirdcoast.swerve.SwerveDrive; |
| 7 | +import org.strykeforce.thirdcoast.swerve.Wheel; |
13 | 8 | import org.strykeforce.thirdcoast.talon.config.StatusFrameRate; |
14 | 9 | import org.strykeforce.thirdcoast.telemetry.item.Item; |
15 | 10 | import org.strykeforce.thirdcoast.telemetry.item.TalonItem; |
16 | 11 |
|
| 12 | +import javax.inject.Inject; |
| 13 | +import javax.inject.Singleton; |
| 14 | +import java.util.*; |
| 15 | + |
17 | 16 | /** |
18 | 17 | * The Telemetry service registers {@link Item} instances for data collection and controls the |
19 | 18 | * starting and stopping of the service. When active, the services listens for incoming config |
@@ -79,17 +78,6 @@ public void clear() { |
79 | 78 | logger.info("item set was cleared"); |
80 | 79 | } |
81 | 80 |
|
82 | | - /** |
83 | | - * Convenience method to register a TalonSRX for telemetry sending. |
84 | | - * |
85 | | - * @param talon the TalonSRX to register for data collection |
86 | | - * @throws IllegalStateException if TelemetryService is running. |
87 | | - * @see StatusFrameRate |
88 | | - */ |
89 | | - public void register(TalonSRX talon) { |
90 | | - register(new TalonItem(talon)); |
91 | | - } |
92 | | - |
93 | 81 | /** |
94 | 82 | * Registers an Item for telemetry sending. |
95 | 83 | * |
@@ -117,6 +105,31 @@ public void registerAll(Collection<Item> collection) { |
117 | 105 | logger.info("registered all: {}", collection); |
118 | 106 | } |
119 | 107 |
|
| 108 | + /** |
| 109 | + * Convenience method to register a {@code TalonSRX} for telemetry sending. |
| 110 | + * |
| 111 | + * @param talon the TalonSRX to register for data collection |
| 112 | + * @throws IllegalStateException if TelemetryService is running. |
| 113 | + * @see StatusFrameRate |
| 114 | + */ |
| 115 | + public void register(TalonSRX talon) { |
| 116 | + register(new TalonItem(talon)); |
| 117 | + } |
| 118 | + |
| 119 | + /** |
| 120 | + * Convenience method to register a {@code SwerveDrive} for telemetry sending. |
| 121 | + * |
| 122 | + * @param swerveDrive the SwerveDrive to register for data collection |
| 123 | + * @throws IllegalStateException if TelemetryService is running. |
| 124 | + * @see StatusFrameRate |
| 125 | + */ |
| 126 | + public void register(SwerveDrive swerveDrive) { |
| 127 | + for (Wheel wheel : swerveDrive.getWheels()) { |
| 128 | + register(new TalonItem(wheel.getAzimuthTalon())); |
| 129 | + register(new TalonItem(wheel.getDriveTalon())); |
| 130 | + } |
| 131 | + } |
| 132 | + |
120 | 133 | /** |
121 | 134 | * Configure the Talon with the given ID with the given status frame rates. |
122 | 135 | * |
|
0 commit comments