Code cleared up...

Supplement the function ExportScript.Tools.SelectModule() to determine the possible map and to send the information to Ikarus.
This commit is contained in:
mcmicha 2017-02-15 23:26:35 +01:00
parent 7b2193e753
commit fae5e59f31

View File

@ -38,9 +38,15 @@ function ExportScript.Tools.ProcessInput()
if lCommand == "R" then -- R == Reset if lCommand == "R" then -- R == Reset
if ExportScript.Config.IkarusExport then if ExportScript.Config.IkarusExport then
ExportScript.Tools.ResetChangeValues() ExportScript.Tools.ResetChangeValues()
if ExportScript.Config.Debug then
ExportScript.Tools.WriteToLog("Reset fuer Ikarus Daten")
end
end end
if ExportScript.Config.DACExport then if ExportScript.Config.DACExport then
ExportScript.Tools.ResetChangeValuesDAC() ExportScript.Tools.ResetChangeValuesDAC()
if ExportScript.Config.Debug then
ExportScript.Tools.WriteToLog("Reset fuer DAC Daten")
end
end end
end end
@ -50,10 +56,16 @@ function ExportScript.Tools.ProcessInput()
if lDevice ~= "1000" then if lDevice ~= "1000" then
if type(lDevice) == "table" then if type(lDevice) == "table" then
lDevice:performClickableAction(lCommandArgs[2],lCommandArgs[3]) lDevice:performClickableAction(lCommandArgs[2],lCommandArgs[3])
if ExportScript.Config.Debug then
ExportScript.Tools.WriteToLog("Verarbeite fuer Device: "..lCommandArgs[1]..", ButtonID: "..lCommandArgs[2]..", mit Wert: "..lCommandArgs[3])
end
end end
elseif lDevice == "1000" then elseif lDevice == "1000" then
--ExportScript.genericRadio(key, value) --ExportScript.genericRadio(key, value)
ExportScript.genericRadio(lCommandArgs[2],lCommandArgs[3]) ExportScript.genericRadio(lCommandArgs[2],lCommandArgs[3])
if ExportScript.Config.Debug then
ExportScript.Tools.WriteToLog("Verarbeite fuer genericRadio, ButtonID: "..lCommandArgs[2]..", mit Wert: "..lCommandArgs[3])
end
end end
end end
end end
@ -224,11 +236,9 @@ end
function ExportScript.Tools.FlushData() function ExportScript.Tools.FlushData()
if #ExportScript.SendStrings > 0 then if #ExportScript.SendStrings > 0 then
local lES_SimID = "" local lES_SimID = ""
if ExportScript.GlassCockpitType == 1 then
lES_SimID = ExportScript.SimID lES_SimID = ExportScript.SimID
elseif ExportScript.GlassCockpitType == 2 then
lES_SimID = ""
end
local lPacket = lES_SimID .. table.concat(ExportScript.SendStrings, ExportScript.Config.IkarusSeparator) .. "\n" local lPacket = lES_SimID .. table.concat(ExportScript.SendStrings, ExportScript.Config.IkarusSeparator) .. "\n"
ExportScript.socket.try(ExportScript.UDPsender:sendto(lPacket, ExportScript.Config.IkarusHost, ExportScript.Config.IkarusPort)) ExportScript.socket.try(ExportScript.UDPsender:sendto(lPacket, ExportScript.Config.IkarusHost, ExportScript.Config.IkarusPort))
ExportScript.SendStrings = {} ExportScript.SendStrings = {}
@ -276,6 +286,10 @@ function ExportScript.Tools.SelectModule()
return return
end end
if ExportScript.Config.Debug then
ExportScript.Tools.WriteToLog("MyInfo: "..ExportScript.Tools.dump(lMyInfo))
end
ExportScript.ModuleName = lMyInfo.Name ExportScript.ModuleName = lMyInfo.Name
local lModuleName = ExportScript.ModuleName..".lua" local lModuleName = ExportScript.ModuleName..".lua"
local lModuleFile = "" local lModuleFile = ""
@ -297,12 +311,16 @@ function ExportScript.Tools.SelectModule()
-- load Aircraft File -- load Aircraft File
dofile(lModuleFile) dofile(lModuleFile)
if ExportScript.Config.DACExport then
ExportScript.Tools.SendDataDAC("File", lMyInfo.Name) ExportScript.Tools.SendDataDAC("File", lMyInfo.Name)
for i=1, #ExportScript.Config.DAC, 1 do for i=1, #ExportScript.Config.DAC, 1 do
ExportScript.Tools.FlushDataDAC(i) ExportScript.Tools.FlushDataDAC(i)
end end
end
if ExportScript.Config.IkarusExport then
ExportScript.Tools.SendData("File", lMyInfo.Name) ExportScript.Tools.SendData("File", lMyInfo.Name)
ExportScript.Tools.FlushData() end
ExportScript.Tools.WriteToLog("File '"..lModuleFile.."' loaded") ExportScript.Tools.WriteToLog("File '"..lModuleFile.."' loaded")
@ -351,6 +369,20 @@ function ExportScript.Tools.SelectModule()
ExportScript.Tools.WriteToLog("Unknown Module Type: "..lMyInfo.Name) ExportScript.Tools.WriteToLog("Unknown Module Type: "..lMyInfo.Name)
end end
if ExportScript.Config.IkarusExport then
for Map, LatLong in pairs(ExportScript.Maps) do
if lMyInfo.LatLongAlt.Lat > LatLong.Lat2 and lMyInfo.LatLongAlt.Lat < LatLong.Lat1 then
if lMyInfo.LatLongAlt.Long > LatLong.Long1 and lMyInfo.LatLongAlt.Long < LatLong.Long2 then
ExportScript.Tools.WriteToLog("Detected Map: "..Map)
ExportScript.Tools.SendData("Map", Map)
break
end
end
end
ExportScript.Tools.FlushData()
end
else -- Unknown Module else -- Unknown Module
ExportScript.ProcessIkarusDCSHighImportance = ExportScript.ProcessIkarusDCSHighImportanceNoConfig ExportScript.ProcessIkarusDCSHighImportance = ExportScript.ProcessIkarusDCSHighImportanceNoConfig
ExportScript.ProcessIkarusDCSLowImportance = ExportScript.ProcessIkarusDCSLowImportanceNoConfig ExportScript.ProcessIkarusDCSLowImportance = ExportScript.ProcessIkarusDCSLowImportanceNoConfig