round trip metric

This commit is contained in:
rusefi 2020-07-25 10:01:46 -04:00
parent b99c81f7ac
commit 2c19ff8c48
3 changed files with 11 additions and 4 deletions

View File

@ -26,12 +26,12 @@ import java.util.concurrent.TimeUnit;
*/
public class NetworkConnector {
public static SessionDetails runNetworkConnector(String authToken, String controllerPort, int serverPortForControllers, TcpIoStream.DisconnectListener disconnectListener) throws InterruptedException, IOException {
LinkManager linkManager = new LinkManager()
LinkManager controllerConnector = new LinkManager()
.setCompositeLogicEnabled(false)
.setNeedPullData(false);
CountDownLatch onConnected = new CountDownLatch(1);
linkManager.startAndConnect(controllerPort, new ConnectionStateListener() {
controllerConnector.startAndConnect(controllerPort, new ConnectionStateListener() {
@Override
public void onConnectionEstablished() {
onConnected.countDown();
@ -50,7 +50,7 @@ public class NetworkConnector {
return null;
}
return runNetworkConnector(serverPortForControllers, linkManager, Logger.CONSOLE, authToken, disconnectListener);
return runNetworkConnector(serverPortForControllers, controllerConnector, Logger.CONSOLE, authToken, disconnectListener);
}
@NotNull

View File

@ -293,6 +293,7 @@ public class Backend implements Closeable {
.add(UserDetails.USER_ID, client.getUserDetails().getUserId())
.add(UserDetails.USERNAME, client.getUserDetails().getUserName())
.add(AGE, client.getBirthday().getDuration())
.add("OUTPUT_ROUND_TRIP", client.getOutputRoundAroundDuration())
.add(ProxyClient.IS_USED, client.getTwoKindSemaphore().isUsed())
.add(ControllerStateDetails.RPM, rpm)
.add(ControllerStateDetails.CLT, clt)

View File

@ -37,6 +37,7 @@ public class ControllerConnectionState {
private final TwoKindSemaphore twoKindSemaphore = new TwoKindSemaphore();
private final SensorsHolder sensorsHolder = new SensorsHolder();
private final Birthday birthday = new Birthday();
private int outputRoundAroundDuration;
public ControllerConnectionState(Socket clientSocket, UserDetailsResolver userDetailsResolver) {
this.clientSocket = clientSocket;
@ -53,6 +54,10 @@ public class ControllerConnectionState {
return birthday;
}
public int getOutputRoundAroundDuration() {
return outputRoundAroundDuration;
}
public IoStream getStream() {
return stream;
}
@ -98,10 +103,11 @@ public class ControllerConnectionState {
public void getOutputs() throws IOException {
byte[] commandPacket = GetOutputsCommand.createRequest();
long start = System.currentTimeMillis();
stream.sendPacket(commandPacket);
byte[] packet = incomingData.getPacket("msg", true);
outputRoundAroundDuration = (int) (System.currentTimeMillis() - start);
if (packet == null)
throw new IOException("getOutputs: No response");
sensorsHolder.grabSensorValues(packet);