The online racing simulator
LFSStats v2.1 (work in progress)
(11 posts, started )
LFSStats v2.1 (work in progress)
Hi everyone,

this is a continuation of previous LFSStats v1.xx that was developed by Gai-Luron. I've made an updated version v2.0 a long time ago that was submitted in previous thread and it seemed to be used. It had mainly cosmetic fixes at the time as it was otherwise working well. LFS has changed though and the old base code of LFSStats started to be outdated.

Now I wanted to practice and make it usable again so I've started to make an update v2.1 almost 2 months ago. Working on and off on it as I have time.

There are going to be major changes and hopefully a completely new network layer with a working TCP. Swapping the networking to InsimDotNet. Added all fixes I could find that Luron made but none seem to work very well, they work but TCP still does not work flawlessly.

See change log below to see what updates have been made:
(I'm not even sure it has them all, there is unlikely to be a part of code I did not change by the end.)

Changelog:
==========
v2.1
----
* Graphs:
* Adding option to generate graph from DLL or EXE and adding Yamakawa's YGraph as an option
* Updated NPlot library to 0.9.10.0 and due to NPlot a .NET 4.0 Client Profile is not enough and a full .NET 4.0 is needed
* Changed default graph config to not output unused images
* Changed default graph background to transparent
* Networking:
* Fixed new Insim flags (AXIS_CLUTCH / THROTTLE, ...), proper names and exporting all of them, including SwapSide
* Changed them to be displayed via CSS3 - easy to modify at any time
* Added changes from Luron's v1.12 in Insim4.cs but TCP is still buggy
* Added changes from Luron's LFSLapper update tcp.cs/GetPackFromInsimServer, it could now support TCP better
* (InSim.Decoder.PIT.PIT) Pit flags text but still needs localization I think
* Ohter:
* Looked up and commented out some unused code
* Fixed {*Conditions} "Sunny,no wind" formatting to "Sunny, no wind"
* Added a few language file substitutions
* LFSStat changed to .NET 4.0 Client Profile and update some outdated code for better performance and conventions
* Cleaner version reporting and maintaining in the project
* Removed #MONO and #WINDOWS from source files since these are supposed to be defined elsewhere, in build/compiler options,
and not in source files, just change the #IFs back to #IF MONO and define #IF at build/compile level not in source files
* Command line options with help text and usage
* Customizable program ouput verbosity
* fixed 45 sec. penalty string
* Config errors are not reported but wrong values are set to default
* IMPORTANT: the application is now multithreaded, uses .NET tasks for exporting the collected data,
removes slight application hang up while exporting, thus main thread = networking runs continuously and exporting is asynchronous
* All command line interaction removed except when config defines to ask for filename, it should not hang up anywhere and should
quit on errors
* Fixed some of the weird exceptions that were happening because Insim does not report well session states, thus things were being
accessed while a session did not even start yet. It should be safe now to browse LFS without LFSStats crashing.
* Cleaner and formatted output to command line and console title
* Exit codes: 0 success, 1 network error, 2 connect timeout, 3 template error
* Fixed LFS World links, HTML link encoding
* Fixed car plate export, HTML encoding
* Updated export of statistics to accomodate template changes = more freedom when making templates
* Rewrote the configuration importer that now contains the loaded settings and comments starting with '#' can be anywhere on a line
* Templates:
* Changed template names to .html for easier processing
* Added back to templates what Yamakawa decided to throw away but LFSStats can export and is useful, like driver swaps!
* LBL integrated in template
* LBL colors are HSLA, partly transparent and colors change continuously not discretely, saturation and alpha can be changed in tempplate
in code easily, want only 2 colors sure, want crazy mixed rainbow with 100 colors and all the way to 2000% best laptime? sure!
Just type it in there.
* More sensible html titles (16 laps of Fern Bay Green)
* Tag start "[-" disables output of that tag content, ends normally with tag end "]", used on [Include in the template for example
* Chat integrated in template

v2.0
----
* Nickname colors - fixed
* Nickname 2 HTML - fixed
* Chat 2 HTML - fixed
* Some minor renaming of templates and generated files
* Changed templates (hope old templates will still work), more space saving, added link to Chat
* When exporting on STAte changed (leave, exit) added option to CFG yes/no/ask to decide if export.
* When exporting on Race STart (race [re]started, mpr [re]starts from begining) added option to CFG yes/no/ask to decide if export.
* Question for name of stats instead of generated time, for STA and RST separatedly
* Globals in templates now work for chat to.
* Chat template and language files updated.
* StartOrder Nickname link to LFSW - fixed
* Dns.Resolve() changed to Dns.GetHostEntry()
* integrate Graph.exe (got original src files for v1.20 )
* integrated as .DLL
* fixed .TSV path
* added option to LFSStats.CFG, generate automatically YES/NO
* fix some tables in templates, no white backround
* update Console.WriteLine() stuff (names, emails, ...)

Command line usage:

LFSStats v2.1
Copyright (C) 2008-2013 Jaroslav Černý

Usage: Statistics [options]

-c, --config (Default: LFSStats.cfg) Config file.
-i, --interval (Default: 100) Insim refresh interval: [1-1000]ms.
-v, --verbose (Default: 1) Verbose level: [0-4] Program, Session, Lap,
Split, Info.
--version Display version information.
--help Display this information.

I'm not sure what are valid Insim interval times, anybody knows?
The rest of configuration is per usual in a config file.

---

OLD version 2.0 (temporary hosting, same release only config changed to UDP mode):

binary
source


v2.1

I'll get the newer versions on one of the open source project hosting sites sourceforge, github, codeplex or similar once it's done and releasable.

---

The templates are made new from scratch, HTML5 and CSS3, not finished yet with Qualification, Practice and CSS. Here is a preview of LBL colors that LFSStats generates so it's something not changeable in CSS completely.



The colors are continuous and can be redefined in source code easily if needed. Any other colors are only temporary in CSS.

I'm thinking of changing the menu once again, right now it works the same way as Yamakawa's template that is via JavaScript showing and hiding parts of the webpage but it's not very user friendly to be honest. Thinking of switching it to scrolling down and up with the header and menu being fixed on top and possibly avoiding JavaScript.

This is the current HTML5 outline of race statistics template:


If you wish for a different order or grouping in navigation, let me know below.
Update: Splits were changed to sectors.

---

Please keep bug reports for later when v2.1 is released, a lot has been already fixed.
Can't help you with bugs of older versions made by Luron, please report those in his thread.
Rewriting the class that collects and calculates individual stats, inevitable.

Sectors named as splits, defined as individual variables instead of indexable arrays or lists.
I'm surprised nobody notified for so many years that the split times in output html are actually sectors.
And yes just found another bug, all best splits(= sectors) apart from the last one show a lap lower by 1 than where they have been done. Saw that in code and verified on v2.0. Set best split times in first lap, it will show 0 as a lap where those splits were done. There is no such thing as lap 0 *laugh* How could we miss this for so long.

Qualification seems a little off as well.

I think the further networking update is going to be v2.2 after this works once again.
! Acquired LFS world record has invalid format, does not contain 10 space delimi
ted fields:
"56 601 FOX 19740 0 0 46090 513 Pe?a Racing 1327731053"

Can hack around this but I'm probably going to finally rewrite it once more and make it use XML. There can be spaces in names which breaks the use of spaces as delimiters.

BTW the errors reported by pubstat seem to be the same for plain text and XML, just pain text errors. Found these, anybody aware of some other related to reading WR?
Quote :not authed (invalid identkey)
Invalid Ident-Key
Identification is required
can't reload this page that quickly after another

Might add command line options to config file and maybe allow more cmd options, where cmd options would override those in config.

Empty config file, everything alright
LFSStats v2.1
Copyright (C) 2008-2013 Jaroslav Černý

LFSStats comes with ABSOLUTELY NO WARRANTY.
This is free software, and you are welcome to redistribute it
under certain conditions. Read LICENSE for details.
You should have received a copy of the GNU General Public License
along with LFSStats. If not, see <http://www.gnu.org/licenses/>.


! Config param invalid: host =
! Using default value: host = 127.0.0.1

! Config param invalid: port =
! Using default value: port = 29999

! Config param invalid: tcpMode =
! Using default value: tcpMode = True

! Config param invalid: isLocal =
! Using default value: isLocal = True

! Config param invalid: language =
! Using default value: language = English

! Config param invalid: pracDir =
! Using default value: pracDir = results

! Config param invalid: qualDir =
! Using default value: qualDir = results

! Config param invalid: raceDir =
! Using default value: raceDir = results

! Config param invalid: exportOnRaceSTart =
! Using default value: exportOnRaceSTart = yes

! Config param invalid: askForFileNameOnRST =
! Using default value: askForFileNameOnRST = False

! Config param invalid: exportOnSTAte =
! Using default value: exportOnSTAte = no

! Config param invalid: askForFileNameOnSTA =
! Using default value: askForFileNameOnSTA = False

! Config param invalid: generateGraphs =
! Using default value: generateGraphs = dll
Loading LFSWorld WRs... not loaded (no ID key)
TCP: 127.0.0.1:29999 connecting...
Goodbye.

Hope this thing will be a little more error proof in the end. It should catch wrong IPs and ports as well. Host names are supported too now.

Quote :# Host IP or host name
host = localhost

Hi
I noticed a quirk:
Sometimes drivers will retire from a race (shift+s) but then rejoin and after few moments retire/leave for real. Maybe they accidently join or it is a reflex to click the button, not sure.
So technically they have driven twice (first time say until lap 20, then rejoin and stand in pit for 10 seconds)
In LFSstats it will look like they only stood in pit but the 20 driven laps are discarded.
A bit tricky to decide which "run" should be shown in stats, for example if a driver drives 10 laps, crashes, rejoins, drives 20 laps. But this is just about standing in pits for a few moments after retiring.
I see it happens from time to time.
If driver does not complete any laps after rejoin, that could maybe be filtered out?

Example replay:
https://drive.google.com/folde ... 2cbH56Sx8ndWRjdW53WGxhRzQ
See driver MZR Kelle for example, he drove multiple laps but the "Positions Lap by Lap" graph makes it looks like he retired right at green light.
http://lfs.petsamo.fi/stats/2013-10-13_1_results_race.html
Or, would it be possible to display all laps completed by a car on the track (per PLID basically). That way if there's something mucked up as Gutholz has mentioned, the one who generated the report can edit out or aggregate the bogus / bonus lines.
Quote from Gutholz :Hi
I noticed a quirk:
Sometimes drivers will retire from a race (shift+s) but then rejoin and after few moments retire/leave for real. Maybe they accidentally join or it is a reflex to click the button, not sure.
So technically they have driven twice (first time say until lap 20, then rejoin and stand in pit for 10 seconds)
In LFSstats it will look like they only stood in pit but the 20 driven laps are discarded.

Sounds correct from what I remember.
Previous is lost.

Quote : A bit tricky to decide which "run" should be shown in stats

Simple. Your last valid run. Which in the case of LFS is your last run.

Quote :, for example if a driver drives 10 laps, crashes,

And retires from race.

Quote :rejoins

= starts again
Quote :drives 20 laps. But this is just about standing in pits for a few moments after retiring.

Retired. Those original 20 laps are DNF. Since LFS allows you to start over again the last one is then recorded.
Quote : I see it happens from time to time.
If driver does not complete any laps after rejoin, that could maybe be filtered out?

It still invalidates that original result. Yes I could possibly filter it out by detecting some things like pitlane exit if possible, SPX.

Quote :Example replay:
https://drive.google.com/folde ... 2cbH56Sx8ndWRjdW53WGxhRzQ
See driver MZR Kelle for example, he drove multiple laps but the "Positions Lap by Lap" graph makes it looks like he retired right at green light.
http://lfs.petsamo.fi/stats/2013-10-13_1_results_race.html

That is what he did if he started his race over again. It's way more simple when LFS acts more like real racing and race mid join is disabled.

Quote from dekojester :Or, would it be possible to display all laps completed by a car on the track (per PLID basically). That way if there's something mucked up as Gutholz has mentioned, the one who generated the report can edit out or aggregate the bogus / bonus lines.

As I understand it, is it about something like a tracker does?
That if you disconnect and then connect again you would be allowed to continue without discarding your old result? Which is what LFS does but tracker for leagues may be set to count the previous laps. You will lose a lot by a disconnect but it may be ok for long races.

Lap by lap is generated from the same data as the rest of the stats. That means keeping old laps affects all other results as well.

What happens I think is that if the player joins again and exists the previous results are discarded. New are created or the old ones are cleared.


I could add a config option to allow this different behavior if it does not break something else. Which may happen because such a player will then have more laps finished than what is the number of laps in a race. Does 20, retires, joins again, does 30 and finishes = 50 laps instead of 30.
Although if you only want to filter that rejoin and do not clear it unless at least a split is done or pits are left, that would not break that but it needs to be detected and new stats have to be started later which can be an issue for other things that may happen before driving first split. There is things to keep an eye on. Would have to check the code.


Otherwise it's simple. Do not rejoin a race if you want your stats
You've retired, stay in spectate do not enter pit lane.
Quote :Yes I could possibly filter it out by detecting some things like pitlane exit if possible, SPX.

That would be good enough, I think.
Those "short rejoins" are more result of accidently clicking from wrong buttons..of course league or LFS could forbid that but it is what it is. So filtering by "has not left pitlane" or "no lap completed" or "distance driven" seems okay..

---

In meantime tried to use OLD version 2.0 from this thread, but when the replay starts it stops with this message:

Quote :LFSStat, Version=2.0.0.39150, Culture=neutral, PublicKeyToken=null
GNU license 2008 Jaroslav CERNY ( JackCY )
LFSStat comes with ABSOLUTELY NO WARRANTY
This is free software, and you are welcome to redistribute it
under certain conditions. Read LICENSE for details.

Loading WR...Not Loaded
Connecting
Connection OK
Product:S2 Version:0.6E InSim Version:5
LFSStat is running...
The following error occurred:
Der Objektverweis wurde nicht auf eine Objektinstanz festgelegt.
LFSStat
bei LFSStat.LFSClient.NickNameByUCID(Int32 UCID)
bei LFSStat.LFSClient.Loop(Connect insimConnection)
bei LFSStat.LFSClient..ctor(String scriptfilename, Boolean debugmode)
bei LFSStat.LFSStat.Main(String[] Args)
System.String NickNameByUCID(Int32)

It seems related to driver names so here if replay if you want to test:
https://docs.google.com/file/d ... KZ3NxMGs/edit?usp=sharing
What I mean is that LFS shows a line per car that joins the track, and each time that car's PLID leaves for whatever reason, it KEEPS the old PLID, but then begins a new one when the driver rejoins, but track that new car on a new line.

EG, if I do 24 laps in a 45 lap race, timeout, and rejoin and do 17 more laps to the chequered, I'd have two lines in the output as such:

Jonathan Palmer / dekojester / 24 laps / DNF / other stats from that stint
Jonathan Palmer / dekojester / 17 laps / +28 laps / other stats from that stint

Then if desired, the user can edit the html or just leave it as-is
I will add it to TODO and check what can be done. I have to do other things currently, it's an ON/OFF thing with LFSStats.

Gutholz: I think I saw that or similar error already. It was happening to me when on an online server and the races were restarting, sometimes this would happen. Might have been due to UDP, who knows. I think I fixed some of it already or it's noted there to be fixed.
I hope you have time to update few things,as the app crashes in new version,most likely because of more then 32 cars on track... Shrug



Was a useful tool until now for processing event results.
Massive bump! Is it possible to get an install for this again? Thanks

LFSStats v2.1 (work in progress)
(11 posts, started )
FGED GREDG RDFGDR GSFDG