1. This Software is no longer supported by us. Please download the new motion control software SimTools.
    Dismiss Notice
  2. Do not share user accounts! Any account that is shared by another person will be blocked and closed. This means: we will close not only the account that is shared, but also the main account of the user who uses another person's account. We have the ability to detect account sharing, so please do not try to cheat the system. This action will take place on 04/18/2023. Read all forum rules.
    Dismiss Notice
  3. For downloading SimTools plugins you need a Download Package. Get it with virtual coins that you receive for forum activity or Buy Download Package - We have a zero Spam tolerance so read our forum rules first.

    Buy Now a Download Plan!
  4. Do not try to cheat our system and do not post an unnecessary amount of useless posts only to earn credits here. We have a zero spam tolerance policy and this will cause a ban of your user account. Otherwise we wish you a pleasant stay here! Read the forum rules
  5. We have a few rules which you need to read and accept before posting anything here! Following these rules will keep the forum clean and your stay pleasant. Do not follow these rules can lead to permanent exclusion from this website: Read the forum rules.
    Are you a company? Read our company rules

read the CSV logfile while it is being written?

Discussion in 'Force-Profiler Simulator Control' started by kjg71, Apr 20, 2009.

  1. kjg71

    kjg71 New Member

    Joined:
    Sep 12, 2007
    Messages:
    61
    Occupation:
    Designer
    Location:
    Toledo, Ohio - USA
    Balance:
    9Coins
    Ratings:
    +0 / 0 / -0
    I want to read some data out of the CVS logfile as opposed to the programming involved with accessing the same data from the MMF. I like the filtering available in the CVS exporter, but obviously if X-sim profiler is accessing and constantly writing to the file it is locked from read access elsewhere. Is there any solution to read the CVS file while it is being created so that the latest line of parameters (based on end of file) can be read elsewhere? The CVS creator is great!, it just seems to be locked while writing. Is this by X-sim programming or from windows restriction? ....either way is there a way to cheat and override this?

    Thanks
  2. kjg71

    kjg71 New Member

    Joined:
    Sep 12, 2007
    Messages:
    61
    Occupation:
    Designer
    Location:
    Toledo, Ohio - USA
    Balance:
    9Coins
    Ratings:
    +0 / 0 / -0
    Yes, it would be shared reading access, but in an easier way then accessing the MMF file and parsing the required data from that. It seems you need to be familiar with C++, or simular programming language that supports pointers or even use a class to allow for function calls. For more basic programmers or scripting programmers, the CVS export is very intuitive as far as choosing values you want and displaying them in the CVS file. Also it appears to display them after the math as well. I may be wrong but I think the values in MMF would be before it reaches profiler and hence, no math adjustments?... which would make the values cleaner I think.

    It would of course be easier to implement a CVS file data in just about anything you would want to do.

    I see there is also a LCD gauge exporter plugin, but I am not sure if it exports all data (maybe it does?) I think it goes right to the LCD studio app so it is not really going to create anything simple like a CVS file that can be read at runtime easily (unless it is there behing the scenes..perhaps it makes an alternate MMF file)?

    So to answer your question...it would be a way to get a simple shared reading access file. Or as an alternate system file that had read access while the other xsim is currently generating is locked.

    what do you think?
  3. kjg71

    kjg71 New Member

    Joined:
    Sep 12, 2007
    Messages:
    61
    Occupation:
    Designer
    Location:
    Toledo, Ohio - USA
    Balance:
    9Coins
    Ratings:
    +0 / 0 / -0
    excel or the open version would be one example as they can not access when it is logging..however not what I was using to test. I can try in a bit or tommorrow with my test program as it is on other machine...but I would think it behaves just like excel or open office would.

    let me know what you experience when try to open with the spreadsheet programs and it is logging....I'll try to get mine to you as well

    Kyle
  4. kjg71

    kjg71 New Member

    Joined:
    Sep 12, 2007
    Messages:
    61
    Occupation:
    Designer
    Location:
    Toledo, Ohio - USA
    Balance:
    9Coins
    Ratings:
    +0 / 0 / -0
    I am sending a test file that will read/write to a CSV file at this location:

    C:\atestcsv\test_csv_read.csv....just create a blank .csv here on your machine.

    with the test application, you can type in each grey label and then select save labels button to save each as a colum in first row of the .csv (or sequencialy each seperated by ,)

    select re-load labels button to read them in and parse each entry and send them back to the correct label fields.

    note: I only need to read with xsim, but I included a write button so you can test.

    right now, you can read the file as long as it is not being accessed.

    I have no flags set because I am not sure about that part, but have included the source code as an .RTF with comments so you can see how this works so far. this is done with lingo as it is fast and easy but the same code could be changed to VB I'm sure or if successful whatever else people want to use C++ etc.

    If you try this when excel has the file open or X-sim it will do nothing when saving (cause the file is already opened) and will give error message on read cause it thinks no text exist (again cause its open). If you let me know the process for the sharing flag method maybe I can try a few things.... or maybe its the program that is doing the writing that sets the flags?

    ...you can also point to this loc and have x-sim write a log to actually test with x-sim

    Regards
    Kyle

    Attached Files:

  5. kjg71

    kjg71 New Member

    Joined:
    Sep 12, 2007
    Messages:
    61
    Occupation:
    Designer
    Location:
    Toledo, Ohio - USA
    Balance:
    9Coins
    Ratings:
    +0 / 0 / -0
  6. RaceRay

    RaceRay Administrator Staff Member SimAxe Beta Tester

    Joined:
    Nov 8, 2006
    Messages:
    4,656
    Occupation:
    Self-employed | Web and application development
    Location:
    Hamburg, Germany
    Balance:
    23,837Coins
    Ratings:
    +1,965 / 13 / -0
    My Motion Simulator:
    2DOF, DC motor, SimAxe, SimforceGT
    zip is working. You have to select your zip file in the form and than click Add the file.
  7. kjg71

    kjg71 New Member

    Joined:
    Sep 12, 2007
    Messages:
    61
    Occupation:
    Designer
    Location:
    Toledo, Ohio - USA
    Balance:
    9Coins
    Ratings:
    +0 / 0 / -0
    Hit sirnoname,

    Just wondering if you had a chance to check out the .CVS file access at same time from another app via setting sharing flags issue?

    Is the settings for flag sharing something done on the x-sim export to cvs side? Do you have to set the location of the app wanting to use it and then it can while others are still restricted via the default. The default being (never share)?

    Please excuse my lack of knowledge on flag sharing...googled but didn't find much luck on explaining it.

    let me know
    thanks
    Kyle
  8. kjg71

    kjg71 New Member

    Joined:
    Sep 12, 2007
    Messages:
    61
    Occupation:
    Designer
    Location:
    Toledo, Ohio - USA
    Balance:
    9Coins
    Ratings:
    +0 / 0 / -0
    Hi,

    Thanks for looking into it!! I don't know if I have a similar function CFile::shareDenyNone) which leaves it open for xsim. It sounds like x-sim does already leave CVS open and then I am locking when I access? I can see if I can leave it open and not close after access....maybe change some things.... but the shareDenyNone function is what I am worried about. It seems like I may be opening it with deny and need to change that ... maybe I could launch an .exe compiled from the C code that opened it and left it with the shareDenyNone set?...wow is that a messy way. Although it would have to open after I have accessed it and reverse the permissions. Sounds like its possible. Something written is C natively probably is the best because of the shareDenyNone function. I'll look into what I can do with the current testing app, but sounds like X-sim is doing its part.

    so just currious what were you able to do when you said

    you did see some success?

    let me know if you have any other ideas..I if I am understanding all this correct.

    Kyle
  9. kjg71

    kjg71 New Member

    Joined:
    Sep 12, 2007
    Messages:
    61
    Occupation:
    Designer
    Location:
    Toledo, Ohio - USA
    Balance:
    9Coins
    Ratings:
    +0 / 0 / -0
    Since X-sim is not blocking the file. I will look into more and see If I can get it work. If in fact mine would drop some values perhaps it will pick those up in the next second, which might be ok...I'll look more

    Thanks
  10. FAG

    FAG New Member

    Joined:
    Apr 2, 2009
    Messages:
    35
    Occupation:
    Perm/Russia
    Balance:
    413Coins
    Ratings:
    +0 / 0 / -0
    Can this sample help you

    // crt_locking.c
    /* This program opens a file with sharing. It locks
    * some bytes before reading them, then unlocks them. Note that the
    * program works correctly only if the file exists.
    */

    #include <sys/types.h>
    #include <sys/stat.h>
    #include <sys/locking.h>
    #include <share.h>
    #include <fcntl.h>
    #include <stdio.h>
    #include <stdlib.h>
    #include <io.h>

    int main( void )
    {
    int fh, numread;
    char buffer[40];

    /* Quit if can't open file or system doesn't
    * support sharing.
    */
    errno_t err = _sopen_s( &fh, crt_locking.txt, _O_RDONLY, _SH_DENYNO,
    _S_IREAD | _S_IWRITE );
    printf( %d %d\n, err, fh );
    if( err != 0 )
    exit( 1 );

    /* Lock some bytes and read them. Then unlock. */
    if( _locking( fh, LK_NBLCK, 30L ) != -1 )
    {
    long lseek_ret;
    printf( No one can change these bytes while I'm reading them\n );
    numread = _read( fh, buffer, 30 );
    buffer[30] = '\0';
    printf( %d bytes read: %.30s\n, numread, buffer );
    lseek_ret = _lseek( fh, 0L, SEEK_SET );
    _locking( fh, LK_UNLCK, 30L );
    printf( Now I'm done. Do what you will with them\n );
    }
    else
    perror( Locking failed\n );

    _close( fh );
    }
  11. kjg71

    kjg71 New Member

    Joined:
    Sep 12, 2007
    Messages:
    61
    Occupation:
    Designer
    Location:
    Toledo, Ohio - USA
    Balance:
    9Coins
    Ratings:
    +0 / 0 / -0
    FAG,

    Thanks for the code. I do not work with C, but will use the comments and methods to see what I can do. other C users will benifit from it I think.

    I also see I might be inadvertenly closing the file after I open it and if this is the case and X-sim first opens it sets it for share and then I open and leave open then the connection might work. I am going to test tonight...can't believe I missed something.

    Thanks
  12. kjg71

    kjg71 New Member

    Joined:
    Sep 12, 2007
    Messages:
    61
    Occupation:
    Designer
    Location:
    Toledo, Ohio - USA
    Balance:
    9Coins
    Ratings:
    +0 / 0 / -0
    sirnoname,

    I have looked at this again and it seems that X-sim definately locks the file when logging. Is there a more recent version of profiler where this is not the case? or is this something that can be changed? I did see that I can open the CSV file and leave it open for sure with my program....I can definately say that I have it unlocked. I tested this and excel can open the file when I have it open.

    X-sim seemed to do it whether or not I locked it so it seems to open no matter what. However, it does hold it when using so no others can access. I have a newer version of my test program that I include in another post as soon as my server is back up--got an access issue right now, this version of app shows all the data that is read (not just the fields I specified). Also a message appears saying that another app has control of CSV so you can see when the test program is getting blocked. Also shows location of file to double check that x-sim is pointing to same. This may help further maybe.

    Let me know on the x-sim releasing the file thing and if maybe the version I have should be doing this?

    file is over 250 KB so it can be accessed as an attachment. is there a way I can upload 0-3 MB files to this forum? ...or maybe I am doing wrong?

    Thanks!
    Kyle
  13. kjg71

    kjg71 New Member

    Joined:
    Sep 12, 2007
    Messages:
    61
    Occupation:
    Designer
    Location:
    Toledo, Ohio - USA
    Balance:
    9Coins
    Ratings:
    +0 / 0 / -0
    sirnoname and others,

    As promised, Here is the 2nd test file I mention in previous post. Let me know your thoughts on the option to allow x-sim loggin to release the CSV for other apps while its writing the values in real-time.

    http://www.foreveryoursmedia.com/test/r ... ample2.zip

    Kyle
  14. kjg71

    kjg71 New Member

    Joined:
    Sep 12, 2007
    Messages:
    61
    Occupation:
    Designer
    Location:
    Toledo, Ohio - USA
    Balance:
    9Coins
    Ratings:
    +0 / 0 / -0
    Sirnoname,

    Where you able to download and take a look at the test file above from june, in regards to the option to allow x-sim logging feature to release the CSV for other apps while its writing the values in real-time. At one point I think you said that it should be unlocked when it logs, but I am seeing it holding the CSV file while it writes. I think you mentioned X-sim is set to not lock it currently?...just want to confirm that or see if you can check again.

    Many Thanks! :thbup:
    Kyle