Skip to content

Commit

Permalink
Resolve "Connect AutoRef to correct GC address"
Browse files Browse the repository at this point in the history
Closes #1583

See merge request main/Sumatra!1329

sumatra-commit: d6c67bc1d00e369f759cb83b8d36162445eef67b
  • Loading branch information
g3force authored and TIGERs GitLab committed Feb 20, 2021
1 parent 8ed9329 commit d84420d
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 20 deletions.
2 changes: 0 additions & 2 deletions config/moduli/moduli.xml
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,8 @@
<implementation>edu.tigers.sumatra.wp.exporter.VisionTrackerSender</implementation>

<properties>
<source-name>TIGERs AutoRef</source-name>
<address>224.5.23.2</address>
<port>10010</port>
<!-- <interface>enp12s0</interface>-->
</properties>
</module>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
/*
* Copyright (c) 2009 - 2019, DHBW Mannheim - TIGERs Mannheim
* Copyright (c) 2009 - 2021, DHBW Mannheim - TIGERs Mannheim
*/
package edu.tigers.autoreferee.engine;

import java.net.InetAddress;
import java.util.Set;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import edu.tigers.autoreferee.IAutoRefFrame;
import edu.tigers.autoreferee.engine.detector.EGameEventDetectorType;
import edu.tigers.autoreferee.module.AutoRefModule;
Expand All @@ -21,6 +15,11 @@
import edu.tigers.sumatra.referee.control.GcEventFactory;
import edu.tigers.sumatra.referee.data.EGameState;
import edu.tigers.sumatra.referee.gameevent.IGameEvent;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import java.net.InetAddress;
import java.util.Set;


public class ActiveAutoRefEngine extends AutoRefEngine
Expand Down Expand Up @@ -65,6 +64,12 @@ public void stop()
@Override
public void process(final IAutoRefFrame frame)
{
AReferee referee = SumatraModel.getInstance().getModule(AReferee.class);
String hostname = referee.getActiveSource().getRefBoxAddress()
.map(InetAddress::getHostAddress)
.orElse(DEFAULT_REFEREE_HOST);
remote.updateHostname(hostname);

processEngine(frame).forEach(this::processGameEvent);

if (SumatraModel.getInstance().isSimulation())
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2009 - 2020, DHBW Mannheim - TIGERs Mannheim
* Copyright (c) 2009 - 2021, DHBW Mannheim - TIGERs Mannheim
*/
package edu.tigers.autoreferee.remote;

Expand Down Expand Up @@ -65,6 +65,12 @@ public AutoRefToGameControllerConnector(final String hostname, final int port)
}


public void updateHostname(String hostname)
{
protocol.setHostname(hostname);
}


private void register()
{
log.debug("Starting registering");
Expand Down Expand Up @@ -209,6 +215,7 @@ public void addGameEventResponseObserver(IGameEventResponseObserver observer)
this.responseObserverList.add(observer);
}


private static class QueueEntry
{
private final IGameEvent event;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
/*
* Copyright (c) 2009 - 2019, DHBW Mannheim - TIGERs Mannheim
* Copyright (c) 2009 - 2021, DHBW Mannheim - TIGERs Mannheim
*/

package edu.tigers.sumatra.referee;

import com.google.protobuf.Message;
import com.google.protobuf.Parser;
import lombok.Setter;
import lombok.extern.log4j.Log4j2;

import java.io.IOException;
import java.net.Socket;
import java.util.ArrayList;
import java.util.List;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import com.google.protobuf.Message;
import com.google.protobuf.Parser;


/**
* Main Class to interact with the new (2019) SSL GameController Protocol
Expand All @@ -23,10 +22,10 @@
* For more details about this protocol, visit the Repository of the official SSL-Game-Controller:
* https://github.com/RoboCup-SSL/ssl-game-controller
*/
@Log4j2
public class GameControllerProtocol
{
private static final Logger log = LogManager.getLogger(GameControllerProtocol.class);

@Setter
private String hostname;
private Socket socket;
private int port;
Expand Down Expand Up @@ -115,7 +114,7 @@ private boolean connect()
return true;
} catch (IOException e)
{
log.warn("Connection to SSL-Game-Controller Failed", e);
log.warn("Connection to SSL-Game-Controller ({}:{}) failed", hostname, port, e);
}
return false;
}
Expand Down

0 comments on commit d84420d

Please sign in to comment.