VM LiveView Lite for rFactor & rFactor2

Discussion in 'Plugins' started by Frank Geyer, Feb 20, 2012.

  1. Frank Geyer

    Frank Geyer Registered

    Joined:
    Oct 5, 2010
    Messages:
    222
    Likes Received:
    3
    Hi Noel,

    I am guessing that is what's causing your locking problems !?!? You probably need to change your app to a loader-based-scenario.


    Code:
    [B]Fail Safe Scenario - Live Timing Scheme:[/B]
    
    
                                |-- rFactorSL 1 ( via http - 2.5 times a second )
                                |
    rF DS XML (twice a second) ---- rFactorSL 2 ( via local FS - 2.5 times a second )
                                |
                                |-- rFactorSL 3 ( via ftp - 2.5 times a second )
    The loader is a .NET application which transports all RAW DATA presented by the plugin (without any formatting) into the database. Then the RAW DATA within the database is presented thru APACHE via PHP any way you like. Meaning, it doesn't matter how many users are viewing the data, you always ending up with only three processes accessing the rF DS XML file. I always ending up from time to time with a "loader cannot access the XML file", cause it is written twice per seconds by the plugin. But I don't care about this. The data within the database is updated roughly two times a second, which gives me enough room to present live data once a second to the user and statistical data by user request.

    Locking management thru SQL is much more convenient than thru the file system.

    You can even implement this into a load balancing scenario based on DNS-Round-Robin if each loader is writing its collected data into different databases on different mysql servers.

    Cheers
    Frank

    PS: I only use the internal plugins as well, switching everything off which is not required and then building the XML file by fopen( "VMHotlaps\\CurrentScoring.xml", "w" ); and fprintf( fo, "String Data", VARS );
     
    Last edited by a moderator: May 11, 2012
  2. Frank Geyer

    Frank Geyer Registered

    Joined:
    Oct 5, 2010
    Messages:
    222
    Likes Received:
    3
    @Lucky: Sorry pal, but I don't have enough information to get a thorough picture of your environment and configuration. And without this ... :confused:
     
  3. Noel Hibbard

    Noel Hibbard Registered

    Joined:
    Oct 5, 2010
    Messages:
    2,744
    Likes Received:
    40
    On Friday I went another route and that is to just build a windows message using WM_COPYDATA to send the raw data to another app that I wrote in .Net which I will be able to easily deal with from there. It is working perfect so far... well, the WM_COPYDATA is working and I am just building an XML from that and then displaying it in a textbox. I may just send this data over UDP to another server that way all the bandwidth is offloaded to another machine on another network.

    I think I am going to go another route though. I want the .Net app to run as a service and services don't have windows to accept WM_COPYDATA. I could run it as an interactive service but don't really like that idea. So I will probably go with Named Pipes which will take some time to figure out.

    If you are interested in the WM_COPYDATA stuff here is the code I wrote:
    Code:
    string rFdata;
    
    // string some stuff together here
    
    // Find the handle to the .Net app
    HWND hWnd = FindWindow(NULL, "TestApp");
    if (hWnd) {
    	COPYDATASTRUCT cpdata;
    	cpdata.dwData = 0;
    	cpdata.cbData = strlen(rFdata.c_str());
    	cpdata.lpData = (LPVOID) rFdata.c_str() ;
    	SendMessage(hWnd,WM_COPYDATA,(WPARAM)hWnd, (LPARAM)&cpdata);
    }
    
    I wanted to just pass the whole ScoringInfoV2 struct over as is and then pull it apart on the other end but wasn't successful at matching all the datatypes to build a matching structure on the other end. So I went with a big string. Sending the whole struct would have been nice and clean and would have added very little load to the plugin.

    Thanks for the help Frank. I think your right though, having 40+ people all viewing the timing page pulling this XML ever 1.5secs is bound to create some sort of locking problem.
     
  4. LCCMarc

    LCCMarc Registered

    Joined:
    May 16, 2012
    Messages:
    56
    Likes Received:
    0
    Hello,
    Excuse me, my English is bad, I use a translator.

    With me, everything works fine but I have a little problem, the circuit appears in mirror, how to display it correctly?

    Thank you in advance, I want to say that this work is great.

    Marc
     
  5. Frank Geyer

    Frank Geyer Registered

    Joined:
    Oct 5, 2010
    Messages:
    222
    Likes Received:
    3
    @Noel: No problem mate, you are welcome any time and thanx for sharing your code snippet :) !!! One thing to think about your idea to transport scoring data directly via UDP thru the plugin - if I did understand you correctly !?!? If you run in timeouts because of network problems it may block the whole rFactor Dedicated Server ...

    @Marc: You can use the php script http://localhost/vmliveview/trackconfig.php in combination with Map Rotation and Map Mirror X:

    Map Rotation values: from 360 to -360
    Map Mirror X values: 1 and -1

    Or you can edit those values directly within the corresponding database.
     
  6. LCCMarc

    LCCMarc Registered

    Joined:
    May 16, 2012
    Messages:
    56
    Likes Received:
    0
    Ok, thank you Frank, it works perfectly. I changed the database (phpmyadmin)
    Another big thank you for this work.
    Marc.
     
  7. Noel Hibbard

    Noel Hibbard Registered

    Joined:
    Oct 5, 2010
    Messages:
    2,744
    Likes Received:
    40
    UDP is connection-less so theoretically if there are network troubles the code keeps going. But I am not doing UDP directly from the plugin. My plugin simply exports all the structs and sends them as WMs via WM_COPYDATA to a ProxyApp I wrote in .Net which then sends the structs via UDP to another server which then logs the laps into a MSSQL database and generates the live timing page. I calculated the bandwidth needed to stream the scorring info and it is about 3456bps/Sec/Driver. So with 45 drivers on the server it will use about 155Kbps/Sec.

    Also, on clients it also exports the telemetry structs. The ProxyApp can do a UDP broadcast and then I can run a telemetry app of some sort on any other machine on the local network. I do endurance racing with three other guys. I think I am going to write an app to grab all the telemetry (for everyone on the team) and upload it to a central server which will then generate a nice webpage with all the data so that we can keep tabs on the teams progress while the other drivers are waiting for their stint. The telemetry takes about 256Kbps/Sec to stream.
     
  8. Valbuena72

    Valbuena72 Registered

    Joined:
    Dec 23, 2011
    Messages:
    194
    Likes Received:
    0
    Hi,
    I made a video of my problem
    it marks me OFFLINE yet everything is well parameterized

    Thank's for help
     
  9. Florian Mueller

    Florian Mueller Registered

    Joined:
    Mar 28, 2012
    Messages:
    3
    Likes Received:
    0
    Hallo Frank.

    Hab das mit dem Trackviewer nicht so richtig verstanden könntest du mir mal erklären wie das genau geht mit der einstellung und welche datei ich einfügen muss damit ich die strecke sehe ? würde mich um deine hilfe freuen lg

    Flo
     
  10. Frank Geyer

    Frank Geyer Registered

    Joined:
    Oct 5, 2010
    Messages:
    222
    Likes Received:
    3
    Yeah, you are right! UDP is connection-less ... sometimes "I wasn't thinking" suppose to be my middle name *big grin* and shouldn't give you any problem in that case !!!

    Anyhow I think you are doing a great job at your site and league, and if there wouldn't be the time difference of approx. 6 hrs between Florida and Germany I would thinking about registering a team to take part in the VLMS !!!
     
  11. Frank Geyer

    Frank Geyer Registered

    Joined:
    Oct 5, 2010
    Messages:
    222
    Likes Received:
    3
    Hi Val,

    from what I've seen you added a wrong value for <xmlURL>file://D:\rFactor\VMHotlaps\CurrentScoring.xsl</xmlURL>.

    Please try changing it to <xmlURL>file://D:/rFactor/VMHotlaps/CurrentScoring.xml</xmlURL>. Also make sure you are using the right VMHotlaps.dll for rFactor1.

    Sorry for being late ...

    Cheers
    Frank

    PS: The delivered .xsl file is only a style sheet to view the generated .xml file by the plugin in a more readable way for "debugging".
     
  12. Valbuena72

    Valbuena72 Registered

    Joined:
    Dec 23, 2011
    Messages:
    194
    Likes Received:
    0
    Thank you for the reply!
    But I had resolved within hours.

    Otherwise, the "Hotlap" if you change car (skin), with the same nickname. make it a duplicate of the hotlap.
    There is there a way to remedy
    thank you
     
  13. Frank Geyer

    Frank Geyer Registered

    Joined:
    Oct 5, 2010
    Messages:
    222
    Likes Received:
    3
    Hi Flo,

    1. Die .aiw-Datei einer Strecke ins TrackData-Verzeichnis des Loaders kopieren.
    2. Die .aiw-Datei der Strecke umbennen laut dem angegebenen TrackName in der .gdb-Datei der Strecke.
    3. Über den Loader die Streckendaten der umbenannten .aiw-Datei in die Datenbank inportieren.
    4. Die Darstellung der Strecke über ../trackconfig.php bzw. direkt in der Datenbank anpassen.

    Gruß
    Frank
     
  14. Frank Geyer

    Frank Geyer Registered

    Joined:
    Oct 5, 2010
    Messages:
    222
    Likes Received:
    3
    Hi Val,

    the way the hotlaps within the Loader are determined is:
    Code:
    "SELECT `TrackName`, `DriverName`, `VehicleClass`, `Vehicle`, `LapNo`, `LapTime` FROM `hotlaps` WHERE `TrackName` = '" & TrackName & "' AND `DriverName` = '" & DriverName & "' AND `VehicleClass` = '" & VehicleClass & "' AND `Vehicle` = '" & Vehicle & "' LIMIT 1"
    I am thinking about removing the Vehicle parameter ...
    Code:
    "SELECT `TrackName`, `DriverName`, `VehicleClass`, `LapNo`, `LapTime` FROM `hotlaps` WHERE `TrackName` = '" & TrackName & "' AND `DriverName` = '" & DriverName & "' AND `VehicleClass` = '" & VehicleClass & "' LIMIT 1"
    so in that case the VehicleClass would be "the leading parameter" to differ between Hotlaps per Driver per Track, but I am not sure yet. Anyhow the more I think about it, the more it does make sense doing it the second way ...

    Cheers
    Frank
     
  15. Valbuena72

    Valbuena72 Registered

    Joined:
    Dec 23, 2011
    Messages:
    194
    Likes Received:
    0
    hello,
    now I know which file I edit for your changes as you give ?
    Also another idea, would it be possible to scroll the best time of the file hotlap.php in the file marquee.php?
     
  16. Valbuena72

    Valbuena72 Registered

    Joined:
    Dec 23, 2011
    Messages:
    194
    Likes Received:
    0
    I created a page on wordpress, I would like to display the hotlap using an Iframe, only the url of the page is generated from the circuit.
    Is it possible to display the page hotlap by retrieving the address without manually editing .. ?
     
  17. M3T

    M3T Registered

    Joined:
    May 26, 2012
    Messages:
    1
    Likes Received:
    0
    Hi guys.

    i am a totally noob on this things and i tried to install and configure the live view.....i have the webserver with the mysql hosted in another server and via a store that i have i have the rfactor server here.

    i just can´t open the database...i don't get any errors but when i open rfactorSL.exe it says to me that sql is closed and on the logs it appears the following errors:

    - "sql connection open - unable to connect to any of specified Mysql hosts"

    can someone help me please ??

    all the other things iare working properly but this one dont and the live timing does not show up properly :(

    thank you
     
  18. DerKutscher

    DerKutscher Registered

    Joined:
    Sep 13, 2011
    Messages:
    139
    Likes Received:
    1
    Hi,

    ich habe folgendes Problem. Ich habe vm installiert und klappt für einen Server wunderbar. Jetzt möchte ich es aber für 3 Server einrichten. Habe alles für 3 Server eingerichtet. wenn ich jetzt aber den 2. sl.exe starte und dann den 2. Server wird alles an den 1. sl.exe übertragen. Habe auch 3 datenbanken und auch alles so eingetragen. Finde meinen Fehler nicht. Kann jemand helfen der es schon für mehr als 1 server eingerichtet hat? Teamviewer und TS wären nicht nur möglich sondern klasse. Es sei denn es wäre ganz simpel. Angelegt habe ich im rF2 folder rFactorSL, rFactorSL2, rFactorSL3. des weiteren VMHotlaps, VMHotlaps2, VMHotlaps3.
    Das gleiche natürlich auf den Webserver.

    hi,

    I have the following problem. I installed vm and works just fine for a server. Now I want to set it up but for 3 servers. Have everything set up for 3 servers. If I now get the second sl.exe start and then the second Everything on the server is first sl.exe transferred. Also have 3 databases and everything so incorporated. Can not find my mistake. Can anyone help who has already set up for more than 1 server? TeamViewer and TS were not only possible, but great. Unless it would be quite simple. I have created folder in the RF2 rFactorSL, rFactorSL2, rFactorSL3. further VMHotlaps, VMHotlaps2 VMHotlaps3.
    The same course on the web server.
     
  19. Frank Geyer

    Frank Geyer Registered

    Joined:
    Oct 5, 2010
    Messages:
    222
    Likes Received:
    3
    New inofficial release. See first post for a download link.

    - Added selections for Track and Class to the hotlaps page (php change).
    - In Hotlaps there is no distinction anymore between two different cars in the same class (loader change).
    - Added a new parameter (<LogAI>0</LogAI>) to the config file of the loader to exclude the logging of AI hotlaps (loader change).
    - Recompiled the VMHotlaps.dll for rFactor2 with new rF2 Example Plugin release dated 24. May 2012.

    Have fun.

    Cheers
    Frank
     
    Last edited by a moderator: Jun 5, 2012
  20. Hoschi

    Hoschi Registered

    Joined:
    Nov 18, 2011
    Messages:
    94
    Likes Received:
    0
    Thanks Frank, nice work ! ;-)
     

Share This Page