Discussion Commanders log manual and data sample

The “Periapsis” parameter in Scan events is misnamed: it really ought to be “ArgOfPeriapsis” or something like that. I guess we can live with that, though; worse errors are known to occur in official standards :)
 
More than complicated and not necessary at all. For me, it's only required to allow scans on all present stellar bodies (should be simple).
Because normally the scan is done automatically, when close to ca. 30 LS of an object, but it could be changed to a hotkey or
by adding a sub command to UNEXPLORED entries of the Navigation or Contact list, if the body is the target and the scanner is installed.

That requires a little more work, but feels more reasonable to activate the scanner by a key or command.

I would like to bring Sandro's Exploration Scan thread to your attention.
 
lol that would explain that :D thanks

also is there a entry for credits? like when they change value?

No single one, but I believe that every transaction that provides or receives credits is covered across the various events.
 
No single one, but I believe that every transaction that provides or receives credits is covered across the various events.

yea that does.. hrm no credit one.. oh well guess i'll have to add the things manually :D

thanks for the answers <3
 
Hello all, I was trying to read from the log files while playing, but it seems that the logs are not saved until the game is closed, anyone else faced the same problem?
 
I'm using C# FileSystemWatcher Class
The change event is triggered only when the file is created, which is when the game starts and when the game exits.

You have to poll for new content in the file stream. Check out my EliteDMX project on github for an example. Link in my signature.
 
I'm using C# FileSystemWatcher Class
The change event is triggered only when the file is created, which is when the game starts and when the game exits.
What Toumal said, also it might be that you're locking ED out of the file? Fileaccess can be a mess in C#, I had some fights with it too.
 
I don't know if this is the right place to post this here but here is my code, i can't find anything wrong, but still it is not working.
View attachment 112469

I forgot to mention that this code snapshot is from Toumal solution.

I think i got what is the issue. the OnChanged event of the FileSystemWatcher is triggered when the file size changes. on the other hand, the game is updating the log file using the Flush method of the FileStream class, which does not cause Windows to flush the file’s metadata. The metadata is not flushed until the FileStream Close method is called.

I believe a fix for that, is to use Close method when a log is written and not to rely only only on Flush.
 
Last edited:
I forgot to mention that this code snapshot is from Toumal solution.

I think i got what is the issue. the OnChanged event of the FileSystemWatcher is triggered when the file size changes. on the other hand, the game is updating the log file using the Flush method of the FileStream class, which does not cause Windows to flush the file’s metadata. The metadata is not flushed until the FileStream Close method is called.

I believe a fix for that, is to use Close method when a log is written and not to rely only only on Flush.

Hi Tommy, the trick is to not only rely on the FileWatcher. For instance, check out this bit of code: https://github.com/MagicMau/EliteJo...liteJournalReader/JournalWatcher.cs#L241-L256

It's just a basic loop over the currently active journal file that checks if there is more info written to the file. If so, read the new lines and parse them.

You can then use the FileWatcher to be notified if new files arrive (a new journal file for instance).

Hope that helps!
 
I forgot to mention that this code snapshot is from Toumal solution.

I think i got what is the issue. the OnChanged event of the FileSystemWatcher is triggered when the file size changes. on the other hand, the game is updating the log file using the Flush method of the FileStream class, which does not cause Windows to flush the file’s metadata. The metadata is not flushed until the FileStream Close method is called.

I believe a fix for that, is to use Close method when a log is written and not to rely only only on Flush.


I had the same problem. My solution is to open
a read stream on the current file and polling it with
Code:
Thread.Sleep(1000)
if(!journalStreamReader.EndOfStream)
{
    //do some work because there is a new event entry
    // e.g. var newLine = journalStreamReader.ReadLine()
}

it works 100%
 
Last edited:
@MagicMau, @Duke Thx for the links and the code snapshot
Yes if you open / read the file, refresh the directory, read a single byte...etc you will get the updates, my point is that what are we doing is a workaround but not a normal solution.
 
My code uses the filesystemwatcher to find new logfiles as they are created. I use polling to check if new content is in the current logfile. Yes that is the classic way to do this, though under linux FAM works even for still open files.

If you take my polling code and the filesystemwatcher bits then you have all you need.
 
Here's a class to read the stuff:

Code:
        public class AddedContentReader
        {

            private readonly FileStream _fileStream;
            private readonly StreamReader _reader;

            //Start position is from where to start reading first time. consequent read are managed by the Stream reader
            public AddedContentReader(string fileName, long startPosition = 0)
            {
                //Open the file as FileStream
                _fileStream = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
                _reader = new StreamReader(_fileStream);
                //Set the starting position
                _fileStream.Position = startPosition;
            }


            //Get the current offset. You can save this when the application exits and on next reload
            //set startPosition to value returned by this method to start reading from that location
            public long CurrentOffset
            {
                get { return _fileStream.Position; }
            }

            public bool NewDataReady()
            {
                return (_fileStream.Length >= _fileStream.Position);
            }

            //Returns the lines added after this function was last called
            public string GetAddedLine()
            {
                return _reader.ReadLine();
            }
        }


To use, do this:

Code:
        _continuousFileReader = new AddedContentReader(file.FullPath);
        while (true) {
        Thread.yield();
            if (_continuousFileReader != null && _continuousFileReader.NewDataReady())
            { 
                // Specify what is done when a file is changed, created, or deleted.
                string newLines = _continuousFileReader.GetAddedLine();
                if (newLines != null && newLines.Length > 0)
                {
                    Console.WriteLine("New data: " + newLines);
                    //Do stuff
                }
            }
         }


I still recommend using the filesystemwatcher to handle the "create" event of files, that way you don't have to parse the logfile for the filename of the next logfile once it grows beyond max size.
 
Last edited:
Back
Top Bottom