mirror of
https://github.com/weyne85/DCS-ExportScripts.git
synced 2025-10-29 16:58:18 +00:00
Add callback funktions for standard functions LuaExportStart, LuaExportStop, LuaExportBeforeNextFrame, LuaExportAfterNextFrame...
Delete function LuaExportActivityNextEvent(t). Add new function request for ExportScript.Tools.ProcessOutput() in function LuaExportBeforeNextFrame().
This commit is contained in:
parent
140bbd4c14
commit
a1b9b865fd
@ -19,6 +19,12 @@ ExportScript.PacketSizeDAC = {}
|
||||
ExportScript.SendStringsDAC = {}
|
||||
ExportScript.LastDataDAC = {}
|
||||
|
||||
local PrevExport = {}
|
||||
PrevExport.LuaExportStart = LuaExportStart
|
||||
PrevExport.LuaExportStop = LuaExportStop
|
||||
PrevExport.LuaExportBeforeNextFrame = LuaExportBeforeNextFrame
|
||||
PrevExport.LuaExportAfterNextFrame = LuaExportAfterNextFrame
|
||||
|
||||
dofile(lfs.writedir()..[[Scripts\DCS-ExportScript\Config.lua]])
|
||||
dofile(lfs.writedir()..[[Scripts\DCS-ExportScript\lib\Tools.lua]])
|
||||
dofile(lfs.writedir()..[[Scripts\DCS-ExportScript\lib\genericRadio.lua]])
|
||||
@ -75,6 +81,11 @@ function LuaExportStart()
|
||||
ExportScript.AF = {} -- Table for Auxiliary functions
|
||||
|
||||
ExportScript.Tools.SelectModule() -- point globals to Module functions and data.
|
||||
|
||||
-- Chain previously-included export as necessary
|
||||
if PrevExport.LuaExportStart then
|
||||
PrevExport.LuaExportStart()
|
||||
end
|
||||
end
|
||||
|
||||
function LuaExportBeforeNextFrame()
|
||||
@ -84,9 +95,20 @@ function LuaExportBeforeNextFrame()
|
||||
ExportScript.coProcessArguments_BeforeNextFrame = coroutine.create(ExportScript.Tools.ProcessInput)
|
||||
coStatus = coroutine.resume(ExportScript.coProcessArguments_BeforeNextFrame)
|
||||
end
|
||||
|
||||
ExportScript.Tools.ProcessOutput()
|
||||
|
||||
-- Chain previously-included export as necessary
|
||||
if PrevExport.LuaExportBeforeNextFrame then
|
||||
PrevExport.LuaExportBeforeNextFrame()
|
||||
end
|
||||
end
|
||||
|
||||
function LuaExportAfterNextFrame()
|
||||
-- Chain previously-included export as necessary
|
||||
if PrevExport.LuaExportAfterNextFrame then
|
||||
PrevExport.LuaExportAfterNextFrame()
|
||||
end
|
||||
end
|
||||
|
||||
function LuaExportStop()
|
||||
@ -116,184 +138,10 @@ function LuaExportStop()
|
||||
ExportScript.logFile:flush()
|
||||
ExportScript.logFile:close()
|
||||
ExportScript.logFile = nil
|
||||
end
|
||||
end
|
||||
|
||||
function LuaExportActivityNextEvent(t)
|
||||
t = t + ExportScript.Config.ExportInterval
|
||||
local coStatus
|
||||
|
||||
--ExportScript.TickCount = ExportScript.TickCount + 1
|
||||
ExportScript.TickCount = ExportScript.TickCount + ExportScript.Config.ExportInterval
|
||||
|
||||
local lMyInfo = LoGetSelfData()
|
||||
if lMyInfo ~= nil then
|
||||
if ExportScript.ModuleName ~= lMyInfo.Name then
|
||||
ExportScript.Tools.SelectModule() -- point globals to Module functions and data.
|
||||
end
|
||||
lMyInfo = nil
|
||||
end
|
||||
|
||||
local lDevice = GetDevice(0)
|
||||
if type(lDevice) == "table" and ExportScript.FoundDCSModule then
|
||||
|
||||
lDevice:update_arguments()
|
||||
|
||||
if ExportScript.Config.Debug then
|
||||
ExportScript.Tools.WriteToLog("run hight importance export universally")
|
||||
ExportScript.Tools.ProcessArguments(lDevice, ExportScript.EveryFrameArguments) -- Module arguments as appropriate
|
||||
else
|
||||
ExportScript.coProcessArguments_EveryFrame = coroutine.create(ExportScript.Tools.ProcessArguments)
|
||||
coStatus = coroutine.resume( ExportScript.coProcessArguments_EveryFrame, lDevice, ExportScript.EveryFrameArguments)
|
||||
end
|
||||
|
||||
if ExportScript.Config.IkarusExport then
|
||||
if ExportScript.Config.Debug then
|
||||
ExportScript.Tools.WriteToLog("run hight importance export Ikarus")
|
||||
ExportScript.ProcessIkarusDCSHighImportance(lDevice) -- Module, as appropriate; determined in ExportScript.Tools.SelectModule()
|
||||
else
|
||||
ExportScript.coProcessIkarusDCSHighImportance = coroutine.create(ExportScript.ProcessIkarusDCSHighImportance)
|
||||
coStatus = coroutine.resume( ExportScript.coProcessIkarusDCSHighImportance, lDevice)
|
||||
end
|
||||
end
|
||||
|
||||
if ExportScript.Config.DACExport then
|
||||
if ExportScript.Config.Debug then
|
||||
ExportScript.Tools.WriteToLog("run hight importance export DAC")
|
||||
ExportScript.ProcessDACHighImportance(lDevice) -- Module, as appropriate; determined in ExportScript.Tools.SelectModule()
|
||||
else
|
||||
ExportScript.coProcessDACHighImportance = coroutine.create(ExportScript.ProcessDACHighImportance)
|
||||
coStatus = coroutine.resume( ExportScript.coProcessDACHighImportance, lDevice)
|
||||
end
|
||||
end
|
||||
|
||||
if ExportScript.FirstNewDataSend and ExportScript.FirstNewDataSendCount == 0 then
|
||||
if ExportScript.Config.DACExport then
|
||||
ExportScript.Tools.ResetChangeValuesDAC()
|
||||
end
|
||||
if ExportScript.Config.IkarusExport then
|
||||
ExportScript.Tools.ResetChangeValues()
|
||||
end
|
||||
ExportScript.FirstNewDataSend = false
|
||||
else
|
||||
ExportScript.FirstNewDataSendCount = ExportScript.FirstNewDataSendCount - 1
|
||||
end
|
||||
|
||||
if ExportScript.TickCount >= ExportScript.Config.ExportLowTickInterval then
|
||||
if ExportScript.Config.Debug then
|
||||
ExportScript.Tools.WriteToLog("run low importance export universally")
|
||||
ExportScript.Tools.ProcessArguments(lDevice, ExportScript.Arguments) -- Module arguments as appropriate
|
||||
else
|
||||
ExportScript.coProcessArguments_Arguments = coroutine.create(ExportScript.Tools.ProcessArguments)
|
||||
coStatus = coroutine.resume( ExportScript.coProcessArguments_Arguments, lDevice, ExportScript.Arguments)
|
||||
end
|
||||
|
||||
if ExportScript.Config.IkarusExport then
|
||||
if ExportScript.Config.Debug then
|
||||
ExportScript.Tools.WriteToLog("run low importance export Ikarus")
|
||||
ExportScript.ProcessIkarusDCSLowImportance(lDevice) -- Module as appropriate; determined in ExportScript.Tools.SelectModule()
|
||||
else
|
||||
ExportScript.coProcessIkarusDCSLowImportance = coroutine.create(ExportScript.ProcessIkarusDCSLowImportance)
|
||||
coStatus = coroutine.resume( ExportScript.coProcessIkarusDCSLowImportance, lDevice)
|
||||
end
|
||||
end
|
||||
|
||||
if ExportScript.Config.DACExport then
|
||||
if ExportScript.Config.Debug then
|
||||
ExportScript.Tools.WriteToLog("run low importance export DAC")
|
||||
ExportScript.ProcessDACLowImportance(lDevice) -- Module, as appropriate; determined in ExportScript.Tools.SelectModule()
|
||||
else
|
||||
ExportScript.coProcessDACLowImportance = coroutine.create(ExportScript.ProcessDACLowImportance)
|
||||
coStatus = coroutine.resume( ExportScript.coProcessDACLowImportance, lDevice)
|
||||
end
|
||||
ExportScript.TickCountDAC = ExportScript.TickCountDAC + 1
|
||||
end
|
||||
ExportScript.TickCount = 0
|
||||
end
|
||||
|
||||
if ExportScript.Config.IkarusExport then
|
||||
ExportScript.Tools.FlushData()
|
||||
end
|
||||
|
||||
if ExportScript.Config.DACExport then
|
||||
for i=1, #ExportScript.Config.DAC, 1 do
|
||||
ExportScript.Tools.FlushDataDAC(i)
|
||||
end
|
||||
end
|
||||
elseif ExportScript.FoundFCModule then -- Assume FC Aircraft
|
||||
|
||||
ExportScript.AF.EventNumber = os.clock() --tonumber(tostring(os.clock()):gsub(".", ""))
|
||||
|
||||
if ExportScript.Config.IkarusExport then
|
||||
if ExportScript.Config.Debug then
|
||||
ExportScript.Tools.WriteToLog("run hight importance export Ikarus")
|
||||
ExportScript.ProcessIkarusFCHighImportance()
|
||||
else
|
||||
ExportScript.coProcessGlassCockpitFCHighImportance = coroutine.create(ExportScript.ProcessIkarusFCHighImportance)
|
||||
coStatus = coroutine.resume( ExportScript.coProcessGlassCockpitFCHighImportance)
|
||||
end
|
||||
end
|
||||
if ExportScript.Config.DACExport then
|
||||
if ExportScript.Config.Debug then
|
||||
ExportScript.Tools.WriteToLog("run hight importance export DAC")
|
||||
ExportScript.ProcessDACHighImportance(lDevice)
|
||||
else
|
||||
ExportScript.coProcessDACHighImportance = coroutine.create(ExportScript.ProcessDACHighImportance)
|
||||
coStatus = coroutine.resume( ExportScript.coProcessDACHighImportance, lDevice)
|
||||
end
|
||||
end
|
||||
|
||||
if ExportScript.FirstNewDataSend and ExportScript.FirstNewDataSendCount == 0 then
|
||||
if ExportScript.Config.DACExport then
|
||||
ExportScript.Tools.ResetChangeValuesDAC()
|
||||
end
|
||||
if ExportScript.Config.IkarusExport then
|
||||
ExportScript.Tools.ResetChangeValues()
|
||||
end
|
||||
ExportScript.FirstNewDataSend = false
|
||||
else
|
||||
ExportScript.FirstNewDataSendCount = ExportScript.FirstNewDataSendCount - 1
|
||||
end
|
||||
|
||||
if ExportScript.TickCount >= ExportScript.Config.ExportLowTickInterval then
|
||||
if ExportScript.Config.IkarusExport then
|
||||
if ExportScript.Config.Debug then
|
||||
ExportScript.Tools.WriteToLog("run low importance export Ikarus")
|
||||
ExportScript.ProcessIkarusFCLowImportance()
|
||||
else
|
||||
ExportScript.coProcessIkarusFCLowImportance = coroutine.create(ExportScript.ProcessIkarusFCLowImportance)
|
||||
coStatus = coroutine.resume( ExportScript.coProcessIkarusFCLowImportance)
|
||||
end
|
||||
end
|
||||
|
||||
if ExportScript.Config.DACExport then
|
||||
if ExportScript.Config.Debug then
|
||||
ExportScript.Tools.WriteToLog("run low importance export DAC")
|
||||
ExportScript.ProcessDACLowImportance(lDevice)
|
||||
else
|
||||
ExportScript.coProcessDACLowImportance = coroutine.create(ExportScript.ProcessDACLowImportance)
|
||||
coStatus = coroutine.resume( ExportScript.coProcessDACLowImportance, lDevice)
|
||||
end
|
||||
ExportScript.TickCountDAC = ExportScript.TickCountDAC + 1
|
||||
end
|
||||
ExportScript.TickCount = 0
|
||||
end
|
||||
|
||||
if ExportScript.Config.IkarusExport then
|
||||
ExportScript.Tools.FlushData()
|
||||
end
|
||||
|
||||
if ExportScript.Config.DACExport then
|
||||
for i=1, #ExportScript.Config.DAC, 1 do
|
||||
ExportScript.Tools.FlushDataDAC(i)
|
||||
end
|
||||
end
|
||||
else -- No Module found
|
||||
if ExportScript.FoundNoModul then
|
||||
ExportScript.Tools.WriteToLog("No Module Found.")
|
||||
ExportScript.Tools.SelectModule() -- point globals to Module functions and data.
|
||||
end
|
||||
|
||||
-- Chain previously-included export as necessary
|
||||
if PrevExport.LuaExportStop then
|
||||
PrevExport.LuaExportStop()
|
||||
end
|
||||
|
||||
return t
|
||||
end
|
||||
end
|
||||
Loading…
x
Reference in New Issue
Block a user