Logger v1.1— XML → HDD → XML
Installation
FS9
Copy Logger9.dll
to the Modules folder. For example,
into this folder:C:\Program Files\Microsoft Games\Flight Simulator
9\Modules
. That's it.
FSX
Create a Modules folder in the root FSX directory if the Modules folder does not already
exist, and put LoggerX.dll
in it.
Next, locate the FSX dll.xml
file. Its path may be something
like:
C:\Users\username\AppData\Roaming\Microsoft\FSX\dll.xml
or,
C:\Documents and Settings\username\Application Data\Microsoft\FSX\dll.xml
Then, edit the dll.xml
file by adding the following lines of
code to the end of the SimBase.Document
element:
<Launch.Addon>
<Name>Logger</Name>
<Disabled>False</Disabled>
<ManualLoad>False</ManualLoad>
<Path>Modules\LoggerX.dll</Path>
<DllStartName>module_init</DllStartName>
<DllStopName>module_deinit</DllStopName>
</Launch.Addon>
FS9 and FSX Command Syntax
Regardless of use in FS9 or FSX, Logger commands use the name LOGGER, not LOGGER9 or LOGGERX. For example:
(>C:LOGGER:openRead)
, but not
(>C:LOGGER9:openRead)
Logger API Summary
Name | R/W | Type | Operation |
---|---|---|---|
openAppend | Write | String | Opens the given file for writing. Appends to the end of it. Creates file if it doesn't exist. Writes using Line Format |
Read | String | Returns full path file name of file currently open for writing | |
openCsvAppend | Write | String | Opens the given file for writing. Appends to the end of it. Creates file if it doesn't exist. Writes using CSV Format |
Read | String | Returns full path file name of file currently open for writing | |
openWrite | Write | String | Creates the given file for writing. Erases file if it exists. Writes using Line format |
Read | String | Returns full path file name of file currently open for writing | |
openCsvWrite | Write | String | Creates the given file for writing. Erases file if it exists. Writes using CSV format |
Read | String | Returns full path file name of file currently open for writing | |
openRead | Write | String | Opens the given file for reading. Reading assumes Line Format |
Read | String | Returns full path file name of file currently open for reading | |
openCsvRead | Write | String | Opens the given file for reading. Reading assumes CSV Format |
Read | String | Returns full path file name of file currently open for reading | |
countRead | Read | Number | Returns the number of records read since opening the file. It does not count records bypassed using the skip command |
number | Write | Number | Writes a number to the writable file |
Read | Number | Reads a number from the readable file | |
string | Write | String | Writes a string to the writable file |
Read | String | Reads a string from the readable file | |
newline | Write | Number | Writing anything to this variable inserts a new line to the writable file |
eof | Read | Number | Returns 1 if End Of File has been reached. Otherwise, 0 |
skip | Write | Number | Skips X records from the current record position in the opened read file |
closeWrite | Write | Number | Closes the file that's open for writing |
closeRead | Write | Number | Closes the file that's open for reading |
delete | Write | String | Deletes the specified file by removing it to the Recycle Bin |
version | Read | Number | Returns Logger version number |
File Open and File Close Commands
Logger reads and writes standard text files. The files can be any text file type such as .txt, .cfg, .ini, or .csv, but not .doc or .xls. The full directory path should be specified in the filename. If only the Filename.ext is specified, Logger will look for, or create the file in the root Flight Simulator directory.
(>C:LOGGER:openRead)
Opens an existing file that was written in standard line format.
Example usage:
C:\Documents and Settings\username\Desktop\LOGGER\File.txt
(>C:LOGGER:openRead)
This opens File.txt
and makes it available for reading using
Logger read commands (discussed later).
Or, if a macro is used for the file path:
<Macro Name="Path">
'C:\Documents and Settings\TEMP\Desktop\LOGGER\'
</Macro>
@Path 'File.txt' scat (>C:LOGGER:openRead)
(>C:LOGGER:openCsvRead)
Opens an existing file that was written in comma separated value (csv) format.
Example usage:
@Path 'File.txt' scat (>C:LOGGER:openCsvRead)
(>C:LOGGER:openWrite)
Creates/truncates and opens a new file and instructs Logger to write records to the file using standard line format.
Example usage:
@Path 'File.txt' scat (>C:LOGGER:openWrite)
(>C:LOGGER:openCsvWrite)
Creates/truncates and opens a new file and instructs Logger to write records to the file using comma separated value (csv) format.
Example usage:
@Path 'File.txt' scat (>C:LOGGER:openCsvWrite)
(>C:LOGGER:openAppend)
Opens an existing file (or creates it if it doesn't exist) and instructs Logger to write records to the file using standard line format, appending new data to the existing records starting after the last record in the file.
Example usage:
@Path 'File.txt' scat (>C:LOGGER:openAppend)
(>C:LOGGER:openCsvAppend)
Opens an existing file (or creates it if it doesn't exist) and instructs Logger to write records to the file using comma separated value (csv) format, appending new data to the existing records starting after the last record in the file.
Example usage:
@Path 'File.txt' scat (>C:LOGGER:openCsvAppend)
(>C:LOGGER:closeRead)
Closes the file currently opened for reading.
Example usage:
1 (>C:LOGGER:closeRead)
(>C:LOGGER:closeWrite)
Closes the file currently opened for writing.
Example usage:
1 (>C:LOGGER:closeWrite)
(>C:LOGGER:delete)
Deletes the specified file by removing it to the Recycle Bin if the full path to the
file is specified. If the full path is not specified, the file may be permanently deleted.
Please read the very important instructions regarding use of
LOGGER:delete
in the RULES section below.
Example usage:
@Path 'File.txt' scat (>C:LOGGER:delete)
(C:LOGGER:openAppend)
(C:LOGGER:openCsvAppend)
(C:LOGGER:openWrite)
(C:LOGGER:openCsvWrite)
(C:LOGGER:openRead)
(C:LOGGER:openCsvRead)
Reading any of the open file variables returns the full path file name of file currently open for reading or writing. This feature can be used to store the names of initialization or parameter files as they are written, then at the start of a flight, read those file names and pass to a Logger openRead operation.
For example, (C:LOGGER:openWrite)
returns the following:
C:\Documents and Settings\TEMP\Desktop\LOGGER\WriteFile.txt
and
(C:LOGGER:openWrite) (>C:LOGGER:string)
writes that file name to file.
Reading (C:LOGGER:openRead)
or (C:LOGGER:openCsvRead)
is also a
useful way to verify that a file was successfully opened, and a best practice to include in
your code.
@Path ‘File.txt’ scat (>C:LOGGER:openRead)
opens File.txt, but if that file does not exist, for example because of a typo error in
the file name, then the file will not open and reading (C:LOGGER:openRead)
will
return an empty string. Consequently, the following can be used to verify a successful file
open:
(C:LOGGER:openRead) slen 0 !=
if{ do your code }
els{ 1 (>L:ReadFailure, bool) }
or something equivalent.
(C:LOGGER:version)
Returns the Logger version number.
Example usage:
(C:LOGGER:version)
In a display element, for example:
<String>Logger v%((C:LOGGER:version))%!3.2f!</String>
Data Read and Write Commands
Logger reads and writes number and string records using either standard line format or comma separated value format. Standard line format contains one record per line. Comma separated value format may contain multiple records per line, all separated by commas.
There are several combinations of Logger open file and data read/write instructions. Download the Read and Write Format Tables from this website for more detailed examples file read and write results.
Read Commands
Used to read individual records from a file
(C:LOGGER:number)
Reads a number record from the file that was opened with
openRead
or openCsvRead
commands.
Example usage:
(C:LOGGER:number) (>L:OxygenBottle1Pressure, psi)
(C:LOGGER:string)
Reads a string record from the file that was opened with
openRead
or openCsvRead
commands.
Example usage:
(C:LOGGER:string) (>C:fs9gps:FlightPlanNewWaypointICAO)
(C:LOGGER:eof)
End Of File. Used in reading files. Returns 0 if the end of file, or last record in the file has not been reached, and 1 when it has.
Example usage:
(C:LOGGER:eof) 1 == if{ do something }
(C:LOGGER:skip)
Skips X records from the current record position in the opened read file.
Example Usage: If reading a file that contains consecutive integers starting at 1,
9 (>C:LOGGER:skip)
(C:LOGGER:number) (>L:Num1, number)
4 (>C:LOGGER:skip)
(C:LOGGER:number) (>L:Num2, number)
L:Num1 will receive record number 10 and L:Num2 will receive record number 15
(C:LOGGER:countRead)
Returns the number of records read since the read file was opened. LOGGER:countRead does not count records bypassed using LOGGER:skip.
Example Usage: The following counts the number of records in a file and stores that number into L:NumberOfRecords:
:2000
(C:LOGGER:string)
(C:LOGGER:eof) 1 == if{ g2001 }
g2000
:2001
(C:LOGGER:countRead) (>L:NumberOfRecords, enum)
The read command LOGGER:string is used in the example above, but nothing is done with the records as they are read - they are not stored into L:Vars or string variables or displayed. They are only counted. In this use, it does not matter if LOGGER:string or LOGGER:number is used or if an individual record type is string or number. Both types will be ‘read’ and LOGGER:countRead will count it.
Write Commands
Used to write individual records to a file
(>C:LOGGER:number)
Writes a number record in the file that has been opened with
openWrite
, openCsvWrite
,
openAppend
, or openCsvAppend
commands.
Example usage:
(A:AIRSPEED INDICATED, knots) (>C:LOGGER:number)
(>C:LOGGER:string)
Writes a string record in the file that has been opened with
openWrite
, openCsvWrite
,
openAppend
, or openCsvAppend
commands.
Example usage:
(C:fs9gps:WaypointAirportName) (>C:LOGGER:string)
(>C:LOGGER:newline)
Directs writing of the next record to a new line. Newline is used primarily when writing
repetitive data to a file using the csv record format
(openCsvWrite
or openCsvAppend
) such
as in a Flight Data Recorder application.
Example usage:
1 (>C:LOGGER:newline)
Rules
Write
Logger will allow only one Write file to be open at a time. Creating a second Write file
will automatically close a previous Write file if it is open. As a consequence, there is
never a need to execute more than one closeWrite
command in
order for all Write files to be closed.
For example:
'File1.txt' (>C:LOGGER:openWrite)
creates
File1.txt
'File2.ini' (>C:LOGGER:openWrite)
closes
File1.txt
then creates
File2.ini
1 (>C:LOGGER:closeWrite)
closes File2.ini
.
All Write files are now closed.
Additionally, openWrite
and
openCsvWrite
will first erase the file if it already exists.
Read
Logger will allow only one Read file to be open at a time. Creating a second Read file will automatically close a previous Read file if it is open. As a consequence, there is never a need to execute more than one closeRead command in order for all Read files to be closed.
For example:
'File3.csv' (>C:LOGGER:openRead)
opens
File3.csv
'File4.txt' (>C:LOGGER:openRead)
closes
File3.csv
then opens
File4.txt
1 (>C:LOGGER:closeRead)
closes File4.txt
.
All Read files are now closed.
Read and Write
A single Read and a single Write file can be open at the same time.
Append
openAppend
and openCsvAppend
behave identically to openWrite
and
openCsvWrite
respectively, except that Append mode will append
content to the end of a file if it exists, rather than overwriting the existing file.
For example:
'Write1.txt' (>C:LOGGER:openWrite)
creates
Write1.txt
'Read1.txt' (>C:LOGGER:openRead)
opens
Read1.txt
'Write2.ini' (>C:LOGGER:openAppend)
closes
Write1.txt
then opens
Write2.ini
.
Read1.txt
is not affected.
All Read files are now closed.
If Write2.ini
did not previously exist, it will be created
and records will be appended to it.
Reload_Panels
RELOAD conflicts with Logger's ability to close files and its use should be avoided while Logger is active.
Whenever (>K:RELOAD_PANELS)
is executed after a Read or Write file has
been opened, Logger loses its ability to automatically close that file when a subsequent
Read or Write file is opened.
Additionally, following execution of (>K:RELOAD_PANELS)
, Logger's
closeRead
and closeWrite
commands
will not be able to close a Read or Write file that was opened before the RELOAD.
Consequently, with no way for Logger to close the file, Flight Simulator will have to be
exited in order to release the file and close it.
Files created or opened after (>K:RELOAD_PANELS)
has been executed will
behave normally. Creating or opening a second file will close the first, and the
closeRead
and closeWrite
commands
will function normally. Still, however, files that were open before the
(>K:RELOAD_PANELS)
event will remain open until Flight Simulator is
exited.
Delete
LOGGER:delete
, like all delete commands, can have unintended
consequences if the file path and name are not designated perfectly.
Assume that file AAA.txt
has the following directory
path:
C:\Documents and Settings\username\Desktop\LOGGER\AAA.txt
Proper file path designation
'C:\Documents and Settings\username\Desktop\LOGGER\AAA.txt' (>C:LOGGER:delete)
will delete AAA.txt
to the Recycle Bin as intended.
Improper file path designation
'C:\Documents and Settings\username\Desktop\LOGGER\' (>C:LOGGER:delete)
will have no effect. However:
'C:\Documents and Settings\username\Desktop\LOGGER' (>C:LOGGER:delete)
(note the absence of the final \) will delete the Logger folder to the Recycle bin.
Managing Output (Write) File Size
A tremendous amount of data can be recorded to file using Logger. Hundreds of different variables of any type (A:, E:, P:, G:, L:, or fs9gps) can be written to file each gauge update cycle. Unless some cycles are skipped between recordings, the output file will get very large, very rapidly, especially if recording data every cycle at 18 update cycles per second.
Examples of update cycle skipping XML can be found in the FLIGHT DATA RECORDER.xml and FDR for Google Earth.xml files (see below).
Write File Limitations and FS Cycle Timeout Limit
Writing data to hard disk is one of the most time consuming operations your gauge can undertake. Unlike the Flight Simulator gps module (in which data base searches can also be very time consuming) that operates asynchronously with your gauge, Logger is synchronous with the host gauge, so it is possible to reach the update cycle time-out limit of around 55 milliseconds before all data have been written to hard disk.
The number of records that can be written to hard disk each update cycle is dependent upon the hard drive capability, system resource load, and especially gauge complexity. It is independent of update cycle frequency. During tests using a fairly simple gauge, around 750 different variables were written to hard disk every update cycle (with Update running 18 cycles per second) before exceeding the cycle time-out limit and losing some records. With a very complex gauge and a convoluted Logger write command structure, at least 250 variables were written to hard disk each update cycle before exceeding the time-out limit.
Effect on Framerate
Use of Logger has no, or negligible effect on frame rate, even when recording hundreds of variables each update cycle.
Using Logger - Examples
XML script examples of several Logger applications can be downloaded from this site.
Flight Data Recorder
A common use of Logger is as a Flight Data Recorder to record to HDD file flight variables for later playback, or to record interactions of various variables for detailed debugging analysis.
Example XML snippet: FLIGHT DATA RECORDER.xml
Save and Load a Flight Plan (or SID or STAR)
The Flight Simulator gps module provides the capability to easily create new Flight Plans, SIDs or STARs consisting of Waypoint coordinates using the FlightPlanDirectToDestination, DeleteWaypoint and AddWaypoint variables. Combining gps XML instructions with Logger enables the User to create, save and load Flight Plans to and from HDD file from within an XML Flight Management System gauge or GPS gauge without needing to use Flight Simulator's Flight Planner application.
Limitations to this method of creating Flight Plans include the inability of the Flight Simulator gps module to write (set) Flight Plan Type (VFR or IFR), Route Type (Direct, VOR, Low Alt or High Alt Airways), Cruising Altitude and automatic engagement of Flight Sim's ATC module. Flight Simulator's Flight Planner is still required to set those variables. On the other hand, one advantage of creating Flight Plans from within XML and using Logger to store the Flight Plan is the ability to add VNAV Target Altitude and VS Profile to the Waypoint information.
Example XML snippet: SAVE AND LOAD FLIGHT PLAN.xml
Save and Load Initial Values
Logger can be used to save and load initial values or settings of gauges you create - values that cannot otherwise be saved when you perform a Save Flight.
Example XML snippet: SAVE AND LOAD INIT VALUES.xml
Replaying Flight Simulator Flights in Google Earth
There are several very compelling visualizations (tracks) and playbacks (tours) that can be performed using Google Earth once you have recorded a few flight A:Vars with Logger during a Flight Simulator flight and saved them to a .csv file.
To view Logger flight data in Google Earth, a .kml (keyhole markup language) format file that Google Earth reads must be made. Using the excel macro LOGGER - Google Earth v0.90 Beta.xls, Google Earth Tours and Tracks are easy to generate. The tours replay the flight from the pilot's perspective. The tracks show the course of the flight over the ground and in the air. Several example kml files are available for download from this site that demonstrate what can be done. Just download the kml files and double click the filename to launch Google Earth.
Google Earth version 6 or newer is required.
Example XML: FDR for Google Earth.xml. This is a complete xml gauge that can be used to record the flight information needed to generate Google Earth playback. It is recommended that the gauge be set up as a separate window in your panel.cfg file. The gauge size is 200 X 200 pix.
Before running the flight recorder, open the xml file and edit line 5 to show the file path that you want used for the output file. Indicate the file path, but exclude the file name and .csv file extension - those are entered while Flight Simulator is running.
To operate the recorder while Flight Simulator is running, first click the white FILENAME.CSV text box to enable keyboard entry, then type the desired file name. Include the file extension .csv, but do not include the entire file path here. Click the text box again to disable keyboard entry.
Click the white CYCLES TO SKIP entry box and enter the number of gauge update cycles to skip in between Logger recordings. A value of 0 or 1 causes Logger to record flight variables every update cycle. A value of 18 causes Logger to record flight variables every 18 cycles, or once every second at the default update frequency of 18 cycles per second, and so forth. Click the number entry box again to disable keyboard entry.
Finally, click the ON/OFF button to start and stop the recorder.
KML generation spreadsheet: LOGGER - Google Earth v0.90 Beta.xls is a Microsoft Excel 2003 application that contains macros to generate a Google Earth tour or track kml file. It functions also in Excel 2007. Copy Logger - Google Earth v0.90 Beta.xls to any directory, and then open it in Excel. Excel may issue a Security Warning asking permission to Enable Macros. Adjust Excel macro security settings if necessary (Tools > Macro > Security > Medium), click "Enable Macros", and then open the Instructions Worksheet. Follow directions on the Instructions Worksheet.
The LOGGER - Google Earth v0.90 Beta.xls spreadsheet was written entirely by Bob McElrath