Simresults is an open-source, object-oriented library built using PHP. It allows you to read out log files of a race game and transforms them to a simple data model to easily read out this data.
This project is the core of the website simresults.net , which allows you to upload your race log files and transform them to a readable format. The uploaded results become saved and public, so visitors can share them with their fellow racers. An example result can be found at http://simresults.net/130529-X2g.
The website is a service but also a demonstration of what is possible using this library. This library does not supply any HTML templates or whatsoever. Any 'implementation' is up to you within your own project and is not limited to any framework.
This project is created (2013) and maintained by Maurice van der Star
Please consider donating to cover future development.
It's also possible to use the Simresults website remote results API. This requires much less work and programming knowledge.
Simresults supports a wide range of games:
The following expansions of RACE (07) should work too:
Please note that Formula Truck will be reported as as a rFactor game.
Results from F1 challenge and GTR might miss laps.
Results from Assetto Corsa (race_out.json) and Raceroom might only contain 1 lap.
getBestLap()
and
getBestLapBySector(<int>)
h:i:s.u
)getLapsSortedBySector(<int>)
. This is very useful
with endurance results that have 200+ lapslib/Data/Reader/Rfactor2.php
lib/Data/Reader/ProjectCarsServer.php
lib/Data/Reader/AssettoCorsa.php
lib/Data/Reader/AssettoCorsaServer.php
lib/Data/Reader/AssettoCorsaServerJson.php
lib/Data/Reader/AssettoCorsaCompetizione.php
lib/Data/Reader/RaceRoomServer.php
lib/Data/Reader/Race07.php
lib/Data/Reader/Iracing.php
Simresults can be installed and autoloaded using composer. But ofcourse it will work with any PSR-0 autoloader.
Add the Simresults package to the composer.json
file:
composer require mauserrifle/simresults:dev-develop
Create index.php:
<?php
// Load code
require(realpath('vendor/autoload.php'));
// Path to the result source file
$file = realpath(dirname(__FILE__)
.'/vendor/mauserrifle/simresults/tests/logs/rfactor2'
.DIRECTORY_SEPARATOR.'race.xml');
// Get a reader using the source file
$reader = \Simresults\Data_Reader::factory($file);
// Get the first session. Note: Use `getSessions()` to get all sessions
$session = $reader->getSession();
// Get participants sorted by their position
$participants = $session->getParticipants();
// Get the driver name of the second participant
$driver_name = $participants[1]->getDriver()->getName();
// Get the best lap of the second participant
$best_lap = $participants[1]->getBestLap();
// Get the best lap of the session
$session_best_lap = $session->getBestLap();
// Format the gap between the two laps
$helper = new \Simresults\Helper;
$best_lap_gap = $helper->formatTime($session_best_lap->getGap($best_lap));
echo $best_lap_gap;
Run server
php -S localhost:8000
Open http://localhost:8000 and all should work!
For further usage please read the classes code within the lib
folder. They
are carefully documented.
Big thanks to the following sponsors for supporting Simresults! Please pay them a visit :)
Have a bug or a feature request? Please open a new issue.
Some classes like Participant
do heavy caching. So changing any value after
calling sorting methods will be pointless. There are no cache invalidate
methods (yet). Most likely they will never be needed as there's no use case you
actually would want to change values after reading out all data.
When writing a reader. NEVER call methods like getVehicle()
on Participant
(which uses cached methods). Re-use your own created objects (like $vehicle
)
within the reading to prevent any early invalid cache. Do this for all type of
objects.
Logs tend to miss lap data on all games. Check the logs.
The Race 07 reader detects qualify if all drivers are DNF. There's no session type in these log files. This detection might be false in some cases.
GTR, GTL, F1 challenge don't have a timestamp or timezone information. So dates are created using the default timezone.
The project is designed to be extended with new features and game support. Feel free to fork Simresults on GitHub and submit a pull request!
The project is tested using PHPUnit and phpspec. If you offer any changes, make sure all your new additions are tested.
To run the tests, use the following command:
./vendor/bin/phpunit
./vendor/bin/phpspec run
The Simresults library is open-sourced software licensed under the ISC license.