diff --git a/wwt/ufcPatch/aircraft/ufcPatchJF17.lua b/wwt/ufcPatch/aircraft/ufcPatchJF17.lua new file mode 100644 index 0000000..422b805 --- /dev/null +++ b/wwt/ufcPatch/aircraft/ufcPatchJF17.lua @@ -0,0 +1,109 @@ +local ufcUtils = require("ufcPatch\\utilities\\ufcPatchUtils") + +ufcPatchJF17 = {} + +-- JF-17 Thunder: Shows UFCP values +function ufcPatchJF17.generateUFCData() + + local MainPanel = GetDevice(0) + local Radio1 = GetDevice(25) + local Radio2 = GetDevice(26) + +--Initial Data + local PwrSwpos = MainPanel:get_argument_value(904) + + if PwrSwpos == 1 then + + Radio1Freq = Radio1:get_frequency() + Radio2Freq = Radio2:get_frequency() + + MasterArmStatus = MainPanel:get_argument_value(509) + AAlight = MainPanel:get_argument_value(163) + AG1light = MainPanel:get_argument_value(164) + AG2light = MainPanel:get_argument_value(165) + UFCPL4Button = MainPanel:get_argument_value(724) + UFCPR4Button = MainPanel:get_argument_value(725) + + JF17Data3 = ufcUtils.getDCSListIndication(3) --1st Line of UFCP + JF17Data4 = ufcUtils.getDCSListIndication(4) --2nd Line of UFCP + JF17Data5 = ufcUtils.getDCSListIndication(5) --3rd Line of UFCP + JF17Data6 = ufcUtils.getDCSListIndication(6) --4th Line of UFCP + + UFCP1 = JF17Data3.txt_win1 + UFCP2 = JF17Data4.txt_win2 + UFCP3 = JF17Data5.txt_win3 + UFCP4 = JF17Data6.txt_win4 + + UFCP4_R_Three = string.sub(UFCP4, 6, 8) --Shows the last three digits of the string (Comm2 Channel) + end + --Radio Freq Display + + local Radio1digits = {math.floor(Radio1Freq / 1000)} + + local Radio1String = "" + for index, value in ipairs(Radio1digits) do + local Radio1digitToAppend = value + if value >= 400000 then + Radio1digitToAppend = 400000 + end + Radio1String = Radio1String..Radio1digitToAppend + end + + local Radio2digits = {math.floor(Radio2Freq / 1000)} + + local Radio2String = "" + for index, value in ipairs(Radio2digits) do + local Radio2digitToAppend = value + if value >= 400000 then + Radio2digitToAppend = 400000 + end + Radio2String = Radio2String..Radio2digitToAppend + end + + --Radio Freq Display cont + if UFCPL4Button == 1 then + RadioDisplay = Radio1String + RadioDisplay1 = "C" + RadioDisplay2 = "1" + elseif UFCPR4Button == 1 then + RadioDisplay = Radio2String + RadioDisplay1 = "C" + RadioDisplay2 = "2" + end + + --Master Arm Status + if MasterArmStatus < 0 then + MasterArmIndicator = "S" + elseif MasterArmStatus == 0 then + MasterArmIndicator = "X" + elseif MasterArmStatus > 0 then + MasterArmIndicator = "A" + end + + --AG Mode + if AAlight ~= 0 then + ModeIndicator = "A" + elseif AG1light ~= 0 then + ModeIndicator = "1" + elseif AG2light ~= 0 then + ModeIndicator = "2" + end + + -- Generate the required SimApp Pro values to "mock" the F18 UFC with JF-17 values + -- In theory, you could replace these with a custom value from another module, and have them appear on the DCS UFC + return ufcUtils.buildSimAppProUFCPayload({ + option1=JF17Data3.txt_win1, + option2=JF17Data4.txt_win2, + option3=JF17Data5.txt_win3, + option4=JF17Data6.txt_win4, + option5=UFCP4_R_Three, + scratchPadNumbers=RadioDisplay, + scratchPadString1=RadioDisplay1, + scratchPadString2=RadioDisplay2, + com1=MasterArmIndicator, + com2=ModeIndicator + }) + +end + +return ufcPatchJF17 --v1.0 by ANDR0ID \ No newline at end of file diff --git a/wwt/ufcPatch/aircraft/ufcPatchTF51D.lua b/wwt/ufcPatch/aircraft/ufcPatchTF51D.lua new file mode 100644 index 0000000..db6effd --- /dev/null +++ b/wwt/ufcPatch/aircraft/ufcPatchTF51D.lua @@ -0,0 +1,82 @@ +local ufcUtils = require("ufcPatch\\utilities\\ufcPatchUtils") + +ufcPatchTF51D = {} + +function ufcPatchTF51D.generateUFCData() + + local MainPanel = GetDevice(0) + local VHFRadio = GetDevice(24) + + local VHFFreq = VHFRadio:get_frequency() + + + --Altimeter + local barodigits = { + math.floor(MainPanel:get_argument_value(96) * 100000) + } + + local AltitudeString = "" + for index, value in ipairs(barodigits) do + local barodigitToAppend = value + if value >= 9999 then + barodigitToAppend = 9999 + end + AltitudeString = tostring(value) + if value < 10 then + AltitudeString = "000"..value + elseif value >= 1000 then + AltitudeString = ""..value + elseif (value >= 100 and value <= 999) then + AltitudeString = "0"..value + elseif (value >= 10 and value <= 99) then + AltitudeString = "00"..value + end + end + + --Heading + local Headingdigits = {math.floor(MainPanel:get_argument_value(12) * 360)} + + local HeadingString = "" + for index, value in ipairs(Headingdigits) do + local HeadingdigitToAppend = value + if value >= 360 then + HeadingdigitToAppend = 0 + end + HeadingString = tostring(value) + if value < 10 then + HeadingString = "00"..value.."T" + elseif value >= 100 then + HeadingString = ""..value.."T" + elseif value >= 10 then + HeadingString = "0"..value.."T" + end + end + + --SCR-522A VHF + local VHFdigits = {math.floor(VHFFreq / 1000)} + + local VHFString = "" + for index, value in ipairs(VHFdigits) do + local VHFdigitToAppend = value + if value >= 157000 then + VHFdigitToAppend = 157000 + end + VHFString = VHFString..VHFdigitToAppend + end + + --Send info to UFC components + return ufcUtils.buildSimAppProUFCPayload({ + scratchPadNumbers=VHFString, --Freq of Slectected Radio + option1=AltitudeString, + option2=HeadingString, + option3="XXXX", + option4="XXXX", + option5="XXXX", + com1="5", + com2="1", + scratchPadString1="V", + scratchPadString2="H" + }) +end + +return ufcPatchTF51D --v1.0 by ANDR0ID \ No newline at end of file diff --git a/wwt/ufcPatch/ufcPatch.lua b/wwt/ufcPatch/ufcPatch.lua index b0ec0f9..3229e96 100644 --- a/wwt/ufcPatch/ufcPatch.lua +++ b/wwt/ufcPatch/ufcPatch.lua @@ -16,6 +16,8 @@ local ufcPatchMH60R = require("ufcPatch\\aircraft\\ufcPatchMH60R") local ufcPatchMI8 = require("ufcPatch\\aircraft\\ufcPatchMI8") local ufcPatchMI24 = require("ufcPatch\\aircraft\\ufcPatchMI24") local ufcPatchKA50 = require("ufcPatch\\aircraft\\ufcPatchKA50") +local ufcPatchJF17 = require("ufcPatch\\aircraft\\ufcPatchJF17") +local ufcPatchTF51D = require("ufcPatch\\aircraft\\ufcPatchTF51D") -- Add new module names here, then create a supporting lua file for the aircraft -- See aircraft/ufcPatchCustomModuleExample.lua for an example. @@ -74,6 +76,18 @@ function ufcPatch.generateUFCExport(deltaTime, moduleName) return ufcPatchMI8.generateUFCData() end + -- JF-17 sends throttled data every 0.2 seconds + elseif moduleName == "JF-17" then + if ufcExportClock.canTransmitLatestPayload then + return ufcPatchJF17.generateUFCData() + end + + -- TF-51D sends throttled data every 0.2 seconds + elseif moduleName == "TF-51D" then + if ufcExportClock.canTransmitLatestPayload then + return ufcPatchTF51D.generateUFCData() + end + --Mi-24 sends throttled data every 0.2 seconds elseif moduleName == "Mi-24P" then if ufcExportClock.canTransmitLatestPayload then