updated m2k radios and PCA

This commit is contained in:
Bailey 2022-07-24 20:15:16 +09:00 committed by GitHub
parent 9a3fb7c96f
commit 5014f815bc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -738,6 +738,10 @@ end
-- Pointed to by ExportScript.ProcessIkarusDCSConfigLowImportance
function ExportScript.ProcessIkarusDCSConfigLowImportance(mainPanelDevice)
--ExportScript.DeviceMetaTableLogDump(mainPanelDevice)
--ExportScript.ListIndicationLogDump(mainPanelDevice)
ExportScript.Radios(mainPanelDevice)
ExportScript.PCApanel(mainPanelDevice)
--[[
export in low tick interval to Ikarus
Example from A-10C
@ -804,144 +808,6 @@ function ExportScript.ProcessIkarusDCSConfigLowImportance(mainPanelDevice)
ExportScript.Tools.SendData(2003, " ")
end
-- PCA_UR (Weappon Panel top line)
local lPCAUR = list_indication(6)
if ExportScript.Config.Debug then
ExportScript.Tools.WriteToLog('lPCAUR : '..ExportScript.Tools.dump(lPCAUR))
end
local to1, to2, from1, from2 = nil, nil, nil, nil
local lPCA_UR = {"", "", "", "", ""}
to1, to2 = lPCAUR:find("PCA_UR")
if (to1 ~= nil) then
for lIndex = 1, 5, 1 do
from1, from2 = lPCAUR:find("text_PCA_UR"..lIndex.."%c")
if (from2 ~= nill) then
to1, to2 = lPCAUR:find("%c", from2+2)
if (to1 ~= nil) then
lPCA_UR[lIndex] = lPCAUR:sub(from2+1, to1-1)
end
end
end -- for
end
-- string with max 3 charachters
if ExportScript.Config.Debug then
ExportScript.Tools.WriteToLog("2010: "..string.format("%s", lPCA_UR[1]))
ExportScript.Tools.WriteToLog("2011: "..string.format("%s", lPCA_UR[2]))
ExportScript.Tools.WriteToLog("2012: "..string.format("%s", lPCA_UR[3]))
ExportScript.Tools.WriteToLog("2013: "..string.format("%s", lPCA_UR[4]))
ExportScript.Tools.WriteToLog("2014: "..string.format("%s", lPCA_UR[5]))
end
ExportScript.Tools.SendData(2010, string.format("%s", lPCA_UR[1]))
ExportScript.Tools.SendData(2011, string.format("%s", lPCA_UR[2]))
ExportScript.Tools.SendData(2012, string.format("%s", lPCA_UR[3]))
ExportScript.Tools.SendData(2013, string.format("%s", lPCA_UR[4]))
ExportScript.Tools.SendData(2014, string.format("%s", lPCA_UR[5]))
-- PCA_BR (Weappon Panel bottom line)
local lPCABR = list_indication(7)
if ExportScript.Config.Debug then
ExportScript.Tools.WriteToLog('lPCABR : '..ExportScript.Tools.dump(lPCABR))
end
local to1, to2, from1, from2 = nil, nil, nil, nil
local lPCA_BR = {"", "", "", "", ""}
to1, to2 = lPCABR:find("PCA_BR")
if (to1 ~= nil) then
for lIndex = 1, 5, 1 do
from1, from2 = lPCABR:find("text_PCA_BR"..lIndex.."%c")
if (from2 ~= nill) then
to1, to2 = lPCABR:find("%c", from2+2)
if (to1 ~= nil) then
lPCA_BR[lIndex] = lPCABR:sub(from2+1, to1-1)
end
end
end-- for
end
-- string with max 3 charachters
if ExportScript.Config.Debug then
ExportScript.Tools.WriteToLog("2015: "..string.format("%s", lPCA_BR[1]))
ExportScript.Tools.WriteToLog("2016: "..string.format("%s", lPCA_BR[2]))
ExportScript.Tools.WriteToLog("2017: "..string.format("%s", lPCA_BR[3]))
ExportScript.Tools.WriteToLog("2018: "..string.format("%s", lPCA_BR[4]))
ExportScript.Tools.WriteToLog("2019: "..string.format("%s", lPCA_BR[5]))
end
ExportScript.Tools.SendData(2015, string.format("%s", lPCA_BR[1]))
ExportScript.Tools.SendData(2016, string.format("%s", lPCA_BR[2]))
ExportScript.Tools.SendData(2017, string.format("%s", lPCA_BR[3]))
ExportScript.Tools.SendData(2018, string.format("%s", lPCA_BR[4]))
ExportScript.Tools.SendData(2019, string.format("%s", lPCA_BR[5]))
-- COM
local lCOM = list_indication(9)
if ExportScript.Config.Debug then
ExportScript.Tools.WriteToLog('lCOM : '..ExportScript.Tools.dump(lCOM))
end
local to1, to2, from1, from2, lCOM1, lCOM2 = nil, nil, nil, nil, "", ""
to1, to2 = lCOM:find("COM")
if (to1 ~= nil) then
from1, from2 = lCOM:find("text_COM_UHF1%c")
if (from2 ~= nil) then
to1, to2 = lCOM:find("%c", from2+2)
if (to1 ~= nil) then
lCOM1 = lCOM:sub(from2+1, to1-1)
end
end
from1, from2 = lCOM:find("text_COM_UHF2%c", to2)
if (from2 ~= nil) then
to1, to2 = lCOM:find("%c", from2+2)
if (to1 ~= nil) then
lCOM2 = lCOM:sub(from2+1, to1-1)
end
end
end
-- string with max 7 charachters
if ExportScript.Config.Debug then
ExportScript.Tools.WriteToLog("2020: "..string.format("%s", lCOM1))
ExportScript.Tools.WriteToLog("2021: "..string.format("%s", lCOM2))
end
ExportScript.Tools.SendData(2020, string.format("%s", lCOM1))
ExportScript.Tools.SendData(2021, string.format("%s", lCOM2))
-- PPA Bomb Display
local lPPA = list_indication(8)
if ExportScript.Config.Debug then
ExportScript.Tools.WriteToLog('lPPA : '..ExportScript.Tools.dump(lPPA))
end
local to1, to2, from1, from2, lPPA1, lPPA2 = nil, nil, nil, nil, "", ""
to1, to2 = lPPA:find("PPA")
if (to1 ~= nil) then
from1, from2 = lPPA:find("text_PPA_QTY%c")
if (from2 ~= nil) then
to1, to2 = lPPA:find("%c", from2+2)
if (to1 ~= nil) then
lPPA1 = lPPA:sub(from2+1, to1-1)
end
end
from1, from2 = lPPA:find("text_PPA_INT%c", to2)
if (from2 ~= nil) then
to1, to2 = lPPA:find("%c", from2+2)
if (to1 ~= nil) then
lPPA2 = lPPA:sub(from2+1, to1-1)
end
end
end
-- string with max 2 charachters
if ExportScript.Config.Debug then
ExportScript.Tools.WriteToLog("2022: "..string.format("%s", lPPA1))
ExportScript.Tools.WriteToLog("2023: "..string.format("%s", lPPA2))
end
ExportScript.Tools.SendData(2022, string.format("%s", lPPA1))
ExportScript.Tools.SendData(2023, string.format("%s", lPPA2))
-- PCN_UR Navigation Displays
if ExportScript.Config.Debug then
local lPCNUR = list_indication(10)
@ -1179,29 +1045,6 @@ function ExportScript.ProcessIkarusDCSConfigLowImportance(mainPanelDevice)
ExportScript.Tools.WriteToLog('2042-2: '..ExportScript.Tools.dump(lTmpNumber))
end
-- U/VHF Com Preset
--[436] = "%.4f", -- Preset display (1-20)
local lUVHF_RADIO_PRESET = {[0.00]="1",[0.10]="2",[0.15]="3",[0.20]="4",[0.25]="5",[0.30]="6",[0.35]="7",[0.40]="8",[0.45]="9",[0.50]="10",[0.55]="11",[0.60]="12",[0.65]="13",[0.70]="14",[0.75]="15",[0.80]="16",[0.85]="17",[0.90]="18",[0.95]="19",[1.00]="20"}
ExportScript.Tools.SendData(436, ExportScript.Tools.DisplayFormat(lUVHF_RADIO_PRESET[tonumber(string.format("%1.2f",mainPanelDevice:get_argument_value(436)))], 2))
if ExportScript.Config.Debug then
ExportScript.Tools.WriteToLog('436-1: '..ExportScript.Tools.dump(string.format("%1.2f",mainPanelDevice:get_argument_value(436))))
ExportScript.Tools.WriteToLog('436-2: '..ExportScript.Tools.dump(lUVHF_RADIO_PRESET[tonumber(string.format("%1.2f",mainPanelDevice:get_argument_value(436)))]))
end
-- VHF Com Preset
--[190] = "%.4f", -- Drum X0 Preset (0-1-2)
--[189] = "%.4f", -- Drum 0X Preset (0-9-0)
local lVHF_RADIO_PRESET = {[0.0]="0",[0.1]="1",[0.2]="2",[0.3]="3",[0.4]="4",[0.5]="5",[0.6]="6",[0.7]="7",[0.8]="8",[0.9]="9",[1.0]="0"}
local lTmpNumber = mainPanelDevice:get_argument_value(190)
if lTmpNumber > 0.2 then
lTmpNumber = 0.2
end
ExportScript.Tools.SendData(189, ExportScript.Tools.DisplayFormat(lVHF_RADIO_PRESET[tonumber(string.format("%1.1f",lTmpNumber))]..lVHF_RADIO_PRESET[tonumber(string.format("%1.1f",mainPanelDevice:get_argument_value(189)))], 2))
if ExportScript.Config.Debug then
ExportScript.Tools.WriteToLog('189: '..ExportScript.Tools.dump(lVHF_RADIO_PRESET[tonumber(string.format("%1.1f",lTmpNumber))]..lVHF_RADIO_PRESET[tonumber(string.format("%1.1f",mainPanelDevice:get_argument_value(189)))]))
end
-- Display Settings
--[224] = "%.4f", --Drum X000
@ -1281,68 +1124,6 @@ function ExportScript.ProcessDACConfigLowImportance(mainPanelDevice)
ExportScript.Tools.WriteToLog('COM : '..ExportScript.Tools.dump(lCOM))
end
local to1, to2, from1, from2, lCOM1, lCOM2 = nil, nil, nil, nil, "-", "-"
to1, to2 = lCOM:find("COM")
if (to1 ~= nil) then
from1, from2 = lCOM:find("text_COM_UHF1%c")
if (from2 ~= nil) then
to1, to2 = lCOM:find("%c", from2+2)
if (to1 ~= nil) then
lCOM1 = lCOM:sub(from2+1, to1-1)
end
end
from1, from2 = lCOM:find("text_COM_UHF2%c", to2)
if (from2 ~= nil) then
to1, to2 = lCOM:find("%c", from2+2)
if (to1 ~= nil) then
lCOM2 = lCOM:sub(from2+1, to1-1)
end
end
end
-- string with max 7 charachters
if ExportScript.Config.Debug then
ExportScript.Tools.WriteToLog("lCOM1: "..string.format("%s", lCOM1))
ExportScript.Tools.WriteToLog("lCOM2: "..string.format("%s", lCOM2))
end
ExportScript.Tools.SendDataDAC(2020, string.format("%s", lCOM1))
ExportScript.Tools.SendDataDAC(2021, string.format("%s", lCOM2))
-- PPA (vielelicht die Bomben Anzeige unten rechts)
local lPPA = list_indication(8)
if ExportScript.Config.Debug then
ExportScript.Tools.WriteToLog('PPA : '..ExportScript.Tools.dump(lPPA))
end
local to1, to2, from1, from2, lPPA1, lPPA2 = nil, nil, nil, nil, "-", "-"
to1, to2 = lPPA:find("PPA")
if (to1 ~= nil) then
from1, from2 = lPPA:find("text_PPA_QTY%c")
if (from2 ~= nil) then
to1, to2 = lPPA:find("%c", from2+2)
if (to1 ~= nil) then
lPPA1 = lPPA:sub(from2+1, to1-1)
end
end
from1, from2 = lPPA:find("text_PPA_INT%c", to2)
if (from2 ~= nil) then
to1, to2 = lPPA:find("%c", from2+2)
if (to1 ~= nil) then
lPPA2 = lPPA:sub(from2+1, to1-1)
end
end
end
-- string with max 2 charachters
if ExportScript.Config.Debug then
ExportScript.Tools.WriteToLog("lPPA1: "..string.format("%s", lPPA1))
ExportScript.Tools.WriteToLog("lPPA2: "..string.format("%s", lPPA2))
end
ExportScript.Tools.SendDataDAC(2022, string.format("%s", lPPA1))
ExportScript.Tools.SendDataDAC(2023, string.format("%s", lPPA2))
-- send data
ExportScript.Tools.FlushDataDAC(#ExportScript.Config.DAC)
@ -1368,7 +1149,89 @@ function ExportScript.ProcessDACConfigLowImportance(mainPanelDevice)
]]
end
-----------------------------
-- Custom functions --
-----------------------------
function ExportScript.DeviceMetaTableLogDump(mainPanelDevice)
local ltmp1 = 0
for ltmp2 = 1, 30, 1 do
ltmp1 = GetDevice(ltmp2)
ExportScript.Tools.WriteToLog(ltmp2 .. ': ' .. ExportScript.Tools.dump(ltmp1))
ExportScript.Tools.WriteToLog(ltmp2 ..' (metatable): '..ExportScript.Tools.dump(getmetatable(ltmp1)))
end
end
function ExportScript.ListIndicationLogDump(mainPanelDevice)
local ltmp1 = 0
for ltmp2 = 0, 30, 1 do
ltmp1 = list_indication(ltmp2)
ExportScript.Tools.WriteToLog(ltmp2 ..': '..ExportScript.Tools.dump(ltmp1))
end
end
function ExportScript.Radios(mainPanelDevice)
-- top radio
local top_RADIO = GetDevice(20)
local topFreq = ExportScript.Tools.RoundFreqeuncy((top_RADIO:get_frequency()/1000000))
ExportScript.Tools.SendData(2020, string.format("%7.3f",topFreq))
-- U/VHF Com Preset (top radio)
--[436] = "%.4f", -- Preset display (1-20)
local lUVHF_RADIO_PRESET = {[0.00]="1",[0.10]="2",[0.15]="3",[0.20]="4",[0.25]="5",[0.30]="6",[0.35]="7",[0.40]="8",[0.45]="9",[0.50]="10",[0.55]="11",[0.60]="12",[0.65]="13",[0.70]="14",[0.75]="15",[0.80]="16",[0.85]="17",[0.90]="18",[0.95]="19",[1.00]="20"}
ExportScript.Tools.SendData(2021, ExportScript.Tools.DisplayFormat(lUVHF_RADIO_PRESET[tonumber(string.format("%1.2f",mainPanelDevice:get_argument_value(436)))], 2))
-- bottom radio
local bot_RADIO = GetDevice(19)
local botFreq = ExportScript.Tools.RoundFreqeuncy((bot_RADIO:get_frequency()/1000000))
ExportScript.Tools.SendData(2022, string.format("%7.3f",botFreq))
-- Best way to get digital radio preset channel is unknown. Use export 2023
end
function ExportScript.PCApanel(mainPanelDevice)
-- Weapon Panel top line
local lPCAUR = ExportScript.Tools.getListIndicatorValue(4)
local pca1 = ''
local pca2 = ''
local pca3 = ''
local pca4 = ''
local pca5 = ''
if lPCAUR ~= nil then
if lPCAUR.PCA_LCD_1_0 ~= nil then pca1 = lPCAUR.PCA_LCD_1_0 end
if lPCAUR.PCA_LCD_1_1 ~= nil then pca2 = lPCAUR.PCA_LCD_1_1 end
if lPCAUR.PCA_LCD_1_2 ~= nil then pca3 = lPCAUR.PCA_LCD_1_2 end
if lPCAUR.PCA_LCD_1_3 ~= nil then pca4 = lPCAUR.PCA_LCD_1_3 end
if lPCAUR.PCA_LCD_1_4 ~= nil then pca5 = lPCAUR.PCA_LCD_1_4 end
end
ExportScript.Tools.SendData(2010, pca1)
ExportScript.Tools.SendData(2011, pca2)
ExportScript.Tools.SendData(2012, pca3)
ExportScript.Tools.SendData(2013, pca4)
ExportScript.Tools.SendData(2014, pca5)
-- Weapon Panel bottom line
local lPCABR = ExportScript.Tools.getListIndicatorValue(5)
local stores1 = ''
local stores2 = ''
local stores3 = ''
local stores4 = ''
local stores5 = ''
if lPCABR ~= nil then
if lPCABR.PCA_LCD_2_0 ~= nil then stores1 = lPCABR.PCA_LCD_2_0 end
if lPCABR.PCA_LCD_2_1 ~= nil then stores2 = lPCABR.PCA_LCD_2_1 end
if lPCABR.PCA_LCD_2_2 ~= nil then stores3 = lPCABR.PCA_LCD_2_2 end
if lPCABR.PCA_LCD_2_3 ~= nil then stores4 = lPCABR.PCA_LCD_2_3 end
if lPCABR.PCA_LCD_2_4 ~= nil then stores5 = lPCABR.PCA_LCD_2_4 end
end
ExportScript.Tools.SendData(2015, stores1)
ExportScript.Tools.SendData(2016, stores2)
ExportScript.Tools.SendData(2017, stores3)
ExportScript.Tools.SendData(2018, stores4)
ExportScript.Tools.SendData(2019, stores5)
end