mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-07-03 03:01:44 +00:00
[wpilib] Publish AllianceStationID (#8856)
Glass now internally uses the AllianceStationID enum, but the two separate topics remain for simple use cases. The Invalid alliance is now published as Red, Station 0, instead of 3. Fixes #6488 and fixes #8725.
This commit is contained in:
@@ -107,6 +107,8 @@ struct MatchDataSender {
|
||||
true};
|
||||
MatchDataSenderEntry<wpi::nt::IntegerTopic> station{table, "StationNumber",
|
||||
1};
|
||||
MatchDataSenderEntry<wpi::nt::IntegerTopic> allianceStation{
|
||||
table, "AllianceStationID", 0};
|
||||
wpi::nt::StructPublisher<wpi::hal::ControlWord> controlWord;
|
||||
wpi::nt::StringPublisher opMode;
|
||||
wpi::hal::ControlWord prevControlWord;
|
||||
@@ -931,10 +933,14 @@ void SendMatchData() {
|
||||
isRedAlliance = true;
|
||||
stationNumber = 2;
|
||||
break;
|
||||
default:
|
||||
case HAL_ALLIANCE_STATION_RED_3:
|
||||
isRedAlliance = true;
|
||||
stationNumber = 3;
|
||||
break;
|
||||
default:
|
||||
isRedAlliance = true;
|
||||
stationNumber = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
HAL_MatchInfo tmpDataStore;
|
||||
@@ -944,14 +950,15 @@ void SendMatchData() {
|
||||
HAL_GetGameData(&tmpGameData);
|
||||
|
||||
auto& inst = GetInstance();
|
||||
inst.matchDataSender.alliance.Set(isRedAlliance);
|
||||
inst.matchDataSender.station.Set(stationNumber);
|
||||
inst.matchDataSender.eventName.Set(tmpDataStore.eventName);
|
||||
inst.matchDataSender.gameData.Set(
|
||||
std::string(reinterpret_cast<char*>(tmpGameData.gameData)));
|
||||
inst.matchDataSender.matchNumber.Set(tmpDataStore.matchNumber);
|
||||
inst.matchDataSender.replayNumber.Set(tmpDataStore.replayNumber);
|
||||
inst.matchDataSender.matchType.Set(static_cast<int>(tmpDataStore.matchType));
|
||||
inst.matchDataSender.alliance.Set(isRedAlliance);
|
||||
inst.matchDataSender.station.Set(stationNumber);
|
||||
inst.matchDataSender.allianceStation.Set(alliance);
|
||||
|
||||
hal::ControlWord ctlWord = hal::GetControlWord();
|
||||
if (ctlWord != inst.matchDataSender.prevControlWord) {
|
||||
|
||||
Reference in New Issue
Block a user