Jump to content
The simFlight Network Forums
Sign in to follow this  
spokes2112

Log only specific L:Vars in a display window for gauge debugging

Recommended Posts

I have always wanted to have a "quick and dirty" way to monitor specific L:VARs without installing a new gauge and trying to find the ones needed by scrolling etc. Perfect for things like programming sub-systems and such.

 

It's a 3 step process.

  • Run "LVARS_2_TXT.lua" to get the full list (output = "ALL LVARS.txt") of L:VARs currently loaded by the selected aircraft. It's a "run once" lua but, one can use it multiple times if multiple aircraft projects are being done as it appends to the file. (creates a master list) -OR- Run the FSUIPC command "List local panel variables" to do the same and written to the FSUIPC log (Formatting necessary!) , without using  "LVARS_2_TXT.lua" - The former provides a pre-formatted, easy to use output.
  • Pick the LVARs needed to monitor and copy them over into the array in "LVAR_SPECIFIC.lua". NOTE - The output in "ALL LVARS.txt" are pre-formatted for an easy copy --> paste. See notes in lua. Note - The lua display will truncate anything after 1023 characters so if this starts happening reorder your list in priority order.
  • Run  "LVAR_SPECIFIC.lua" to monitor your selected L:VARs.

LVARS_2_TXT.lua

-- "LVARS_2_TXT" Loaded LVARs writer, by Roman Stoviak, September 2015
 
-- Open an exisitng "All LVARS.txt" file to append to, or create it if it doesn't exist.
-- It will go into the Modules folder because I've not included a full path (like "C:\....")
-- By using "assert" you get an error message if this fails
 
f = assert(io.open("ALL LVARS.txt","a+"))
 
-- get aircraft name and air file name
air, title = ipc.readStruct(0x3C00, "256STR", "256STR")
air = air:gsub('%z','')
title = title:gsub('%z','')
 
-- write the text headings
f:write("_______________________________________________________________\nTITLE,      AIR FILE\n" .. title .. ",      " .. air .. "\n_______________________________________________________________\n")
 
i = 0
while i < 65536 do     
name = ipc.getLvarName(i) 
if name ~= nil then
f:write("\"" .. name .. "\",\n")
i = i + 1
else 
break
end
 
end
 
-- tidy up at end ...
f:write("\n____________________   END OF LIST   ____________________\n\n")
f:close()
 
ipc.display("A pre-formatted L:VARs list has been created as FSX/Modules/ALL LVARS.txt", 0, 3)
ipc.sleep(3000)
 
-- end of program

 

LVAR_SPECIFIC.lua

Note - The lua below has the array preloaded with L:VARs "test1" thru "test4" as an example. 

-- "MONITOR SPECIFIC LVARS" fsuipc display, by Roman Stoviak, September 2015

--[[
NOTES -
Enter each L:VAR to monitor by getting the "preformated" list provided by "LVARS_2_TXT.lua". Each L:VAR name MUST be surrounded in quotes and followed by a comma for each the array entry(s). One could use a single line for each L:VAR -or- Place all the L:VARs inline.

EX. separate lines
"test1",
"test2",
"test3",
"test4",

EX. same line
"test1","test2","test3","test4",

PLACE THE L:VAR LISTING IN THE ARRAY BELOW BETWEEN THE 2 COMMENTS CONTAINING "!!!!!"

END NOTES   
]]


local monitor = { 
-- COMMENT   !!!!! START ARRAY ON NEXT LINE !!!!!
"test1",
"test2",
"test3",
"test4",
-- COMMENT   !!!!! END ARRAY !!!!!
		   }

local size = table.getn(monitor)

while 1 do
local i = 1
local out = ""
local disp = ""
	repeat
		out = ipc.readLvar(monitor[i])
		if out == nil then  -- NEW SECTION TO KEEP LUA ALIVE IN CERTAIN SITUATIONS
			out = "no value"
		end
		disp = disp .. monitor[i] .. " = " .. out .. "\n"
		i = i + 1            
	until i == size + 1
	ipc.display(disp)		 
ipc.sleep(50)
end
Edited by spokes2112
added a check for nil values to keep lua alive
  • Upvote 1

Share this post


Link to post
Share on other sites

Rustam,

 

 Thank You!  Yes, there are other ways to do the same thing but they are too bulky meaning, must install gauge per aircraft, modify gauge to suit etc.. I've been using this setup extensively now and it saves a bunch of time.. Last night I decided to automate it a little more..

 

  1. If I am going to run LVARS_2_TXT.lua doesn't it mean I want to see the output ALL LVARS.txt instantly?
  2. If I am going to read the output ALL LVARS.txt it doesn't it mean I want to modify LVAR_SPECIFIC.lua to include new Lvars to monitor?
  3. Why not open them up right away instead of navigating to them?

Below is the last section of  LVARS_2_TXT.lua to make this happen.. Remember to change paths/programs to suit what's needed!

-- tidy up at end ...
f:write("\n____________________   END OF LIST   ____________________\n\n")
f:close()

ipc.display("A pre-formatted L:VARs list has been created as FSX/Modules/ALL LVARS.txt", 0, 1)
ipc.sleep(1000) 

-- CHANGE PATHS/PROGRAMS TO SUIT !!!!!!!
handle, error = ext.runif("E:/Notepad++/notepad++.exe","G:/FSX/Modules/ALL LVARS.txt")
handle2, error2 = ext.runif("E:/Notepad++/notepad++.exe","G:/FSX/Modules/LVAR_SPECIFIC.lua")

-- UNCOMMENT BELOW IF TEXT PROGRAMS DO NOT START - GET WINDOWS ERROR CODES
-- ipc.display(handle .. error .. "\n" .. handle2 .. error2, 0, 5)
-- ipc.sleep(5000)

-- end of program
  • Upvote 1

Share this post


Link to post
Share on other sites

In the initial post the last lua, "LVAR_SPECIFIC.lua" has been modified to include a check for nil values to keep the lua alive if a nil is ever encountered. 
Example of these are:
1) Poor L:Var name entries in to the lua. IE spelling, poor formatting etc...
2) Primarily this change came about when checking an output of a .dll where the .dll itself does not report/initialize its expected L:Var outputs until a certain situation has occurred.

Roman 

  

 

  • Upvote 1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

By using this site, you agree to our Terms of Use. Guidelines Privacy Policy We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.