diff --git a/dcs-dtc/DCS/DCSDTC/f16Functions.lua b/dcs-dtc/DCS/DCSDTC/f16Functions.lua index ec44b9e..c8f56b7 100644 --- a/dcs-dtc/DCS/DCSDTC/f16Functions.lua +++ b/dcs-dtc/DCS/DCSDTC/f16Functions.lua @@ -42,6 +42,34 @@ function DTC_F16C_GetPage(page, mfd, data) end end +function DTC_F16C_ExecCmd_SelectMFDPage(page, data) + local leftMFDPage = DTC_F16C_GetPage(page, DTC_F16C_GetLeftMFD(), data) + local rightMFDPage = DTC_F16C_GetPage(page, DTC_F16C_GetRightMFD(), data) + + if leftMFDPage == false and rightMFDPage == false then + return + end + + local deviceID = 0 + local mfd = "" + + if leftMFDPage ~= false then + deviceID = data.leftMFDDeviceID + mfd = "left" + if leftMFDPage ~= true then + DTC_ExecCommand(deviceID, leftMFDPage, data.delay, data.activation) + end + elseif rightMFDPage ~= false then + deviceID = data.rightMFDDeviceID + mfd = "right" + if rightMFDPage ~= true then + DTC_ExecCommand(deviceID, rightMFDPage, data.delay, data.activation) + end + end + + return mfd, deviceID +end + -- # Shared # function DTC_F16C_CheckCondition_NAVMode() @@ -92,35 +120,15 @@ function DTC_F16C_CheckCondition_TDOA(position, status) end function DTC_F16C_ExecCmd_EnableXMIT(data) - local leftMFDPage = DTC_F16C_GetPage("HSD", DTC_F16C_GetLeftMFD(), data) - local rightMFDPage = DTC_F16C_GetPage("HSD", DTC_F16C_GetRightMFD(), data) - - if leftMFDPage == false and rightMFDPage == false then - return - end - - local deviceID = 0 - local mfd = "" - - if leftMFDPage ~= false then - deviceID = data.leftMFDDeviceID - mfd = "left" - if leftMFDPage ~= true then - DTC_ExecCommand(deviceID, leftMFDPage, data.delay, data.activation) - end - elseif rightMFDPage ~= false then - deviceID = data.rightMFDDeviceID - mfd = "right" - if rightMFDPage ~= true then - DTC_ExecCommand(deviceID, rightMFDPage, data.delay, data.activation) - end - end + local mfd, deviceID = DTC_F16C_ExecCmd_SelectMFDPage("HSD", data) local table = {} if mfd == "left" then table = DTC_LinesToList(list_indication(4)) - else + elseif mfd == "right" then table = DTC_LinesToList(list_indication(5)) + else + return end local i = 1 @@ -177,6 +185,29 @@ function DTC_F16C_CheckCondition_HTSEnabled() return false end +function DTC_F16C_ExecCmd_SelectHARM(data) + local mfd, deviceID = DTC_F16C_ExecCmd_SelectMFDPage("SMS", data) + local strSearch = "AG88"; + + for i = 1, 5, 1 do + local table = {} + if mfd == "left" then + table = DTC_F16C_GetLeftMFD() + elseif mfd == "right" then + table = DTC_F16C_GetRightMFD() + else + return + end + + local str = table["Table. Root. Unic ID: _id:1321.2.Table. Root. Unic ID: _id:1321. Text.1"]; + if str == nil or str:sub(-#strSearch) == strSearch then + return + end + + DTC_ExecCommand(deviceID, data.weaponStep, data.delay, data.activation) + end +end + function DTC_F16C_CheckCondition_HTSAllNotSelected(mfd) local mfdTable; diff --git a/dcs-dtc/New/Uploader/Aircrafts/F16/Systems/HARMHTS.cs b/dcs-dtc/New/Uploader/Aircrafts/F16/Systems/HARMHTS.cs index 58a72b8..84d1444 100644 --- a/dcs-dtc/New/Uploader/Aircrafts/F16/Systems/HARMHTS.cs +++ b/dcs-dtc/New/Uploader/Aircrafts/F16/Systems/HARMHTS.cs @@ -1,6 +1,7 @@  using DTC.New.Uploader.Base; using DTC.Utilities; +using static DTC.Utilities.DataReceiver; namespace DTC.New.Uploader.Aircrafts.F16; @@ -107,6 +108,8 @@ private void BuildHARM() Cmd(UFC.LIST); Cmd(UFC.D0); Cmd(Wait()); + IfNot(HARMEnabled(), SelectHARM()); + Cmd(Wait()); If(HARMEnabled(), cmds.ToArray()); Cmd(UFC.RTN); } @@ -121,6 +124,22 @@ private Condition HTSEnabled() return new Condition("HTSEnabled()"); } + private CustomCommand SelectHARM() + { + var data = "{" + + $"firstPageId = {LMFD.OSB14.Id}, " + + $"secondPageId = {LMFD.OSB13.Id}, " + + $"thirdPageId = {LMFD.OSB12.Id}, " + + $"leftMFDDeviceID = {LMFD.Id}, " + + $"rightMFDDeviceID = {RMFD.Id}, " + + $"weaponStep = {LMFD.OSB06.Id}, " + + $"delay = {Settings.ViperCommandDelayMs * LMFD.OSB06.DelayFactor}, " + + $"activation = {LMFD.OSB06.Activation}" + + "}"; + + return new CustomCommand("SelectHARM(" + data + ")"); + } + private CustomCommand BuildHTSMFD(string data) { return new CustomCommand("BuildHTSMFD(" + data + ")");