Class TestController


  • public final class TestController
    extends Object
    Test client for AimsunController.

    Copyright (c) 2013-2020 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
    BSD-style license. See OpenTrafficSim License.

    Version:
    $Revision$, $LastChangedDate$, by $Author$, initial version Apr 18, 2017
    Author:
    Alexander Verbraeck, Peter Knoppers, Wouter Schakel
    • Method Detail

      • main

        public static void main​(String[] args)
                         throws IOException
        Parameters:
        args - String[]; command line arguments
        Throws:
        IOException - when communication fails
      • sendProtoMessage

        public static void sendProtoMessage​(OutputStream outputStream,
                                            AimsunControlProtoBuf.OTSMessage message)
                                     throws IOException
        Transit one message to the OTS server.
        Parameters:
        outputStream - OutputStream; output stream to the OTS server
        message - AimsunControlProtoBuf.OTSMessage; the message
        Throws:
        IOException - when communication fails in any way
      • receiveProtoMessage

        public static AimsunControlProtoBuf.OTSMessage receiveProtoMessage​(InputStream inputStream)
                                                                    throws IOException
        Read one OTSMessage.
        Parameters:
        inputStream - InputStream; input stream to read from
        Returns:
        OTSMessage; the OTSMessage that was constructed from the read bytes
        Throws:
        IOException - when communication fails
      • receiveBytes

        public static byte[] receiveBytes​(InputStream inputStream,
                                          int size)
                                   throws IOException
        Read a specified number of bytes.
        Parameters:
        inputStream - InputStream; input stream to read from
        size - int; number of bytes to read
        Returns:
        byte[]; byte array filled with the read bytes
        Throws:
        IOException - when communication fails