ets2-job-logger

ETS2 Job Logger

ETS2 Job Logger

Cross-platform Euro Truck Simulator 2 and American Truck Simulator job logger written in C++.

Linux Windows MacOS
pipeline status Build status see #16

Functionality

ETS2 Job Logger consists of wxWidgets based application and ETS2 plugin.

Plugin sends job related data to the application via websocket. Application then sends a POST request to the specified API URL when a new job is taken or a current job is delivered. See JSON Format paragraph for details of the format sent to your API endpoint.

Applications stores job information in memory until it's sent to your API. If sending failed, eg. your API did not return expected HTTP code, applications tries to send it again later until it's sent successfully.

API Documentation

Current version v1.

URL

Differents payload will be sent with POST request to <API_URL>/<API_VERSION>/<MESSAGE>. In rest of this document <API_URL> will refer to URL of <API_URL>/<API_VERSION>.

API is being expected to response with HTTP code 200 on succes.

Job

Jobs will be sent to API to <API_URL>/job when user takes a job or cancels or delivers it.

Below is an example of JSON format for a job.

{
    "game": "ets2",               // Game type (ets2, ats)
    "status": 1,                  // 0 = FreeAsWind, 1 = OnJob, 2 = Cancelled, 3 = Delivered
    "income": 6878,               // In game specific units (€, $)
    "maxSpeed": 0.0,              // Maximum  speed during the delivery (can be negative)
    "fuelConsumed": 0.0,          // Liters
    "distance": {
        "driven": 0.0,            // Kilometers
        "planned": 248            // Planned trip distance kilometers
    },
    "cargo": {
        "id": "paper",
        "name": "Office Paper",
        "mass": 18000.0           // Kilograms
        "damage": 0.0,            // Percentage (e.g. 10.0 = 10%)
    },
    "source": {
        "city": {
            "id": "tampere",
            "name": "Tampere"
        },
        "company": {
            "id": "viljo_paper",
            "name": "Viljo Paperitehdas Oy"
        }
    },
    "destination": {
        "city": {
            "id": "helsinki",
            "name": "Helsinki"
        },
        "company": {
            "id": "cont_port",
            "name": "Container Port"
        }
    }
}

Truck

Trucks positional data will be sent to <API_URL>/truck once in a second only if game is not paused.

Below is an example of JSON format for a truck positional data.

{
    "speed": 0.0,
    "heading": 0.723,
    "x": 34496.559,
    "y": 11.938,
    "z": -61094.948
}

Building

Dependencies

  • cmake
  • msgpack
  • websocketpp
  • curl
  • openssl
  • jsoncpp
  • wxWidgets

Windows

Install conan. Open PowerShell and add remotes for conan:

conan remote add public-conan https://api.bintray.com/conan/bincrafters/public-conan
conan remote add theirix https://api.bintray.com/conan/bincrafters/theirix
  • Open project in Visual Studio via File -> Open -> CMake... by choosing the CMakeListst.xt.
  • Edit CMake options via CMake -> Change CMake settings -> CMakelists.txt
    • Change generator value to Visual Studio 15 2017 Win64.
    • Remove -v from buildCommandArgs or specify valid verbosity level.
  • CMake will produce error, note down the path from the error:

    include could not find load file:

    C:/Users/Test/CMakeBuilds/d76aad98-e5ad-0738-bbe9-bc20c6d93f9c/build/x64-Debug/conanbuildinfo.cmake`

  • Open PowerShell in the source directory and run:
    • conan install . -s build_type=Debug -if='<PATH_FROM_PREVIOUS_STEP>'
  • After installation finished go back to Visual Studio click Generate in the notification.
  • After CMake generation finished you're ready to build.

When you're ready to build a release just replace Debug with Release in:

  • CMakeSettings.json (CMake -> Change CMake settings -> CMakelists.txt)
  • Replace all Debug parts of the conan install command.


Content fethced from Gitlab trough Gitlab API.