diff --git a/Scripts/DCS-ExportScript/ExportsModules/A-10A.lua b/Scripts/DCS-ExportScript/ExportsModules/A-10A.lua index 9bc6d43..401e5e5 100644 --- a/Scripts/DCS-ExportScript/ExportsModules/A-10A.lua +++ b/Scripts/DCS-ExportScript/ExportsModules/A-10A.lua @@ -1,5 +1,5 @@ -- A-10A Export --- Version 0.9.9 BETA +-- Version 1.0.0 BETA ExportScript.FoundFCModule = true @@ -12,7 +12,7 @@ dofile(ExportScript.Config.ExportModulePath.."FC_AuxiliaryFuntions.lua") ----------------------------------------- function ExportScript.ProcessIkarusFCHighImportanceConfig() - + local lFunctionTyp = "Ikarus" -- function type for shared function local myData = LoGetSelfData() if (myData) then @@ -20,538 +20,505 @@ function ExportScript.ProcessIkarusFCHighImportanceConfig() local lLongitude = myData.LatLongAlt.Long -- LONGITUDE local lBasicAtmospherePressure = LoGetBasicAtmospherePressure() -- BAROMETRIC PRESSURE local lAltBar = LoGetAltitudeAboveSeaLevel() -- ALTITUDE SEA LEVEL (Meter) - local lAltRad = LoGetAltitudeAboveGroundLevel() -- ALTITUDE GROUND LEVEL (Meter) - --local lTrueAirSpeed = LoGetTrueAirSpeed() -- TRUE AIRSPEED (Meter/Second) - local lPitch, lBank, lYaw = LoGetADIPitchBankYaw() -- PITCH, BANK, YAW (Radian) - local lHeading = myData.Heading -- HEADING (Radian) - local lVVI = LoGetVerticalVelocity() -- VERTICAL SPEED (Meter/Second) - local lIAS = LoGetIndicatedAirSpeed() -- INDICATED AIRSPEED (Meter/Second) - --local lMachNumber = LoGetMachNumber -- MACH - local lAoA = LoGetAngleOfAttack() -- ANGLE OF ATTACK AoA (Radian) - - local lGlide = LoGetGlideDeviation() -- VOR1 HORIZONTAL DEFLECTION (-1 +1) - local lSide = LoGetSideDeviation() -- VOR1 VERTICAL DEFLECTION (-1 +1) - --local lSlipBallPosition = LoGetSlipBallPosition() -- SLIP BALL (-1 +1) - --local lAccelerationUnits = LoGetAccelerationUnits().y -- G-LOAD - - --local lNavInfoPitch = LoGetNavigationInfo().Requirements.pitch -- AP REQUIRED PITCH (Radian) - --local lNavInfoRoll = LoGetNavigationInfo().Requirements.roll -- AP REQUIRED BANK (Radian) - --local lNavInfoSpeed = LoGetNavigationInfo().Requirements.speed -- AP SPEED (Meter/Second) - --local lNavInfoAltitude = LoGetNavigationInfo().Requirements.altitude -- AP ALTITUDE (Meter) - --local lNavInfoVerticalSpeed = LoGetNavigationInfo().Requirements.vertical_speed -- AP VERTICAL SPEED (Meter/Second) - - --local lControlPanel_HSI = LoGetControlPanel_HSI() -- HSI Data - local lHSI_RMI = LoGetControlPanel_HSI().RMI_raw -- VOR1 OBS (Radian) - local lHSI_ADF = LoGetControlPanel_HSI().ADF_raw -- ADF OBS (Radian) - --local lHSI_Heading = LoGetControlPanel_HSI().Heading_raw -- Heading (Radian) - local lEngineRPMleft = LoGetEngineInfo().RPM.left -- ENG1 RPM % local lEngineRPMright = LoGetEngineInfo().RPM.right -- ENG2 RPM % local lEngineTempLeft = LoGetEngineInfo().Temperature.left -- ENG1 EGT ºC - local lEngineTempRight = LoGetEngineInfo().Temperature.right -- ENG2 EGT ºC + local lEngineTempRight = LoGetEngineInfo().Temperature.right -- ENG2 EGT ºC + + local lIAS = LoGetIndicatedAirSpeed() -- INDICATED AIRSPEED (Meter/Second) + local lAoA = LoGetAngleOfAttack() -- ANGLE OF ATTACK AoA (Radian) + local lEngineFuelConsumptionLeft = LoGetEngineInfo().FuelConsumption.left local lEngineFuelConsumptionRight = LoGetEngineInfo().FuelConsumption.right local lEngineHydraulicPressureLeft = LoGetEngineInfo().HydraulicPressure.left local lEngineHydraulicPressureRight = LoGetEngineInfo().HydraulicPressure.right - --local lEngineFuelInternal = LoGetEngineInfo().fuel_internal -- TANK1 (INT) (KG) - --local lEngineFuelExternal = LoGetEngineInfo().fuel_external -- TANK2 (EXT) (KG) - - --local lMechInfo = LoGetMechInfo() -- mechanical components, e.g. Flaps, Wheelbrakes,... - --local lPayloadInfo = LoGetPayloadInfo() -- Paylod, e.g. bombs, guns, rockets, fuel tanks,... - + + --[[ + local lAltRad = LoGetAltitudeAboveGroundLevel() -- ALTITUDE GROUND LEVEL (Meter) + local lTrueAirSpeed = LoGetTrueAirSpeed() -- TRUE AIRSPEED (Meter/Second) + local lPitch, lBank, lYaw = LoGetADIPitchBankYaw() -- PITCH, BANK, YAW (Radian) + + local lHeading = myData.Heading -- HEADING (Radian) + local lVVI = LoGetVerticalVelocity() -- VERTICAL SPEED (Meter/Second) + local lMachNumber = LoGetMachNumber() -- MACH + + local lGlide = LoGetGlideDeviation() -- VOR1 HORIZONTAL DEFLECTION (-1 +1) + local lSide = LoGetSideDeviation() -- VOR1 VERTICAL DEFLECTION (-1 +1) + local lSlipBallPosition = LoGetSlipBallPosition() -- SLIP BALL (-1 +1) + local lAccelerationUnits = LoGetAccelerationUnits().y -- G-LOAD + + local lNavInfoPitch = LoGetNavigationInfo().Requirements.pitch -- AP REQUIRED PITCH (Radian) + local lNavInfoRoll = LoGetNavigationInfo().Requirements.roll -- AP REQUIRED BANK (Radian) + local lNavInfoSpeed = LoGetNavigationInfo().Requirements.speed -- AP SPEED (Meter/Second) + local lNavInfoAltitude = LoGetNavigationInfo().Requirements.altitude -- AP ALTITUDE (Meter) + local lNavInfoVerticalSpeed = LoGetNavigationInfo().Requirements.vertical_speed -- AP VERTICAL SPEED (Meter/Second) + + local lControlPanel_HSI = LoGetControlPanel_HSI() -- HSI Data + local lHSI_RMI = LoGetControlPanel_HSI().RMI_raw -- VOR1 OBS (Radian) + local lHSI_ADF = LoGetControlPanel_HSI().ADF_raw -- ADF OBS (Radian) + local lHSI_Heading = LoGetControlPanel_HSI().Heading_raw -- Heading (Radian) + + local lEngineFuelInternal = LoGetEngineInfo().fuel_internal -- TANK1 (INT) (KG) + local lEngineFuelExternal = LoGetEngineInfo().fuel_external -- TANK2 (EXT) (KG) + + local lMechInfo = LoGetMechInfo() -- mechanical components, e.g. Flaps, Wheelbrakes,... + local lPayloadInfo = LoGetPayloadInfo() -- Paylod, e.g. bombs, guns, rockets, fuel tanks,... + ]] + local lDistanceToWay = 999 local lRoute = LoGetRoute() - + if (myData and lRoute) then -- if neither are nil local myLoc = LoGeoCoordinatesToLoCoordinates(lLongitude, lLatitude) --lDistanceToWay = math.sqrt((myLoc.x - lRoute.goto_point.world_point.x)^2 + (myLoc.y - lRoute.goto_point.world_point.y)^2) lDistanceToWay = math.sqrt((myLoc.x - lRoute.goto_point.world_point.x)^2 + (myLoc.z - lRoute.goto_point.world_point.z)^2) end - if gES_GlassCockpitType == 1 then - -- HELIOS Version 1.3 - -- customizing for HELOS - --lBasicAtmospherePressure = lBasicAtmospherePressure * 0.03937 -- BAROMETRIC PRESSURE (MM TO IN) - --lTrueAirSpeed = lTrueAirSpeed * 1.94 -- TRUE AIRSPEED (M/S TO KNOTS) - lAltBar = lAltBar * 3.28084 -- ALTITUDE SEA LEVEL (MTS TO FT) - lAltRad = lAltRad * 3.28084 -- ALTITUDE GROUND LEVEL (MTS TO FT) - lVVI = lVVI * 196.8504 -- VERTICAL SPEED (M/S TO FPM) - lIAS = lIAS * 1.9438444924574 -- INDICATED AIRSPEED (M/S TO KNOTS) - lPitch = math.deg(lPitch) -- PITCH, (Radian to Grad) - lBank = math.deg(lBank) -- BANK (Radian to Grad) - lYaw = math.deg(lYaw) -- YAW (Radian to Grad) - lHSI_RMI = math.deg(lHSI_RMI) -- VOR1 OBS (Radian to Grad) - lHSI_ADF = math.deg(lHSI_ADF) -- ADF OBS (Radian to Grad) - lAoA = math.deg(lAoA) -- ANGLE OF ATTACK AoA (Radian to Grad) - lHeading = math.deg(lHeading) -- Heading (Radian to Grad) - lHSI_ADF = (360 - lHSI_ADF) + (360 - lHeading) - lHSI_RMI = 360 - lHSI_RMI - - SendData("1", string.format("%.2f", lPitch) ) - SendData("2", string.format("%.2f", lBank) ) - SendData("3", string.format("%.2f", lYaw) ) - SendData("4", string.format("%.2f", lAltBar) ) - SendData("5", string.format("%.2f", lAltRad) ) - SendData("6", string.format("%.2f", lHSI_ADF) ) - SendData("7", string.format("%.2f", lHSI_RMI) ) - SendData("8", string.format("%.2f", lHeading) ) - SendData("9", string.format("%.2f", lEngineRPMleft) ) - SendData("10", string.format("%.2f", lEngineRPMright) ) - SendData("11", string.format("%.2f", lEngineTempLeft) ) - SendData("12", string.format("%.2f", lEngineTempRight) ) - SendData("13", string.format("%.2f", lVVI) ) - SendData("14", string.format("%.2f", lIAS) ) - SendData("15", string.format("%.2f", lDistanceToWay) ) - SendData("16", string.format("%.2f", lAoA) ) - SendData("17", string.format("%.2f", lGlide) ) - SendData("18", string.format("%.2f", lSide) ) + -- ADI + ExportScript.AF.FC_US_ADI() -- ID 1 to 10 + + -- HSI + ExportScript.AF.FC_US_HSI(lDistanceToWay) -- ID 11 to 23 + + -- VVI + ExportScript.AF.FC_US_VVI() -- ID 24 + + -- G-LOAD + ExportScript.AF.FC_US_GLOAD() -- ID 25 to 27 + + -- Clock + ExportScript.AF.FC_US_Clock() -- ID 28 to 30 + + -- Standby Compass + ExportScript.AF.FC_US_Compass() -- ID 31 to 33 + + -- Standby ADI + ExportScript.AF.FC_US_stbyADI() -- ID 34, 35 + + -- Barometrisic Altimeter + --local lAltCounter = {[0] = 0.0, [1] = 0.11, [2] = 0.22, [3] = 0.33, [4] = 0.44, [5] = 0.55, [6] = 0.66, [7] = 0.77, [8] = 0.88, [9] = 0.99} + local lAltCounter = {[0] = 0.0, [1] = 0.1, [2] = 0.2, [3] = 0.3, [4] = 0.4, [5] = 0.5, [6] = 0.6, [7] = 0.7, [8] = 0.8, [9] = 0.9} + --local lAltBarTmp = string.format("%03d", ((lAltBar * 3.28084) / 100)) -- meter to feeds + --lAltBar = lAltBar + (9.5 * (760 - lBasicAtmospherePressure)) -- 9.5 m per 1mmHg difference , eventuell minus der Differenz + local lAltBarTmp = ((lAltBar * 3.28084) / 100) -- meter to feeds + lAltBar = lAltBar * 3.28084 -- meter to feeds + lBasicAtmospherePressure = lBasicAtmospherePressure * 3.937023 -- mmHg to inPa (0.03937023 * 100) + lBasicAtmospherePressure = string.format("%04d", lBasicAtmospherePressure) + + lAltBar = lAltBar / 1000 + lAltBar = lAltBar - ExportScript.Tools.round(lAltBar, 0, "floor") + + local lAltCounter3 = 0 + local lAltBarTmp2 = string.format("%03d", lAltBarTmp) + + if lAltBarTmp > 10 then + lAltCounter3 = (lAltBarTmp - (ExportScript.Tools.round(lAltBarTmp / 10, 0, "floor") * 10)) * 0.1 + else + lAltCounter3 = lAltBarTmp * 0.1 + end + + -- AltBar {0.0,1.0} + -- AltBar_1000 {0.0,1.0} + -- AltBar_100 {0.0,1.0} + -- AltBar_10 {0.0,1.0} + -- BasicAtmospherePressure_1 {0.0,1.0} + -- BasicAtmospherePressure_10 {0.0,1.0} + -- BasicAtmospherePressure_100 {0.0,1.0} + -- BasicAtmospherePressure_1000 {0.0,1.0} - elseif gES_GlassCockpitType == 2 then - -- HawgTouch version 1.6 + ExportScript.Tools.SendData(36, lAltBar) + ExportScript.Tools.SendData(37, lAltCounter[tonumber(string.sub(lAltBarTmp2, 1, 1))]) + ExportScript.Tools.SendData(38, lAltCounter[tonumber(string.sub(lAltBarTmp2, 2, 2))]) + ExportScript.Tools.SendData(39, lAltCounter3) + ExportScript.Tools.SendData(40, lAltCounter[tonumber(string.sub(lBasicAtmospherePressure, 4, 4))]) + ExportScript.Tools.SendData(41, lAltCounter[tonumber(string.sub(lBasicAtmospherePressure, 3, 3))]) + ExportScript.Tools.SendData(42, lAltCounter[tonumber(string.sub(lBasicAtmospherePressure, 2, 2))]) + ExportScript.Tools.SendData(43, lAltCounter[tonumber(string.sub(lBasicAtmospherePressure, 1, 1))]) + -- Barometrisic Altimeter end - -- Barometrisic Altimeter - --local lAltCounter = {[0] = 0.0, [1] = 0.11, [2] = 0.22, [3] = 0.33, [4] = 0.44, [5] = 0.55, [6] = 0.66, [7] = 0.77, [8] = 0.88, [9] = 0.99} - local lAltCounter = {[0] = 0.0, [1] = 0.1, [2] = 0.2, [3] = 0.3, [4] = 0.4, [5] = 0.5, [6] = 0.6, [7] = 0.7, [8] = 0.8, [9] = 0.9} - --local lAltBarTmp = string.format("%03d", ((lAltBar * 3.28084) / 100)) -- meter to feeds - --lAltBar = lAltBar + (9.5 * (760 - lBasicAtmospherePressure)) -- 9.5 m per 1mmHg difference , eventuell minus der Differenz - local lAltBarTmp = ((lAltBar * 3.28084) / 100) -- meter to feeds - lAltBar = lAltBar * 3.28084 -- meter to feeds - lBasicAtmospherePressure = lBasicAtmospherePressure * 3.937023 -- mmHg to inPa (0.03937023 * 100) - lBasicAtmospherePressure = string.format("%04d", lBasicAtmospherePressure) + -- Air Speed Indicator (IAS) + lAltBar = LoGetAltitudeAboveSeaLevel() * 3.28084 -- ALTITUDE SEA LEVEL (Meter to Feeds) + lIAS = lIAS * 1.9438444924574 -- INDICATED AIRSPEED (M/S TO KNOTS) + local lIAStmp = lIAS - lAltBar = lAltBar / 1000 - lAltBar = lAltBar - math.round(lAltBar, 0, "floor") + --[[ + y_min = 0.0 -- minimaler Ausgabewert + y_max = 1.0 -- maximaler Ausgabewert + x_min = 0.0 -- minimaler Eingangswert + x_max = 550.0 -- maximaler Eingangswert + x = 250.0 -- aktueller Eingangswert - local lAltCounter3 = 0 - local lAltBarTmp2 = string.format("%03d", lAltBarTmp) + d_y = 1.0 -- Delta Ausgabewerte (y_max - y_min) + d_x = 550.0 -- Delta Eingangswerte (x_max - x_min) + m = 0.00181818181818181818181818181818 -- Steigung der linearen Funktion (d_y / d_x) + n = 0.000000000000000000000000000001 -- Schnittpunkt der Funktion mit y-Achse (y_max - m * x_max) - if lAltBarTmp > 10 then - lAltCounter3 = (lAltBarTmp - (math.round(lAltBarTmp / 10, 0, "floor") * 10)) * 0.1 - else - lAltCounter3 = lAltBarTmp * 0.1 - end + y = 0.45454545454545454545454545454645 -- Ergebnis (m * x + n) + ]] + lIAS = 0.00181818181818181818181818181818 * lIAS + 0.000000000000000000000000000001 - -- AltBar {0.0,1.0} - -- AltBar_1000 {0.0,1.0} - -- AltBar_100 {0.0,1.0} - -- AltBar_10 {0.0,1.0} - -- BasicAtmospherePressure_1 {0.0,1.0} - -- BasicAtmospherePressure_10 {0.0,1.0} - -- BasicAtmospherePressure_100 {0.0,1.0} - -- BasicAtmospherePressure_1000 {0.0,1.0} - SendData(1, string.format("%.4f;%.2f;%.2f;%.2f;%.2f;%.2f;%.2f;%.2f", - lAltBar, - lAltCounter[tonumber(string.sub(lAltBarTmp2, 1, 1))], - lAltCounter[tonumber(string.sub(lAltBarTmp2, 2, 2))], - lAltCounter3, - lAltCounter[tonumber(string.sub(lBasicAtmospherePressure, 4, 4))], - lAltCounter[tonumber(string.sub(lBasicAtmospherePressure, 3, 3))], - lAltCounter[tonumber(string.sub(lBasicAtmospherePressure, 2, 2))], - lAltCounter[tonumber(string.sub(lBasicAtmospherePressure, 1, 1))])) - -- Barometrisic Altimeter end + if lIAStmp > 100 then + lIAStmp = lIAStmp - (ExportScript.Tools.round((lIAStmp / 100), 0, "floor") * 100) + end - -- Air Speed Indicator (IAS) - lAltBar = LoGetAltitudeAboveSeaLevel() * 3.28084 -- ALTITUDE SEA LEVEL (Meter to Feeds) - lIAS = lIAS * 1.9438444924574 -- INDICATED AIRSPEED (M/S TO KNOTS) - local lIAStmp = lIAS + lIAStmp = lIAStmp / 100 + --[[ + local lAltBarTmp = ((lAltBar * 3.28084) / 100) -- meter to feeds + lBasicAtmospherePressure = string.format("%04d", lBasicAtmospherePressure) - --[[ - y_min = 0.0 -- minimaler Ausgabewert - y_max = 1.0 -- maximaler Ausgabewert - x_min = 0.0 -- minimaler Eingangswert - x_max = 550.0 -- maximaler Eingangswert - x = 250.0 -- aktueller Eingangswert + local lAltCounter3 = 0 + local lAltBarTmp2 = string.format("%03d", lAltBarTmp) - d_y = 1.0 -- Delta Ausgabewerte (y_max - y_min) - d_x = 550.0 -- Delta Eingangswerte (x_max - x_min) - m = 0.00181818181818181818181818181818 -- Steigung der linearen Funktion (d_y / d_x) - n = 0.000000000000000000000000000001 -- Schnittpunkt der Funktion mit y-Achse (y_max - m * x_max) + if lAltBarTmp > 10 then + lAltCounter3 = (lAltBarTmp - (ExportScript.Tools.round(lAltBarTmp / 10, 0, "floor") * 10)) * 0.1 + else + lAltCounter3 = lAltBarTmp * 0.1 + end]] - y = 0.45454545454545454545454545454645 -- Ergebnis (m * x + n) - ]] - lIAS = 0.00181818181818181818181818181818 * lIAS + 0.000000000000000000000000000001 + -- IAS {0.0,1.0} + -- IAS Decimals {0.0,1.0} + -- Barometric Altimeter in 1000 Feeds for calculate max Air Speed + -- Barometric Altimeter in 100 Feeds for calculate max Air Speed + -- Barometric Altimeter in 10 Feeds for calculate max Air Speed - if lIAStmp > 100 then - lIAStmp = lIAStmp - (math.round((lIAStmp / 100), 0, "floor") * 100) - end + ExportScript.Tools.SendData(44, string.format("%.4f", lIAS)) + ExportScript.Tools.SendData(45, string.format("%.4f", lIAStmp)) + --ExportScript.Tools.SendData(37, lAltCounter[tonumber(string.sub(lAltBarTmp2, 1, 1))]) + --ExportScript.Tools.SendData(38, lAltCounter[tonumber(string.sub(lAltBarTmp2, 2, 2))]) + --ExportScript.Tools.SendData(39, lAltCounter3) + -- Air Speed Indicator End - lIAStmp = lIAStmp / 100 + -- RPM Engine Left + ExportScript.AF.FC_TwoNeedlesGauge(lEngineRPMleft, 105, 10, 50, 51) - -- IAS {0.0,1.0} - -- IAS Decimals {0.0,1.0} - -- Barometric Altimeter in Feeds for calculate max Air Speed - SendData(2, string.format("%.4f;%.4f;%d", lIAS, lIAStmp, lAltBar)) - -- Air Speed Indicator End + -- RPM Engine Right + ExportScript.AF.FC_TwoNeedlesGauge(lEngineRPMright, 105, 10, 52, 53) - -- RPM Engine Left - FC_TwoNeedlesGauge(lEngineRPMleft, 105, 10, 3) + -- Oil Pressure Left, no value but similar to Engine RPM + ExportScript.AF.FC_OneNeedleGauge(lEngineRPMleft, 110, 54) - -- RPM Engine Right - FC_TwoNeedlesGauge(lEngineRPMright, 105, 10, 4) + -- Oil Pressure Right, no value but similar to Engine RPM + ExportScript.AF.FC_OneNeedleGauge(lEngineRPMright, 110, 55) - -- Oil Pressure Left, no value but similar to Engine RPM - FC_OneNeedleGauge(lEngineRPMleft, 110, 11) + -- RPM FAN Left + if lEngineRPMleft > 98.85 then + lEngineRPMleft = lEngineRPMleft / 1.88 --52.58 > 80% + elseif lEngineRPMleft > 97.9768 then + lEngineRPMleft = lEngineRPMleft / 2.33278 --42.0 = 79% + elseif lEngineRPMleft > 97.2773 then + lEngineRPMleft = lEngineRPMleft / 3.03992 --32.0 = 78% + elseif lEngineRPMleft > 96.7213 then + lEngineRPMleft = lEngineRPMleft / 3.5429 --27.3 = 77% + elseif lEngineRPMleft > 96.2496 then + lEngineRPMleft = lEngineRPMleft / 3.5648 --27.0 = 76% + elseif lEngineRPMleft > 95.7494 then + lEngineRPMleft = lEngineRPMleft / 3.5996 --26.6 = 75% + elseif lEngineRPMleft > 93.2737 then + lEngineRPMleft = lEngineRPMleft / 3.54653 --26.3 = 70% + elseif lEngineRPMleft > 90.7216 then + lEngineRPMleft = lEngineRPMleft / 3.4893 --26.0 = 65% + elseif lEngineRPMleft > 88.1733 then + lEngineRPMleft = lEngineRPMleft / 3.4376 --25.65 = 60% + elseif lEngineRPMleft > 85.0282 then + lEngineRPMleft = lEngineRPMleft / 3.3608 --25.3 = 55% + elseif lEngineRPMleft > 81.9344 then + lEngineRPMleft = lEngineRPMleft / 3.2774 --25.0 = 50% + elseif lEngineRPMleft > 77.7911 then + lEngineRPMleft = lEngineRPMleft / 3.53596 --22.0 = 45% + elseif lEngineRPMleft > 72.1855 then + lEngineRPMleft = lEngineRPMleft / 3.6093 --20.0 = 40% + elseif lEngineRPMleft > 67.8386 then + lEngineRPMleft = lEngineRPMleft / 3.9905 --17.0 = 35% + elseif lEngineRPMleft > 63.4883 then + lEngineRPMleft = lEngineRPMleft / 3.968 --16.0 = 33% + end - -- Oil Pressure Right, no value but similar to Engine RPM - FC_OneNeedleGauge(lEngineRPMright, 110, 12) + --[[ + y_min = 0.0 0.25 0.2659 0.49 -- minimaler Ausgabewert + y_max = 0.25 0.2659 0.49 1.0 -- maximaler Ausgabewert + x_min = 0.0 50.0 70.0 80.0 -- minimaler Eingangswert + x_max = 50.0 70.0 80.0 100.0 -- maximaler Eingangswert + x = 40.0 60.0 75.0 95.0 -- aktueller Eingangswert - -- RPM FAN Left - if lEngineRPMleft > 98.85 then - lEngineRPMleft = lEngineRPMleft / 1.88 --52.58 > 80% - elseif lEngineRPMleft > 97.9768 then - lEngineRPMleft = lEngineRPMleft / 2.33278 --42.0 = 79% - elseif lEngineRPMleft > 97.2773 then - lEngineRPMleft = lEngineRPMleft / 3.03992 --32.0 = 78% - elseif lEngineRPMleft > 96.7213 then - lEngineRPMleft = lEngineRPMleft / 3.5429 --27.3 = 77% - elseif lEngineRPMleft > 96.2496 then - lEngineRPMleft = lEngineRPMleft / 3.5648 --27.0 = 76% - elseif lEngineRPMleft > 95.7494 then - lEngineRPMleft = lEngineRPMleft / 3.5996 --26.6 = 75% - elseif lEngineRPMleft > 93.2737 then - lEngineRPMleft = lEngineRPMleft / 3.54653 --26.3 = 70% - elseif lEngineRPMleft > 90.7216 then - lEngineRPMleft = lEngineRPMleft / 3.4893 --26.0 = 65% - elseif lEngineRPMleft > 88.1733 then - lEngineRPMleft = lEngineRPMleft / 3.4376 --25.65 = 60% - elseif lEngineRPMleft > 85.0282 then - lEngineRPMleft = lEngineRPMleft / 3.3608 --25.3 = 55% - elseif lEngineRPMleft > 81.9344 then - lEngineRPMleft = lEngineRPMleft / 3.2774 --25.0 = 50% - elseif lEngineRPMleft > 77.7911 then - lEngineRPMleft = lEngineRPMleft / 3.53596 --22.0 = 45% - elseif lEngineRPMleft > 72.1855 then - lEngineRPMleft = lEngineRPMleft / 3.6093 --20.0 = 40% - elseif lEngineRPMleft > 67.8386 then - lEngineRPMleft = lEngineRPMleft / 3.9905 --17.0 = 35% - elseif lEngineRPMleft > 63.4883 then - lEngineRPMleft = lEngineRPMleft / 3.968 --16.0 = 33% - end + d_y = 0.25 0.0159 0.2241 0.51 -- Delta Ausgabewerte (y_max - y_min) + d_x = 50.0 20.0 10.0 20.0 -- Delta Eingangswerte (x_max - x_min) + m = 0.005 0.000795 0.02241 0.0255 -- Steigung der linearen Funktion (d_y / d_x) + n = 0.0 0.21025 -1.3028 -1.55 -- Schnittpunkt der Funktion mit y-Achse (y_max - m * x_max) - --[[ - y_min = 0.0 0.25 0.2659 0.49 -- minimaler Ausgabewert - y_max = 0.25 0.2659 0.49 1.0 -- maximaler Ausgabewert - x_min = 0.0 50.0 70.0 80.0 -- minimaler Eingangswert - x_max = 50.0 70.0 80.0 100.0 -- maximaler Eingangswert - x = 40.0 60.0 75.0 95.0 -- aktueller Eingangswert - - d_y = 0.25 0.0159 0.2241 0.51 -- Delta Ausgabewerte (y_max - y_min) - d_x = 50.0 20.0 10.0 20.0 -- Delta Eingangswerte (x_max - x_min) - m = 0.005 0.000795 0.02241 0.0255 -- Steigung der linearen Funktion (d_y / d_x) - n = 0.0 0.21025 -1.3028 -1.55 -- Schnittpunkt der Funktion mit y-Achse (y_max - m * x_max) - - y = 0.2 0.25795 0.37795 0.8725 -- Ergebnis (m * x + n) - ]] + y = 0.2 0.25795 0.37795 0.8725 -- Ergebnis (m * x + n) + ]] --[[ if lEngineRPMleft > 80 then - lEngineRPMleft = 0.0255 * lEngineRPMleft + -1.55 - elseif lEngineRPMleft > 70 then - lEngineRPMleft = 0.02241 * lEngineRPMleft + -1.3028 - elseif lEngineRPMleft > 50 then - lEngineRPMleft = 0.000795 * lEngineRPMleft + 0.21025 - else - lEngineRPMleft = 0.005 * lEngineRPMleft - end + lEngineRPMleft = 0.0255 * lEngineRPMleft + -1.55 + elseif lEngineRPMleft > 70 then + lEngineRPMleft = 0.02241 * lEngineRPMleft + -1.3028 + elseif lEngineRPMleft > 50 then + lEngineRPMleft = 0.000795 * lEngineRPMleft + 0.21025 + else + lEngineRPMleft = 0.005 * lEngineRPMleft + end - lEngineRPMleft = lEngineRPMleft * 85.263157894736842105263157894737 + lEngineRPMleft = lEngineRPMleft * 85.263157894736842105263157894737 ]] - FC_OneNeedleGauge(lEngineRPMleft, 100, 5) + ExportScript.AF.FC_OneNeedleGauge(lEngineRPMleft, 100, 56) - -- RPM FAN Right - if lEngineRPMright > 94 then - lEngineRPMright = lEngineRPMright / 1.88 --50.0 - elseif lEngineRPMright > 90 then - lEngineRPMright = lEngineRPMright / 3.384 --26.6 - elseif lEngineRPMright > 85 then - lEngineRPMright = lEngineRPMright / 3.334 --25.5 - elseif lEngineRPMright > 80 then - lEngineRPMright = lEngineRPMright / 3.2 --25.0 - elseif lEngineRPMright > 75 then - lEngineRPMright = lEngineRPMright / 3.75 --20.0 - elseif lEngineRPMright > 70 then - lEngineRPMright = lEngineRPMright / 4.667 --15.0 - elseif lEngineRPMright > 65 then - lEngineRPMright = lEngineRPMright / 4.815 --13.5 - elseif lEngineRPMright > 60 then - lEngineRPMright = lEngineRPMright / 5 --12.0 - end - FC_OneNeedleGauge(lEngineRPMright, 100, 6) + -- RPM FAN Right + if lEngineRPMright > 94 then + lEngineRPMright = lEngineRPMright / 1.88 --50.0 + elseif lEngineRPMright > 90 then + lEngineRPMright = lEngineRPMright / 3.384 --26.6 + elseif lEngineRPMright > 85 then + lEngineRPMright = lEngineRPMright / 3.334 --25.5 + elseif lEngineRPMright > 80 then + lEngineRPMright = lEngineRPMright / 3.2 --25.0 + elseif lEngineRPMright > 75 then + lEngineRPMright = lEngineRPMright / 3.75 --20.0 + elseif lEngineRPMright > 70 then + lEngineRPMright = lEngineRPMright / 4.667 --15.0 + elseif lEngineRPMright > 65 then + lEngineRPMright = lEngineRPMright / 4.815 --13.5 + elseif lEngineRPMright > 60 then + lEngineRPMright = lEngineRPMright / 5 --12.0 + end + ExportScript.AF.FC_OneNeedleGauge(lEngineRPMright, 100, 57) - -- RPM APU, no value - -- Exaust Gas Temperature APU, no value + -- RPM APU, no value + -- Exaust Gas Temperature APU, no value - -- Exaust Gas Temperature Left - --FC_TwoNeedlesGauge(lEngineTempLeft, 1200, 100, 7) - FC_A10A_ExaustGasTemp(lEngineTempLeft, 7) + -- Exaust Gas Temperature Left + ExportScript.AF.FC_TwoNeedlesGauge(lEngineTempLeft, 1200, 100, 58, 59) + --ExportScript.AF.FC_A10A_ExaustGasTemp(lEngineTempLeft, 7) - -- Exaust Gas Temperature Right - FC_TwoNeedlesGauge(lEngineTempRight, 1200, 100, 8) - --FC_A10A_ExaustGasTemp(lEngineTempRight, 8) + -- Exaust Gas Temperature Right + ExportScript.AF.FC_TwoNeedlesGauge(lEngineTempRight, 1200, 100, 60, 61) + --ExportScript.AF.FC_A10A_ExaustGasTemp(lEngineTempRight, 8) - -- Fuel Flow Left - FC_OneNeedleGauge((lEngineFuelConsumptionLeft * 2.2046223302272) * 3600, 5000, 9) + -- Fuel Flow Left + ExportScript.AF.FC_OneNeedleGauge((lEngineFuelConsumptionLeft * 2.2046223302272) * 3600, 5000, 62) - -- Fuel Flow Right - FC_OneNeedleGauge((lEngineFuelConsumptionRight * 2.2046223302272) * 3600, 5000, 10) + -- Fuel Flow Right + ExportScript.AF.FC_OneNeedleGauge((lEngineFuelConsumptionRight * 2.2046223302272) * 3600, 5000, 63) - -- Hydraulic Pressure Left (small gauges over fuel gauge) - FC_OneNeedleGauge(lEngineHydraulicPressureLeft, 100, 13) + -- Hydraulic Pressure Left (small gauges over fuel gauge) + ExportScript.AF.FC_OneNeedleGauge(lEngineHydraulicPressureLeft, 100, 64) - -- Hydraulic Pressure Right (small gauges over fuel gauge) - FC_OneNeedleGauge(lEngineHydraulicPressureRight, 100, 14) + -- Hydraulic Pressure Right (small gauges over fuel gauge) + ExportScript.AF.FC_OneNeedleGauge(lEngineHydraulicPressureRight, 100, 65) - -- VVI - FC_US_VVI(15) + -- AOA + --ExportScript.AF.FC_US_AOA(16) + --ExportScript.Tools.WriteToLog('lAoA 1: '..ExportScript.Tools.dump(lAoA)) + --local lAoATmp = 0.7728 * math.deg(lAoA) + 12.22 + --ExportScript.Tools.WriteToLog('lAoA 2: '..ExportScript.Tools.dump(lAoATmp)) + --[[ + y_min = 0.0 -- minimaler Ausgabewert + y_max = 1.0 -- maximaler Ausgabewert + x_min = 0.0 -- minimaler Eingangswert + x_max = 30.0 -- maximaler Eingangswert + x = 12.6 -- aktueller Eingangswert - -- AOA - --FC_US_AOA(16) - --WriteToLog('lAoA 1: '..dump(lAoA)) - --local lAoATmp = 0.7728 * math.deg(lAoA) + 12.22 - --WriteToLog('lAoA 2: '..dump(lAoATmp)) + d_y = 1.0 -- Delta Ausgabewerte (y_max - y_min) + d_x = 30.0 -- Delta Eingangswerte (x_max - x_min) + m = 0.03333333333333333333333333333333 -- Steigung der linearen Funktion (d_y / d_x) + n = 0.0000000000000000000000000000001 -- Schnittpunkt der Funktion mit y-Achse (y_max - m * x_max) + + y = 0.4200000000000000000000000000001 -- Ergebnis (m * x + n) + ]] + --lAoATmp = 0.03333333333333333333333333333333 * lAoATmp + 0.0000000000000000000000000000001 + + if lAoA > -2.7 then -- positive AOA + --[[ + y_min = 0.333 -- minimaler Ausgabewert + y_max = 1.0 -- maximaler Ausgabewert + x_min = -2.7 -- minimaler Eingangswert + x_max = 23.0 -- maximaler Eingangswert + x = 10.6 -- aktueller Eingangswert + + d_y = 0.667 -- Delta Ausgabewerte (y_max - y_min) + d_x = 27.7 -- Delta Eingangswerte (x_max - x_min) + m = 0.02407942238267148014440433212996 -- Steigung der linearen Funktion (d_y / d_x) + n = 0,44617328519855595667870036101083 -- Schnittpunkt der Funktion mit y-Achse (y_max - m * x_max) + + y = 0.615808 -- Ergebnis (m * x + n) + ]] + lAoA = 0.02407942238267148014440433212996 * lAoA + 0.44617328519855595667870036101083 + else --[[ y_min = 0.0 -- minimaler Ausgabewert - y_max = 1.0 -- maximaler Ausgabewert - x_min = 0.0 -- minimaler Eingangswert - x_max = 30.0 -- maximaler Eingangswert - x = 12.6 -- aktueller Eingangswert + y_max = 0.333 -- maximaler Ausgabewert + x_min = -2.7 -- minimaler Eingangswert + x_max = -15.3 -- maximaler Eingangswert + x = -3.6 -- aktueller Eingangswert - d_y = 1.0 -- Delta Ausgabewerte (y_max - y_min) - d_x = 30.0 -- Delta Eingangswerte (x_max - x_min) - m = 0.03333333333333333333333333333333 -- Steigung der linearen Funktion (d_y / d_x) - n = 0.0000000000000000000000000000001 -- Schnittpunkt der Funktion mit y-Achse (y_max - m * x_max) - - y = 0.4200000000000000000000000000001 -- Ergebnis (m * x + n) - ]] - --lAoATmp = 0.03333333333333333333333333333333 * lAoATmp + 0.0000000000000000000000000000001 - --SendData(16, string.format("%.4f;%d", lAoATmp, 0) ) + d_y = 0.333 -- Delta Ausgabewerte (y_max - y_min) + d_x = -12.6 -- Delta Eingangswerte (x_max - x_min) + m = -0.02642857142857142857142857142857 -- Steigung der linearen Funktion (d_y / d_x) + n = -0.07135714285714285714285714285714 -- Schnittpunkt der Funktion mit y-Achse (y_max - m * x_max) - if lAoA > -2.7 then -- positive AOA - --[[ - y_min = 0.333 -- minimaler Ausgabewert - y_max = 1.0 -- maximaler Ausgabewert - x_min = -2.7 -- minimaler Eingangswert - x_max = 23.0 -- maximaler Eingangswert - x = 10.6 -- aktueller Eingangswert - - d_y = 0.667 -- Delta Ausgabewerte (y_max - y_min) - d_x = 27.7 -- Delta Eingangswerte (x_max - x_min) - m = 0.02407942238267148014440433212996 -- Steigung der linearen Funktion (d_y / d_x) - n = 0,44617328519855595667870036101083 -- Schnittpunkt der Funktion mit y-Achse (y_max - m * x_max) - - y = 0.615808 -- Ergebnis (m * x + n) - ]] - lAoA = 0.02407942238267148014440433212996 * lAoA + 0.44617328519855595667870036101083 - SendData(16, string.format("%.4f;%d", lAoA, 0) ) - else - --[[ - y_min = 0.0 -- minimaler Ausgabewert - y_max = 0.333 -- maximaler Ausgabewert - x_min = -2.7 -- minimaler Eingangswert - x_max = -15.3 -- maximaler Eingangswert - x = -3.6 -- aktueller Eingangswert - - d_y = 0.333 -- Delta Ausgabewerte (y_max - y_min) - d_x = -12.6 -- Delta Eingangswerte (x_max - x_min) - m = -0.02642857142857142857142857142857 -- Steigung der linearen Funktion (d_y / d_x) - n = -0.07135714285714285714285714285714 -- Schnittpunkt der Funktion mit y-Achse (y_max - m * x_max) - - y = 0.0238 -- Ergebnis 0.333 - (m * x + n) - ]] - lAoA = 0.333 - (-0.02642857142857142857142857142857 * lAoA + -0.07135714285714285714285714285714) - SendData(16, string.format("%.4f;%d", lAoA, 0) ) - end - - -- G-LOAD - FC_US_GLOAD(17) - - -- Clock - FC_US_Clock(18) - - -- Standby Compass - FC_US_Compass(19) - - -- ADI - FC_US_ADI(20) - - -- Standby ADI - FC_US_stbyADI(21) - - -- HSI - FC_US_HSI(lDistanceToWay, 22) + y = 0.0238 -- Ergebnis 0.333 - (m * x + n) + ]] + lAoA = 0.333 - (-0.02642857142857142857142857142857 * lAoA + -0.07135714285714285714285714285714) end + + ExportScript.Tools.SendData(66, string.format("%.4f", lAoA)) + ExportScript.Tools.SendData(67, 0) --??ExportID fehlt noch else - WriteToLog("Unknown FC Error, no LoGetSelfData.") + ExportScript.Tools.WriteToLog("Unknown FC Error, no LoGetSelfData.") end end -function ExportScript.ProcessDACHighImportance(mainPanelDevice) - --[[ - local lPayloadInfo = LoGetPayloadInfo() - WriteToLog('lPayloadInfo: '..dump(lPayloadInfo)) - - local lSnares = LoGetSnares() -- Flare and Chaff - WriteToLog('lSnares: '..dump(lSnares)) - - local lSightingSystemInfo = LoGetSightingSystemInfo() - WriteToLog('lSightingSystemInfo: '..dump(lSightingSystemInfo)) - - local lTWSInfo = LoGetTWSInfo() -- SPO Informationen, z.B. Radarwarner F15C - WriteToLog('lTWSInfo: '..dump(lTWSInfo)) - - local lTargetInformation = LoGetTargetInformation() -- detalierte Radar Infos z.B. F15C - WriteToLog('lTargetInformation: '..dump(lTargetInformation)) - - local lLockedTargetInformation = LoGetLockedTargetInformation() - WriteToLog('lLockedTargetInformation: '..dump(lLockedTargetInformation)) - - local lF15_TWS_Contacs = LoGetF15_TWS_Contacts() -- the same information but only for F-15 in TWS mode - WriteToLog('lF15_TWS_Contacs: '..dump(lF15_TWS_Contacs)) - - local lMechInfo = LoGetMechInfo() -- mechanical components, e.g. Flaps, Wheelbrakes,... - WriteToLog('lMechInfo: '..dump(lMechInfo)) - - local lMCPState = LoGetMCPState() -- Warnlichter - WriteToLog('lMCPState: '..dump(lMCPState)) - - local lControlPanel_HSI = LoGetControlPanel_HSI() - WriteToLog('lControlPanel_HSI: '..dump(lControlPanel_HSI)) - - local lRadioBeaconsStatus = LoGetRadioBeaconsStatus() - WriteToLog('lRadioBeaconsStatus: '..dump(lRadioBeaconsStatus)) - - local lEngineInfo = LoGetEngineInfo() - WriteToLog('lEngineInfo: '..dump(lEngineInfo)) - ]] +function ExportScript.ProcessDACConfigHighImportance() + local lFunctionTyp = "DAC" -- function type for shared function + + -- your script + end function ExportScript.ProcessIkarusFCLowImportanceConfig() + local lFunctionTyp = "Ikarus" -- function type for shared function + + -- UHF Gauges, no value + ExportScript.Tools.SendData(68, "001.00") + + -- Flaps Indicator + -- Gear Lamps + ExportScript.AF.MechanicalDevicesIndicator(lFunctionTyp) + + -- Fuel Indicator local lEngineFuelInternal = LoGetEngineInfo().fuel_internal -- TANK1 (INT) (KG) local lEngineFuelExternal = LoGetEngineInfo().fuel_external -- TANK2 (EXT) (KG) - local lMechInfo = LoGetMechInfo() -- mechanical components, e.g. Flaps, Wheelbrakes,... - local lPayloadInfo = LoGetPayloadInfo() -- Paylod, e.g. bombs, guns, rockets, fuel tanks,... + local lCounter = {[0] = 0.0, [1] = 0.1, [2] = 0.2, [3] = 0.3, [4] = 0.4, [5] = 0.5, [6] = 0.6, [7] = 0.7, [8] = 0.8, [9] = 0.9} - if gES_GlassCockpitType == 1 then - -- HELIOS Version 1.3 + lEngineFuelInternal = lEngineFuelInternal * 2.2046223302272 -- kg to lbs + local lFuelNeedle = (lEngineFuelInternal / 2) / 6000 -- 6000 = scala + lEngineFuelInternal = lEngineFuelInternal / 100 -- um unf die ersten drei stellen zukommen + local lEngineFuelInternalTmp = string.format("%03d", lEngineFuelInternal) - elseif gES_GlassCockpitType == 2 then - -- HawgTouch version 1.6 - - -- Flaps Indicator - local lFlapsValue = lMechInfo.flaps.value - - lFlapsValue = lFlapsValue / 1.6 - lFlapsValue = (lFlapsValue > 1.0 and 1.0 or lFlapsValue) -- the result is limited to 1.0 - - SendData(23, string.format("%.4f", lFlapsValue)) - -- Flaps Indicator end - - -- Gear Lamps - local lGearValue = lMechInfo.gear.value - local lGear1, lGear2, lGear3 = 0, 0, 0 - - if lGearValue > 0.85 then - lGear1 = 1 - end - if lGearValue > 0.9 then - lGear2 = 1 - end - if lGearValue == 1.0 then - lGear3 = 1 - end - SendData(24, string.format("%d;%d;%d", - lGear1, -- GEAR_N_SAFE - lGear2, -- GEAR_L_SAFE - lGear3)) -- GEAR_R_SAFE - -- Gear Lamps end - - -- Fuel Indicator - local lCounter = {[0] = 0.0, [1] = 0.1, [2] = 0.2, [3] = 0.3, [4] = 0.4, [5] = 0.5, [6] = 0.6, [7] = 0.7, [8] = 0.8, [9] = 0.9} - - lEngineFuelInternal = lEngineFuelInternal * 2.2046223302272 -- kg to lbs - local lFuelNeedle = (lEngineFuelInternal / 2) / 6000 -- 6000 = scala - lEngineFuelInternal = lEngineFuelInternal / 100 -- um unf die ersten drei stellen zukommen - local lEngineFuelInternalTmp = string.format("%03d", lEngineFuelInternal) - - local lFuelCounter3 = 0 - if lEngineFuelInternal > 10 then - lFuelCounter3 = (lEngineFuelInternal - (math.round(lEngineFuelInternal / 10, 0, "floor") * 10)) * 0.1 - else - lFuelCounter3 = lEngineFuelInternal * 0.1 - end - - SendData(25, string.format("%.2f;%.2f;%.2f;%.4f;%.4f", - lCounter[tonumber(string.sub(lEngineFuelInternalTmp, 1, 1))], - lCounter[tonumber(string.sub(lEngineFuelInternalTmp, 2, 2))], - lFuelCounter3, - lFuelNeedle, - lFuelNeedle)) - -- Fuel Indicator end - - -- Weapon Panel - ExportScript.AF.PayloadInfo = LoGetPayloadInfo() - --[[ - ShellsCounter - Station1 - Station2 - ... - Station11 - - Station Data: - 0.0 = off - 0.1 = E (Empty, yellow E) - 0.2 = 1 (load, white one) - 0.3 = RR (active, two green R and white 1 for load) - ]] - --[[ - Weapon Panel - | - --------------------------------------------------- - | | | | | | | | | | | - 1 2 3 4 5 6 7 8 9 10 11 - 1 3 5 7 9 11 10 8 6 4 2 -- Weapon Station ID - ]] - ExportScript.AF.TmpWeaponPanelActive = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0} - - for lIndex = 1, 11, 1 do - ExportScript.AF.TmpWeaponPanelActive[lIndex] = (ExportScript.AF.PayloadInfo.Stations[lIndex].count > 0 and 0.2 or 0.1) -- get status, empty or load - end - - if ExportScript.AF.PayloadInfo.CurrentStation > 0 then - ExportScript.AF.TmpWeaponPanelActive[ExportScript.AF.PayloadInfo.CurrentStation] = 0.3 -- currrent value - - table.foreach(ExportScript.AF.PayloadInfo.Stations, WeaponStatusPanel_selectCurrentPayloadStationGlassCockpit_A10A) -- corresponding station - end - - SendData(26, string.format("%d;%0.1f;%0.1f;%0.1f;%0.1f;%0.1f;%0.1f;%0.1f;%0.1f;%0.1f;%0.1f;%0.1f", - ExportScript.AF.PayloadInfo.Cannon.shells, - ExportScript.AF.TmpWeaponPanelActive[1], - ExportScript.AF.TmpWeaponPanelActive[3], - ExportScript.AF.TmpWeaponPanelActive[5], - ExportScript.AF.TmpWeaponPanelActive[7], - ExportScript.AF.TmpWeaponPanelActive[9], - ExportScript.AF.TmpWeaponPanelActive[11], - ExportScript.AF.TmpWeaponPanelActive[10], - ExportScript.AF.TmpWeaponPanelActive[8], - ExportScript.AF.TmpWeaponPanelActive[6], - ExportScript.AF.TmpWeaponPanelActive[4], - ExportScript.AF.TmpWeaponPanelActive[2])) - -- Wepaon Panel end - - -- UHF Gauges, no value - SendData(27, "001.00") + local lFuelCounter3 = 0 + if lEngineFuelInternal > 10 then + lFuelCounter3 = (lEngineFuelInternal - (ExportScript.Tools.round(lEngineFuelInternal / 10, 0, "floor") * 10)) * 0.1 + else + lFuelCounter3 = lEngineFuelInternal * 0.1 end + + ExportScript.Tools.SendData(300, string.format("%.2f", lCounter[tonumber(string.sub(lEngineFuelInternalTmp, 1, 1))])) + ExportScript.Tools.SendData(301, string.format("%.2f", lCounter[tonumber(string.sub(lEngineFuelInternalTmp, 2, 2))])) + ExportScript.Tools.SendData(302, string.format("%.2f", lFuelCounter3)) + ExportScript.Tools.SendData(303, string.format("%.4f", lFuelNeedle)) + ExportScript.Tools.SendData(304, string.format("%.4f", lFuelNeedle)) + -- Fuel Indicator end + + -- Weapon Panel + ExportScript.AF.PayloadInfo = LoGetPayloadInfo() + --[[ + ShellsCounter + Station1 + Station2 + ... + Station11 + + Station Data: + 0.0 = off + 0.1 = E (Empty, yellow E) + 0.2 = 1 (load, white one) + 0.3 = RR (active, two green R and white 1 for load) + ]] + --[[ + Weapon Panel + | + --------------------------------------------------- + | | | | | | | | | | | + 1 2 3 4 5 6 7 8 9 10 11 + 1 3 5 7 9 11 10 8 6 4 2 -- Weapon Station ID + ]] + ExportScript.AF.TmpWeaponPanelActive = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0} + + for lIndex = 1, 11, 1 do + ExportScript.AF.TmpWeaponPanelActive[lIndex] = (ExportScript.AF.PayloadInfo.Stations[lIndex].count > 0 and 0.2 or 0.1) -- get status, empty or load + end + + if ExportScript.AF.PayloadInfo.CurrentStation > 0 then + ExportScript.AF.TmpWeaponPanelActive[ExportScript.AF.PayloadInfo.CurrentStation] = 0.3 -- currrent value + + table.foreach(ExportScript.AF.PayloadInfo.Stations, ExportScript.AF.WeaponStatusPanel_selectCurrentPayloadStationIkarus_A10A) -- corresponding station + end + + ExportScript.Tools.SendData(100, ExportScript.AF.PayloadInfo.Cannon.shells) + ExportScript.Tools.SendData(101, string.format("%0.1f", ExportScript.AF.TmpWeaponPanelActive[1])) -- Station 1 + ExportScript.Tools.SendData(102, string.format("%0.1f", ExportScript.AF.TmpWeaponPanelActive[3])) -- Station 2 + ExportScript.Tools.SendData(103, string.format("%0.1f", ExportScript.AF.TmpWeaponPanelActive[5])) -- Station 3 + ExportScript.Tools.SendData(104, string.format("%0.1f", ExportScript.AF.TmpWeaponPanelActive[7])) -- Station 4 + ExportScript.Tools.SendData(105, string.format("%0.1f", ExportScript.AF.TmpWeaponPanelActive[9])) -- Station 5 + ExportScript.Tools.SendData(106, string.format("%0.1f", ExportScript.AF.TmpWeaponPanelActive[11])) -- Station 6 + ExportScript.Tools.SendData(107, string.format("%0.1f", ExportScript.AF.TmpWeaponPanelActive[10])) -- Station 7 + ExportScript.Tools.SendData(108, string.format("%0.1f", ExportScript.AF.TmpWeaponPanelActive[8])) -- Station 8 + ExportScript.Tools.SendData(109, string.format("%0.1f", ExportScript.AF.TmpWeaponPanelActive[6])) -- Station 9 + ExportScript.Tools.SendData(110, string.format("%0.1f", ExportScript.AF.TmpWeaponPanelActive[4])) -- Station 10 + ExportScript.Tools.SendData(111, string.format("%0.1f", ExportScript.AF.TmpWeaponPanelActive[2])) -- Station 11 + -- Wepaon Panel end + + local lMCPState = LoGetMCPState() -- Warning Lights + if lMCPState ~= nil then + ExportScript.Tools.SendData(702, lMCPState.MasterWarning == true and 1 or 0 ) + end + + -- Missle launch / Scan Warning + ExportScript.AF.RWRStatusPanel(lFunctionTyp) + + -- (x < 0 and 'negative' or 'non-negative') + --[[ + local lPayloadInfo = LoGetPayloadInfo() + ExportScript.Tools.WriteToLog('lPayloadInfo: '..ExportScript.Tools.dump(lPayloadInfo)) + + local lSnares = LoGetSnares() -- Flare and Chaff + ExportScript.Tools.WriteToLog('lSnares: '..ExportScript.Tools.dump(lSnares)) + + local lSightingSystemInfo = LoGetSightingSystemInfo() + ExportScript.Tools.WriteToLog('lSightingSystemInfo: '..ExportScript.Tools.dump(lSightingSystemInfo)) + + local lTWSInfo = LoGetTWSInfo() -- SPO Informationen, z.B. Radarwarner F15C + ExportScript.Tools.WriteToLog('lTWSInfo: '..ExportScript.Tools.dump(lTWSInfo)) + + local lTargetInformation = LoGetTargetInformation() -- detalierte Radar Infos z.B. F15C + ExportScript.Tools.WriteToLog('lTargetInformation: '..ExportScript.Tools.dump(lTargetInformation)) + + local lLockedTargetInformation = LoGetLockedTargetInformation() + ExportScript.Tools.WriteToLog('lLockedTargetInformation: '..ExportScript.Tools.dump(lLockedTargetInformation)) + + local lF15_TWS_Contacs = LoGetF15_TWS_Contacts() -- the same information but only for F-15 in TWS mode + ExportScript.Tools.WriteToLog('lF15_TWS_Contacs: '..ExportScript.Tools.dump(lF15_TWS_Contacs)) + + local lMechInfo = LoGetMechInfo() -- mechanical components, e.g. Flaps, Wheelbrakes,... + ExportScript.Tools.WriteToLog('lMechInfo: '..ExportScript.Tools.dump(lMechInfo)) + + local lMCPState = LoGetMCPState() -- Warnlichter + ExportScript.Tools.WriteToLog('lMCPState: '..ExportScript.Tools.dump(lMCPState)) + + local lControlPanel_HSI = LoGetControlPanel_HSI() + ExportScript.Tools.WriteToLog('lControlPanel_HSI: '..ExportScript.Tools.dump(lControlPanel_HSI)) + + local lRadioBeaconsStatus = LoGetRadioBeaconsStatus() + ExportScript.Tools.WriteToLog('lRadioBeaconsStatus: '..ExportScript.Tools.dump(lRadioBeaconsStatus)) + + local lEngineInfo = LoGetEngineInfo() + ExportScript.Tools.WriteToLog('lEngineInfo: '..ExportScript.Tools.dump(lEngineInfo)) + ]] + -- Weapon Control System + -- local lNameByType = LoGetNameByType () -- args 4 (number : level1,level2,level3,level4), result string + -- values from LoGetTargetInformation().type + -- ExportScript.Tools.WriteToLog('lNameByType: '..ExportScript.Tools.dump(lNameByType)) end -function ExportScript.ProcessDACLowImportance(mainPanelDevice) --- where necessary, specify HardwareID, example SightingSystem(2) +function ExportScript.ProcessDACConfigLowImportance() + local lFunctionTyp = "DAC" -- function type for shared function + ExportScript.AF.MechanicalDevicesIndicator(lFunctionTyp) + ExportScript.AF.RWRStatusPanel(lFunctionTyp) ExportScript.AF.SightingSystem() ExportScript.AF.FuelQuantityIndicator() ExportScript.AF.StatusLamp() - ExportScript.AF.MechanicalDevicesIndicator() ExportScript.AF.FlareChaff() ExportScript.AF.WeaponStatusPanel() - ExportScript.AF.RWRStatusPanel() ExportScript.AF.AOAIndicator() end @@ -559,13 +526,12 @@ end -- Custom functions -- ----------------------------- -function ExportScript.AF.SightingSystem(hardware) - local lHardware = hardware or 1 +function ExportScript.AF.SightingSystem() local lSightingSystemInfo = LoGetSightingSystemInfo() if lSightingSystemInfo == nil then return end - --WriteToLog('lSightingSystemInfo: '..dump(lSightingSystemInfo)9 + --ExportScript.Tools.WriteToLog('lSightingSystemInfo: '..ExportScript.Tools.dump(lSightingSystemInfo)9 --[[ [PRF] = { [selection] = string: "ILV" @@ -602,21 +568,20 @@ function ExportScript.AF.SightingSystem(hardware) } } ]] - SendDataHW("600", lSightingSystemInfo.ECM_on == true and 1 or 0, lHardware ) - SendDataHW("601", lSightingSystemInfo.laser_on == true and 1 or 0, lHardware ) - SendDataHW("602", lSightingSystemInfo.optical_system_on == true and 1 or 0, lHardware ) - SendDataHW("603", lSightingSystemInfo.LaunchAuthorized == true and 1 or 0, lHardware ) - --SendDataHW("604", lSightingSystemInfo.radar_on == true and 1 or 0, lHardware ) + ExportScript.Tools.SendDataDAC("600", lSightingSystemInfo.ECM_on == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("601", lSightingSystemInfo.laser_on == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("602", lSightingSystemInfo.optical_system_on == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("603", lSightingSystemInfo.LaunchAuthorized == true and 1 or 0 ) + --ExportScript.Tools.SendDataDAC("604", lSightingSystemInfo.radar_on == true and 1 or 0 ) end -function ExportScript.AF.FuelQuantityIndicator(hardware) +function ExportScript.AF.FuelQuantityIndicator() -- Fuel quantity shows the fuel remaining in all tanks - local lHardware = hardware or 1 local lEngineInfo = LoGetEngineInfo() if lEngineInfo == nil then return end - --WriteToLog('lEngineInfo: '..dump(lEngineInfo)) + --ExportScript.Tools.WriteToLog('lEngineInfo: '..ExportScript.Tools.dump(lEngineInfo)) --[[ [fuel_external] = number: "0" [Temperature] = { @@ -643,29 +608,28 @@ function ExportScript.AF.FuelQuantityIndicator(hardware) lPayloadInfo.Stations[8].CLSID == E8D4652F-FD48-45B7-BA5B-2AE05BB5A9CF -- ext 800l Fuel Tank ]] - SendDataHW("300", string.format("%d", math.round((((lEngineInfo.fuel_internal + lEngineInfo.fuel_external) * 2.2) / 100), 0, "ceil") * 100), lHardware ) -- total fuel in lbs - --SendDataHW("301", string.format("%d", lEngineInfo.fuel_internal * 2.2), lHardware ) -- internal fuel in lbs - --SendDataHW("302", string.format("%d", lEngineInfo.fuel_external * 2.2), lHardware ) -- external fuel in lbs - + ExportScript.Tools.SendDataDAC("300", string.format("%d", ExportScript.Tools.round((((lEngineInfo.fuel_internal + lEngineInfo.fuel_external) * 2.2) / 100), 0, "ceil") * 100) ) -- total fuel in lbs + --ExportScript.Tools.SendDataDAC("301", string.format("%d", lEngineInfo.fuel_internal * 2.2) ) -- internal fuel in lbs + --ExportScript.Tools.SendDataDAC("302", string.format("%d", lEngineInfo.fuel_external * 2.2) ) -- external fuel in lbs + --[[ local lPayloadInfo = LoGetPayloadInfo() if lPayloadInfo == nil then return end - SendDataHW("303", ((lPayloadInfo.Stations[5].count > 0 and lPayloadInfo.Stations[5].CLSID == "Fuel_Tank_FT600") and 1 or 0), lHardware ) -- weapon presend > 0 (panel 5) - SendDataHW("304", ((lPayloadInfo.Stations[6].count > 0 and lPayloadInfo.Stations[6].CLSID == "Fuel_Tank_FT600") and 1 or 0), lHardware ) -- weapon presend > 0 (panel 6) - SendDataHW("305", ((lPayloadInfo.Stations[7].count > 0 and lPayloadInfo.Stations[7].CLSID == "Fuel_Tank_FT600") and 1 or 0), lHardware ) -- weapon presend > 0 (panel 7) - SendDataHW("307", (lEngineInfo.fuel_internal < 600.0 and 1 or 0), lHardware ) -- Bingo Fuel + ExportScript.Tools.SendDataDAC("303", ((lPayloadInfo.Stations[5].count > 0 and lPayloadInfo.Stations[5].CLSID == "Fuel_Tank_FT600") and 1 or 0) ) -- weapon presend > 0 (panel 5) + ExportScript.Tools.SendDataDAC("304", ((lPayloadInfo.Stations[6].count > 0 and lPayloadInfo.Stations[6].CLSID == "Fuel_Tank_FT600") and 1 or 0) ) -- weapon presend > 0 (panel 6) + ExportScript.Tools.SendDataDAC("305", ((lPayloadInfo.Stations[7].count > 0 and lPayloadInfo.Stations[7].CLSID == "Fuel_Tank_FT600") and 1 or 0) ) -- weapon presend > 0 (panel 7) + ExportScript.Tools.SendDataDAC("307", (lEngineInfo.fuel_internal < 600.0 and 1 or 0) ) -- Bingo Fuel ]] end -function ExportScript.AF.StatusLamp(hardware) - local lHardware = hardware or 1 +function ExportScript.AF.StatusLamp() local lMCPState = LoGetMCPState() -- Warning Lights if lMCPState == nil then return end - --WriteToLog('lMCPState: '..dump(lMCPState)) + --ExportScript.Tools.WriteToLog('lMCPState: '..ExportScript.Tools.dump(lMCPState)) --[[ [RightTailPlaneFailure] = boolean: "false" [EOSFailure] = boolean: "false" @@ -696,62 +660,61 @@ function ExportScript.AF.StatusLamp(hardware) [AutopilotOn] = boolean: "false" [LeftTailPlaneFailure] = boolean: "false" ]] - - SendDataHW("700", lMCPState.LeftTailPlaneFailure == true and 1 or 0, lHardware ) - SendDataHW("701", lMCPState.RightTailPlaneFailure == true and 1 or 0, lHardware ) - SendDataHW("702", lMCPState.MasterWarning == true and 1 or 0, lHardware ) - SendDataHW("703", lMCPState.LeftEngineFailure == true and 1 or 0, lHardware ) - SendDataHW("704", lMCPState.RightEngineFailure == true and 1 or 0, lHardware ) - SendDataHW("705", lMCPState.LeftAileronFailure == true and 1 or 0, lHardware ) - SendDataHW("706", lMCPState.RightAileronFailure == true and 1 or 0, lHardware ) - SendDataHW("707", lMCPState.LeftMainPumpFailure == true and 1 or 0, lHardware ) - SendDataHW("708", lMCPState.RightMainPumpFailure == true and 1 or 0, lHardware ) - SendDataHW("709", lMCPState.LeftWingPumpFailure == true and 1 or 0, lHardware ) - SendDataHW("710", lMCPState.RightWingPumpFailure == true and 1 or 0, lHardware ) - SendDataHW("711", lMCPState.EOSFailure == true and 1 or 0, lHardware ) - SendDataHW("712", lMCPState.ECMFailure == true and 1 or 0, lHardware ) - SendDataHW("713", lMCPState.CannonFailure == true and 1 or 0, lHardware ) - SendDataHW("714", lMCPState.MLWSFailure == true and 1 or 0, lHardware ) - SendDataHW("715", lMCPState.ACSFailure == true and 1 or 0, lHardware ) - SendDataHW("716", lMCPState.RadarFailure == true and 1 or 0, lHardware ) - SendDataHW("717", lMCPState.HelmetFailure == true and 1 or 0, lHardware ) - SendDataHW("718", lMCPState.HUDFailure == true and 1 or 0, lHardware ) - SendDataHW("719", lMCPState.MFDFailure == true and 1 or 0, lHardware ) - SendDataHW("720", lMCPState.RWSFailure == true and 1 or 0, lHardware ) - SendDataHW("721", lMCPState.GearFailure == true and 1 or 0, lHardware ) - SendDataHW("722", lMCPState.HydraulicsFailure == true and 1 or 0, lHardware ) - SendDataHW("723", lMCPState.AutopilotFailure == true and 1 or 0, lHardware ) - SendDataHW("724", lMCPState.FuelTankDamage == true and 1 or 0, lHardware ) - SendDataHW("725", lMCPState.CanopyOpen == true and 1 or 0, lHardware ) - SendDataHW("726", lMCPState.StallSignalization == true and 1 or 0, lHardware ) - SendDataHW("727", lMCPState.AutopilotOn == true and 1 or 0, lHardware ) - + + ExportScript.Tools.SendDataDAC("700", lMCPState.LeftTailPlaneFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("701", lMCPState.RightTailPlaneFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("702", lMCPState.MasterWarning == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("703", lMCPState.LeftEngineFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("704", lMCPState.RightEngineFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("705", lMCPState.LeftAileronFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("706", lMCPState.RightAileronFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("707", lMCPState.LeftMainPumpFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("708", lMCPState.RightMainPumpFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("709", lMCPState.LeftWingPumpFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("710", lMCPState.RightWingPumpFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("711", lMCPState.EOSFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("712", lMCPState.ECMFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("713", lMCPState.CannonFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("714", lMCPState.MLWSFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("715", lMCPState.ACSFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("716", lMCPState.RadarFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("717", lMCPState.HelmetFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("718", lMCPState.HUDFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("719", lMCPState.MFDFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("720", lMCPState.RWSFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("721", lMCPState.GearFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("722", lMCPState.HydraulicsFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("723", lMCPState.AutopilotFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("724", lMCPState.FuelTankDamage == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("725", lMCPState.CanopyOpen == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("726", lMCPState.StallSignalization == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("727", lMCPState.AutopilotOn == true and 1 or 0 ) + local lEngineInfo = LoGetEngineInfo() if lEngineInfo ~= nil then - --WriteToLog('lEngineInfo: '..dump(lEngineInfo)) - SendDataHW("728", lEngineInfo.EngineStart.left, lHardware ) -- lamp start left engine 1 (0|1) - SendDataHW("729", lEngineInfo.EngineStart.right, lHardware ) -- lamp start right engine 1 (0|1) + --ExportScript.Tools.WriteToLog('lEngineInfo: '..ExportScript.Tools.dump(lEngineInfo)) + ExportScript.Tools.SendDataDAC("728", lEngineInfo.EngineStart.left ) -- lamp start left engine 1 (0|1) + ExportScript.Tools.SendDataDAC("729", lEngineInfo.EngineStart.right ) -- lamp start right engine 1 (0|1) end end -function ExportScript.AF.FlareChaff(hardware) - local lHardware = hardware or 1 +function ExportScript.AF.FlareChaff() local lSnares = LoGetSnares() -- Flare and Chaff if lSnares == nil then return end - --WriteToLog('lSnares: '..dump(lSnares)) - + --ExportScript.Tools.WriteToLog('lSnares: '..ExportScript.Tools.dump(lSnares)) + --[chaff] = number: "30" --[flare] = number: "30" - - SendDataHW("800", lSnares.chaff, lHardware ) - SendDataHW("801", lSnares.flare, lHardware ) + + ExportScript.Tools.SendDataDAC("800", lSnares.chaff ) + ExportScript.Tools.SendDataDAC("801", lSnares.flare ) end -function ExportScript.AF.MechanicalDevicesIndicator(hardware) +function ExportScript.AF.MechanicalDevicesIndicator(FunctionTyp) + local lFunctionTyp = FunctionTyp or "Ikarus" -- The mechanical devices indicator shows the position of the landing gear, flaps, leading edge flaps and airbrake - local lHardware = hardware or 1 local lMechInfo = LoGetMechInfo() -- mechanical components, e.g. Flaps, Wheelbrakes,... if lMechInfo == nil then return @@ -826,43 +789,47 @@ function ExportScript.AF.MechanicalDevicesIndicator(hardware) [status] = number: "0" [value] = number: "0" }]] - --SendDataHW("500", lMechInfo.gear.status ) - --SendDataHW("501", lMechInfo.gear.value ) - --SendDataHW("502", lMechInfo.gear.nose.rod ) -- zeigt an wie weit das Fahrwerk einsackt wenn das Flugzeug auf dem Boden ist - --SendDataHW("503", lMechInfo.gear.main.left.rod ) -- zeigt an wie weit das Fahrwerk einsackt wenn das Flugzeug auf dem Boden ist - --SendDataHW("504", lMechInfo.gear.main.right.rod ) -- zeigt an wie weit das Fahrwerk einsackt wenn das Flugzeug auf dem Boden ist - --SendDataHW("500", ((lMechInfo.gear.status == 1 and lMechInfo.gear.value < 1) and 1 or 0 ) ) -- gear warning light, go up - --SendDataHW("500", ((lMechInfo.gear.status == 0 and lMechInfo.gear.value > 0) and 1 or 0 ) ) -- gear warning light, go down - --SendDataHW("500", (((lMechInfo.gear.status == 1 and lMechInfo.gear.value < 1) or (lMechInfo.gear.status == 0 and lMechInfo.gear.value > 0)) and 1 or 0 ), lHardware ) -- gear warning light - SendDataHW("501", (lMechInfo.gear.value > 0.85 and 1 or 0), lHardware ) -- nose gear - SendDataHW("502", (lMechInfo.gear.value > 0.95 and 1 or 0), lHardware ) -- left gear - SendDataHW("503", (lMechInfo.gear.value == 1 and 1 or 0), lHardware ) -- right gear - - --SendDataHW("510", lMechInfo.speedbrakes.status ) -- speedbreakes on 1 (0|1) - SendDataHW("510", (lMechInfo.speedbrakes.value > 0.1 and 1 or 0), lHardware ) -- speedbreakes on > 0.1 (0 - 1) - - --SendDataHW("520", lMechInfo.wheelbrakes.status ) -- not in use - --SendDataHW("521", lMechInfo.wheelbrakes.value ) -- not in use - local lGetTrueAirSpeed = LoGetTrueAirSpeed() if lGetTrueAirSpeed == nil then lGetTrueAirSpeed = 0 end - --SendDataHW("530", lMechInfo.flaps.status ) -- flap switch off 0, 1. position 1, 2. position 2 (0|1|2) - --SendDataHW("531", lMechInfo.flaps.value ) -- flap 1. position > 0.25, 2. position > 0.93 (0 - 1) - SendDataHW("531", (lMechInfo.flaps.value > 0.25 and 1 or 0), lHardware ) -- flap 1. position - SendDataHW("532", (lMechInfo.flaps.value > 0.93 and 1 or 0), lHardware ) -- flap 2. position - SendDataHW("533", ((lMechInfo.flaps.value > 0.93 and lGetTrueAirSpeed > 340) and 1 or 0), lHardware ) -- Speed Warning for Flaps, same light as gear warning light, but blinking light + + if ExportScript.Config.IkarusExport and lFunctionTyp == "Ikarus" then + ExportScript.Tools.SendData(501, (lMechInfo.gear.value > 0.85 and 1 or 0) ) -- nose gear + ExportScript.Tools.SendData(502, (lMechInfo.gear.value > 0.95 and 1 or 0) ) -- left gear + ExportScript.Tools.SendData(503, (lMechInfo.gear.value == 1 and 1 or 0) ) -- right gear + + local lFlapsValue = lMechInfo.flaps.value + lFlapsValue = lFlapsValue / 1.6 + lFlapsValue = (lFlapsValue > 1.0 and 1.0 or lFlapsValue) -- the result is limited to 1.0 + + ExportScript.Tools.SendData(530, string.format("%.4f", lFlapsValue)) + end + + if ExportScript.Config.DACExport and lFunctionTyp == "DAC" then + ExportScript.Tools.SendDataDAC("501", (lMechInfo.gear.value > 0.85 and 1 or 0) ) -- nose gear + ExportScript.Tools.SendDataDAC("502", (lMechInfo.gear.value > 0.95 and 1 or 0) ) -- left gear + ExportScript.Tools.SendDataDAC("503", (lMechInfo.gear.value == 1 and 1 or 0) ) -- right gear + + --ExportScript.Tools.SendDataDAC("510", lMechInfo.speedbrakes.status ) -- speedbreakes on 1 (0|1) + ExportScript.Tools.SendDataDAC("510", (lMechInfo.speedbrakes.value > 0.1 and 1 or 0) ) -- speedbreakes on > 0.1 (0 - 1) + + --ExportScript.Tools.SendDataDAC("530", lMechInfo.flaps.status ) -- flap switch off 0, 1. position 1, 2. position 2 (0|1|2) + --ExportScript.Tools.SendDataDAC("531", lMechInfo.flaps.value ) -- flap 1. position > 0.25, 2. position > 0.93 (0 - 1) + ExportScript.Tools.SendDataDAC("531", (lMechInfo.flaps.value > 0.25 and 1 or 0) ) -- flap 1. position + ExportScript.Tools.SendDataDAC("532", (lMechInfo.flaps.value > 0.93 and 1 or 0) ) -- flap 2. position + ExportScript.Tools.SendDataDAC("533", ((lMechInfo.flaps.value > 0.93 and lGetTrueAirSpeed > 340) and 1 or 0) ) -- Speed Warning for Flaps, same light as gear warning light, but blinking light + end end -function ExportScript.AF.RWRStatusPanel(hardware) +function ExportScript.AF.RWRStatusPanel(FunctionTyp) + local lFunctionTyp = FunctionTyp or "Ikarus" -- RWR Status Panel only - local lHardware = hardware or 1 local lTWSInfo = LoGetTWSInfo() if lTWSInfo == nil then return end - --WriteToLog('lTWSInfo: '..dump(lTWSInfo)) + --ExportScript.Tools.WriteToLog('lTWSInfo: '..ExportScript.Tools.dump(lTWSInfo)) --[[ [Emitters] = { [1] = { @@ -894,35 +861,49 @@ function ExportScript.AF.RWRStatusPanel(hardware) } [Mode] = number: "0" ]] - - local lPrimaryThreatTmp = 0 - local lPriorityTmp = 0 - local lScanTmp = false - local lMissileTmp = false - - if(#lTWSInfo.Emitters > 0) then - for EmitterIndex = 1, #lTWSInfo.Emitters, 1 do - if(lTWSInfo.Emitters[EmitterIndex].Priority > lPriorityTmp) then - lPrimaryThreatTmp = EmitterIndex - end - if(lTWSInfo.Emitters[EmitterIndex].SignalType == "scan") then - lScanTmp = true - elseif(lTWSInfo.Emitters[EmitterIndex].SignalType == "missile_radio_guided") then - lMissileTmp = true + + if ExportScript.AF.EventNumberRWRStatusPanel == nil then + ExportScript.AF.EventNumberRWRStatusPanel = 0 + end + + if(ExportScript.AF.EventNumberRWRStatusPanel < ExportScript.AF.EventNumber) then + ExportScript.AF.EventNumberRWRStatusPanel = ExportScript.AF.EventNumber + + local lPrimaryThreatTmp = 0 + local lPriorityTmp = 0 + ExportScript.AF.ScanTmp = 0 + ExportScript.AF.MissileTmp = 0 + + if(#lTWSInfo.Emitters > 0) then + for EmitterIndex = 1, #lTWSInfo.Emitters, 1 do + if(lTWSInfo.Emitters[EmitterIndex].Priority > lPriorityTmp) then + lPrimaryThreatTmp = EmitterIndex + end + if(lTWSInfo.Emitters[EmitterIndex].SignalType == "scan") then + ExportScript.AF.ScanTmp = 1 + elseif(lTWSInfo.Emitters[EmitterIndex].SignalType == "missile_radio_guided") then + ExportScript.AF.MissileTmp = 1 + end end + else + lPrimaryThreatTmp = 0 + lPriorityTmp = 0 end - else - lPrimaryThreatTmp = 0 - lPriorityTmp = 0 end - - SendDataHW("440", (lMissileTmp and 1 or 0), lHardware ) - SendDataHW("444", (lScanTmp and 1 or 0), lHardware ) + + if ExportScript.Config.DACExport and lFunctionTyp == "DAC" then + ExportScript.Tools.SendDataDAC("440", ExportScript.AF.MissileTmp) + ExportScript.Tools.SendDataDAC("444", ExportScript.AF.ScanTmp) + end + + if ExportScript.Config.IkarusExport and lFunctionTyp == "Ikarus" then + ExportScript.Tools.SendData(440, ExportScript.AF.MissileTmp) + ExportScript.Tools.SendData(444, ExportScript.AF.ScanTmp) + end end -function ExportScript.AF.AOAIndicator(hardware) +function ExportScript.AF.AOAIndicator() -- AOA Indicator only - local lHardware = hardware or 1 local lAoA = LoGetAngleOfAttack() if lAoA == nil then return @@ -931,29 +912,28 @@ function ExportScript.AF.AOAIndicator(hardware) if lMechInfo == nil then return end - + if lMechInfo.gear.status == 1 then local lAOAUnits = (lAoA * 57.3) * 0.7728 + 12.22 - --WriteToLog('lAoA: '..dump(lAoA)) - --WriteToLog('lAOAUnits: '..dump(lAOAUnits)) - SendDataHW("900", (lAOAUnits > 21.0 and 1 or 0), lHardware ) - SendDataHW("901", ((lAOAUnits > 18.0 and lAOAUnits < 22.0) and 1 or 0), lHardware ) - SendDataHW("902", (lAOAUnits < 19.0 and 1 or 0), lHardware ) + --ExportScript.Tools.WriteToLog('lAoA: '..ExportScript.Tools.dump(lAoA)) + --ExportScript.Tools.WriteToLog('lAOAUnits: '..ExportScript.Tools.dump(lAOAUnits)) + ExportScript.Tools.SendDataDAC("900", (lAOAUnits > 21.0 and 1 or 0) ) + ExportScript.Tools.SendDataDAC("901", ((lAOAUnits > 18.0 and lAOAUnits < 22.0) and 1 or 0) ) + ExportScript.Tools.SendDataDAC("902", (lAOAUnits < 19.0 and 1 or 0) ) else -- AOA Index Lamps off - SendDataHW("900", 0, lHardware ) - SendDataHW("901", 0, lHardware ) - SendDataHW("902", 0, lHardware ) + ExportScript.Tools.SendDataDAC("900", 0 ) + ExportScript.Tools.SendDataDAC("901", 0 ) + ExportScript.Tools.SendDataDAC("902", 0 ) end end - -function ExportScript.AF.WeaponStatusPanel(hardware) + +function ExportScript.AF.WeaponStatusPanel() -- The weapon status panel, quantity and readiness of the currently selected weapon and the remaining gun ammunition are indicated. - local lHardware = hardware or 1 ExportScript.AF.PayloadInfo = LoGetPayloadInfo() if ExportScript.AF.PayloadInfo == nil then return end - --WriteToLog('ExportScript.AF.PayloadInfo: '..dump(ExportScript.AF.PayloadInfo)) + --ExportScript.Tools.WriteToLog('ExportScript.AF.PayloadInfo: '..ExportScript.Tools.dump(ExportScript.AF.PayloadInfo)) --[[ exsample [Stations] = { [1] = { @@ -1177,100 +1157,93 @@ function ExportScript.AF.WeaponStatusPanel(hardware) ]] -- Payload Info -- weapon stations (panel) 1 (left) - 11 (right) reserved - SendDataHW("100", ExportScript.AF.PayloadInfo.Cannon.shells, lHardware ) -- count cannon shells - SendDataHW("101", (ExportScript.AF.PayloadInfo.Stations[1].count > 0 and 1 or 0), lHardware ) -- weapon presend > 0 (panel 1) - SendDataHW("102", (ExportScript.AF.PayloadInfo.Stations[3].count > 0 and 1 or 0), lHardware ) -- weapon presend > 0 (panel 2) - SendDataHW("103", (ExportScript.AF.PayloadInfo.Stations[5].count > 0 and 1 or 0), lHardware ) -- weapon presend > 0 (panel 3) - SendDataHW("104", (ExportScript.AF.PayloadInfo.Stations[7].count > 0 and 1 or 0), lHardware ) -- weapon presend > 0 (panel 4) - SendDataHW("105", (ExportScript.AF.PayloadInfo.Stations[9].count > 0 and 1 or 0), lHardware ) -- weapon presend > 0 (panel 5) - SendDataHW("106", (ExportScript.AF.PayloadInfo.Stations[11].count > 0 and 1 or 0), lHardware ) -- weapon presend > 0 (panel 6, center station) - SendDataHW("107", (ExportScript.AF.PayloadInfo.Stations[10].count > 0 and 1 or 0), lHardware ) -- weapon presend > 0 (panel 7) - SendDataHW("108", (ExportScript.AF.PayloadInfo.Stations[8].count > 0 and 1 or 0), lHardware ) -- weapon presend > 0 (panel 8) - SendDataHW("109", (ExportScript.AF.PayloadInfo.Stations[6].count > 0 and 1 or 0), lHardware ) -- weapon presend > 0 (panel 9) - SendDataHW("110", (ExportScript.AF.PayloadInfo.Stations[4].count > 0 and 1 or 0), lHardware ) -- weapon presend > 0 (panel 10) - SendDataHW("111", (ExportScript.AF.PayloadInfo.Stations[2].count > 0 and 1 or 0), lHardware ) -- weapon presend > 0 (panel 11) + ExportScript.Tools.SendDataDAC("100", ExportScript.AF.PayloadInfo.Cannon.shells ) -- count cannon shells + ExportScript.Tools.SendDataDAC("101", (ExportScript.AF.PayloadInfo.Stations[1].count > 0 and 1 or 0) ) -- weapon presend > 0 (panel 1) + ExportScript.Tools.SendDataDAC("102", (ExportScript.AF.PayloadInfo.Stations[3].count > 0 and 1 or 0) ) -- weapon presend > 0 (panel 2) + ExportScript.Tools.SendDataDAC("103", (ExportScript.AF.PayloadInfo.Stations[5].count > 0 and 1 or 0) ) -- weapon presend > 0 (panel 3) + ExportScript.Tools.SendDataDAC("104", (ExportScript.AF.PayloadInfo.Stations[7].count > 0 and 1 or 0) ) -- weapon presend > 0 (panel 4) + ExportScript.Tools.SendDataDAC("105", (ExportScript.AF.PayloadInfo.Stations[9].count > 0 and 1 or 0) ) -- weapon presend > 0 (panel 5) + ExportScript.Tools.SendDataDAC("106", (ExportScript.AF.PayloadInfo.Stations[11].count > 0 and 1 or 0) ) -- weapon presend > 0 (panel 6, center station) + ExportScript.Tools.SendDataDAC("107", (ExportScript.AF.PayloadInfo.Stations[10].count > 0 and 1 or 0) ) -- weapon presend > 0 (panel 7) + ExportScript.Tools.SendDataDAC("108", (ExportScript.AF.PayloadInfo.Stations[8].count > 0 and 1 or 0) ) -- weapon presend > 0 (panel 8) + ExportScript.Tools.SendDataDAC("109", (ExportScript.AF.PayloadInfo.Stations[6].count > 0 and 1 or 0) ) -- weapon presend > 0 (panel 9) + ExportScript.Tools.SendDataDAC("110", (ExportScript.AF.PayloadInfo.Stations[4].count > 0 and 1 or 0) ) -- weapon presend > 0 (panel 10) + ExportScript.Tools.SendDataDAC("111", (ExportScript.AF.PayloadInfo.Stations[2].count > 0 and 1 or 0) ) -- weapon presend > 0 (panel 11) -- weapon stations (panel) 1 (left) - 11 (right) empty - SendDataHW("121", (ExportScript.AF.PayloadInfo.Stations[1].count == 0 and 1 or 0), lHardware ) -- weapon presend > 0 (panel 1) - SendDataHW("122", (ExportScript.AF.PayloadInfo.Stations[3].count == 0 and 1 or 0), lHardware ) -- weapon presend > 0 (panel 2) - SendDataHW("123", (ExportScript.AF.PayloadInfo.Stations[5].count == 0 and 1 or 0), lHardware ) -- weapon presend > 0 (panel 3) - SendDataHW("124", (ExportScript.AF.PayloadInfo.Stations[7].count == 0 and 1 or 0), lHardware ) -- weapon presend > 0 (panel 4) - SendDataHW("125", (ExportScript.AF.PayloadInfo.Stations[9].count == 0 and 1 or 0), lHardware ) -- weapon presend > 0 (panel 5) - SendDataHW("126", (ExportScript.AF.PayloadInfo.Stations[11].count == 0 and 1 or 0), lHardware ) -- weapon presend > 0 (panel 6, center station) - SendDataHW("127", (ExportScript.AF.PayloadInfo.Stations[10].count == 0 and 1 or 0), lHardware ) -- weapon presend > 0 (panel 7) - SendDataHW("128", (ExportScript.AF.PayloadInfo.Stations[8].count == 0 and 1 or 0), lHardware ) -- weapon presend > 0 (panel 8) - SendDataHW("129", (ExportScript.AF.PayloadInfo.Stations[6].count == 0 and 1 or 0), lHardware ) -- weapon presend > 0 (panel 9) - SendDataHW("130", (ExportScript.AF.PayloadInfo.Stations[4].count == 0 and 1 or 0), lHardware ) -- weapon presend > 0 (panel 10) - SendDataHW("131", (ExportScript.AF.PayloadInfo.Stations[2].count == 0 and 1 or 0), lHardware ) -- weapon presend > 0 (panel 11) - --SendDataHW("CurrentStation", ExportScript.AF.PayloadInfo.CurrentStation, lHardware ) + ExportScript.Tools.SendDataDAC("121", (ExportScript.AF.PayloadInfo.Stations[1].count == 0 and 1 or 0) ) -- weapon presend > 0 (panel 1) + ExportScript.Tools.SendDataDAC("122", (ExportScript.AF.PayloadInfo.Stations[3].count == 0 and 1 or 0) ) -- weapon presend > 0 (panel 2) + ExportScript.Tools.SendDataDAC("123", (ExportScript.AF.PayloadInfo.Stations[5].count == 0 and 1 or 0) ) -- weapon presend > 0 (panel 3) + ExportScript.Tools.SendDataDAC("124", (ExportScript.AF.PayloadInfo.Stations[7].count == 0 and 1 or 0) ) -- weapon presend > 0 (panel 4) + ExportScript.Tools.SendDataDAC("125", (ExportScript.AF.PayloadInfo.Stations[9].count == 0 and 1 or 0) ) -- weapon presend > 0 (panel 5) + ExportScript.Tools.SendDataDAC("126", (ExportScript.AF.PayloadInfo.Stations[11].count == 0 and 1 or 0) ) -- weapon presend > 0 (panel 6, center station) + ExportScript.Tools.SendDataDAC("127", (ExportScript.AF.PayloadInfo.Stations[10].count == 0 and 1 or 0) ) -- weapon presend > 0 (panel 7) + ExportScript.Tools.SendDataDAC("128", (ExportScript.AF.PayloadInfo.Stations[8].count == 0 and 1 or 0) ) -- weapon presend > 0 (panel 8) + ExportScript.Tools.SendDataDAC("129", (ExportScript.AF.PayloadInfo.Stations[6].count == 0 and 1 or 0) ) -- weapon presend > 0 (panel 9) + ExportScript.Tools.SendDataDAC("130", (ExportScript.AF.PayloadInfo.Stations[4].count == 0 and 1 or 0) ) -- weapon presend > 0 (panel 10) + ExportScript.Tools.SendDataDAC("131", (ExportScript.AF.PayloadInfo.Stations[2].count == 0 and 1 or 0) ) -- weapon presend > 0 (panel 11) + --ExportScript.Tools.SendDataDAC("CurrentStation", ExportScript.AF.PayloadInfo.CurrentStation ) -- air-to-air missils panel 1 and 11, air combat modus, CurrentStation = 1, panel 1 and 11 on -- wenn die Waffenstationen gleichmässig belegt sind, hat bei Auswahl CurrentStation immer den Wert der linken Station -- bei ungleichmäßiger Belegung, hat CurrentStation immer den Wert der jeweiligen Station -- Waffenbezeichnung als UUID, ExportScript.AF.PayloadInfo.Stations[X].CLSID - + -- defination if ExportScript.AF.CurrentStationTmp == nil then ExportScript.AF.CurrentStationTmp = -1 end - + if ExportScript.AF.PayloadInfo.CurrentStation > 0 and ExportScript.AF.CurrentStationTmp ~= ExportScript.AF.PayloadInfo.CurrentStation then ExportScript.AF.CurrentStationTmp = ExportScript.AF.PayloadInfo.CurrentStation - gTmpStationToPanel = {} - gTmpStationToPanel[1] = {Panel = 1, StationID = 101, CurrentID = 201, CurrentID2 = 221, HardwareID = lHardware } -- left - gTmpStationToPanel[3] = {Panel = 2, StationID = 102, CurrentID = 202, CurrentID2 = 222, HardwareID = lHardware } - gTmpStationToPanel[5] = {Panel = 3, StationID = 103, CurrentID = 203, CurrentID2 = 223, HardwareID = lHardware } - gTmpStationToPanel[7] = {Panel = 4, StationID = 104, CurrentID = 204, CurrentID2 = 224, HardwareID = lHardware } - gTmpStationToPanel[9] = {Panel = 5, StationID = 105, CurrentID = 205, CurrentID2 = 225, HardwareID = lHardware } - gTmpStationToPanel[11] = {Panel = 6, StationID = 106, CurrentID = 206, CurrentID2 = 226, HardwareID = lHardware } - gTmpStationToPanel[10] = {Panel = 7, StationID = 107, CurrentID = 207, CurrentID2 = 227, HardwareID = lHardware } - gTmpStationToPanel[8] = {Panel = 8, StationID = 108, CurrentID = 208, CurrentID2 = 228, HardwareID = lHardware } - gTmpStationToPanel[6] = {Panel = 9, StationID = 109, CurrentID = 209, CurrentID2 = 229, HardwareID = lHardware } - gTmpStationToPanel[4] = {Panel = 10, StationID = 110, CurrentID = 210, CurrentID2 = 230, HardwareID = lHardware } - gTmpStationToPanel[2] = {Panel = 11, StationID = 111, CurrentID = 211, CurrentID2 = 231, HardwareID = lHardware } -- right - - WeaponStatusPanel_Reset(201, 211, lHardware) - WeaponStatusPanel_Reset(221, 231, lHardware) - - SendDataHW(gTmpStationToPanel[ExportScript.AF.PayloadInfo.CurrentStation].CurrentID, 1, lHardware) -- eigentliche Auswahl - --WriteToLog('aktiv: '..gTmpStationToPanel[ExportScript.AF.PayloadInfo.CurrentStation].CurrentID) + ExportScript.AF.TmpStationToPanel = {} + ExportScript.AF.TmpStationToPanel[1] = {Panel = 1, StationID = 101, CurrentID = 201, CurrentID2 = 221 } -- left + ExportScript.AF.TmpStationToPanel[3] = {Panel = 2, StationID = 102, CurrentID = 202, CurrentID2 = 222 } + ExportScript.AF.TmpStationToPanel[5] = {Panel = 3, StationID = 103, CurrentID = 203, CurrentID2 = 223 } + ExportScript.AF.TmpStationToPanel[7] = {Panel = 4, StationID = 104, CurrentID = 204, CurrentID2 = 224 } + ExportScript.AF.TmpStationToPanel[9] = {Panel = 5, StationID = 105, CurrentID = 205, CurrentID2 = 225 } + ExportScript.AF.TmpStationToPanel[11] = {Panel = 6, StationID = 106, CurrentID = 206, CurrentID2 = 226 } + ExportScript.AF.TmpStationToPanel[10] = {Panel = 7, StationID = 107, CurrentID = 207, CurrentID2 = 227 } + ExportScript.AF.TmpStationToPanel[8] = {Panel = 8, StationID = 108, CurrentID = 208, CurrentID2 = 228 } + ExportScript.AF.TmpStationToPanel[6] = {Panel = 9, StationID = 109, CurrentID = 209, CurrentID2 = 229 } + ExportScript.AF.TmpStationToPanel[4] = {Panel = 10, StationID = 110, CurrentID = 210, CurrentID2 = 230 } + ExportScript.AF.TmpStationToPanel[2] = {Panel = 11, StationID = 111, CurrentID = 211, CurrentID2 = 231 } -- right + + ExportScript.AF.WeaponStatusPanel_Reset(201, 211) + ExportScript.AF.WeaponStatusPanel_Reset(221, 231) + + ExportScript.Tools.SendDataDAC(ExportScript.AF.TmpStationToPanel[ExportScript.AF.PayloadInfo.CurrentStation].CurrentID, 1) -- eigentliche Auswahl + --ExportScript.Tools.WriteToLog('aktiv: '..ExportScript.AF.TmpStationToPanel[ExportScript.AF.PayloadInfo.CurrentStation].CurrentID) if ExportScript.AF.PayloadInfo.Stations[ExportScript.AF.PayloadInfo.CurrentStation].container then if ExportScript.AF.PayloadInfo.Stations[ExportScript.AF.PayloadInfo.CurrentStation].count > 1 then - SendDataHW(gTmpStationToPanel[ExportScript.AF.PayloadInfo.CurrentStation].CurrentID2, 1, lHardware) -- eigentliche Auswahl - --WriteToLog('aktiv2: '..gTmpStationToPanel[ExportScript.AF.PayloadInfo.CurrentStation].CurrentID2) + ExportScript.Tools.SendDataDAC(ExportScript.AF.TmpStationToPanel[ExportScript.AF.PayloadInfo.CurrentStation].CurrentID2, 1) -- eigentliche Auswahl + --ExportScript.Tools.WriteToLog('aktiv2: '..ExportScript.AF.TmpStationToPanel[ExportScript.AF.PayloadInfo.CurrentStation].CurrentID2) end end - table.foreach(ExportScript.AF.PayloadInfo.Stations, WeaponStatusPanel_selectCurrentPayloadStation) -- zugehörige Stationen + table.foreach(ExportScript.AF.PayloadInfo.Stations, ExportScript.AF.WeaponStatusPanel_selectCurrentPayloadStation_A10A) -- zugehörige Stationen elseif ExportScript.AF.PayloadInfo.CurrentStation == 0 and ExportScript.AF.CurrentStationTmp > 0 then - WeaponStatusPanel_Reset(201, 211, lHardware) - WeaponStatusPanel_Reset(221, 231, lHardware) + ExportScript.AF.WeaponStatusPanel_Reset(201, 211) + ExportScript.AF.WeaponStatusPanel_Reset(221, 231) ExportScript.AF.CurrentStationTmp = -1 end end -- Helper functions -function WeaponStatusPanel_selectCurrentPayloadStation(_index) +function ExportScript.AF.WeaponStatusPanel_selectCurrentPayloadStation_A10A(_index) if ExportScript.AF.PayloadInfo.Stations[ExportScript.AF.PayloadInfo.CurrentStation].CLSID == ExportScript.AF.PayloadInfo.Stations[_index].CLSID and ExportScript.AF.PayloadInfo.CurrentStation ~= _index then - SendDataHW(gTmpStationToPanel[_index].CurrentID, 1, gTmpStationToPanel[_index].HardwareID) - --WriteToLog('aktiv3: '..gTmpStationToPanel[_index].CurrentID) + ExportScript.Tools.SendDataDAC(ExportScript.AF.TmpStationToPanel[_index].CurrentID, 1) + --ExportScript.Tools.WriteToLog('aktiv3: '..ExportScript.AF.TmpStationToPanel[_index].CurrentID) if ExportScript.AF.PayloadInfo.Stations[ExportScript.AF.PayloadInfo.CurrentStation].container then if ExportScript.AF.PayloadInfo.Stations[ExportScript.AF.PayloadInfo.CurrentStation].count > 1 then - SendDataHW(gTmpStationToPanel[_index].CurrentID2, 1, gTmpStationToPanel[_index].HardwareID) - --WriteToLog('aktiv3: '..gTmpStationToPanel[_index].CurrentID2) + ExportScript.Tools.SendDataDAC(ExportScript.AF.TmpStationToPanel[_index].CurrentID2, 1) + --ExportScript.Tools.WriteToLog('aktiv3: '..ExportScript.AF.TmpStationToPanel[_index].CurrentID2) end end end end -function WeaponStatusPanel_Reset(lMinId, lMaxID, lHardware) ---WriteToLog('WeaponStatusPanel_Reset') - for lCounter = lMinId, lMaxID, 1 do - SendDataHW(lCounter, 0, lHardware) - end -end - -function WeaponStatusPanel_selectCurrentPayloadStationGlassCockpit_A10A(_index) +function ExportScript.AF.WeaponStatusPanel_selectCurrentPayloadStationIkarus_A10A(_index) if ExportScript.AF.PayloadInfo.Stations[ExportScript.AF.PayloadInfo.CurrentStation].CLSID == ExportScript.AF.PayloadInfo.Stations[_index].CLSID and ExportScript.AF.PayloadInfo.CurrentStation ~= _index then ExportScript.AF.TmpWeaponPanelActive[_index] = 0.3 end diff --git a/Scripts/DCS-ExportScript/ExportsModules/F-15C.lua b/Scripts/DCS-ExportScript/ExportsModules/F-15C.lua index 626df29..18d8e1d 100644 --- a/Scripts/DCS-ExportScript/ExportsModules/F-15C.lua +++ b/Scripts/DCS-ExportScript/ExportsModules/F-15C.lua @@ -1,18 +1,18 @@ -- F-15C Export --- Version 0.9.9 BETA +-- Version 1.0.0 BETA -gES_FoundFCModule = true +ExportScript.FoundFCModule = true -- auxiliary function -dofile(gES_ExportModulePath.."FC_AuxiliaryFuntions.lua") +dofile(ExportScript.Config.ExportModulePath.."FC_AuxiliaryFuntions.lua") ----------------------------------------- -- FLAMING CLIFFS AIRCRAFT / F-15C -- -- FC aircraft don't support GetDevice -- ----------------------------------------- -function ProcessGlassCockpitFCHighImportanceConfig() - +function ExportScript.ProcessIkarusFCHighImportanceConfig() + local lFunctionTyp = "Ikarus" -- function type for shared function local myData = LoGetSelfData() if (myData) then @@ -20,595 +20,444 @@ function ProcessGlassCockpitFCHighImportanceConfig() local lLongitude = myData.LatLongAlt.Long -- LONGITUDE local lBasicAtmospherePressure = LoGetBasicAtmospherePressure() -- BAROMETRIC PRESSURE local lAltBar = LoGetAltitudeAboveSeaLevel() -- ALTITUDE SEA LEVEL (Meter) - local lAltRad = LoGetAltitudeAboveGroundLevel() -- ALTITUDE GROUND LEVEL (Meter) - --local lTrueAirSpeed = LoGetTrueAirSpeed() -- TRUE AIRSPEED (Meter/Second) - local lPitch, lBank, lYaw = LoGetADIPitchBankYaw() -- PITCH, BANK, YAW (Radian) - local lHeading = myData.Heading -- HEADING (Radian) - local lVVI = LoGetVerticalVelocity() -- VERTICAL SPEED (Meter/Second) - local lIAS = LoGetIndicatedAirSpeed() -- INDICATED AIRSPEED (Meter/Second) - local lMachNumber = LoGetMachNumber() -- MACH - local lAoA = LoGetAngleOfAttack() -- ANGLE OF ATTACK AoA (Radian) - - local lGlide = LoGetGlideDeviation() -- VOR1 HORIZONTAL DEFLECTION (-1 +1) - local lSide = LoGetSideDeviation() -- VOR1 VERTICAL DEFLECTION (-1 +1) - --local lSlipBallPosition = LoGetSlipBallPosition() -- SLIP BALL (-1 +1) - local lAccelerationUnits = LoGetAccelerationUnits().y -- G-LOAD - --local lMagneticYaw = LoGetMagneticYaw() -- Magnetic Yaw(Radian) - - --local lNavInfoPitch = LoGetNavigationInfo().Requirements.pitch -- AP REQUIRED PITCH (Radian) - --local lNavInfoRoll = LoGetNavigationInfo().Requirements.roll -- AP REQUIRED BANK (Radian) - --local lNavInfoSpeed = LoGetNavigationInfo().Requirements.speed -- AP SPEED (Meter/Second) - --local lNavInfoAltitude = LoGetNavigationInfo().Requirements.altitude -- AP ALTITUDE (Meter) - --local lNavInfoVerticalSpeed = LoGetNavigationInfo().Requirements.vertical_speed -- AP VERTICAL SPEED (Meter/Second) - - --local lControlPanel_HSI = LoGetControlPanel_HSI() -- HSI Data - local lHSI_RMI = LoGetControlPanel_HSI().RMI_raw -- VOR1 OBS (Radian) - local lHSI_ADF = LoGetControlPanel_HSI().ADF_raw -- ADF OBS (Radian) - --local lHSI_Heading = LoGetControlPanel_HSI().Heading_raw -- Heading (Radian) - local lEngineRPMleft = LoGetEngineInfo().RPM.left -- ENG1 RPM % local lEngineRPMright = LoGetEngineInfo().RPM.right -- ENG2 RPM % local lEngineTempLeft = LoGetEngineInfo().Temperature.left -- ENG1 EGT ºC - local lEngineTempRight = LoGetEngineInfo().Temperature.right -- ENG2 EGT ºC + local lEngineTempRight = LoGetEngineInfo().Temperature.right -- ENG2 EGT ºC + + local lIAS = LoGetIndicatedAirSpeed() -- INDICATED AIRSPEED (Meter/Second) + local lMachNumber = LoGetMachNumber() -- MACH + local lAoA = LoGetAngleOfAttack() -- ANGLE OF ATTACK AoA (Radian) + local lAccelerationUnits = LoGetAccelerationUnits().y -- G-LOAD + local lEngineFuelConsumptionLeft = LoGetEngineInfo().FuelConsumption.left local lEngineFuelConsumptionRight = LoGetEngineInfo().FuelConsumption.right local lEngineHydraulicPressureLeft = LoGetEngineInfo().HydraulicPressure.left local lEngineHydraulicPressureRight = LoGetEngineInfo().HydraulicPressure.right + + --[[ + local lAltRad = LoGetAltitudeAboveGroundLevel() -- ALTITUDE GROUND LEVEL (Meter) + local lTrueAirSpeed = LoGetTrueAirSpeed() -- TRUE AIRSPEED (Meter/Second) + local lPitch, lBank, lYaw = LoGetADIPitchBankYaw() -- PITCH, BANK, YAW (Radian) + + local lHeading = myData.Heading -- HEADING (Radian) + local lVVI = LoGetVerticalVelocity() -- VERTICAL SPEED (Meter/Second) + + local lGlide = LoGetGlideDeviation() -- VOR1 HORIZONTAL DEFLECTION (-1 +1) + local lSide = LoGetSideDeviation() -- VOR1 VERTICAL DEFLECTION (-1 +1) + local lSlipBallPosition = LoGetSlipBallPosition() -- SLIP BALL (-1 +1) + + local lNavInfoPitch = LoGetNavigationInfo().Requirements.pitch -- AP REQUIRED PITCH (Radian) + local lNavInfoRoll = LoGetNavigationInfo().Requirements.roll -- AP REQUIRED BANK (Radian) + local lNavInfoSpeed = LoGetNavigationInfo().Requirements.speed -- AP SPEED (Meter/Second) + local lNavInfoAltitude = LoGetNavigationInfo().Requirements.altitude -- AP ALTITUDE (Meter) + local lNavInfoVerticalSpeed = LoGetNavigationInfo().Requirements.vertical_speed -- AP VERTICAL SPEED (Meter/Second) + + local lControlPanel_HSI = LoGetControlPanel_HSI() -- HSI Data + local lHSI_RMI = LoGetControlPanel_HSI().RMI_raw -- VOR1 OBS (Radian) + local lHSI_ADF = LoGetControlPanel_HSI().ADF_raw -- ADF OBS (Radian) + local lHSI_Heading = LoGetControlPanel_HSI().Heading_raw -- Heading (Radian) + local lEngineFuelInternal = LoGetEngineInfo().fuel_internal -- TANK1 (INT) (KG) local lEngineFuelExternal = LoGetEngineInfo().fuel_external -- TANK2 (EXT) (KG) - - --local lMechInfo = LoGetMechInfo() -- mechanical components, e.g. Flaps, Wheelbrakes,... - --local lPayloadInfo = LoGetPayloadInfo() -- Paylod, e.g. bombs, guns, rockets, fuel tanks,... - + + local lMechInfo = LoGetMechInfo() -- mechanical components, e.g. Flaps, Wheelbrakes,... + local lPayloadInfo = LoGetPayloadInfo() -- Paylod, e.g. bombs, guns, rockets, fuel tanks,... + ]] + local lDistanceToWay = 999 local lRoute = LoGetRoute() - + if (myData and lRoute) then -- if neither are nil local myLoc = LoGeoCoordinatesToLoCoordinates(lLongitude, lLatitude) --lDistanceToWay = math.sqrt((myLoc.x - lRoute.goto_point.world_point.x)^2 + (myLoc.y - lRoute.goto_point.world_point.y)^2) lDistanceToWay = math.sqrt((myLoc.x - lRoute.goto_point.world_point.x)^2 + (myLoc.z - lRoute.goto_point.world_point.z)^2) end - - if gES_GlassCockpitType == 1 then - -- HELIOS Version 1.3 - -- customizing for HELOS - --lBasicAtmospherePressure = lBasicAtmospherePressure * 0.03937 -- BAROMETRIC PRESSURE (MM TO IN) - --lTrueAirSpeed = lTrueAirSpeed * 1.94 -- TRUE AIRSPEED (M/S TO KNOTS) - lAltBar = lAltBar --* 3.28084 -- ALTITUDE SEA LEVEL (MTS TO FT) - lAltRad = lAltRad * 3.28084 -- ALTITUDE GROUND LEVEL (MTS TO FT) - lVVI = lVVI --* 196.8504 -- VERTICAL SPEED (M/S TO FPM) - lIAS = lIAS * 1.9438444924574 -- INDICATED AIRSPEED (M/S TO KNOTS) - lPitch = math.deg(lPitch) -- PITCH, (Radian to Grad) - lBank = math.deg(lBank) -- BANK (Radian to Grad) - lYaw = math.deg(lYaw) -- YAW (Radian to Grad) - lHSI_RMI = math.deg(lHSI_RMI) -- VOR1 OBS (Radian to Grad) - lHSI_ADF = math.deg(lHSI_ADF) -- ADF OBS (Radian to Grad) - lAoA = math.deg(lAoA) -- ANGLE OF ATTACK AoA (Radian to Grad) - lHeading = math.deg(lHeading) -- Heading (Radian to Grad) - lHSI_ADF = 360 - lHSI_ADF --(360 - lHSI_ADF) + (360 - lHeading) - lHSI_RMI = 360 - lHSI_RMI - local lnavInfo = LoGetNavigationInfo() - SendData("1", string.format("%.2f", lPitch) ) - SendData("2", string.format("%.2f", lBank) ) - SendData("3", string.format("%.2f", lYaw) ) - SendData("4", string.format("%.2f", lAltBar) ) - SendData("5", string.format("%.2f", lAccelerationUnits) ) - SendData("6", string.format("%.2f", lHSI_ADF) ) - SendData("7", string.format("%.2f", lHSI_RMI) ) - SendData("8", string.format("%.2f", lHeading) ) - SendData("9", string.format("%.2f", (math.floor(lEngineFuelInternal) + (lEngineRPMleft /1000))) ) - SendData("10", string.format("%.2f", (math.floor(lEngineFuelExternal) + (lEngineRPMright /1000))) ) - SendData("11", string.format("%.2f", (math.floor(lEngineFuelInternal + lEngineFuelExternal) + (lEngineTempLeft/1000))) ) - if math.floor(lRoute.goto_point.world_point.x) < 0 then - SendData("12", string.format("%.4f", (math.floor(lRoute.goto_point.world_point.x) - (lEngineRPMright/1000)) ) ) --x coord + eng temp left in eng temp rifgt import data - else - SendData("12", string.format("%.4f", (math.floor(lRoute.goto_point.world_point.x) + (lEngineTempLeft/1000)) ) ) --x coord + eng temp left in eng temp rifgt import data - end - --SendData("12", string.format("%.2f", lEngineTempRight) ) - SendData("13", string.format("%.2f", lVVI) ) - SendData("14", string.format("%.2f", (math.floor(lDistanceToWay) + (lIAS /10000))) ) --distance to way + ias in IAS import data - SendData("15", string.format("%s", lnavInfo.SystemMode.master .." / ".. lnavInfo.SystemMode.submode)) -- HUD MODE and SUBMODE in distancetoway import data - --SendData("15", string.format("%.2f", lDistanceToWay) ) - SendData("16", string.format("%.2f", lAoA) ) - SendData("17", string.format("%.2f", lGlide) ) - SendData("18", string.format("%.2f", lSide) ) - - elseif gES_GlassCockpitType == 2 then - -- HawgTouch version 1.6 + -- ADI + ExportScript.AF.FC_US_ADI() -- ID 1 to 10 - -- Barometrisic Altimeter - --local lAltCounter = {[0] = 0.0, [1] = 0.11, [2] = 0.22, [3] = 0.33, [4] = 0.44, [5] = 0.55, [6] = 0.66, [7] = 0.77, [8] = 0.88, [9] = 0.99} - local lAltCounter = {[0] = 0.0, [1] = 0.1, [2] = 0.2, [3] = 0.3, [4] = 0.4, [5] = 0.5, [6] = 0.6, [7] = 0.7, [8] = 0.8, [9] = 0.9} - --local lAltBarTmp2 = string.format("%03d", ((lAltBar * 3.28084) / 100)) -- meter to feeds - lAltBar = lAltBar - (9.5 * (760 - lBasicAtmospherePressure)) -- 9.5 m per 1mmHg difference - local lAltBarTmp = lAltBar * 3.28084 -- meter to feeds - local lAltBarTmp2 = ((lAltBar * 3.28084) / 100) -- meter to feeds + -- HSI + ExportScript.AF.FC_US_HSI(lDistanceToWay) -- ID 11 to 23 - lAltBarTmp = lAltBarTmp / 1000 - lAltBarTmp = lAltBarTmp - math.round(lAltBarTmp, 0, "floor") + -- VVI + ExportScript.AF.FC_US_VVI() -- ID 24 - local lAltCounter1 = 0 - local lAltCounter2 = 0 - local lAltCounter3 = 0 - local lAltCounter4 = 0 - local lAltBarTmp3 = string.format("%03d", lAltBarTmp2) + -- G-LOAD + ExportScript.AF.FC_US_GLOAD() -- ID 25 to 27 + + -- Clock + ExportScript.AF.FC_US_Clock() -- ID 28 to 30 + + -- Standby Compass + ExportScript.AF.FC_US_Compass() -- ID 31 to 33 + + -- Standby ADI + ExportScript.AF.FC_US_stbyADI() -- ID 34, 35 + + -- Barometrisic Altimeter + --local lAltCounter = {[0] = 0.0, [1] = 0.11, [2] = 0.22, [3] = 0.33, [4] = 0.44, [5] = 0.55, [6] = 0.66, [7] = 0.77, [8] = 0.88, [9] = 0.99} + local lAltCounter = {[0] = 0.0, [1] = 0.1, [2] = 0.2, [3] = 0.3, [4] = 0.4, [5] = 0.5, [6] = 0.6, [7] = 0.7, [8] = 0.8, [9] = 0.9} + --local lAltBarTmp2 = string.format("%03d", ((lAltBar * 3.28084) / 100)) -- meter to feeds + lAltBar = lAltBar - (9.5 * (760 - lBasicAtmospherePressure)) -- 9.5 m per 1mmHg difference + --lAltBar = lAltBar + (9.5 * (760 - lBasicAtmospherePressure)) -- 9.5 m per 1mmHg difference + local lAltBarTmp = lAltBar * 3.28084 -- meter to feeds + local lAltBarTmp2 = ((lAltBar * 3.28084) / 100) -- meter to feeds + + lAltBarTmp = lAltBarTmp / 1000 + lAltBarTmp = lAltBarTmp - ExportScript.Tools.round(lAltBarTmp, 0, "floor") + + local lAltCounter1 = 0 + local lAltCounter2 = 0 + local lAltCounter3 = 0 + local lAltCounter4 = 0 + local lAltBarTmp3 = string.format("%03d", lAltBarTmp2) + + lAltCounter4 = lAltBarTmp * 10 + if lAltCounter4 > 1.0 then + lAltCounter4 = lAltCounter4 - ExportScript.Tools.round(lAltCounter4, 0, "floor") + end + + -- AltBar {0.0,1.0} + -- AltBar_10000 {0.0,1.0} + -- AltBar_1000 {0.0,1.0} + -- AltBar_100 {0.0,1.0} + -- AltBar_10 {0.0,1.0} + ExportScript.Tools.SendData(36, lAltBarTmp) + ExportScript.Tools.SendData(37, lAltCounter[tonumber(string.sub(lAltBarTmp3, 1, 1))]) + ExportScript.Tools.SendData(38, lAltCounter[tonumber(string.sub(lAltBarTmp3, 2, 2))]) + ExportScript.Tools.SendData(39, lAltCounter[tonumber(string.sub(lAltBarTmp3, 3, 3))]) + ExportScript.Tools.SendData(40, lAltCounter4) + -- Barometrisic Altimeter end + + -- Air Speed Indicator (IAS, Mach) + --[[ + y_min = 0.0 -- minimaler Ausgabewert + y_max = 1.0 -- maximaler Ausgabewert + x_min = 0.0 -- minimaler Eingangswert + x_max = 514,44444443999953012349519517095 -- maximaler Eingangswert + x = 257.0 -- aktueller Eingangswert + + d_y = 1.0 -- Delta Ausgabewerte (y_max - y_min) + d_x = 514,44444443999953012349519517095 -- Delta Eingangswerte (x_max - x_min) + m = 0.0019438444924574 -- Steigung der linearen Funktion (d_y / d_x) + n = 0.0 -- Schnittpunkt der Funktion mit y-Achse (y_max - m * x_max) + + y = 0.4995680345615518 -- Ergebnis (m * x + n) + ]] + lIAS = 0.0019438444924574 * lIAS + + if lMachNumber < 1.01 then --[[ - if lAltBarTmp2 > 10000 then - lAltCounter1 = math.round((lAltBarTmp2 / 10000), 0, "floor") * 0.1 - lAltCounter1 = lAltCounter1 - math.round(lAltCounter1, 0, "floor") - end - if lAltBarTmp2 > 1000 then - lAltCounter2 = math.round((lAltBarTmp2 / 1000), 0, "floor") * 0.1 - lAltCounter2 = lAltCounter2 - math.round(lAltCounter1, 0, "floor") - end - if lAltBarTmp2 > 100 then - if lAltBarTmp2 > 100 then - lAltCounter3 = (math.round((lAltBarTmp2 - (math.round(lAltBarTmp2 / 100, 0, "floor") * 100)), 0, "floor") / 10) * 0.1 - else - lAltCounter3 = (lAltBarTmp2 / 100) * 0.1 - lAltCounter3 = lAltCounter3 - math.round(lAltCounter3, 0, "floor") - end - end - if lAltBarTmp2 > 10 then - lAltCounter4 = (lAltBarTmp2 - (math.round(lAltBarTmp2 / 10, 0, "floor") * 10)) * 0.1 - else - lAltCounter4 = lAltBarTmp2 --* 0.1 - end]] - lAltCounter4 = lAltBarTmp * 10 - if lAltCounter4 > 1.0 then - lAltCounter4 = lAltCounter4 - math.round(lAltCounter4, 0, "floor") - end + y_min = 0.0 0.1 -- minimaler Ausgabewert + y_max = 0.1 1.0 -- maximaler Ausgabewert + x_min = 0.0 1.0 -- minimaler Eingangswert + x_max = 1.0 3.6 -- maximaler Eingangswert + x = 0.5 2.0 -- aktueller Eingangswert - -- AltBar {0.0,1.0} - -- AltBar_10000 {0.0,1.0} - -- AltBar_1000 {0.0,1.0} - -- AltBar_100 {0.0,1.0} - -- AltBar_10 {0.0,1.0} - SendData(1, string.format("%.4f;%.2f;%.2f;%.2f;%.2f", - lAltBarTmp, - --lAltCounter1, - --lAltCounter2, - --lAltCounter3, - --lAltCounter4, - lAltCounter[tonumber(string.sub(lAltBarTmp3, 1, 1))], - lAltCounter[tonumber(string.sub(lAltBarTmp3, 2, 2))], - lAltCounter[tonumber(string.sub(lAltBarTmp3, 3, 3))], - --lAltCounter[tonumber(string.sub(lAltBarTmp3, 4, 4))], - lAltCounter4)) - -- Barometrisic Altimeter end - - -- Air Speed Indicator (IAS, Mach) + d_y = 0.1 0.9 -- Delta Ausgabewerte (y_max - y_min) + d_x = 1.0 2.6 -- Delta Eingangswerte (x_max - x_min) + m = 0.1 0.34615384615384615384615384615385 -- Steigung der linearen Funktion (d_y / d_x) + n = 0.0 -0.24615384615384615384615384615385 -- Schnittpunkt der Funktion mit y-Achse (y_max - m * x_max) + + y = 0.05 0.44615384615384615384615384615384 -- Ergebnis (m * x + n) + ]] + + lMachNumber = 0.1 * lMachNumber + else + lMachNumber = 0.34615384615384615384615384615385 * lMachNumber + -0.24615384615384615384615384615385 + end + -- IAS {0.0,1.0} + -- MachNumber + --SendData(2, string.format("%.4f;%.4f", lIAS, lMachNumber)) + ExportScript.Tools.SendData(44, string.format("%.4f", lIAS)) + ExportScript.Tools.SendData(45, string.format("%.4f", lMachNumber)) + -- Air Speed Indicator End + + -- RPM Engine Left + ExportScript.AF.FC_OneNeedleGauge(lEngineRPMleft, 110, 46) + + -- RPM Engine Right + ExportScript.AF.FC_OneNeedleGauge(lEngineRPMright, 110, 47) + + -- Oil Pressure Left, no value but similar to Engine RPM + --[[ + y_min = 0.0 0.76 -- minimaler Ausgabewert + y_max = 0.76 1.0 -- maximaler Ausgabewert + x_min = 0.0 74.0 -- minimaler Eingangswert + x_max = 74.0 95.0 -- maximaler Eingangswert + x = 74.0 90.0 -- aktueller Eingangswert + + d_y = 0.76 0.24 -- Delta Ausgabewerte (y_max - y_min) + d_x = 74.0 21.0 -- Delta Eingangswerte (x_max - x_min) + m = 0.01027027027027027027027027027027 0.01142857142857142857142857142857 -- Steigung der linearen Funktion (d_y / d_x) + n = 0.0 -0.08571428571428571428571428571415 -- Schnittpunkt der Funktion mit y-Achse (y_max - m * x_max) + + y = 0.7599999 0.943-- Ergebnis (m * x + n) + ]] + if lEngineRPMleft < 74 then + ExportScript.AF.FC_OneNeedleGauge(1.027027027027027027027027027027 * lEngineRPMleft, 100, 48) + else + ExportScript.AF.FC_OneNeedleGauge(1.142857142857142857142857142857 * lEngineRPMleft + -8.571428571428571428571428571415, 100, 48) + end + + -- Oil Pressure Right, no value but similar to Engine RPM + if lEngineRPMright < 74 then + ExportScript.AF.FC_OneNeedleGauge(1.027027027027027027027027027027 * lEngineRPMright, 100, 49) + else + ExportScript.AF.FC_OneNeedleGauge(1.142857142857142857142857142857 * lEngineRPMright + -8.571428571428571428571428571415, 100, 49) + end + + -- Engine Exhaust Nozzle Position Indicator Left, very imprecise + --[[ + y_min = 0.0 -- minimaler Ausgabewert + y_max = 0.76 -- maximaler Ausgabewert + x_min = 95.0 -- minimaler Eingangswert + x_max = 96.0 -- maximaler Eingangswert + x = 95.5 -- aktueller Eingangswert + + d_y = 0.76 -- Delta Ausgabewerte (y_max - y_min) + d_x = 1.0 -- Delta Eingangswerte (x_max - x_min) + m = 0.76 -- Steigung der linearen Funktion (d_y / d_x) + n = -72.2 -- Schnittpunkt der Funktion mit y-Achse (y_max - m * x_max) + + y = 0.5 -- Ergebnis (m * x + n) + ]] + if lEngineRPMleft > 95.0 then + ExportScript.AF.FC_OneNeedleGauge((0.76 * lEngineRPMleft + -72.2) * 100, 100, 50) + else + ExportScript.AF.FC_OneNeedleGauge(0, 100, 50) + end + + -- Engine Exhaust Nozzle Position Indicator Right, very imprecise + if lEngineRPMright > 95.0 then + ExportScript.AF.FC_OneNeedleGauge((0.76 * lEngineRPMright + -72.2) * 100, 100, 51) + else + ExportScript.AF.FC_OneNeedleGauge(0, 100, 51) + end + + -- Exaust Gas Temperature Left + ExportScript.AF.FC_F15C_ExaustGasTemp(lEngineTempLeft - 1.4, 52, 53, 54, 55) + + -- Exaust Gas Temperature Right + ExportScript.AF.FC_F15C_ExaustGasTemp(lEngineTempLeft - 1.4, 56, 57, 58, 59) + + -- Fuel Flow Left + --ExportScript.AF.FC_OneNeedleGauge3Digits(((lEngineFuelConsumptionLeft * 2.2046223302272) * 3600), 10000, 2, 60, 61, 62, 63) + + -- Fuel Flow Right + --ExportScript.AF.FC_OneNeedleGauge3Digits(((lEngineFuelConsumptionRight * 2.2046223302272) * 3600), 10000, 2, 64, 65, 66, 67) + + -- Hydraulic Pressure Left + ExportScript.AF.FC_OneNeedleGauge(lEngineHydraulicPressureLeft, 100, 68) + + -- Hydraulic Pressure Right + ExportScript.AF.FC_OneNeedleGauge(lEngineHydraulicPressureRight, 100, 69) + + -- AOA + --FC_US_AOA(16) + --ExportScript.Tools.WriteToLog('lAoA 1: '..ExportScript.Tools.dump(lAoA)) + --local lAoATmp = math.deg(lAoA) + 10 + --ExportScript.Tools.WriteToLog('lAoA 2: '..ExportScript.Tools.dump(lAoATmp)) + --[[ + y_min = 0.0 -- minimaler Ausgabewert + y_max = 1.0 -- maximaler Ausgabewert + x_min = 0.0 -- minimaler Eingangswert + x_max = 45.0 -- maximaler Eingangswert + x = 12.6 -- aktueller Eingangswert + + d_y = 1.0 -- Delta Ausgabewerte (y_max - y_min) + d_x = 45.0 -- Delta Eingangswerte (x_max - x_min) + m = 0.02222222222222222222222222222222 -- Steigung der linearen Funktion (d_y / d_x) + n = 0.0000000000000000000000000000001 -- Schnittpunkt der Funktion mit y-Achse (y_max - m * x_max) + + y = 0.2800000000000000000000000000001 -- Ergebnis (m * x + n) + ]] + --lAoATmp = 0.02222222222222222222222222222222 * lAoATmp + 0.0000000000000000000000000000001 + --SendData(16, string.format("%.4f;%d", lAoATmp, 0) ) + + if lAoA > 0.0 then -- positive AOA --[[ - y_min = 0.0 -- minimaler Ausgabewert + y_min = 0.33 -- minimaler Ausgabewert y_max = 1.0 -- maximaler Ausgabewert x_min = 0.0 -- minimaler Eingangswert - x_max = 514,44444443999953012349519517095 -- maximaler Eingangswert - x = 257.0 -- aktueller Eingangswert - - d_y = 1.0 -- Delta Ausgabewerte (y_max - y_min) - d_x = 514,44444443999953012349519517095 -- Delta Eingangswerte (x_max - x_min) - m = 0.0019438444924574 -- Steigung der linearen Funktion (d_y / d_x) - n = 0.0 -- Schnittpunkt der Funktion mit y-Achse (y_max - m * x_max) - - y = 0.4995680345615518 -- Ergebnis (m * x + n) - ]] - lIAS = 0.0019438444924574 * lIAS - - if lMachNumber < 1.01 then - --[[ - y_min = 0.0 0.1 -- minimaler Ausgabewert - y_max = 0.1 1.0 -- maximaler Ausgabewert - x_min = 0.0 1.0 -- minimaler Eingangswert - x_max = 1.0 3.6 -- maximaler Eingangswert - x = 0.5 2.0 -- aktueller Eingangswert - - d_y = 0.1 0.9 -- Delta Ausgabewerte (y_max - y_min) - d_x = 1.0 2.6 -- Delta Eingangswerte (x_max - x_min) - m = 0.1 0.34615384615384615384615384615385 -- Steigung der linearen Funktion (d_y / d_x) - n = 0.0 -0.24615384615384615384615384615385 -- Schnittpunkt der Funktion mit y-Achse (y_max - m * x_max) - - y = 0.05 0.44615384615384615384615384615384 -- Ergebnis (m * x + n) - ]] - - lMachNumber = 0.1 * lMachNumber - else - lMachNumber = 0.34615384615384615384615384615385 * lMachNumber + -0.24615384615384615384615384615385 - end - -- IAS {0.0,1.0} - -- MachNumber - SendData(2, string.format("%.4f;%.4f", lIAS, lMachNumber)) - -- Air Speed Indicator End - - -- RPM Engine Left - FC_OneNeedleGauge3Digits(lEngineRPMleft, 110, 0, 3) - - -- RPM Engine Right - FC_OneNeedleGauge3Digits(lEngineRPMright, 110, 0, 4) - - -- Oil Pressure Left, no value but similar to Engine RPM - --[[ - y_min = 0.0 0.76 -- minimaler Ausgabewert - y_max = 0.76 1.0 -- maximaler Ausgabewert - x_min = 0.0 74.0 -- minimaler Eingangswert - x_max = 74.0 95.0 -- maximaler Eingangswert - x = 74.0 90.0 -- aktueller Eingangswert - - d_y = 0.76 0.24 -- Delta Ausgabewerte (y_max - y_min) - d_x = 74.0 21.0 -- Delta Eingangswerte (x_max - x_min) - m = 0.01027027027027027027027027027027 0.01142857142857142857142857142857 -- Steigung der linearen Funktion (d_y / d_x) - n = 0.0 -0.08571428571428571428571428571415 -- Schnittpunkt der Funktion mit y-Achse (y_max - m * x_max) - - y = 0.7599999 0.943-- Ergebnis (m * x + n) - ]] - if lEngineRPMleft < 74 then - FC_OneNeedleGauge(1.027027027027027027027027027027 * lEngineRPMleft, 100, 11) - else - FC_OneNeedleGauge(1.142857142857142857142857142857 * lEngineRPMleft + -8.571428571428571428571428571415, 100, 11) - end - - -- Oil Pressure Right, no value but similar to Engine RPM - if lEngineRPMright < 74 then - FC_OneNeedleGauge(1.027027027027027027027027027027 * lEngineRPMright, 100, 12) - else - FC_OneNeedleGauge(1.142857142857142857142857142857 * lEngineRPMright + -8.571428571428571428571428571415, 100, 12) - end - - -- Engine Exhaust Nozzle Position Indicator Left, very imprecise - --[[ - y_min = 0.0 -- minimaler Ausgabewert - y_max = 0.76 -- maximaler Ausgabewert - x_min = 95.0 -- minimaler Eingangswert - x_max = 96.0 -- maximaler Eingangswert - x = 95.5 -- aktueller Eingangswert - - d_y = 0.76 -- Delta Ausgabewerte (y_max - y_min) - d_x = 1.0 -- Delta Eingangswerte (x_max - x_min) - m = 0.76 -- Steigung der linearen Funktion (d_y / d_x) - n = -72.2 -- Schnittpunkt der Funktion mit y-Achse (y_max - m * x_max) - - y = 0.5 -- Ergebnis (m * x + n) - ]] - if lEngineRPMleft > 95.0 then - FC_OneNeedleGauge((0.76 * lEngineRPMleft + -72.2) * 100, 100, 5) - else - FC_OneNeedleGauge(0, 100, 5) - end - - -- Engine Exhaust Nozzle Position Indicator Right, very imprecise - if lEngineRPMright > 95.0 then - FC_OneNeedleGauge((0.76 * lEngineRPMright + -72.2) * 100, 100, 6) - else - FC_OneNeedleGauge(0, 100, 6) - end - - -- Exaust Gas Temperature Left - FC_F15C_ExaustGasTemp(lEngineTempLeft - 1.4, 7) - - -- Exaust Gas Temperature Right - FC_F15C_ExaustGasTemp(lEngineTempLeft - 1.4, 8) - - -- Fuel Flow Left - FC_OneNeedleGauge3Digits((lEngineFuelConsumptionLeft * 2.2046223302272) * 3600, 10000, 2, 9) - - -- Fuel Flow Right - FC_OneNeedleGauge3Digits((lEngineFuelConsumptionRight * 2.2046223302272) * 3600, 10000, 2, 10) - - -- Hydraulic Pressure Left - FC_OneNeedleGauge(lEngineHydraulicPressureLeft, 100, 13) - - -- Hydraulic Pressure Right - FC_OneNeedleGauge(lEngineHydraulicPressureRight, 100, 14) - - -- VVI - FC_US_VVI(15) - - -- AOA - --FC_US_AOA(16) - --WriteToLog('lAoA 1: '..dump(lAoA)) - --local lAoATmp = math.deg(lAoA) + 10 - --WriteToLog('lAoA 2: '..dump(lAoATmp)) - --[[ - y_min = 0.0 -- minimaler Ausgabewert - y_max = 1.0 -- maximaler Ausgabewert - x_min = 0.0 -- minimaler Eingangswert - x_max = 45.0 -- maximaler Eingangswert + x_max = 30.0 -- maximaler Eingangswert x = 12.6 -- aktueller Eingangswert - d_y = 1.0 -- Delta Ausgabewerte (y_max - y_min) - d_x = 45.0 -- Delta Eingangswerte (x_max - x_min) - m = 0.02222222222222222222222222222222 -- Steigung der linearen Funktion (d_y / d_x) - n = 0.0000000000000000000000000000001 -- Schnittpunkt der Funktion mit y-Achse (y_max - m * x_max) - - y = 0.2800000000000000000000000000001 -- Ergebnis (m * x + n) + d_y = 0.67 -- Delta Ausgabewerte (y_max - y_min) + d_x = 30.0 -- Delta Eingangswerte (x_max - x_min) + m = 0.02233333333333333333333333333333 -- Steigung der linearen Funktion (d_y / d_x) + n = 0.33 -- Schnittpunkt der Funktion mit y-Achse (y_max - m * x_max) + + y = 0.6114 -- Ergebnis (m * x + n) ]] - --lAoATmp = 0.02222222222222222222222222222222 * lAoATmp + 0.0000000000000000000000000000001 - --SendData(16, string.format("%.4f;%d", lAoATmp, 0) ) - - WriteToLog('lAoA: '..dump(lAoA)) - if lAoA > 0.0 then -- positive AOA - --[[ - y_min = 0.22 -- minimaler Ausgabewert - y_max = 1.0 -- maximaler Ausgabewert - x_min = 0.0 -- minimaler Eingangswert - x_max = 35.0 -- maximaler Eingangswert - x = 12.6 -- aktueller Eingangswert - - d_y = 0.78 -- Delta Ausgabewerte (y_max - y_min) - d_x = 35.0 -- Delta Eingangswerte (x_max - x_min) - m = 0.02228571428571428571428571428571 -- Steigung der linearen Funktion (d_y / d_x) - n = 0.22 -- Schnittpunkt der Funktion mit y-Achse (y_max - m * x_max) - - y = 0.50079999999999999999999999999995 -- Ergebnis (m * x + n) - ]] - lAoA = 0.02228571428571428571428571428571 * lAoA + 0.22 - SendData(16, string.format("%.4f;%d", lAoA, 0) ) - else - --[[ - y_min = 0.0 -- minimaler Ausgabewert - y_max = 0.22 -- maximaler Ausgabewert - x_min = 0.0 -- minimaler Eingangswert - x_max = -10.0 -- maximaler Eingangswert - x = -2.6 -- aktueller Eingangswert - - d_y = 0.22 -- Delta Ausgabewerte (y_max - y_min) - d_x = -10.0 -- Delta Eingangswerte (x_max - x_min) - m = -0.022 -- Steigung der linearen Funktion (d_y / d_x) - n = 0.0 -- Schnittpunkt der Funktion mit y-Achse (y_max - m * x_max) - - y = 0.1628 -- Ergebnis 0.22 - (m * x + n) - ]] - lAoA = 0.22 - (-0.022 * lAoA) - SendData(16, string.format("%.4f;%d", lAoA, 0) ) - end - - -- G-LOAD - FC_US_GLOAD(17) - - -- Clock - FC_US_Clock(18) - - -- Standby Compass - FC_US_Compass(19) - - -- ADI - FC_US_ADI(20) - - -- Standby ADI - FC_US_stbyADI(21) - - -- HSI - FC_US_HSI(lDistanceToWay, 22) - - -- Hydraulic Pressure Util, no value but similar to Engine Hydraulic Pressure (left or right) - local lEngineHydraulicPressure = lEngineHydraulicPressureLeft - lEngineHydraulicPressure = lEngineHydraulicPressureRight > lEngineHydraulicPressureLeft and lEngineHydraulicPressureRight or lEngineHydraulicPressureLeft - FC_OneNeedleGauge(lEngineHydraulicPressure, 100, 23) - - -- Standby Barometrisic Altimeter - --lAltBarTmp = lAltBar - (9.5 * (760 - lBasicAtmospherePressure)) -- 9.5 m per 1mmHg difference, has been calculated - lAltBarTmp = lAltBar * 3.28084 -- meter to feeds - - local AltBar_kilofeet_needle = 0 - local AltBar_hektofeet_needle = 0 - local AltBar_dafeet_needle = 0 - - if lAltBarTmp > 1000 then - AltBar_kilofeet_needle = lAltBarTmp / 10000 - end - if lAltBarTmp > 10000 then - AltBar_hektofeet_needle = (lAltBarTmp - (math.round(lAltBarTmp / 10000, 0, "floor") * 10000)) / 1000 - else - AltBar_hektofeet_needle = lAltBarTmp / 1000 - end - if lAltBarTmp > 1000 then - AltBar_dafeet_needle = (lAltBarTmp - (math.round(lAltBarTmp / 1000, 0, "floor") * 1000)) / 100 - else - AltBar_dafeet_needle = lAltBarTmp / 100 - end - - --[[ - y_min = 0.0 -- minimaler Ausgabewert - y_max = 1.0 -- maximaler Ausgabewert - x_min = 0.0 -- minimaler Eingangswert - x_max = 10.0 -- maximaler Eingangswert - x = 2.5 -- aktueller Eingangswert - - d_y = 1.0 -- Delta Ausgabewerte (y_max - y_min) - d_x = 10.0 -- Delta Eingangswerte (x_max - x_min) - m = 0.1 -- Steigung der linearen Funktion (d_y / d_x) - n = 0.0 -- Schnittpunkt der Funktion mit y-Achse (y_max - m * x_max) - - y = 0.25 -- Ergebnis (m * x + n) - ]] - AltBar_kilofeet_needle = 0.1 * AltBar_kilofeet_needle - AltBar_hektofeet_needle = 0.1 * AltBar_hektofeet_needle - AltBar_dafeet_needle = 0.1 * AltBar_dafeet_needle - -- AltBar_kilofeet_needle {0.0,1.0} - -- AltBar_hektofeet_needle {0.0,1.0} - -- AltBar_dafeet_needle {0.0,1.0} - SendData(24, string.format("%.4f;%.4f;%0.4f", - AltBar_kilofeet_needle, - AltBar_hektofeet_needle, - AltBar_dafeet_needle)) - -- Standby Barometrisic Altimeter end - - -- Standby Air Speed Indicator (IAS, Mach) - -- value has been calculated (from top) - -- IAS {0.0,1.0} - SendData(25, string.format("%.4f", lIAS)) - -- Standby Air Speed Indicator End - end - else - WriteToLog("Unknown FC Error, no LoGetSelfData.") - end - -end - -function ProcessHARDWAREConfigHighImportance(mainPanelDevice) - --[[ - local lPayloadInfo = LoGetPayloadInfo() - WriteToLog('lPayloadInfo: '..dump(lPayloadInfo)) - - local lSnares = LoGetSnares() -- Flare and Chaff - WriteToLog('lSnares: '..dump(lSnares)) - - local lSightingSystemInfo = LoGetSightingSystemInfo() - WriteToLog('lSightingSystemInfo: '..dump(lSightingSystemInfo)) - - local lTWSInfo = LoGetTWSInfo() -- SPO Informationen, z.B. Radarwarner F15C - WriteToLog('lTWSInfo: '..dump(lTWSInfo)) - - local lTargetInformation = LoGetTargetInformation() -- detalierte Radar Infos z.B. F15C - WriteToLog('lTargetInformation: '..dump(lTargetInformation)) - - local lLockedTargetInformation = LoGetLockedTargetInformation() - WriteToLog('lLockedTargetInformation: '..dump(lLockedTargetInformation)) - - local lF15_TWS_Contacs = LoGetF15_TWS_Contacts() -- the same information but only for F-15 in TWS mode - WriteToLog('lF15_TWS_Contacs: '..dump(lF15_TWS_Contacs)) - - local lMechInfo = LoGetMechInfo() -- mechanical components, e.g. Flaps, Wheelbrakes,... - WriteToLog('lMechInfo: '..dump(lMechInfo)) - - local lMCPState = LoGetMCPState() -- Warnlichter - WriteToLog('lMCPState: '..dump(lMCPState)) - - local lControlPanel_HSI = LoGetControlPanel_HSI() - WriteToLog('lControlPanel_HSI: '..dump(lControlPanel_HSI)) - - local lRadioBeaconsStatus = LoGetRadioBeaconsStatus() - WriteToLog('lRadioBeaconsStatus: '..dump(lRadioBeaconsStatus)) - - local lEngineInfo = LoGetEngineInfo() - WriteToLog('lEngineInfo: '..dump(lEngineInfo)) - ]] -end - -function ProcessGlassCockpitFCLowImportanceConfig() - local lEngineFuelInternal = LoGetEngineInfo().fuel_internal -- TANK1 (INT) (KG) - local lEngineFuelExternal = LoGetEngineInfo().fuel_external -- TANK2 (EXT) (KG) - local lEngineRPMleft = LoGetEngineInfo().RPM.left -- ENG1 RPM % - local lEngineRPMright = LoGetEngineInfo().RPM.right -- ENG2 RPM % - - local lMechInfo = LoGetMechInfo() -- mechanical components, e.g. Flaps, Wheelbrakes,... - local lPayloadInfo = LoGetPayloadInfo() -- Paylod, e.g. bombs, guns, rockets, fuel tanks,... - - if gES_GlassCockpitType == 1 then - -- HELIOS Version 1.3 - - elseif gES_GlassCockpitType == 2 then - -- HawgTouch version 1.6 - - -- Gear Lamps - local lGearValue = lMechInfo.gear.value - local lGear1, lGear2, lGear3 = 0, 0, 0 - - if lGearValue > 0.85 then - lGear1 = 1 - end - if lGearValue > 0.9 then - lGear2 = 1 - end - if lGearValue == 1.0 then - lGear3 = 1 - end - SendData(26, string.format("%d;%d;%d", - lGear1, -- GEAR_N_SAFE - lGear2, -- GEAR_L_SAFE - lGear3)) -- GEAR_R_SAFE - -- Gear Lamps end - - -- Fuel Indicator - local lEngineFuelTotal = (lEngineFuelInternal + lEngineFuelExternal) * 2.2046223302272 -- kg to lbs - local lFuelNeedle = lEngineFuelTotal / 12000 -- 12000 = scala - lFuelNeedle = (lFuelNeedle > 1.0 and 1.0 or lFuelNeedle) - --lEngineFuelTotal = math.round(lEngineFuelTotal, 0, "floor") - --[[ - local lFuelCounter1 = 0 - local lFuelCounter2 = 0 - local lFuelCounter3 = 0 - if lEngineFuelInternal > 100 then - lFuelCounter1 = math.round((lEngineFuelInternal / 100), 0, "floor") * 0.11 - lFuelCounter1 = lFuelCounter1 - math.round(lFuelCounter1, 0, "floor") - end - if lEngineFuelInternal > 10 then - if lEngineFuelInternal > 100 then - lFuelCounter2 = (math.round((lEngineFuelInternal - (math.round(lEngineFuelInternal / 100, 0, "floor") * 100)), 0, "floor") / 10) * 0.11 - else - lFuelCounter2 = (lEngineFuelInternal / 10) * 0.11 - lFuelCounter2 = lFuelCounter2 - math.round(lFuelCounter2, 0, "floor") - end - end - if lEngineFuelInternal > 10 then - lFuelCounter3 = (lEngineFuelInternal - (math.round(lEngineFuelInternal / 10, 0, "floor") * 10)) * 0.11 + lAoA = 0.02228571428571428571428571428571 * lAoA + 0.33 else - lFuelCounter3 = lEngineFuelInternal * 0.11 + --[[ + y_min = 0.0 -- minimaler Ausgabewert + y_max = 0.33 -- maximaler Ausgabewert + x_min = 0.0 -- minimaler Eingangswert + x_max = -10.0 -- maximaler Eingangswert + x = -2.6 -- aktueller Eingangswert + + d_y = 0.33 -- Delta Ausgabewerte (y_max - y_min) + d_x = -10.0 -- Delta Eingangswerte (x_max - x_min) + m = -0.033 -- Steigung der linearen Funktion (d_y / d_x) + n = 0.0 -- Schnittpunkt der Funktion mit y-Achse (y_max - m * x_max) + + y = 0.2442 -- Ergebnis 0.33 - (m * x + n) + ]] + --lAoA = 0.22 - (-0.022 * lAoA) + lAoA = 0.33 - (-0.033 * lAoA) end + ExportScript.Tools.SendData(70, string.format("%.4f", lAoA)) + ExportScript.Tools.SendData(0, 0) -- AOA Off Flag off + -- AOA End + + -- Hydraulic Pressure Util, no value but similar to Engine Hydraulic Pressure (left or right) + local lEngineHydraulicPressure = lEngineHydraulicPressureLeft + lEngineHydraulicPressure = lEngineHydraulicPressureRight > lEngineHydraulicPressureLeft and lEngineHydraulicPressureRight or lEngineHydraulicPressureLeft + ExportScript.AF.FC_OneNeedleGauge(lEngineHydraulicPressure, 100, 71) + + -- Standby Air Speed Indicator (IAS, Mach) + -- value has been calculated (from top) + -- IAS {0.0,1.0} + ExportScript.Tools.SendData(72, string.format("%.4f", lIAS)) + -- Standby Air Speed Indicator End + + -- AccelerationUnits + ExportScript.Tools.WriteToLog("lAccelerationUnits: "..ExportScript.Tools.dump(lAccelerationUnits)) + if lAccelerationUnits > 0.0 then -- positive AccelerationUnits + --[[ + y_min = 0.333 -- minimaler Ausgabewert + y_max = 1.0 -- maximaler Ausgabewert + x_min = 0.0 -- minimaler Eingangswert + x_max = 10.0 -- maximaler Eingangswert + x = 2.6 -- aktueller Eingangswert + + d_y = 0.667 -- Delta Ausgabewerte (y_max - y_min) + d_x = 10.0 -- Delta Eingangswerte (x_max - x_min) + m = 0.0667 -- Steigung der linearen Funktion (d_y / d_x) + n = 0.333 -- Schnittpunkt der Funktion mit y-Achse (y_max - m * x_max) + + y = 0.50642 -- Ergebnis (m * x + n) + ]] + lAccelerationUnits = 0.0667 * lAccelerationUnits + 0.333 + else + --[[ + y_min = 0.0 -- minimaler Ausgabewert + y_max = 0.333 -- maximaler Ausgabewert + x_min = 0.0 -- minimaler Eingangswert + x_max = -5.0 -- maximaler Eingangswert + x = -2.6 -- aktueller Eingangswert + + d_y = 0.333 -- Delta Ausgabewerte (y_max - y_min) + d_x = -5.0 -- Delta Eingangswerte (x_max - x_min) + m = -0.0666 -- Steigung der linearen Funktion (d_y / d_x) + n = 0.666 -- Schnittpunkt der Funktion mit y-Achse (y_max - m * x_max) + + y = 0.17316 -- Ergebnis 0.666 - (m * x + n) + ]] + lAccelerationUnits = 0.666 - (-0.0666 * lAccelerationUnits + 0.666) + end + ExportScript.Tools.SendData(73, string.format("%.4f", lAccelerationUnits)) + -- AccelerationUnits End +--[[ + -- Standby Barometrisic Altimeter + --lAltBarTmp = lAltBar - (9.5 * (760 - lBasicAtmospherePressure)) -- 9.5 m per 1mmHg difference, has been calculated + lAltBarTmp = lAltBar * 3.28084 -- meter to feeds + + local AltBar_kilofeet_needle = 0 + local AltBar_hektofeet_needle = 0 + local AltBar_dafeet_needle = 0 + + if lAltBarTmp > 1000 then + AltBar_kilofeet_needle = lAltBarTmp / 10000 + end + if lAltBarTmp > 10000 then + AltBar_hektofeet_needle = (lAltBarTmp - (ExportScript.Tools.round(lAltBarTmp / 10000, 0, "floor") * 10000)) / 1000 + else + AltBar_hektofeet_needle = lAltBarTmp / 1000 + end + if lAltBarTmp > 1000 then + AltBar_dafeet_needle = (lAltBarTmp - (ExportScript.Tools.round(lAltBarTmp / 1000, 0, "floor") * 1000)) / 100 + else + AltBar_dafeet_needle = lAltBarTmp / 100 + end +]] + --[[ + y_min = 0.0 -- minimaler Ausgabewert + y_max = 1.0 -- maximaler Ausgabewert + x_min = 0.0 -- minimaler Eingangswert + x_max = 10.0 -- maximaler Eingangswert + x = 2.5 -- aktueller Eingangswert + + d_y = 1.0 -- Delta Ausgabewerte (y_max - y_min) + d_x = 10.0 -- Delta Eingangswerte (x_max - x_min) + m = 0.1 -- Steigung der linearen Funktion (d_y / d_x) + n = 0.0 -- Schnittpunkt der Funktion mit y-Achse (y_max - m * x_max) + + y = 0.25 -- Ergebnis (m * x + n) ]] - local lFuelCounterLeft = 1200 - local lFuelCounterRight = 1500 - - if lEngineRPMleft > 0 then - if lEngineRPMright > 0 then - if lEngineFuelTotal < 2700 then - lFuelCounterLeft = lEngineFuelTotal * 0.44444444444444444444444444444444 - end - else - if lEngineFuelTotal < 1200 then - lFuelCounterLeft = lEngineFuelTotal - end - end - end - if lEngineRPMright > 0 then - if lEngineRPMleft > 0 then - if lEngineFuelTotal < 2700 then - lFuelCounterRight = lEngineFuelTotal * 0.55555555555555555555555555555556 - end - else - if lEngineFuelTotal < 1500 then - lFuelCounterRight = lEngineFuelTotal - end - end - end - - --lFuelCounterLeft = math.round(lFuelCounterLeft, 0, "floor") - --lFuelCounterRight = math.round(lFuelCounterRight, 0, "floor") - - SendData(27, string.format("%04d;%04d;%05d;%.4f", - lFuelCounterLeft, - lFuelCounterRight, - lEngineFuelTotal, - lFuelNeedle)) - -- Fuel Indicator end - - FC_US_RWR(28) +--[[ + AltBar_kilofeet_needle = 0.1 * AltBar_kilofeet_needle + AltBar_hektofeet_needle = 0.1 * AltBar_hektofeet_needle + AltBar_dafeet_needle = 0.1 * AltBar_dafeet_needle + -- AltBar_kilofeet_needle {0.0,1.0} + -- AltBar_hektofeet_needle {0.0,1.0} + -- AltBar_dafeet_needle {0.0,1.0} + SendData(24, string.format("%.4f;%.4f;%0.4f", + AltBar_kilofeet_needle, + AltBar_hektofeet_needle, + AltBar_dafeet_needle)) + -- Standby Barometrisic Altimeter end +]] + else + ExportScript.Tools.WriteToLog("Unknown FC Error, no LoGetSelfData.") end end -function ProcessHARDWAREConfigLowImportance(mainPanelDevice) --- where necessary, specify HardwareID, example SightingSystem(2) - SightingSystem() - FuelQuantityIndicator() - StatusLamp() - MechanicalDevicesIndicator() - FlareChaff() - WeaponStatusPanel() - RWRlite() +function ExportScript.ProcessDACConfigHighImportance() + local lFunctionTyp = "DAC" -- function type for shared function + + -- your script + +end + +function ExportScript.ProcessIkarusFCLowImportanceConfig() + local lFunctionTyp = "Ikarus" -- function type for shared function + + -- Gear Lamps + ExportScript.AF.MechanicalDevicesIndicator(lFunctionTyp) + + -- Fuel Indicator + ExportScript.AF.FuelQuantityIndicator(lFunctionTyp) +end + +function ExportScript.ProcessDACConfigLowImportance() + local lFunctionTyp = "DAC" -- function type for shared function + + ExportScript.AF.MechanicalDevicesIndicator(lFunctionTyp) + ExportScript.AF.FuelQuantityIndicator(lFunctionTyp) + + ExportScript.AF.SightingSystem() + ExportScript.AF.StatusLamp() + ExportScript.AF.FlareChaff() + ExportScript.AF.WeaponStatusPanel() + ExportScript.AF.RWRlite() end ----------------------------- -- Custom functions -- ----------------------------- -function SightingSystem(hardware) - local lHardware = hardware or 1 +function ExportScript.AF.SightingSystem() local lSightingSystemInfo = LoGetSightingSystemInfo() if lSightingSystemInfo == nil then return end - --WriteToLog('lSightingSystemInfo: '..dump(lSightingSystemInfo)9 + --ExportScript.Tools.WriteToLog('lSightingSystemInfo: '..ExportScript.Tools.dump(lSightingSystemInfo)9 --[[ [PRF] = { [selection] = string: "ILV" @@ -645,21 +494,21 @@ function SightingSystem(hardware) } } ]] - SendDataHW("600", lSightingSystemInfo.ECM_on == true and 1 or 0, lHardware ) - --SendDataHW("601", lSightingSystemInfo.laser_on == true and 1 or 0, lHardware ) - --SendDataHW("602", lSightingSystemInfo.optical_system_on == true and 1 or 0, lHardware ) - SendDataHW("603", lSightingSystemInfo.LaunchAuthorized == true and 1 or 0, lHardware ) - SendDataHW("604", lSightingSystemInfo.radar_on == true and 1 or 0, lHardware ) + ExportScript.Tools.SendDataDAC("600", lSightingSystemInfo.ECM_on == true and 1 or 0 ) + --ExportScript.Tools.SendDataDAC("601", lSightingSystemInfo.laser_on == true and 1 or 0 ) + --ExportScript.Tools.SendDataDAC("602", lSightingSystemInfo.optical_system_on == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("603", lSightingSystemInfo.LaunchAuthorized == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("604", lSightingSystemInfo.radar_on == true and 1 or 0 ) end -function FuelQuantityIndicator(hardware) +function ExportScript.AF.FuelQuantityIndicator(FunctionTyp) + local lFunctionTyp = FunctionTyp or "Ikarus" -- Fuel quantity shows the fuel remaining in all tanks - local lHardware = hardware or 1 local lEngineInfo = LoGetEngineInfo() if lEngineInfo == nil then return end - --WriteToLog('lEngineInfo: '..dump(lEngineInfo)) + --ExportScript.Tools.WriteToLog('lEngineInfo: '..ExportScript.Tools.dump(lEngineInfo)) --[[ [fuel_external] = number: "0" [Temperature] = { @@ -686,27 +535,56 @@ function FuelQuantityIndicator(hardware) lPayloadInfo.Stations[8].CLSID == E8D4652F-FD48-45B7-BA5B-2AE05BB5A9CF -- ext 800l Fuel Tank ]] - SendDataHW("300", string.format("%d", math.round((((lEngineInfo.fuel_internal + lEngineInfo.fuel_external) * 2.2) / 100), 0, "ceil") * 100), lHardware ) -- total fuel in lbs - --SendDataHW("301", string.format("%d", lEngineInfo.fuel_internal * 2.2), lHardware ) -- internal fuel in lbs - --SendDataHW("302", string.format("%d", lEngineInfo.fuel_external * 2.2), lHardware ) -- external fuel in lbs - - --[[ - local lPayloadInfo = LoGetPayloadInfo() - if lPayloadInfo == nil then - return + local lEngineFuelTotal = (lEngineInfo.fuel_internal + lEngineInfo.fuel_external) * 2.2046223302272 -- kg to lbs + local lFuelNeedle = lEngineFuelTotal / 12000 -- 12000 = scala + lFuelNeedle = (lFuelNeedle > 1.0 and 1.0 or lFuelNeedle) + + local lFuelCounterLeft = 1200 + local lFuelCounterRight = 1500 + + if lEngineInfo.RPM.left > 0 then + if lEngineInfo.RPM.right > 0 then + if lEngineFuelTotal < 2700 then + lFuelCounterLeft = lEngineFuelTotal * 0.44444444444444444444444444444444 + end + else + if lEngineFuelTotal < 1200 then + lFuelCounterLeft = lEngineFuelTotal + end + end + end + if lEngineInfo.RPM.right > 0 then + if lEngineInfo.RPM.left > 0 then + if lEngineFuelTotal < 2700 then + lFuelCounterRight = lEngineFuelTotal * 0.55555555555555555555555555555556 + end + else + if lEngineFuelTotal < 1500 then + lFuelCounterRight = lEngineFuelTotal + end + end + end + + if ExportScript.Config.IkarusExport and lFunctionTyp == "Ikarus" then + ExportScript.Tools.SendData(300, string.format("%d", lFuelCounterLeft)) -- Left Fuel + ExportScript.Tools.SendData(301, string.format("%d", lFuelCounterRight)) -- Right Fuel + ExportScript.Tools.SendData(302, string.format("%d", lEngineFuelTotal)) -- Total Fuel + ExportScript.Tools.SendData(303, string.format("%.4f", lFuelNeedle)) -- Needle + end + + if ExportScript.Config.DACExport and lFunctionTyp == "DAC" then + ExportScript.Tools.SendDataDAC("300", string.format("%d", lFuelCounterLeft)) -- Left Fuel + ExportScript.Tools.SendDataDAC("301", string.format("%d", lFuelCounterRight)) -- Right Fuel + ExportScript.Tools.SendDataDAC("302", string.format("%d", lEngineFuelTotal)) -- Total Fuel end - SendDataHW("303", ((lPayloadInfo.Stations[5].count > 0 and lPayloadInfo.Stations[5].CLSID == "Fuel_Tank_FT600") and 1 or 0), lHardware ) -- weapon presend > 0 (panel 5) - SendDataHW("304", ((lPayloadInfo.Stations[6].count > 0 and lPayloadInfo.Stations[6].CLSID == "Fuel_Tank_FT600") and 1 or 0), lHardware ) -- weapon presend > 0 (panel 6) - SendDataHW("305", ((lPayloadInfo.Stations[7].count > 0 and lPayloadInfo.Stations[7].CLSID == "Fuel_Tank_FT600") and 1 or 0), lHardware ) -- weapon presend > 0 (panel 7) - SendDataHW("307", (lEngineInfo.fuel_internal < 600.0 and 1 or 0), lHardware ) -- Bingo Fuel - ]] end -function StatusLamp(hardware) - local lHardware = hardware or 1 +function ExportScript.AF.StatusLamp() local lMCPState = LoGetMCPState() -- Warning Lights - - --WriteToLog('lMCPState: '..dump(lMCPState)) + if lMCPState == nil then + return + end + --ExportScript.Tools.WriteToLog('lMCPState: '..ExportScript.Tools.dump(lMCPState)) --[[ [RightTailPlaneFailure] = boolean: "false" [EOSFailure] = boolean: "false" @@ -737,213 +615,208 @@ function StatusLamp(hardware) [AutopilotOn] = boolean: "false" [LeftTailPlaneFailure] = boolean: "false" ]] - - if lMCPState ~= nil then - SendDataHW("700", lMCPState.LeftTailPlaneFailure == true and 1 or 0, lHardware ) - SendDataHW("701", lMCPState.RightTailPlaneFailure == true and 1 or 0, lHardware ) - SendDataHW("702", lMCPState.MasterWarning == true and 1 or 0, lHardware ) - SendDataHW("703", lMCPState.LeftEngineFailure == true and 1 or 0, lHardware ) - SendDataHW("704", lMCPState.RightEngineFailure == true and 1 or 0, lHardware ) - SendDataHW("705", lMCPState.LeftAileronFailure == true and 1 or 0, lHardware ) - SendDataHW("706", lMCPState.RightAileronFailure == true and 1 or 0, lHardware ) - SendDataHW("707", lMCPState.LeftMainPumpFailure == true and 1 or 0, lHardware ) - SendDataHW("708", lMCPState.RightMainPumpFailure == true and 1 or 0, lHardware ) - SendDataHW("709", lMCPState.LeftWingPumpFailure == true and 1 or 0, lHardware ) - SendDataHW("710", lMCPState.RightWingPumpFailure == true and 1 or 0, lHardware ) - SendDataHW("711", lMCPState.EOSFailure == true and 1 or 0, lHardware ) - SendDataHW("712", lMCPState.ECMFailure == true and 1 or 0, lHardware ) - SendDataHW("713", lMCPState.CannonFailure == true and 1 or 0, lHardware ) - SendDataHW("714", lMCPState.MLWSFailure == true and 1 or 0, lHardware ) - SendDataHW("715", lMCPState.ACSFailure == true and 1 or 0, lHardware ) - SendDataHW("716", lMCPState.RadarFailure == true and 1 or 0, lHardware ) - SendDataHW("717", lMCPState.HelmetFailure == true and 1 or 0, lHardware ) - SendDataHW("718", lMCPState.HUDFailure == true and 1 or 0, lHardware ) - SendDataHW("719", lMCPState.MFDFailure == true and 1 or 0, lHardware ) - SendDataHW("720", lMCPState.RWSFailure == true and 1 or 0, lHardware ) - SendDataHW("721", lMCPState.GearFailure == true and 1 or 0, lHardware ) - SendDataHW("722", lMCPState.HydraulicsFailure == true and 1 or 0, lHardware ) - SendDataHW("723", lMCPState.AutopilotFailure == true and 1 or 0, lHardware ) - SendDataHW("724", lMCPState.FuelTankDamage == true and 1 or 0, lHardware ) - SendDataHW("725", lMCPState.CanopyOpen == true and 1 or 0, lHardware ) - SendDataHW("726", lMCPState.StallSignalization == true and 1 or 0, lHardware ) - SendDataHW("727", lMCPState.AutopilotOn == true and 1 or 0, lHardware ) - end - + + ExportScript.Tools.SendDataDAC("700", lMCPState.LeftTailPlaneFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("701", lMCPState.RightTailPlaneFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("702", lMCPState.MasterWarning == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("703", lMCPState.LeftEngineFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("704", lMCPState.RightEngineFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("705", lMCPState.LeftAileronFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("706", lMCPState.RightAileronFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("707", lMCPState.LeftMainPumpFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("708", lMCPState.RightMainPumpFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("709", lMCPState.LeftWingPumpFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("710", lMCPState.RightWingPumpFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("711", lMCPState.EOSFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("712", lMCPState.ECMFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("713", lMCPState.CannonFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("714", lMCPState.MLWSFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("715", lMCPState.ACSFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("716", lMCPState.RadarFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("717", lMCPState.HelmetFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("718", lMCPState.HUDFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("719", lMCPState.MFDFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("720", lMCPState.RWSFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("721", lMCPState.GearFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("722", lMCPState.HydraulicsFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("723", lMCPState.AutopilotFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("724", lMCPState.FuelTankDamage == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("725", lMCPState.CanopyOpen == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("726", lMCPState.StallSignalization == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("727", lMCPState.AutopilotOn == true and 1 or 0 ) + local lEngineInfo = LoGetEngineInfo() if lEngineInfo ~= nil then - --WriteToLog('lEngineInfo: '..dump(lEngineInfo)) + --ExportScript.Tools.WriteToLog('lEngineInfo: '..ExportScript.Tools.dump(lEngineInfo)) - SendDataHW("728", lEngineInfo.EngineStart.left, lHardware ) -- lamp start left engine 1 (0|1) - SendDataHW("729", lEngineInfo.EngineStart.right, lHardware ) -- lamp start right engine 1 (0|1) - - SendDataHW("730", lEngineInfo.RPM.left < 45 and 1 or 0, lHardware ) -- lamp generator left engine 1 (0|1) - SendDataHW("731", lEngineInfo.RPM.right < 45 and 1 or 0, lHardware ) -- lamp generator right engine 1 (0|1) + ExportScript.Tools.SendDataDAC("728", lEngineInfo.EngineStart.left ) -- lamp start left engine 1 (0|1) + ExportScript.Tools.SendDataDAC("729", lEngineInfo.EngineStart.right ) -- lamp start right engine 1 (0|1) + + ExportScript.Tools.SendDataDAC("730", lEngineInfo.RPM.left < 45 and 1 or 0 ) -- lamp generator left engine 1 (0|1) + ExportScript.Tools.SendDataDAC("731", lEngineInfo.RPM.right < 45 and 1 or 0 ) -- lamp generator right engine 1 (0|1) end end -function FlareChaff(hardware) - local lHardware = hardware or 1 +function ExportScript.AF.FlareChaff() local lSnares = LoGetSnares() -- Flare and Chaff if lSnares == nil then return end - --WriteToLog('lSnares: '..dump(lSnares)) - + --ExportScript.Tools.WriteToLog('lSnares: '..ExportScript.Tools.dump(lSnares)) + --[chaff] = number: "30" --[flare] = number: "30" - if gES_maxChaff == nil then - gES_maxChaff = lSnares.chaff - gES_tmpChaff = gES_maxChaff + if ExportScript.AF.maxChaff == nil then + ExportScript.AF.maxChaff = lSnares.chaff + ExportScript.AF.tmpChaff = ExportScript.AF.maxChaff end - if gES_maxFlare == nil then - gES_maxFlare = lSnares.flare - gES_tmpFlare = gES_maxFlare + if ExportScript.AF.maxFlare == nil then + ExportScript.AF.maxFlare = lSnares.flare + ExportScript.AF.tmpFlare = ExportScript.AF.maxFlare end - if gES_timerChaff == nil then - gES_timerChaff = 0 - gES_timerChaffCounter = 3 + if ExportScript.AF.timerChaff == nil then + ExportScript.AF.timerChaff = 0 + ExportScript.AF.timerChaffCounter = 3 end - if gES_timerFlare == nil then - gES_timerFlare = 0 - gES_timerFlareCounter = 3 + if ExportScript.AF.timerFlare == nil then + ExportScript.AF.timerFlare = 0 + ExportScript.AF.timerFlareCounter = 3 end local lblinkChaff = 0 local lblinkFlare = 0 local ltmp = 0 - if gES_tmpChaff == 0 then + if ExportScript.AF.tmpChaff == 0 then lblinkChaff = 1 end - if lSnares.chaff < gES_tmpChaff then - WriteToLog('Chaff: '..dump(lSnares.chaff)..', gES_tmpChaff:'..dump(gES_tmpChaff)) - gES_tmpChaff = lSnares.chaff - --gES_timerChaff = os.time() - gES_timerChaff = os.clock() - WriteToLog('Chaff ausgeworfen, Zeit: '..dump(gES_timerChaff)) - gES_timerChaffCounter = 3 + if lSnares.chaff < ExportScript.AF.tmpChaff then + ExportScript.Tools.WriteToLog('Chaff: '..ExportScript.Tools.dump(lSnares.chaff)..', ExportScript.AF.tmpChaff:'..ExportScript.Tools.dump(ExportScript.AF.tmpChaff)) + ExportScript.AF.tmpChaff = lSnares.chaff + --ExportScript.AF.timerChaff = os.time() + ExportScript.AF.timerChaff = os.clock() + ExportScript.Tools.WriteToLog('Chaff ausgeworfen, Zeit: '..ExportScript.Tools.dump(ExportScript.AF.timerChaff)) + ExportScript.AF.timerChaffCounter = 3 end - if lblinkChaff == 0 and gES_timerChaff > 0.0 and gES_timerChaffCounter > 0 then - --local ldiffTimer = os.difftime (os.time(), gES_timerChaff) - local ldiffTimer = os.clock() - gES_timerChaff + if lblinkChaff == 0 and ExportScript.AF.timerChaff > 0.0 and ExportScript.AF.timerChaffCounter > 0 then + --local ldiffTimer = os.difftime (os.time(), ExportScript.AF.timerChaff) + local ldiffTimer = os.clock() - ExportScript.AF.timerChaff ltmp, ldiffTimer = math.modf(ldiffTimer) - WriteToLog('Zeit: '..gES_timerChaff..', Counter: '..gES_timerChaffCounter) - WriteToLog('Zeit Diff: '..ldiffTimer) - if gES_timerChaffCounter == 1 and ldiffTimer > 0.9 then - WriteToLog('0') + --ExportScript.Tools.WriteToLog('Zeit: '..ExportScript.AF.timerChaff..', Counter: '..ExportScript.AF.timerChaffCounter) + --ExportScript.Tools.WriteToLog('Zeit Diff: '..ldiffTimer) + if ExportScript.AF.timerChaffCounter == 1 and ldiffTimer > 0.9 then + --ExportScript.Tools.WriteToLog('0') lblinkChaff = 0 - gES_timerChaffCounter = 3 - gES_timerChaff = 0.0 - elseif gES_timerChaffCounter == 1 and ldiffTimer > 0.8 then - WriteToLog('1') + ExportScript.AF.timerChaffCounter = 3 + ExportScript.AF.timerChaff = 0.0 + elseif ExportScript.AF.timerChaffCounter == 1 and ldiffTimer > 0.8 then + --ExportScript.Tools.WriteToLog('1') lblinkChaff = 1 - --gES_timerChaffCounter = gES_timerChaffCounter - 1 - elseif gES_timerChaffCounter == 2 and ldiffTimer > 0.6 then - WriteToLog('2') + --ExportScript.AF.timerChaffCounter = ExportScript.AF.timerChaffCounter - 1 + elseif ExportScript.AF.timerChaffCounter == 2 and ldiffTimer > 0.6 then + --ExportScript.Tools.WriteToLog('2') lblinkChaff = 0 - gES_timerChaffCounter = gES_timerChaffCounter - 1 - elseif gES_timerChaffCounter == 2 and ldiffTimer > 0.4 then - WriteToLog('3') + ExportScript.AF.timerChaffCounter = ExportScript.AF.timerChaffCounter - 1 + elseif ExportScript.AF.timerChaffCounter == 2 and ldiffTimer > 0.4 then + --ExportScript.Tools.WriteToLog('3') lblinkChaff = 1 - --gES_timerChaffCounter = gES_timerChaffCounter - 1 - elseif gES_timerChaffCounter == 3 and ldiffTimer > 0.2 then - WriteToLog('4') + --ExportScript.AF.timerChaffCounter = ExportScript.AF.timerChaffCounter - 1 + elseif ExportScript.AF.timerChaffCounter == 3 and ldiffTimer > 0.2 then + --ExportScript.Tools.WriteToLog('4') lblinkChaff = 0 - gES_timerChaffCounter = gES_timerChaffCounter - 1 - elseif gES_timerChaffCounter == 3 and ldiffTimer > 0.0 then - WriteToLog('5') + ExportScript.AF.timerChaffCounter = ExportScript.AF.timerChaffCounter - 1 + elseif ExportScript.AF.timerChaffCounter == 3 and ldiffTimer > 0.0 then + --ExportScript.Tools.WriteToLog('5') lblinkChaff = 1 - --gES_timerChaffCounter = gES_timerChaffCounter - 1 + --ExportScript.AF.timerChaffCounter = ExportScript.AF.timerChaffCounter - 1 elseif ldiffTimer > 0.95 then - WriteToLog('else') + --ExportScript.Tools.WriteToLog('else') lblinkChaff = 0 - gES_timerChaffCounter = 3 - gES_timerChaff = 0.0 + ExportScript.AF.timerChaffCounter = 3 + ExportScript.AF.timerChaff = 0.0 end - + --[[ - if gES_timerChaffCounter == 3 and ldiffTimer < 0.5 then - WriteToLog('0') + if ExportScript.AF.timerChaffCounter == 3 and ldiffTimer < 0.5 then + ExportScript.Tools.WriteToLog('0') lblinkChaff = 1 - --gES_timerChaffCounter = gES_timerChaffCounter - 1 - elseif gES_timerChaffCounter == 3 and ldiffTimer < 1.0 then - WriteToLog('1') + --ExportScript.AF.timerChaffCounter = ExportScript.AF.timerChaffCounter - 1 + elseif ExportScript.AF.timerChaffCounter == 3 and ldiffTimer < 1.0 then + ExportScript.Tools.WriteToLog('1') lblinkChaff = 0 - gES_timerChaffCounter = gES_timerChaffCounter - 1 - elseif gES_timerChaffCounter == 2 and ldiffTimer < 1.5 then - WriteToLog('2') + ExportScript.AF.timerChaffCounter = ExportScript.AF.timerChaffCounter - 1 + elseif ExportScript.AF.timerChaffCounter == 2 and ldiffTimer < 1.5 then + ExportScript.Tools.WriteToLog('2') lblinkChaff = 1 - --gES_timerChaffCounter = gES_timerChaffCounter - 1 - elseif gES_timerChaffCounter == 2 and ldiffTimer < 2.0 then - WriteToLog('3') + --ExportScript.AF.timerChaffCounter = ExportScript.AF.timerChaffCounter - 1 + elseif ExportScript.AF.timerChaffCounter == 2 and ldiffTimer < 2.0 then + ExportScript.Tools.WriteToLog('3') lblinkChaff = 0 - gES_timerChaffCounter = gES_timerChaffCounter - 1 - elseif gES_timerChaffCounter == 1 and ldiffTimer < 2.5 then - WriteToLog('4') + ExportScript.AF.timerChaffCounter = ExportScript.AF.timerChaffCounter - 1 + elseif ExportScript.AF.timerChaffCounter == 1 and ldiffTimer < 2.5 then + ExportScript.Tools.WriteToLog('4') lblinkChaff = 1 - --gES_timerChaffCounter = gES_timerChaffCounter - 1 - elseif gES_timerChaffCounter == 1 and ldiffTimer < 3.0 then - WriteToLog('5') + --ExportScript.AF.timerChaffCounter = ExportScript.AF.timerChaffCounter - 1 + elseif ExportScript.AF.timerChaffCounter == 1 and ldiffTimer < 3.0 then + ExportScript.Tools.WriteToLog('5') lblinkChaff = 0 - gES_timerChaffCounter = gES_timerChaffCounter - 1 - elseif gES_timerChaffCounter == 0 or ldiffTimer > 3.0 then - WriteToLog('else') + ExportScript.AF.timerChaffCounter = ExportScript.AF.timerChaffCounter - 1 + elseif ExportScript.AF.timerChaffCounter == 0 or ldiffTimer > 3.0 then + ExportScript.Tools.WriteToLog('else') lblinkChaff = 0 - gES_timerChaffCounter = 3 - gES_timerChaff = 0 + ExportScript.AF.timerChaffCounter = 3 + ExportScript.AF.timerChaff = 0 end]] --[[ - if gES_timerChaffCounter == 1 and ldiffTimer == 5 then - WriteToLog('0') + if ExportScript.AF.timerChaffCounter == 1 and ldiffTimer == 5 then + ExportScript.Tools.WriteToLog('0') lblinkChaff = 0 - gES_timerChaffCounter = gES_timerChaffCounter - 1 - elseif gES_timerChaffCounter == 1 and ldiffTimer == 4 then - WriteToLog('1') + ExportScript.AF.timerChaffCounter = ExportScript.AF.timerChaffCounter - 1 + elseif ExportScript.AF.timerChaffCounter == 1 and ldiffTimer == 4 then + ExportScript.Tools.WriteToLog('1') lblinkChaff = 1 - --gES_timerChaffCounter = gES_timerChaffCounter - 1 - elseif gES_timerChaffCounter == 2 and ldiffTimer == 3 then - WriteToLog('2') + --ExportScript.AF.timerChaffCounter = ExportScript.AF.timerChaffCounter - 1 + elseif ExportScript.AF.timerChaffCounter == 2 and ldiffTimer == 3 then + ExportScript.Tools.WriteToLog('2') lblinkChaff = 0 - gES_timerChaffCounter = gES_timerChaffCounter - 1 - elseif gES_timerChaffCounter == 2 and ldiffTimer == 2 then - WriteToLog('3') + ExportScript.AF.timerChaffCounter = ExportScript.AF.timerChaffCounter - 1 + elseif ExportScript.AF.timerChaffCounter == 2 and ldiffTimer == 2 then + ExportScript.Tools.WriteToLog('3') lblinkChaff = 1 - --gES_timerChaffCounter = gES_timerChaffCounter - 1 - elseif gES_timerChaffCounter == 3 and ldiffTimer == 1 then - WriteToLog('4') + --ExportScript.AF.timerChaffCounter = ExportScript.AF.timerChaffCounter - 1 + elseif ExportScript.AF.timerChaffCounter == 3 and ldiffTimer == 1 then + ExportScript.Tools.WriteToLog('4') lblinkChaff = 0 - gES_timerChaffCounter = gES_timerChaffCounter - 1 - elseif gES_timerChaffCounter == 3 and ldiffTimer == 0 then - WriteToLog('5') + ExportScript.AF.timerChaffCounter = ExportScript.AF.timerChaffCounter - 1 + elseif ExportScript.AF.timerChaffCounter == 3 and ldiffTimer == 0 then + ExportScript.Tools.WriteToLog('5') lblinkChaff = 1 - --gES_timerChaffCounter = gES_timerChaffCounter - 1 - elseif gES_timerChaffCounter == 0 or ldiffTimer > 5 then - WriteToLog('else') + --ExportScript.AF.timerChaffCounter = ExportScript.AF.timerChaffCounter - 1 + elseif ExportScript.AF.timerChaffCounter == 0 or ldiffTimer > 5 then + ExportScript.Tools.WriteToLog('else') lblinkChaff = 0 - gES_timerChaffCounter = 3 - gES_timerChaff = 0 + ExportScript.AF.timerChaffCounter = 3 + ExportScript.AF.timerChaff = 0 end]] end - - --WriteToLog('lblinkChaff: '..lblinkChaff) - SendDataHW("800", lSnares.chaff, lHardware ) -- display chaff - SendDataHW("801", lSnares.flare, lHardware ) -- display flare - SendDataHW("802", lblinkChaff, lHardware ) -- blink chaff active/aktive empty chaff - SendDataHW("803", lblinkFlare, lHardware ) -- blink flare active/aktive empty flare - SendDataHW("804", gES_tmpChaff < 20 and 1 or 0, lHardware ) -- minimum chaff lamp - SendDataHW("805", gES_tmpFlare < 10 and 1 or 0, lHardware ) -- minimum flare lamp - + --ExportScript.Tools.WriteToLog('lblinkChaff: '..lblinkChaff) + + ExportScript.Tools.SendDataDAC("800", lSnares.chaff ) -- display chaff + ExportScript.Tools.SendDataDAC("801", lSnares.flare ) -- display flare + ExportScript.Tools.SendDataDAC("802", lblinkChaff ) -- blink chaff active/aktive empty chaff + ExportScript.Tools.SendDataDAC("803", lblinkFlare ) -- blink flare active/aktive empty flare + ExportScript.Tools.SendDataDAC("804", ExportScript.AF.tmpChaff < 20 and 1 or 0 ) -- minimum chaff lamp + ExportScript.Tools.SendDataDAC("805", ExportScript.AF.tmpFlare < 10 and 1 or 0 ) -- minimum flare lamp end -function MechanicalDevicesIndicator(hardware) +function ExportScript.AF.MechanicalDevicesIndicator(FunctionTyp) + local lFunctionTyp = FunctionTyp or "Ikarus" -- The mechanical devices indicator shows the position of the landing gear, flaps, leading edge flaps and airbrake - local lHardware = hardware or 1 local lMechInfo = LoGetMechInfo() -- mechanical components, e.g. Flaps, Wheelbrakes,... if lMechInfo == nil then - --WriteToLog('lMechInfo nil') return end --[[ @@ -1016,43 +889,27 @@ function MechanicalDevicesIndicator(hardware) [status] = number: "0" [value] = number: "0" }]] - --SendDataHW("500", lMechInfo.gear.status ) - --SendDataHW("501", lMechInfo.gear.value ) - --SendDataHW("502", lMechInfo.gear.nose.rod ) -- zeigt an wie weit das Fahrwerk einsackt wenn das Flugzeug auf dem Boden ist - --SendDataHW("503", lMechInfo.gear.main.left.rod ) -- zeigt an wie weit das Fahrwerk einsackt wenn das Flugzeug auf dem Boden ist - --SendDataHW("504", lMechInfo.gear.main.right.rod ) -- zeigt an wie weit das Fahrwerk einsackt wenn das Flugzeug auf dem Boden ist - --SendDataHW("500", ((lMechInfo.gear.status == 1 and lMechInfo.gear.value < 1) and 1 or 0 ) ) -- gear warning light, go up - --SendDataHW("500", ((lMechInfo.gear.status == 0 and lMechInfo.gear.value > 0) and 1 or 0 ) ) -- gear warning light, go down - --SendDataHW("500", (((lMechInfo.gear.status == 1 and lMechInfo.gear.value < 1) or (lMechInfo.gear.status == 0 and lMechInfo.gear.value > 0)) and 1 or 0 ), lHardware ) -- gear warning light - SendDataHW("501", (lMechInfo.gear.value > 0.85 and 1 or 0), lHardware ) -- nose gear - SendDataHW("502", (lMechInfo.gear.value > 0.95 and 1 or 0), lHardware ) -- left gear - SendDataHW("503", (lMechInfo.gear.value == 1 and 1 or 0), lHardware ) -- right gear - - --SendDataHW("510", lMechInfo.speedbrakes.status ) -- speedbreakes on 1 (0|1) - SendDataHW("510", (lMechInfo.speedbrakes.value > 0.1 and 1 or 0), lHardware ) -- speedbreakes on > 0.1 (0 - 1) - --SendDataHW("520", lMechInfo.wheelbrakes.status ) -- not in use - --SendDataHW("521", lMechInfo.wheelbrakes.value ) -- not in use - - local lGetTrueAirSpeed = LoGetTrueAirSpeed() - if lGetTrueAirSpeed == nil then - lGetTrueAirSpeed = 0 + if ExportScript.Config.IkarusExport and lFunctionTyp == "Ikarus" then + ExportScript.Tools.SendData(501, (lMechInfo.gear.value > 0.85 and 1 or 0) ) -- nose gear + ExportScript.Tools.SendData(502, (lMechInfo.gear.value > 0.95 and 1 or 0) ) -- left gear + ExportScript.Tools.SendData(503, (lMechInfo.gear.value == 1 and 1 or 0) ) -- right gear + end + + if ExportScript.Config.DACExport and lFunctionTyp == "DAC" then + ExportScript.Tools.SendDataDAC("501", (lMechInfo.gear.value > 0.85 and 1 or 0) ) -- nose gear + ExportScript.Tools.SendDataDAC("502", (lMechInfo.gear.value > 0.95 and 1 or 0) ) -- left gear + ExportScript.Tools.SendDataDAC("503", (lMechInfo.gear.value == 1 and 1 or 0) ) -- right gear end - --SendDataHW("530", lMechInfo.flaps.status ) -- flap switch off 0, 1. position 1, 2. position 2 (0|1|2) - --SendDataHW("531", lMechInfo.flaps.value ) -- flap 1. position > 0.25, 2. position > 0.93 (0 - 1) - SendDataHW("531", (lMechInfo.flaps.value > 0.25 and 1 or 0), lHardware ) -- flap 1. position - SendDataHW("532", (lMechInfo.flaps.value > 0.93 and 1 or 0), lHardware ) -- flap 2. position - SendDataHW("533", ((lMechInfo.flaps.value > 0.93 and lGetTrueAirSpeed > 340) and 1 or 0), lHardware ) -- Speed Warning for Flaps, same light as gear warning light, but blinking light end -function WeaponStatusPanel(hardware) +function ExportScript.AF.WeaponStatusPanel() -- The weapon status panel, quantity and readiness of the currently selected weapon and the remaining gun ammunition are indicated. - local lHardware = hardware or 1 - gES_PayloadInfo = LoGetPayloadInfo() - if gES_PayloadInfo == nil then + ExportScript.AF.PayloadInfo = LoGetPayloadInfo() + if ExportScript.AF.PayloadInfo == nil then return end - --WriteToLog('gES_PayloadInfo: '..dump(gES_PayloadInfo)) + --ExportScript.Tools.WriteToLog('ExportScript.AF.PayloadInfo: '..ExportScript.Tools.dump(ExportScript.AF.PayloadInfo)) --[[ exsample [Stations] = { [1] = { @@ -1275,79 +1132,78 @@ function WeaponStatusPanel(hardware) ]] -- Payload Info -- weapon stations (panel) 1 (left) - 11 (right) reserved - SendDataHW("100", gES_PayloadInfo.Cannon.shells, lHardware ) -- count cannon shells - SendDataHW("101", (gES_PayloadInfo.Stations[1].count > 0 and 1 or 0), lHardware ) -- weapon presend > 0 (panel 1) - SendDataHW("102", (gES_PayloadInfo.Stations[2].count > 0 and 1 or 0), lHardware ) -- weapon presend > 0 (panel 2) - SendDataHW("103", (gES_PayloadInfo.Stations[3].count > 0 and 1 or 0), lHardware ) -- weapon presend > 0 (panel 3) - SendDataHW("104", (gES_PayloadInfo.Stations[4].count > 0 and 1 or 0), lHardware ) -- weapon presend > 0 (panel 4) - SendDataHW("105", (gES_PayloadInfo.Stations[5].count > 0 and 1 or 0), lHardware ) -- weapon presend > 0 (panel 5) - SendDataHW("106", (gES_PayloadInfo.Stations[6].count > 0 and 1 or 0), lHardware ) -- weapon presend > 0 (panel 6, center station) - SendDataHW("107", (gES_PayloadInfo.Stations[7].count > 0 and 1 or 0), lHardware ) -- weapon presend > 0 (panel 7) - SendDataHW("108", (gES_PayloadInfo.Stations[8].count > 0 and 1 or 0), lHardware ) -- weapon presend > 0 (panel 8) - SendDataHW("109", (gES_PayloadInfo.Stations[9].count > 0 and 1 or 0), lHardware ) -- weapon presend > 0 (panel 9) - SendDataHW("110", (gES_PayloadInfo.Stations[10].count > 0 and 1 or 0), lHardware ) -- weapon presend > 0 (panel 10) - SendDataHW("111", (gES_PayloadInfo.Stations[11].count > 0 and 1 or 0), lHardware ) -- weapon presend > 0 (panel 11) + ExportScript.Tools.SendDataDAC("100", ExportScript.AF.PayloadInfo.Cannon.shells ) -- count cannon shells + ExportScript.Tools.SendDataDAC("101", (ExportScript.AF.PayloadInfo.Stations[1].count > 0 and 1 or 0) ) -- weapon presend > 0 (panel 1) + ExportScript.Tools.SendDataDAC("102", (ExportScript.AF.PayloadInfo.Stations[2].count > 0 and 1 or 0) ) -- weapon presend > 0 (panel 2) + ExportScript.Tools.SendDataDAC("103", (ExportScript.AF.PayloadInfo.Stations[3].count > 0 and 1 or 0) ) -- weapon presend > 0 (panel 3) + ExportScript.Tools.SendDataDAC("104", (ExportScript.AF.PayloadInfo.Stations[4].count > 0 and 1 or 0) ) -- weapon presend > 0 (panel 4) + ExportScript.Tools.SendDataDAC("105", (ExportScript.AF.PayloadInfo.Stations[5].count > 0 and 1 or 0) ) -- weapon presend > 0 (panel 5) + ExportScript.Tools.SendDataDAC("106", (ExportScript.AF.PayloadInfo.Stations[6].count > 0 and 1 or 0) ) -- weapon presend > 0 (panel 6, center station) + ExportScript.Tools.SendDataDAC("107", (ExportScript.AF.PayloadInfo.Stations[7].count > 0 and 1 or 0) ) -- weapon presend > 0 (panel 7) + ExportScript.Tools.SendDataDAC("108", (ExportScript.AF.PayloadInfo.Stations[8].count > 0 and 1 or 0) ) -- weapon presend > 0 (panel 8) + ExportScript.Tools.SendDataDAC("109", (ExportScript.AF.PayloadInfo.Stations[9].count > 0 and 1 or 0) ) -- weapon presend > 0 (panel 9) + ExportScript.Tools.SendDataDAC("110", (ExportScript.AF.PayloadInfo.Stations[10].count > 0 and 1 or 0) ) -- weapon presend > 0 (panel 10) + ExportScript.Tools.SendDataDAC("111", (ExportScript.AF.PayloadInfo.Stations[11].count > 0 and 1 or 0) ) -- weapon presend > 0 (panel 11) -- weapon stations (panel) 1 (left) - 11 (right) empty - SendDataHW("121", (gES_PayloadInfo.Stations[1].count == 0 and 1 or 0), lHardware ) -- weapon presend > 0 (panel 1) - SendDataHW("122", (gES_PayloadInfo.Stations[2].count == 0 and 1 or 0), lHardware ) -- weapon presend > 0 (panel 2) - SendDataHW("123", (gES_PayloadInfo.Stations[3].count == 0 and 1 or 0), lHardware ) -- weapon presend > 0 (panel 3) - SendDataHW("124", (gES_PayloadInfo.Stations[4].count == 0 and 1 or 0), lHardware ) -- weapon presend > 0 (panel 4) - SendDataHW("125", (gES_PayloadInfo.Stations[5].count == 0 and 1 or 0), lHardware ) -- weapon presend > 0 (panel 5) - SendDataHW("126", (gES_PayloadInfo.Stations[6].count == 0 and 1 or 0), lHardware ) -- weapon presend > 0 (panel 6, center station) - SendDataHW("127", (gES_PayloadInfo.Stations[7].count == 0 and 1 or 0), lHardware ) -- weapon presend > 0 (panel 7) - SendDataHW("128", (gES_PayloadInfo.Stations[8].count == 0 and 1 or 0), lHardware ) -- weapon presend > 0 (panel 8) - SendDataHW("129", (gES_PayloadInfo.Stations[9].count == 0 and 1 or 0), lHardware ) -- weapon presend > 0 (panel 9) - SendDataHW("130", (gES_PayloadInfo.Stations[10].count == 0 and 1 or 0), lHardware ) -- weapon presend > 0 (panel 10) - SendDataHW("131", (gES_PayloadInfo.Stations[11].count == 0 and 1 or 0), lHardware ) -- weapon presend > 0 (panel 11) - --SendDataHW("CurrentStation", gES_PayloadInfo.CurrentStation, lHardware ) + ExportScript.Tools.SendDataDAC("121", (ExportScript.AF.PayloadInfo.Stations[1].count == 0 and 1 or 0) ) -- weapon presend > 0 (panel 1) + ExportScript.Tools.SendDataDAC("122", (ExportScript.AF.PayloadInfo.Stations[2].count == 0 and 1 or 0) ) -- weapon presend > 0 (panel 2) + ExportScript.Tools.SendDataDAC("123", (ExportScript.AF.PayloadInfo.Stations[3].count == 0 and 1 or 0) ) -- weapon presend > 0 (panel 3) + ExportScript.Tools.SendDataDAC("124", (ExportScript.AF.PayloadInfo.Stations[4].count == 0 and 1 or 0) ) -- weapon presend > 0 (panel 4) + ExportScript.Tools.SendDataDAC("125", (ExportScript.AF.PayloadInfo.Stations[5].count == 0 and 1 or 0) ) -- weapon presend > 0 (panel 5) + ExportScript.Tools.SendDataDAC("126", (ExportScript.AF.PayloadInfo.Stations[6].count == 0 and 1 or 0) ) -- weapon presend > 0 (panel 6, center station) + ExportScript.Tools.SendDataDAC("127", (ExportScript.AF.PayloadInfo.Stations[7].count == 0 and 1 or 0) ) -- weapon presend > 0 (panel 7) + ExportScript.Tools.SendDataDAC("128", (ExportScript.AF.PayloadInfo.Stations[8].count == 0 and 1 or 0) ) -- weapon presend > 0 (panel 8) + ExportScript.Tools.SendDataDAC("129", (ExportScript.AF.PayloadInfo.Stations[9].count == 0 and 1 or 0) ) -- weapon presend > 0 (panel 9) + ExportScript.Tools.SendDataDAC("130", (ExportScript.AF.PayloadInfo.Stations[10].count == 0 and 1 or 0) ) -- weapon presend > 0 (panel 10) + ExportScript.Tools.SendDataDAC("131", (ExportScript.AF.PayloadInfo.Stations[11].count == 0 and 1 or 0) ) -- weapon presend > 0 (panel 11) + --ExportScript.Tools.SendDataDAC("CurrentStation", ExportScript.AF.PayloadInfo.CurrentStation ) -- air-to-air missils panel 1 and 11, air combat modus, CurrentStation = 1, panel 1 and 11 on -- wenn die Waffenstationen gleichmässig belegt sind, hat bei Auswahl CurrentStation immer den Wert der linken Station -- bei ungleichmäßiger Belegung, hat CurrentStation immer den Wert der jeweiligen Station - -- Waffenbezeichnung als UUID, gES_PayloadInfo.Stations[X].CLSID - + -- Waffenbezeichnung als UUID, ExportScript.AF.PayloadInfo.Stations[X].CLSID + -- defination - if gES_CurrentStationTmp == nil then - gES_CurrentStationTmp = -1 + if ExportScript.AF.CurrentStationTmp == nil then + ExportScript.AF.CurrentStationTmp = -1 end - - if gES_PayloadInfo.CurrentStation > 0 and - gES_CurrentStationTmp ~= gES_PayloadInfo.CurrentStation then - gES_CurrentStationTmp = gES_PayloadInfo.CurrentStation - - gTmpStationToPanel = {} - gTmpStationToPanel[1] = {Panel = 1, StationID = 101, CurrentID = 201, CurrentID2 = 221, HardwareID = lHardware } -- left - gTmpStationToPanel[2] = {Panel = 2, StationID = 102, CurrentID = 202, CurrentID2 = 222, HardwareID = lHardware } - gTmpStationToPanel[3] = {Panel = 3, StationID = 103, CurrentID = 203, CurrentID2 = 223, HardwareID = lHardware } - gTmpStationToPanel[4] = {Panel = 4, StationID = 104, CurrentID = 204, CurrentID2 = 224, HardwareID = lHardware } - gTmpStationToPanel[5] = {Panel = 5, StationID = 105, CurrentID = 205, CurrentID2 = 225, HardwareID = lHardware } - gTmpStationToPanel[6] = {Panel = 6, StationID = 106, CurrentID = 206, CurrentID2 = 226, HardwareID = lHardware } - gTmpStationToPanel[7] = {Panel = 7, StationID = 107, CurrentID = 207, CurrentID2 = 227, HardwareID = lHardware } - gTmpStationToPanel[8] = {Panel = 8, StationID = 108, CurrentID = 208, CurrentID2 = 228, HardwareID = lHardware } - gTmpStationToPanel[9] = {Panel = 9, StationID = 109, CurrentID = 209, CurrentID2 = 229, HardwareID = lHardware } - gTmpStationToPanel[10] = {Panel = 10, StationID = 110, CurrentID = 210, CurrentID2 = 230, HardwareID = lHardware } - gTmpStationToPanel[11] = {Panel = 11, StationID = 111, CurrentID = 211, CurrentID2 = 231, HardwareID = lHardware } -- right - - WeaponStatusPanel_Reset(201, 211, lHardware) - WeaponStatusPanel_Reset(221, 231, lHardware) - - SendDataHW(gTmpStationToPanel[gES_PayloadInfo.CurrentStation].CurrentID, 1, lHardware) -- eigentliche Auswahl - --WriteToLog('aktiv: '..gTmpStationToPanel[gES_PayloadInfo.CurrentStation].CurrentID) - if gES_PayloadInfo.Stations[gES_PayloadInfo.CurrentStation].container then - if gES_PayloadInfo.Stations[gES_PayloadInfo.CurrentStation].count > 1 then - SendDataHW(gTmpStationToPanel[gES_PayloadInfo.CurrentStation].CurrentID2, 1, lHardware) -- eigentliche Auswahl - --WriteToLog('aktiv2: '..gTmpStationToPanel[gES_PayloadInfo.CurrentStation].CurrentID2) + + if ExportScript.AF.PayloadInfo.CurrentStation > 0 and + ExportScript.AF.CurrentStationTmp ~= ExportScript.AF.PayloadInfo.CurrentStation then + ExportScript.AF.CurrentStationTmp = ExportScript.AF.PayloadInfo.CurrentStation + + ExportScript.AF.TmpStationToPanel = {} + ExportScript.AF.TmpStationToPanel[1] = {Panel = 1, StationID = 101, CurrentID = 201, CurrentID2 = 221 } -- left + ExportScript.AF.TmpStationToPanel[2] = {Panel = 2, StationID = 102, CurrentID = 202, CurrentID2 = 222 } + ExportScript.AF.TmpStationToPanel[3] = {Panel = 3, StationID = 103, CurrentID = 203, CurrentID2 = 223 } + ExportScript.AF.TmpStationToPanel[4] = {Panel = 4, StationID = 104, CurrentID = 204, CurrentID2 = 224 } + ExportScript.AF.TmpStationToPanel[5] = {Panel = 5, StationID = 105, CurrentID = 205, CurrentID2 = 225 } + ExportScript.AF.TmpStationToPanel[6] = {Panel = 6, StationID = 106, CurrentID = 206, CurrentID2 = 226 } + ExportScript.AF.TmpStationToPanel[7] = {Panel = 7, StationID = 107, CurrentID = 207, CurrentID2 = 227 } + ExportScript.AF.TmpStationToPanel[8] = {Panel = 8, StationID = 108, CurrentID = 208, CurrentID2 = 228 } + ExportScript.AF.TmpStationToPanel[9] = {Panel = 9, StationID = 109, CurrentID = 209, CurrentID2 = 229 } + ExportScript.AF.TmpStationToPanel[10] = {Panel = 10, StationID = 110, CurrentID = 210, CurrentID2 = 230 } + ExportScript.AF.TmpStationToPanel[11] = {Panel = 11, StationID = 111, CurrentID = 211, CurrentID2 = 231 } -- right + + ExportScript.AF.WeaponStatusPanel_Reset(201, 211) + ExportScript.AF.WeaponStatusPanel_Reset(221, 231) + + ExportScript.Tools.SendDataDAC(ExportScript.AF.TmpStationToPanel[ExportScript.AF.PayloadInfo.CurrentStation].CurrentID, 1) -- eigentliche Auswahl + --ExportScript.Tools.WriteToLog('aktiv: '..ExportScript.AF.TmpStationToPanel[ExportScript.AF.PayloadInfo.CurrentStation].CurrentID) + if ExportScript.AF.PayloadInfo.Stations[ExportScript.AF.PayloadInfo.CurrentStation].container then + if ExportScript.AF.PayloadInfo.Stations[ExportScript.AF.PayloadInfo.CurrentStation].count > 1 then + ExportScript.Tools.SendDataDAC(ExportScript.AF.TmpStationToPanel[ExportScript.AF.PayloadInfo.CurrentStation].CurrentID2, 1) -- eigentliche Auswahl + --ExportScript.Tools.WriteToLog('aktiv2: '..ExportScript.AF.TmpStationToPanel[ExportScript.AF.PayloadInfo.CurrentStation].CurrentID2) end end - table.foreach(gES_PayloadInfo.Stations, WeaponStatusPanel_selectCurrentPayloadStation) -- zugehörige Stationen - elseif gES_PayloadInfo.CurrentStation == 0 and gES_CurrentStationTmp > 0 then - WeaponStatusPanel_Reset(201, 211, lHardware) - WeaponStatusPanel_Reset(221, 231, lHardware) - gES_CurrentStationTmp = -1 + table.foreach(ExportScript.AF.PayloadInfo.Stations, ExportScript.AF.WeaponStatusPanel_selectCurrentPayloadStation_F15C) -- zugehörige Stationen + elseif ExportScript.AF.PayloadInfo.CurrentStation == 0 and ExportScript.AF.CurrentStationTmp > 0 then + ExportScript.AF.WeaponStatusPanel_Reset(201, 211) + ExportScript.AF.WeaponStatusPanel_Reset(221, 231) + ExportScript.AF.CurrentStationTmp = -1 end end -function RWRlite(hardware) - local lHardware = hardware or 1 +function ExportScript.AF.RWRlite() local lTWSInfo = LoGetTWSInfo() -- RWR Information if lTWSInfo == nil then return @@ -1363,48 +1219,41 @@ function RWRlite(hardware) lPrimaryThreatTmp = EmitterIndex end end - + for EmitterIndex = 1, #lTWSInfo.Emitters, 1 do local lType = lTWSInfo.Emitters[EmitterIndex].Type - --WriteToLog('level: '..lType.level1..', '..lType.level2..', '..lType.level3..', '..lType.level4) - - local lAzimut = math.round(lTWSInfo.Emitters[EmitterIndex].Azimuth * 90, 1) - + --ExportScript.Tools.WriteToLog('level: '..lType.level1..', '..lType.level2..', '..lType.level3..', '..lType.level4) + + local lAzimut = ExportScript.Tools.round(lTWSInfo.Emitters[EmitterIndex].Azimuth * 90, 1) + if EmitterIndex == lPrimaryThreatTmp then - gES_RWRlite_FoundErmitter = true - - SendDataHW("400", (lType.level1 == 1 and 1 or 0), lHardware ) -- primary Air - - SendDataHW("401", ((lType.level1 == 2 and lType.level2 == 16) and 1 or 0), lHardware ) -- primary SAM + ExportScript.AF.RWRlite_FoundErmitter = true + + ExportScript.Tools.SendDataDAC("400", (lType.level1 == 1 and 1 or 0) ) -- primary Air + + ExportScript.Tools.SendDataDAC("401", ((lType.level1 == 2 and lType.level2 == 16) and 1 or 0) ) -- primary SAM end end else - if gES_RWRlite_FoundErmitter ~= nil and gES_RWRlite_FoundErmitter then - SendDataHW("400", 0, lHardware ) -- primary Air - - SendDataHW("401", 0, lHardware ) -- primary SAM + if ExportScript.AF.RWRlite_FoundErmitter ~= nil and ExportScript.AF.RWRlite_FoundErmitter then + ExportScript.Tools.SendDataDAC("400", 0 ) -- primary Air + + ExportScript.Tools.SendDataDAC("401", 0 ) -- primary SAM end end end - + -- Helper functions -function WeaponStatusPanel_selectCurrentPayloadStation(_index) - if gES_PayloadInfo.Stations[gES_PayloadInfo.CurrentStation].CLSID == gES_PayloadInfo.Stations[_index].CLSID and gES_PayloadInfo.CurrentStation ~= _index then - SendDataHW(gTmpStationToPanel[_index].CurrentID, 1, gTmpStationToPanel[_index].HardwareID) - --WriteToLog('aktiv3: '..gTmpStationToPanel[_index].CurrentID) - if gES_PayloadInfo.Stations[gES_PayloadInfo.CurrentStation].container then - if gES_PayloadInfo.Stations[gES_PayloadInfo.CurrentStation].count > 1 then - SendDataHW(gTmpStationToPanel[_index].CurrentID2, 1, gTmpStationToPanel[_index].HardwareID) - --WriteToLog('aktiv3: '..gTmpStationToPanel[_index].CurrentID2) +function ExportScript.AF.WeaponStatusPanel_selectCurrentPayloadStation_F15C(_index) + if ExportScript.AF.PayloadInfo.Stations[ExportScript.AF.PayloadInfo.CurrentStation].CLSID == ExportScript.AF.PayloadInfo.Stations[_index].CLSID and ExportScript.AF.PayloadInfo.CurrentStation ~= _index then + ExportScript.Tools.SendDataDAC(ExportScript.AF.TmpStationToPanel[_index].CurrentID, 1) + --ExportScript.Tools.WriteToLog('aktiv3: '..ExportScript.AF.TmpStationToPanel[_index].CurrentID) + if ExportScript.AF.PayloadInfo.Stations[ExportScript.AF.PayloadInfo.CurrentStation].container then + if ExportScript.AF.PayloadInfo.Stations[ExportScript.AF.PayloadInfo.CurrentStation].count > 1 then + ExportScript.Tools.SendDataDAC(ExportScript.AF.TmpStationToPanel[_index].CurrentID2, 1) + --ExportScript.Tools.WriteToLog('aktiv3: '..ExportScript.AF.TmpStationToPanel[_index].CurrentID2) end end end -end - -function WeaponStatusPanel_Reset(lMinId, lMaxID, lHardware) ---WriteToLog('WeaponStatusPanel_Reset') - for lCounter = lMinId, lMaxID, 1 do - SendDataHW(lCounter, 0, lHardware) - end end \ No newline at end of file diff --git a/Scripts/DCS-ExportScript/ExportsModules/FC_AuxiliaryFuntions.lua b/Scripts/DCS-ExportScript/ExportsModules/FC_AuxiliaryFuntions.lua index 80cb36e..ccc1404 100644 --- a/Scripts/DCS-ExportScript/ExportsModules/FC_AuxiliaryFuntions.lua +++ b/Scripts/DCS-ExportScript/ExportsModules/FC_AuxiliaryFuntions.lua @@ -1,3033 +1,2677 @@ --- Flaming Cliffs Auxiliary Functons --- Version 1.0.0 - --- Weapon Panel for Su-25A and Su-25T -function ExportScript.AF.WeaponPanel_SU25(FunctionTyp) - local lFunctionTyp = FunctionTyp or "Ikarus" - - if ExportScript.AF.TmpWeaponPanelPresend == nil then - ExportScript.AF.TmpWeaponPanelPresend = {[101] = 0, [102] = 0, [103] = 0, [104] = 0, [105] = 0, [106] = 0, [107] = 0, [108] = 0, [109] = 0, [110] = 0} - end - - if ExportScript.AF.TmpWeaponPanelActive == nil then - ExportScript.AF.TmpWeaponPanelActive = {[201] = 0, [202] = 0, [203] = 0, [204] = 0, [205] = 0, [206] = 0, [207] = 0, [208] = 0, [209] = 0, [210] = 0} - end - - if ExportScript.AF.TmpWeaponPanel == nil then - ExportScript.AF.TmpWeaponPanel = {[231] = 0, [232] = 0, [233] = 0, [234] = 0, [235] = 0} - end - --- if(ExportScript.AF.EventNumberOLD < ExportScript.AF.EventNumber) then - -- defination - ExportScript.AF.PayloadInfo = LoGetPayloadInfo() - if ExportScript.AF.PayloadInfo ~= nil then - if ExportScript.AF.CurrentStationTmp == nil then - ExportScript.AF.CurrentStationTmp = -1 - end - if ExportScript.AF.CannonContainer == nil then -- Find Cannon-Containers, aka SPPU_22 - ExportScript.AF.CannonContainer = {} - ExportScript.AF.CannonContainer.counter = 0 - table.foreach(ExportScript.AF.PayloadInfo.Stations, ExportScript.AF.WeaponStatusPanel_FindCannonContainer) - end - - if ExportScript.AF.PayloadInfo.CurrentStation > 0 and - ExportScript.AF.CurrentStationTmp ~= ExportScript.AF.PayloadInfo.CurrentStation then - ExportScript.AF.CurrentStationTmp = ExportScript.AF.PayloadInfo.CurrentStation - - ExportScript.AF.TmpStationToPanel = {} - ExportScript.AF.TmpStationToPanel[1] = {Panel = 1, StationID = 101, CurrentID = 201 } -- left - ExportScript.AF.TmpStationToPanel[2] = {Panel = 10, StationID = 110, CurrentID = 210 } -- right - ExportScript.AF.TmpStationToPanel[3] = {Panel = 2, StationID = 102, CurrentID = 202 } - ExportScript.AF.TmpStationToPanel[4] = {Panel = 9, StationID = 109, CurrentID = 209 } - ExportScript.AF.TmpStationToPanel[5] = {Panel = 3, StationID = 103, CurrentID = 203 } - ExportScript.AF.TmpStationToPanel[6] = {Panel = 8, StationID = 108, CurrentID = 208 } - ExportScript.AF.TmpStationToPanel[7] = {Panel = 4, StationID = 104, CurrentID = 204 } - ExportScript.AF.TmpStationToPanel[8] = {Panel = 7, StationID = 107, CurrentID = 207 } - ExportScript.AF.TmpStationToPanel[9] = {Panel = 5, StationID = 105, CurrentID = 205 } - ExportScript.AF.TmpStationToPanel[10] = {Panel = 6, StationID = 106, CurrentID = 206 } - - -- ExportScript.AF.TmpWeaponPanelActive reset - for i = 201, 210, 1 do - ExportScript.AF.TmpWeaponPanelActive[i] = 0 - end - - if ExportScript.AF.TmpStationToPanel[ExportScript.AF.PayloadInfo.CurrentStation] ~= nil then - ExportScript.AF.TmpWeaponPanelActive[ExportScript.AF.TmpStationToPanel[ExportScript.AF.PayloadInfo.CurrentStation].CurrentID] = 1 -- currrent value - - table.foreach(ExportScript.AF.PayloadInfo.Stations, ExportScript.AF.WeaponStatusPanel_selectCurrentPayloadStationGlassCockpit) -- corresponding station - end - - end - - local lMainGun = 1.0 -- Full max 250 Rounds "F" - local lReserve = 1.0 - if ExportScript.AF.PayloadInfo.Cannon.shells == 0 then - lMainGun = 0.0 -- transversely striped - lReserve = 0.0 -- transversely striped - elseif ExportScript.AF.PayloadInfo.Cannon.shells < 65 then - lMainGun = 0.1 -- "E" - elseif ExportScript.AF.PayloadInfo.Cannon.shells < 125 then - lMainGun = 0.3 -- "1/2" -- "3/4" - elseif ExportScript.AF.PayloadInfo.Cannon.shells < 187 then - lMainGun = 0.6 -- "1/4" - end - - local lWeaponType = 0.0 -- transversely striped - if ExportScript.AF.PayloadInfo.CurrentStation > 0 then - if ExportScript.AF.PayloadInfo.Stations[ExportScript.AF.PayloadInfo.CurrentStation].weapon.level1 == 4 then - if ExportScript.AF.PayloadInfo.Stations[ExportScript.AF.PayloadInfo.CurrentStation].weapon.level2 == 4 then -- Weapon type Missle - lWeaponType = 0.1 -- MSL - elseif ExportScript.AF.PayloadInfo.Stations[ExportScript.AF.PayloadInfo.CurrentStation].weapon.level2 == 7 then -- Weapon type NURS with Container - if ExportScript.AF.PayloadInfo.Stations[ExportScript.AF.PayloadInfo.CurrentStation].weapon.level3 == 33 then -- Weapon type Rocket - lWeaponType = 0.2 -- RCT - end - elseif ExportScript.AF.PayloadInfo.Stations[ExportScript.AF.PayloadInfo.CurrentStation].weapon.level2 == 5 then -- Weapon type Bomb - lWeaponType = 0.3 -- BB - end - end - end - - local lOuterCannon = 0.0 -- transversely striped - local lInnerCannon = 0.0 -- transversely striped - if ExportScript.AF.CannonContainer.counter > 0 then - for i = 7, 10, 1 do - if ExportScript.AF.CannonContainer[i] == "{E92CBFE5-C153-11d8-9897-000476191836}" then -- SPPU_22 with 260 rounds - if i == 7 or i == 8 then - lOuterCannon = 1.0 -- Full max 260 Rounds "F" - if ExportScript.AF.PayloadInfo.Stations[i].count == 0 then - lOuterCannon = 0.0 -- transversely striped - ExportScript.AF.CannonContainer[i] = "empty" -- do not check - elseif ExportScript.AF.PayloadInfo.Stations[i].count < 65 then - lOuterCannon = 0.1 -- "E" - elseif ExportScript.AF.PayloadInfo.Stations[i].count < 130 then - lOuterCannon = 0.3 -- "3/4" -- "1/2" - elseif ExportScript.AF.PayloadInfo.Stations[i].count < 195 then - lOuterCannon = 0.6 -- "1/4" - end - else - lInnerCannon = 1.0 -- Full max 260 Rounds "F" - if ExportScript.AF.PayloadInfo.Stations[i].count == 0 then - lInnerCannon = 0.0 -- transversely striped - ExportScript.AF.CannonContainer[i] = "empty" -- do not check - elseif ExportScript.AF.PayloadInfo.Stations[i].count < 65 then - lInnerCannon = 0.1 -- "E" - elseif ExportScript.AF.PayloadInfo.Stations[i].count < 130 then - lInnerCannon = 0.3 -- "3/4" -- "1/2" - elseif ExportScript.AF.PayloadInfo.Stations[i].count < 195 then - lInnerCannon = 0.6 -- "1/4" - end - end - end - end - end - - --[[ - Weapon Panel - | - --------------------------------------------------- - | | | | | | | | | | | - 1 2 3 4 5 C 6 7 8 9 10 - ]] - -- Payload Info - -- weapon stations (panel) 1 (left) - 10 (right), no lamp for center station - - -- WeaponPresend1 {0, 1} - -- WeaponPresend2 {0, 1} - -- WeaponPresend3 {0, 1} - -- WeaponPresend4 {0, 1} - -- WeaponPresend5 {0, 1} - -- WeaponPresend6 {0, 1} - -- WeaponPresend7 {0, 1} - -- WeaponPresend8 {0, 1} - -- WeaponPresend9 {0, 1} - -- WeaponPresend10 {0, 1} - -- WeaponActive1 {0, 1} - -- WeaponActive2 {0, 1} - -- WeaponActive3 {0, 1} - -- WeaponActive4 {0, 1} - -- WeaponActive5 {0, 1} - -- WeaponActive6 {0, 1} - -- WeaponActive7 {0, 1} - -- WeaponActive8 {0, 1} - -- WeaponActive9 {0, 1} - -- WeaponActive10 {0, 1} - -- MainCannon {transversely striped = 0.0, 1/4 = 01, 1/2 = 03, 3/4 = 0.6, Full = 1.0} - -- WeaponType {transversely striped = 0.0, Missle = 0.1, Rocket = 0.2, Bomb = 0.3} - -- OuterCannon {transversely striped = 0.0, 1/4 = 01, 1/2 = 03, 3/4 = 0.6, Full = 1.0} - -- InnerCannon {transversely striped = 0.0, 1/4 = 01, 1/2 = 03, 3/4 = 0.6, Full = 1.0} - -- ReserveWeapon {transversely striped = 0.0, Gun = 1.0} - - ExportScript.AF.TmpWeaponPanel = {} - ExportScript.AF.TmpWeaponPanel[231] = lMainGun -- main cannon shells - ExportScript.AF.TmpWeaponPanelPresend[101] = (ExportScript.AF.PayloadInfo.Stations[1].count > 0 and 1 or 0) -- weapon presend panel 1 - ExportScript.AF.TmpWeaponPanelPresend[102] = (ExportScript.AF.PayloadInfo.Stations[3].count > 0 and 1 or 0) -- weapon presend panel 2 - ExportScript.AF.TmpWeaponPanelPresend[103] = (ExportScript.AF.PayloadInfo.Stations[5].count > 0 and 1 or 0) -- weapon presend panel 3 - ExportScript.AF.TmpWeaponPanelPresend[104] = (ExportScript.AF.PayloadInfo.Stations[7].count > 0 and 1 or 0) -- weapon presend panel 4 - ExportScript.AF.TmpWeaponPanelPresend[105] = (ExportScript.AF.PayloadInfo.Stations[9].count > 0 and 1 or 0) -- weapon presend panel 5 - ExportScript.AF.TmpWeaponPanelPresend[106] = (ExportScript.AF.PayloadInfo.Stations[10].count > 0 and 1 or 0) -- weapon presend panel 6 - ExportScript.AF.TmpWeaponPanelPresend[107] = (ExportScript.AF.PayloadInfo.Stations[8].count > 0 and 1 or 0) -- weapon presend panel 7 - ExportScript.AF.TmpWeaponPanelPresend[108] = (ExportScript.AF.PayloadInfo.Stations[6].count > 0 and 1 or 0) -- weapon presend panel 8 - ExportScript.AF.TmpWeaponPanelPresend[109] = (ExportScript.AF.PayloadInfo.Stations[4].count > 0 and 1 or 0) -- weapon presend panel 9 - ExportScript.AF.TmpWeaponPanelPresend[110] = (ExportScript.AF.PayloadInfo.Stations[2].count > 0 and 1 or 0) -- weapon presend panel 10 - --ExportScript.AF.TmpWeaponPanelActive[201] -- weapon active panel 1 - --ExportScript.AF.TmpWeaponPanelActive[202] -- weapon active panel 2 - --ExportScript.AF.TmpWeaponPanelActive[203] -- weapon active panel 3 - --ExportScript.AF.TmpWeaponPanelActive[204] -- weapon active panel 4 - --ExportScript.AF.TmpWeaponPanelActive[205] -- weapon active panel 5 - --ExportScript.AF.TmpWeaponPanelActive[206] -- weapon active panel 6 - --ExportScript.AF.TmpWeaponPanelActive[207] -- weapon active panel 7 - --ExportScript.AF.TmpWeaponPanelActive[208] -- weapon active panel 8 - --ExportScript.AF.TmpWeaponPanelActive[209] -- weapon active panel 9 - --ExportScript.AF.TmpWeaponPanelActive[210] -- weapon active panel 10 - ExportScript.AF.TmpWeaponPanel[232] = lWeaponType -- current weapon type - ExportScript.AF.TmpWeaponPanel[233] = lOuterCannon -- outer cannon shells - ExportScript.AF.TmpWeaponPanel[234] = lInnerCannon -- inner cannon shells - ExportScript.AF.TmpWeaponPanel[235] = lReserve -- reserve weapon - end - --end - - if ExportScript.Config.IkarusExport and lFunctionTyp == "Ikarus" then - for key, value in pairs(ExportScript.AF.TmpWeaponPanelPresend) do - ExportScript.Tools.SendData(key, value) - end - for key, value in pairs(ExportScript.AF.TmpWeaponPanelActive) do - ExportScript.Tools.SendData(key, value) - end - for key, value in pairs(ExportScript.AF.TmpWeaponPanel) do - ExportScript.Tools.SendData(key, value) - end - end - - if ExportScript.Config.DACExport and lFunctionTyp == "DAC" then - for key, value in pairs(ExportScript.AF.TmpWeaponPanelPresend) do - ExportScript.Tools.SendDataDAC(key, value) - end - for key, value in pairs(ExportScript.AF.TmpWeaponPanelActive) do - ExportScript.Tools.SendDataDAC(key, value) - end - end -end - --- Weapon Panel for Su-27 and Su-33 -function ExportScript.AF.FC_WeaponPanel_SU2733(exportid) - local lExportID = exportid or 13 - - -- defination - ExportScript.AF.PayloadInfo = LoGetPayloadInfo() - if ExportScript.AF.PayloadInfo ~= nil then - if ExportScript.AF.CurrentStationTmp == nil then - ExportScript.AF.CurrentStationTmp = -1 - end - - if ExportScript.AF.TmpWeaponPanelActive == nil then - ExportScript.AF.TmpWeaponPanelActive = {[201] = 0, [202] = 0, [203] = 0, [204] = 0, [205] = 0, [206] = 0, [207] = 0, [208] = 0, [209] = 0, [210] = 0} - end - - if ExportScript.AF.PayloadInfo.CurrentStation > 0 and - ExportScript.AF.CurrentStationTmp ~= ExportScript.AF.PayloadInfo.CurrentStation then - ExportScript.AF.CurrentStationTmp = ExportScript.AF.PayloadInfo.CurrentStation - - ExportScript.AF.TmpStationToPanel = {} - ExportScript.AF.TmpStationToPanel[1] = {Panel = 1, StationID = 101, CurrentID = 201 } -- left - ExportScript.AF.TmpStationToPanel[2] = {Panel = 10, StationID = 110, CurrentID = 210 } -- right - ExportScript.AF.TmpStationToPanel[3] = {Panel = 2, StationID = 102, CurrentID = 202 } - ExportScript.AF.TmpStationToPanel[4] = {Panel = 9, StationID = 109, CurrentID = 209 } - ExportScript.AF.TmpStationToPanel[5] = {Panel = 3, StationID = 103, CurrentID = 203 } - ExportScript.AF.TmpStationToPanel[6] = {Panel = 8, StationID = 108, CurrentID = 208 } - ExportScript.AF.TmpStationToPanel[7] = {Panel = 4, StationID = 104, CurrentID = 204 } - ExportScript.AF.TmpStationToPanel[8] = {Panel = 7, StationID = 107, CurrentID = 207 } - ExportScript.AF.TmpStationToPanel[9] = {Panel = 5, StationID = 105, CurrentID = 205 } - ExportScript.AF.TmpStationToPanel[10] = {Panel = 6, StationID = 106, CurrentID = 206 } - - -- ExportScript.AF.TmpWeaponPanelActive reset - for i = 201, 210, 1 do - ExportScript.AF.TmpWeaponPanelActive[i] = 0 - end - - if ExportScript.AF.TmpStationToPanel[ExportScript.AF.PayloadInfo.CurrentStation] ~= nil then - ExportScript.AF.TmpWeaponPanelActive[ExportScript.AF.TmpStationToPanel[ExportScript.AF.PayloadInfo.CurrentStation].CurrentID] = 1 -- currrent value - - table.foreach(ExportScript.AF.PayloadInfo.Stations, ExportScript.AF.WeaponStatusPanel_selectCurrentPayloadStationGlassCockpit) -- corresponding station - end - - end - - local lWeaponType = 0.0 -- transversely striped - if ExportScript.AF.PayloadInfo.CurrentStation > 0 then - if ExportScript.AF.PayloadInfo.Stations[ExportScript.AF.PayloadInfo.CurrentStation].weapon.level1 == 4 then - if ExportScript.AF.PayloadInfo.Stations[ExportScript.AF.PayloadInfo.CurrentStation].weapon.level2 == 4 then -- Weapon type Missle - lWeaponType = 0.1 -- MSL - elseif ExportScript.AF.PayloadInfo.Stations[ExportScript.AF.PayloadInfo.CurrentStation].weapon.level2 == 7 then -- Weapon type NURS with Container - if ExportScript.AF.PayloadInfo.Stations[ExportScript.AF.PayloadInfo.CurrentStation].weapon.level3 == 33 then -- Weapon type Rocket - lWeaponType = 0.2 -- RCT - end - elseif ExportScript.AF.PayloadInfo.Stations[ExportScript.AF.PayloadInfo.CurrentStation].weapon.level2 == 5 then -- Weapon type Bomb - lWeaponType = 0.3 -- BB - end - end - end - - --[[ - Weapon Panel - | - --------------------------------------------------- - | | | | | | | | | | | - 1 2 3 4 5 C 6 7 8 9 10 - ]] - -- Payload Info - -- weapon stations (panel) 1 (left) - 10 (right), no lamp for center station - - -- WeaponPresend1 {0, 1} - -- WeaponPresend2 {0, 1} - -- WeaponPresend3 {0, 1} - -- WeaponPresend4 {0, 1} - -- WeaponPresend5 {0, 1} - -- WeaponPresend6 {0, 1} - -- WeaponPresend7 {0, 1} - -- WeaponPresend8 {0, 1} - -- WeaponPresend9 {0, 1} - -- WeaponPresend10 {0, 1} - -- WeaponActive1 {0, 1} - -- WeaponActive2 {0, 1} - -- WeaponActive3 {0, 1} - -- WeaponActive4 {0, 1} - -- WeaponActive5 {0, 1} - -- WeaponActive6 {0, 1} - -- WeaponActive7 {0, 1} - -- WeaponActive8 {0, 1} - -- WeaponActive9 {0, 1} - -- WeaponActive10 {0, 1} - SendData(lExportID, string.format("%d;%d;%d;%d;%d;%d;%d;%d;%d;%d;%d;%d;%d;%d;%d;%d;%d;%d;%d;%d", - (ExportScript.AF.PayloadInfo.Stations[1].count > 0 and 1 or 0), -- weapon presend panel 1 - (ExportScript.AF.PayloadInfo.Stations[3].count > 0 and 1 or 0), -- weapon presend panel 2 - (ExportScript.AF.PayloadInfo.Stations[5].count > 0 and 1 or 0), -- weapon presend panel 3 - (ExportScript.AF.PayloadInfo.Stations[7].count > 0 and 1 or 0), -- weapon presend panel 4 - (ExportScript.AF.PayloadInfo.Stations[9].count > 0 and 1 or 0), -- weapon presend panel 5 - (ExportScript.AF.PayloadInfo.Stations[10].count > 0 and 1 or 0), -- weapon presend panel 6 - (ExportScript.AF.PayloadInfo.Stations[8].count > 0 and 1 or 0), -- weapon presend panel 7 - (ExportScript.AF.PayloadInfo.Stations[6].count > 0 and 1 or 0), -- weapon presend panel 8 - (ExportScript.AF.PayloadInfo.Stations[4].count > 0 and 1 or 0), -- weapon presend panel 9 - (ExportScript.AF.PayloadInfo.Stations[2].count > 0 and 1 or 0), -- weapon presend panel 10 - ExportScript.AF.TmpWeaponPanelActive[201], -- weapon active panel 1 - ExportScript.AF.TmpWeaponPanelActive[202], -- weapon active panel 2 - ExportScript.AF.TmpWeaponPanelActive[203], -- weapon active panel 3 - ExportScript.AF.TmpWeaponPanelActive[204], -- weapon active panel 4 - ExportScript.AF.TmpWeaponPanelActive[205], -- weapon active panel 5 - ExportScript.AF.TmpWeaponPanelActive[206], -- weapon active panel 6 - ExportScript.AF.TmpWeaponPanelActive[207], -- weapon active panel 7 - ExportScript.AF.TmpWeaponPanelActive[208], -- weapon active panel 8 - ExportScript.AF.TmpWeaponPanelActive[209], -- weapon active panel 9 - ExportScript.AF.TmpWeaponPanelActive[210])) -- weapon active panel 10 - - end -end - --- radar warner SPO-15 for all russian planes -function ExportScript.AF.FC_RadarWarning_SPO15(exportid) - local lExportID = exportid or 14 - - local lTWSInfo = LoGetTWSInfo() -- SPO15 Information - if lTWSInfo ~= nil then - --SendData("15", "1;0.3;0;0.1;1;0;0.1;0.5;0;0;0;0;0;1;0;0;1;0;0;1;0;0;0;1") - --Parameter (PowerOn, PrimaryDirection1, PrimaryDirection2, PrimaryType, TopHemisphere, BottomHemisphere, Lock, ErmitterPower, SecondaryLeftBack, SecondaryLeft90, SecondaryLeft50, SecondaryLeft30, SecondaryLeft10, SecondaryRight10, SecondaryRight30, SecondaryRight50, SecondaryRight90, SecondaryRightBack, SecondaryAIR, SecondaryLRR, SecondaryMRR, SecondarySRR, SecondaryEWR, SecondaryAWACS) - -- Alle Parameter ohne extra Angabe haben den Wert 0 oder 1 - --Power On - --den 1. Wert welche Primäre Richtung leuchtet (es können maximal 2 Richtungsleuchten nebeneinander leuchten) (von links hinten nach recht hinten durchnummeriert, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0 oder 0 für alle aus) - --den 2. Wert welche Primäre Richtung leuchtet (von links hinten nach recht hinten durchnummeriert, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0 oder 0 für alle aus) - --den Wert welche Primäre Typ leuchtet (es kann nur ein Primären Typ geben) (AIR = 0.1, LRR = 0.2, MRR = 0.3, SRR = 0.4, EWR = 0.5 oder AWACS = 0.6) - --den Wert ob Oben leuchtet - --den Wert ob Unten leuchtet - --den Wert ob Lock leuchtet (nichts = 0, Rackete im Anflug = 0.1 (blinken), Lock = 0.2 (dauerlicht)) - --den Wert welche maximale Ermitterstärke leuchtet (alle lampen bis dahin gehen an + das Dreieck) (0.00 bis 0.15) - --den Wert ob Richtung links hinten Sekundär leuchtet - --den Wert ob Richtung links 90 Sekundär leuchtet - -- ... also insgesamt 10 Sekundär Richtungen - --den Wert ob Richtung rechts 90 Sekundär leuchtet - --den Wert ob Richtung rechts hinten Sekundär leuchtet - --den Wert ob Sekundär AIR leuchte -- air plane or missil - --den Wert ob Sekundär LRR leuchte -- long range radar - --den Wert ob Sekundär MRR leuchte -- mid range radar - --den Wert ob Sekundär SRR leuchte -- short range radar - --den Wert ob Sekundär EWR leuchte -- early warning radar - --den Wert ob Sekundär AWACS leuchte - -- Die Beispieldaten sind ein Primäres Flugzeug auf 50° links oberhalb mir, noch recht weit weg aber am scannen, Sekundär Radar ist auf 10° und 90° rechts und es ist ein Long Range und Awacs Radar - - -- prüft ob ein Radarsender vorhadnen ist - if(#lTWSInfo.Emitters > 0) then - - local lPrimaryDirection1, lPrimaryDirection2, lPrimaryType, lTopHemisphere, lBottomHemisphere, lLock, lErmitterPower = 0,0,0,0,0,0,0 - local lSecondaryLeftBack, lSecondaryLeft90, lSecondaryLeft50, lSecondaryLeft30, lSecondaryLeft10, lSecondaryRight10, lSecondaryRight30, lSecondaryRight50, lSecondaryRight90, lSecondaryRightBack = 0,0,0,0,0,0,0,0,0,0 - local lSecondaryType = {AIR = 0, LRR = 0, MRR = 0, SRR = 0, EWR = 0, AWACS = 0} - local lPriorityTmp, lPrimaryThreatTmp = 0,0 - local lHemisphere = 0 - ExportScript.AF.SPO15_FoundErmitter = true - - -- sucht den Primär Sender raus - for EmitterIndex = 1, #lTWSInfo.Emitters, 1 do - if(lTWSInfo.Emitters[EmitterIndex].Priority > lPriorityTmp) then - lPriorityTmp = lTWSInfo.Emitters[EmitterIndex].Priority - lPrimaryThreatTmp = EmitterIndex - end - end - - for EmitterIndex = 1, #lTWSInfo.Emitters, 1 do - - local lAzimut = ExportScript.Tools.round(lTWSInfo.Emitters[EmitterIndex].Azimuth * 90, 1) - - if EmitterIndex == lPrimaryThreatTmp then - -- primary threat - -- direction to the threat - lPrimaryDirection1 = (lAzimut <= -170.0 and 0.1 or lPrimaryDirection1) -- left back side - lPrimaryDirection1 = ((lAzimut <= -90.0 and lAzimut >= -170.0 and lPrimaryDirection1 == 0 ) and 0.2 or lPrimaryDirection1) -- left 90 degree - lPrimaryDirection2 = ((lAzimut <= -90.0 and lAzimut >= -170.0 and lPrimaryDirection1 < 0.2) and 0.2 or lPrimaryDirection2) -- left 90 degree - lPrimaryDirection1 = ((lAzimut <= -55.0 and lAzimut >= -125.0 and lPrimaryDirection1 == 0 ) and 0.3 or lPrimaryDirection1) -- left 50 degree - lPrimaryDirection2 = ((lAzimut <= -55.0 and lAzimut >= -125.0 and lPrimaryDirection1 < 0.3) and 0.3 or lPrimaryDirection2) -- left 50 degree - lPrimaryDirection1 = ((lAzimut <= -30.0 and lAzimut >= -70.5 and lPrimaryDirection1 == 0 ) and 0.4 or lPrimaryDirection1) -- left 30 degree - lPrimaryDirection2 = ((lAzimut <= -30.0 and lAzimut >= -70.5 and lPrimaryDirection1 < 0.4 ) and 0.4 or lPrimaryDirection2) -- left 30 degree - lPrimaryDirection1 = ((lAzimut <= 5.0 and lAzimut >= -40.0 and lPrimaryDirection1 == 0 ) and 0.5 or lPrimaryDirection1) -- left 10 degree - lPrimaryDirection2 = ((lAzimut <= 5.0 and lAzimut >= -40.0 and lPrimaryDirection1 < 0.5 ) and 0.5 or lPrimaryDirection2) -- left 10 degree - lPrimaryDirection1 = ((lAzimut >= -5.0 and lAzimut <= 40.0 and lPrimaryDirection1 == 0 ) and 0.6 or lPrimaryDirection1) -- right 10 degree - lPrimaryDirection2 = ((lAzimut >= -5.0 and lAzimut <= 40.0 and lPrimaryDirection1 < 0.6 ) and 0.6 or lPrimaryDirection2) -- right 10 degree - lPrimaryDirection1 = ((lAzimut >= 30.0 and lAzimut <= 70.5 and lPrimaryDirection1 == 0 ) and 0.7 or lPrimaryDirection1) -- right 30 degree - lPrimaryDirection2 = ((lAzimut >= 30.0 and lAzimut <= 70.5 and lPrimaryDirection1 < 0.7 ) and 0.7 or lPrimaryDirection2) -- right 30 degree - lPrimaryDirection1 = ((lAzimut >= 55.0 and lAzimut <= 125.0 and lPrimaryDirection1 == 0 ) and 0.8 or lPrimaryDirection1) -- right 50 degree - lPrimaryDirection2 = ((lAzimut >= 55.0 and lAzimut <= 125.0 and lPrimaryDirection1 < 0.8 ) and 0.8 or lPrimaryDirection2) -- right 50 degree - lPrimaryDirection1 = ((lAzimut >= 90.0 and lAzimut <= 170.0 and lPrimaryDirection1 == 0 ) and 0.9 or lPrimaryDirection1) -- right 90 degree - lPrimaryDirection2 = ((lAzimut >= 90.0 and lAzimut <= 170.0 and lPrimaryDirection1 < 0.9 ) and 0.9 or lPrimaryDirection2) -- right 90 degree - lPrimaryDirection1 = ((lAzimut >= 170.0 and lPrimaryDirection1 == 0 ) and 1.0 or lPrimaryDirection1) -- right back side - lPrimaryDirection2 = ((lAzimut >= 170.0 and lPrimaryDirection1 < 1.0 ) and 1.0 or lPrimaryDirection2) -- right back side - - -- power of the threat - lErmitterPower = ExportScript.Tools.round(lTWSInfo.Emitters[EmitterIndex].Power * 0.15, 2) + 0.01 - - -- type of the threat - local lPrimaryTypeTmp = FC_FindRadarTypeForSPO15(lTWSInfo, lPrimaryThreatTmp) - if lPrimaryTypeTmp.AIR == 1 then - lPrimaryType = 0.1 - elseif lPrimaryTypeTmp.LRR == 1 then - lPrimaryType = 0.2 - elseif lPrimaryTypeTmp.MRR == 1 then - lPrimaryType = 0.3 - elseif lPrimaryTypeTmp.SRR == 1 then - lPrimaryType = 0.4 - elseif lPrimaryTypeTmp.EWR == 1 then - lPrimaryType = 0.5 - elseif lPrimaryTypeTmp.AWACS == 1 then - lPrimaryType = 0.6 - end - -- look or missil on air - lLock = lPrimaryTypeTmp.Lock - -- hemisphere - lTopHemisphere = lPrimaryTypeTmp.TopHemisphere -- top hemisphere - lBottomHemisphere = lPrimaryTypeTmp.BottomHemisphere -- bottom hemisphere - if lPrimaryTypeTmp.TopHemisphere == 1 and lPrimaryTypeTmp.BottomHemisphere == 0 then - lHemisphere = 0.1 - elseif lPrimaryTypeTmp.TopHemisphere == 0 and lPrimaryTypeTmp.BottomHemisphere == 1 then - lHemisphere = 0.2 - elseif lPrimaryTypeTmp.TopHemisphere == 1 and lPrimaryTypeTmp.BottomHemisphere == 1 then - lHemisphere = 0.3 - end - - lPrimaryTypeTmp = nil - end - - -- secundary threat - -- direction to the threat - lSecondaryLeftBack = (lAzimut <= -170.0 and 1 or lSecondaryLeftBack) -- left back side - lSecondaryLeft90 = ((lAzimut <= -90.0 and lAzimut >= -170.0 ) and 1 or lSecondaryLeft90) -- left 90 degree - lSecondaryLeft50 = ((lAzimut <= -55.0 and lAzimut >= -125.0 ) and 1 or lSecondaryLeft50) -- left 50 degree - lSecondaryLeft30 = ((lAzimut <= -30.0 and lAzimut >= -70.5 ) and 1 or lSecondaryLeft30) -- left 30 degree - lSecondaryLeft10 = ((lAzimut <= 5.0 and lAzimut >= -40.0 ) and 1 or lSecondaryLeft10) -- left 10 degree - lSecondaryRight10 = ((lAzimut >= -5.0 and lAzimut <= 40.0 ) and 1 or lSecondaryRight10) -- right 10 degree - lSecondaryRight30 = ((lAzimut >= 30.0 and lAzimut <= 70.5 ) and 1 or lSecondaryRight30) -- right 30 degree - lSecondaryRight50 = ((lAzimut >= 55.0 and lAzimut <= 125.0 ) and 1 or lSecondaryRight50) -- right 50 degree - lSecondaryRight90 = ((lAzimut >= 90.0 and lAzimut <= 170.0 ) and 1 or lSecondaryRight90) -- right 90 degree - lSecondaryRightBack = (lAzimut >= 170.0 and 1 or lSecondaryRightBack) -- right back side - - end - - lSecondaryType = FC_FindRadarTypeForSPO15(lTWSInfo) - -- Power {1} - -- PrimaryDirection1 {Off = 0.0, LeftBack = 0.1, Left90 = 0.2, Left50 = 0.3, Left30 = 0.4, Left10 = 0.5, Right10 = 0.6, Right30 = 0.7, Right50 = 0.8, Right90 = 0.9, RightBack = 1.0} - -- PrimaryDirection2 {Off = 0.0, LeftBack = 0.1, Left90 = 0.2, Left50 = 0.3, Left30 = 0.4, Left10 = 0.5, Right10 = 0.6, Right30 = 0.7, Right50 = 0.8, Right90 = 0.9, RightBack = 1.0} - -- PrimaryType {Off = 0.0, AIR = 0.1, LRR = 0.2, MRR = 0.3, SRR = 0.4, EWR = 0.5 oder AWACS = 0.6} - -- lHemisphere {0.0 = all off, 0.1 = TopHemisphere, 0.2 = BottomHemisphere, 0.3 = all on} -- TopHemisphere {0, 1} -- BottomHemisphere {0, 1} - -- Lock {off = 0.0, missile = 0.1 (flashing), Lock = 0.2} - -- ErmitterPower {Off = 0.0, LED1 = 0.01, LED2 = 0.02, ... LED15 = 0.15} - -- SecondaryLeftBack {0, 1} - -- SecondaryLeft90 {0, 1} - -- SecondaryLeft50 {0, 1} - -- SecondaryLeft30 {0, 1} - -- SecondaryLeft10 {0, 1} - -- SecondaryRight10 {0, 1} - -- SecondaryRight30 {0, 1} - -- SecondaryRight50 {0, 1} - -- SecondaryRight90 {0, 1} - -- SecondaryRightBack {0, 1} - -- SecondaryType_AIR {0, 1} - -- SecondaryType_LRR {0, 1} - -- SecondaryType_MRR {0, 1} - -- SecondaryType_SRR {0, 1} - -- SecondaryType_EWR {0, 1} - -- SecondaryType_AWACS {0, 1} - SendData(lExportID, string.format("%d;%.1f;%.1f;%.1f;%.1f;%.1f;%.2f;%d;%d;%d;%d;%d;%d;%d;%d;%d;%d;%d;%d;%d;%d;%d;%d", - 1, - lPrimaryDirection1, - lPrimaryDirection2, - lPrimaryType, - lHemisphere, - lLock, - lErmitterPower, - lSecondaryLeftBack, - lSecondaryLeft90, - lSecondaryLeft50, - lSecondaryLeft30, - lSecondaryLeft10, - lSecondaryRight10, - lSecondaryRight30, - lSecondaryRight50, - lSecondaryRight90, - lSecondaryRightBack, - lSecondaryType.AIR, - lSecondaryType.LRR, - lSecondaryType.MRR, - lSecondaryType.SRR, - lSecondaryType.EWR, - lSecondaryType.AWACS)) - - else - SendData(lExportID, "1;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0") - end - end -end - --- HSI for SU25T, SU-27, SU-33, MIG-29 -function ExportScript.AF.FC_Russian_HSI(distancetoway) - local lDistanceToWay = distancetoway or 999 - - local lDefaultOne = 1.0 - local lDefaultNull = 0.0 - local lRadToDCSunsignd = math.pi * 2 - local lPitch,lBank,lYaw = LoGetADIPitchBankYaw() -- PITCH, BANK, YAW (Radian) - local lHSI_RMI = LoGetControlPanel_HSI().RMI_raw -- VOR1 OBS (Radian) - local lHSI_ADF = LoGetControlPanel_HSI().ADF_raw -- ADF OBS (Radian) - local lHSI_Curse = LoGetControlPanel_HSI().Course -- HSI Course (Radian) - local lGlide = LoGetGlideDeviation() -- VOR1 HORIZONTAL DEFLECTION (-1 +1) - local lSide = LoGetSideDeviation() -- VOR1 VERTICAL DEFLECTION (-1 +1) - local lHeading = LoGetSelfData().Heading -- HEADING (Radian) - lPitch, lBank = nil ---[[ - [Course] = number: "0.76548692098835" - [CourseDeviation] = number: "0" - [ADF_raw] = number: "5.5811524391174" - [BearingPointer] = number: "0.80134677481978" - [RMI_raw] = number: "5.4092655181885" - [HeadingPointer] = number: "0.098191173578347" - [Heading_raw] = number: "6.2831854820251" - ]] - --[[ - Ka-50 HSI - [112] = "%.4f", -- HSI_heading {0.0, 1.0} - [118] = "%.4f", -- HSI_commanded_course_needle {0.0, 1.0} - [124] = "%.4f", -- HSI_commanded_heading_needle {0.0, 1.0} - [115] = "%.4f", -- HSI_bearing_needle {0.0, 1.0} - [119] = "%0.1f", -- HSI_heading_warning_flag{0.0,1.0} - [114] = "%0.1f", -- HSI_course_warning_flag{0.0, 1.0} - [125] = "%0.1f", -- HSI_glideslope_warning_flag{0.0, 1.0} - [117] = "%0.4f", -- HSI_range_counter_100 {0.0,1.0} - [527] = "%0.4f", -- HSI_range_counter_10 {0.0,1.0} - [528] = "%0.4f", -- HSI_range_counter_1 {0.0,1.0} - [127] = "%.4f", -- HSI_longitudinal_deviation{-1.0, 1.0} - [128] = "%.4f", -- HSI_lateral_deviation{-1.0, 1.0} - [116] = "%0.1f", -- HSI_range_unavailable_flag{0.0, 1.0} - [121] = "%0.1f", -- HSI_course_unavailable_flag{0.0, 1.0} - ]] - local lAltCounter = {[0] = 0.0, [1] = 0.11, [2] = 0.22, [3] = 0.33, [4] = 0.44, [5] = 0.55, [6] = 0.66, [7] = 0.77, [8] = 0.88, [9] = 0.99} - lDistanceToWay = ExportScript.Tools.round(lDistanceToWay / 1000, 1) - local lDistanceToWayTmp = string.format("%03d", lDistanceToWay) - local lRangeCounter1 = 0 - local lRangeCounter2 = 0 - local lRangeCounter3 = 0 - if lDistanceToWay > 100 then - lRangeCounter1 = ExportScript.Tools.round((lDistanceToWay / 100), 0, "floor") * 0.11 - lRangeCounter1 = lRangeCounter1 - ExportScript.Tools.round(lRangeCounter1, 0, "floor") - end - if lDistanceToWay > 10 then - if lDistanceToWay > 100 then - lRangeCounter2 = (ExportScript.Tools.round((lDistanceToWay - (ExportScript.Tools.round(lDistanceToWay / 100, 0, "floor") * 100)), 0, "floor") / 10) * 0.11 - else - lRangeCounter2 = (lDistanceToWay / 10) * 0.11 - lRangeCounter2 = lRangeCounter2 - ExportScript.Tools.round(lRangeCounter2, 0, "floor") - end - end - if lDistanceToWay > 10 then - lRangeCounter3 = (lDistanceToWay - (ExportScript.Tools.round(lDistanceToWay / 10, 0, "floor") * 10)) * 0.11 - else - lRangeCounter3 = lDistanceToWay * 0.11 - end - - lHeading = (lHeading / lRadToDCSunsignd) - -- HSI_heading {0.0, 1.0} - -- HSI_commanded_course_needle {0.0, 1.0} - -- HSI_commanded_heading_needle {0.0, 1.0} - -- HSI_bearing_needle {0.0, 1.0} - -- HSI_heading_warning_flag{0.0,1.0} - -- HSI_course_warning_flag{0.0, 1.0} - -- HSI_glideslope_warning_flag{0.0, 1.0} - -- HSI_range_counter_100 {0.0,1.0} - -- HSI_range_counter_10 {0.0,1.0} - -- HSI_range_counter_1 {0.0,1.0} - -- HSI_longitudinal_deviation{-1.0, 1.0} - -- HSI_lateral_deviation{-1.0, 1.0} - -- HSI_range_unavailable_flag{0.0, 1.0} - -- HSI_course_unavailable_flag{0.0, 1.0} - --[[SendData(lExportID, string.format("%.4f;%.4f;%.4f;%.4f;%.1f;%.1f;%.1f;%.3f;%.3f;%.3f;%.4f;%.4f;%.1f;%.1f", - lHeading, -- compass card - (lHeading + (lHSI_Curse / lRadToDCSunsignd)) - 1, -- doppel pfeil - lHeading, -- gelbes dreieck - 0 - (lHeading + (lHSI_ADF / lRadToDCSunsignd)), -- gelber pfeil - lDefaultNull, -- KC Flag - lDefaultOne, -- K Flag (left) - lDefaultOne, -- L Flag (left) - lAltCounter[tonumber(string.sub(lDistanceToWayTmp, 1, 1))], - lAltCounter[tonumber(string.sub(lDistanceToWayTmp, 2, 2))], - lRangeCounter3, - lGlide, - lSide, - lDefaultNull, -- ??? - lDefaultNull)) -- deaktiviert die Course Anzeige]] - - ExportScript.Tools.SendData(11, string.format("%.4f", lHeading)) -- compass card - ExportScript.Tools.SendData(12, string.format("%.4f", ((lHeading + (lHSI_Curse / lRadToDCSunsignd)) - 1))) -- double arrow - ExportScript.Tools.SendData(13, string.format("%.4f", lHeading)) -- yellow triangle - ExportScript.Tools.SendData(14, string.format("%.4f", (0 - (lHeading + (lHSI_ADF / lRadToDCSunsignd))))) -- yellow arrow - ExportScript.Tools.SendData(15, lDefaultNull) -- KC Flag - ExportScript.Tools.SendData(16, lDefaultOne) -- K Flag - ExportScript.Tools.SendData(17, lDefaultOne) -- L Flag - ExportScript.Tools.SendData(18, string.format("%.4f", lAltCounter[tonumber(string.sub(lDistanceToWayTmp, 1, 1))])) - ExportScript.Tools.SendData(19, string.format("%.4f", lAltCounter[tonumber(string.sub(lDistanceToWayTmp, 2, 2))])) - ExportScript.Tools.SendData(20, string.format("%.4f", lRangeCounter3)) - ExportScript.Tools.SendData(21, string.format("%.4f", lGlide)) - ExportScript.Tools.SendData(22, string.format("%.4f", lSide)) - ExportScript.Tools.SendData(23, lDefaultNull) - ExportScript.Tools.SendData(24, lDefaultNull) -end - --- HSI for SU25A -function ExportScript.AF.FC_Russian_HSI_old() - - local lDefaultOne = 1.0 - local lDefaultNull = 0.0 - local lRadToDCSunsignd = math.pi * 2 - local lHSI_ADF = LoGetControlPanel_HSI().ADF_raw -- ADF OBS (Radian) - local lHSI_Curse = LoGetControlPanel_HSI().Course -- HSI Course (Radian) - local lGlide = LoGetGlideDeviation() -- VOR1 HORIZONTAL DEFLECTION (-1 +1) - local lSide = LoGetSideDeviation() -- VOR1 VERTICAL DEFLECTION (-1 +1) - local lHeading = LoGetSelfData().Heading -- HEADING (Radian) ---[[ - [Course] = number: "0.76548692098835" - [CourseDeviation] = number: "0" - [ADF_raw] = number: "5.5811524391174" - [BearingPointer] = number: "0.80134677481978" - [RMI_raw] = number: "5.4092655181885" - [HeadingPointer] = number: "0.098191173578347" - [Heading_raw] = number: "6.2831854820251" - ]] - - lHeading = (lHeading / lRadToDCSunsignd) - -- HSI_heading {0.0, 1.0} compass card - -- HSI_commanded_course_needle {0.0, 1.0} (Required heading) white needle - -- HSI_bearing_needle {0.0, 1.0} (RMI bearing) yellow needle - -- Flag Г (T){0.0,1.0} - -- Flag К (K){0.0,1.0} - -- ILS needle horizontal{-1.0, 1.0} - -- ILS needle vertical{-1.0, 1.0} - - --[[SendData(lExportID, string.format("%.4f;%.4f;%.4f;%.1f;%.1f;%.4f;%.4f", - lHeading, -- compass card - (lHeading + (lHSI_Curse / lRadToDCSunsignd)), -- - 1, -- white needle - 0 - (lHeading + (lHSI_ADF / lRadToDCSunsignd)), -- yellow needle - lDefaultOne, -- T Flag - lDefaultOne, -- K Flag - lGlide, - lSide))))]] - - ExportScript.Tools.SendData(11, string.format("%.4f", lHeading)) -- compass card - ExportScript.Tools.SendData(12, string.format("%.4f", (lHeading + (lHSI_Curse / lRadToDCSunsignd)))) -- white needle - ExportScript.Tools.SendData(13, string.format("%.4f", (0 - (lHeading + (lHSI_ADF / lRadToDCSunsignd))))) -- yellow needle - ExportScript.Tools.SendData(16, lDefaultOne) -- T Flag - ExportScript.Tools.SendData(17, lDefaultOne) -- K Flag - ExportScript.Tools.SendData(21, string.format("%.4f", lGlide)) - ExportScript.Tools.SendData(22, string.format("%.4f", lSide)) -end - --- HSI-Distance for SU25A -function ExportScript.AF.FC_Russian_HSI_Distance_old(distancetoway) - local lDistanceToWay = distancetoway or 999 - - local lAltCounter = {[0] = 0.0, [1] = 0.11, [2] = 0.22, [3] = 0.33, [4] = 0.44, [5] = 0.55, [6] = 0.66, [7] = 0.77, [8] = 0.88, [9] = 0.99} - lDistanceToWay = ExportScript.Tools.round(lDistanceToWay / 1000, 1) - local lDistanceToWayTmp = string.format("%03d", lDistanceToWay) - local lRangeCounter1 = 0 - local lRangeCounter2 = 0 - local lRangeCounter3 = 0 - if lDistanceToWay > 100 then - lRangeCounter1 = ExportScript.Tools.round((lDistanceToWay / 100), 0, "floor") * 0.11 - lRangeCounter1 = lRangeCounter1 - ExportScript.Tools.round(lRangeCounter1, 0, "floor") - end - if lDistanceToWay > 10 then - if lDistanceToWay > 100 then - lRangeCounter2 = (ExportScript.Tools.round((lDistanceToWay - (ExportScript.Tools.round(lDistanceToWay / 100, 0, "floor") * 100)), 0, "floor") / 10) * 0.11 - else - lRangeCounter2 = (lDistanceToWay / 10) * 0.11 - lRangeCounter2 = lRangeCounter2 - ExportScript.Tools.round(lRangeCounter2, 0, "floor") - end - end - if lDistanceToWay > 10 then - lRangeCounter3 = (lDistanceToWay - (ExportScript.Tools.round(lDistanceToWay / 10, 0, "floor") * 10)) * 0.11 - else - lRangeCounter3 = lDistanceToWay * 0.11 - end - - --[[SendData(lExportID, string.format("%.3f;%.3f;%.3f", - lAltCounter[tonumber(string.sub(lDistanceToWayTmp, 1, 1))], - lAltCounter[tonumber(string.sub(lDistanceToWayTmp, 2, 2))], - lRangeCounter3)) -- deaktiviert die Course Anzeige]] - - ExportScript.Tools.SendData(18, string.format("%.4f", lAltCounter[tonumber(string.sub(lDistanceToWayTmp, 1, 1))])) - ExportScript.Tools.SendData(19, string.format("%.4f", lAltCounter[tonumber(string.sub(lDistanceToWayTmp, 2, 2))])) - ExportScript.Tools.SendData(20, string.format("%.4f", lRangeCounter3)) -end - --- ADI for SU-25, SU25T, SU-27, MIG-29A and MIG-29S -function ExportScript.AF.FC_Russian_ADI_Old() - - local lDefaultNull = 0.0 - local lRadToDCSsignd = math.pi - local lNavInfoPitch = LoGetNavigationInfo().Requirements.pitch -- AP REQUIRED PITCH (Radian) - local lNavInfoRoll = LoGetNavigationInfo().Requirements.roll -- AP REQUIRED BANK (Radian) - local lPitch, lBank, lYaw = LoGetADIPitchBankYaw() -- PITCH, BANK, YAW (Radian) - local lSlipBallPosition = LoGetSlipBallPosition() -- SLIP BALL (-1 +1) --- ADI (IKP-81) - --------------------------------------------------- - --[[ - [100] = "%.4f", -- ADI_Roll {-1.0,1.0} - [101] = "%.4f", -- ADI_Pitch {-math.pi/2.0,math.pi/2.0}{1.0,-1.0} - [102] = "%0.1f", -- ADI_steering_warning_flag {0.0,1.0} - [109] = "%0.1f", -- ADI_attitude_warning_flag {0.0,1.0} - [107] = "%.4f", -- ADI_bank_steering {-1.0,1.0} - [106] = "%.4f", -- ADI_pitch_steering {-1.0,1.0} - [111] = "%.4f", -- ADI_airspeed_deviation {-1.0,1.0} - [103] = "%.4f", -- ADI_track_deviation {-1.0,1.0} - [526] = "%.4f", -- ADI_height_deviation {-1.0,1.0} - [108] = "%.4f", -- ADI_sideslip {-1.0,1.0} - ]] - lNavInfoPitch = lNavInfoPitch / lRadToDCSsignd - lNavInfoRoll = lNavInfoRoll / lRadToDCSsignd - lPitch = lPitch / (lRadToDCSsignd / 2) - lPitch = (lPitch > 0.0 and (0 - lPitch) or (lPitch + lPitch + lPitch)) -- pitch muss negiert werden - --lBank = lBank / (lRadToDCSsignd / 2) - lBank = lBank / lRadToDCSsignd - --[[SendData(lExportID, string.format("%.4f;%.4f;%.1f;%.1f;%.4f;%.4f;%.4f;%.4f;%.4f;%.4f", - lBank, - lPitch, - lDefaultNull, - lDefaultNull, - lNavInfoRoll, - lNavInfoPitch, - lDefaultNull, - lDefaultNull, - lDefaultNull, - lSlipBallPosition))]] - ExportScript.Tools.SendData(1, string.format("%.4f", lBank)) - ExportScript.Tools.SendData(2, string.format("%.4f", lPitch)) - ExportScript.Tools.SendData(3, lDefaultNull) - ExportScript.Tools.SendData(4, lDefaultNull) - ExportScript.Tools.SendData(5, string.format("%.4f", lNavInfoRoll)) - ExportScript.Tools.SendData(6, string.format("%.4f", lNavInfoPitch)) - ExportScript.Tools.SendData(7, lDefaultNull) - ExportScript.Tools.SendData(8, lDefaultNull) - ExportScript.Tools.SendData(9, lDefaultNull) - ExportScript.Tools.SendData(10, string.format("%.4f", lSlipBallPosition)) -end - --- ADI for SU-33 -function ExportScript.AF.FC_Russian_ADI_New() - - local lDefaultNull = 0.0 - local lRadToDCSsignd = math.pi - local lNavInfoPitch = LoGetNavigationInfo().Requirements.pitch -- AP REQUIRED PITCH (Radian) - local lNavInfoRoll = LoGetNavigationInfo().Requirements.roll -- AP REQUIRED BANK (Radian) - local lPitch, lBank, lYaw = LoGetADIPitchBankYaw() -- PITCH, BANK, YAW (Radian) - local lSlipBallPosition = LoGetSlipBallPosition() -- SLIP BALL (-1 +1) --- ADI - --------------------------------------------------- - --[[ - [100] = "%.4f", -- ADI_Roll {-1.0,1.0} - [101] = "%.4f", -- ADI_Pitch {-math.pi/2.0,math.pi/2.0}{1.0,-1.0} - [102] = "%0.1f", -- ADI_steering_warning_flag {0.0,1.0} - [109] = "%0.1f", -- ADI_attitude_warning_flag {0.0,1.0} - [107] = "%.4f", -- ADI_bank_steering {-1.0,1.0} - [106] = "%.4f", -- ADI_pitch_steering {-1.0,1.0} - [111] = "%.4f", -- ADI_airspeed_deviation {-1.0,1.0} - [103] = "%.4f", -- ADI_track_deviation {-1.0,1.0} - [526] = "%.4f", -- ADI_height_deviation {-1.0,1.0} - [108] = "%.4f", -- ADI_sideslip {-1.0,1.0} - ]] - lNavInfoPitch = lNavInfoPitch / lRadToDCSsignd - lNavInfoRoll = lNavInfoRoll / lRadToDCSsignd - lPitch = lPitch / (lRadToDCSsignd / 2) - lPitch = (lPitch > 0.0 and (0 - lPitch) or (lPitch + lPitch + lPitch)) -- pitch muss negiert werden - lBank = lBank / lRadToDCSsignd --(lRadToDCSsignd / 2) - --[[SendData(lExportID, string.format("%.4f;%.4f;%.1f;%.1f;%.4f;%.4f;%.4f;%.4f;%.4f;%.4f", - lBank, - lPitch, - lDefaultNull, - lDefaultNull, - lNavInfoRoll, - lNavInfoPitch, - lDefaultNull, - lDefaultNull, - lDefaultNull, - lSlipBallPosition))]] - - ExportScript.Tools.SendData(1, string.format("%.4f", lBank)) - ExportScript.Tools.SendData(2, string.format("%.4f", lPitch)) - ExportScript.Tools.SendData(3, lDefaultNull) - ExportScript.Tools.SendData(4, lDefaultNull) - ExportScript.Tools.SendData(5, string.format("%.4f", lNavInfoRoll)) - ExportScript.Tools.SendData(6, string.format("%.4f", lNavInfoPitch)) - ExportScript.Tools.SendData(7, lDefaultNull) - ExportScript.Tools.SendData(8, lDefaultNull) - ExportScript.Tools.SendData(9, lDefaultNull) - ExportScript.Tools.SendData(10, string.format("%.4f", lSlipBallPosition)) -end - --- Radar Altimeter for SU-25A, SU25-T, SU-27, SU-33 -function ExportScript.AF.FC_Russian_RadarAltimeter_1500m(warningflag) - local lWarning_Flag = warningflag or 100 - - local lScaleValue = 1500 - local lAltRad = LoGetAltitudeAboveGroundLevel() -- ALTITUDE GROUND LEVEL (Meter) - - lAltRad = lAltRad / lScaleValue -- (1500 m ist die maximalhoehe des Messgeraetes) - lAltRad = (lAltRad > 1.0 and 1.0 or lAltRad) -- the result is limited to 1.0 - local lDangerRALT = lWarning_Flag / lScaleValue -- 0.14 -- 50m ((50 * 1) / 350) - local lWarning_Flag = (lAltRad == 1.0 and 1.0 or 0.0) -- (Flag an wenn Hoehe auf 1.0 ist) - local lDangerRALT_Lamp = (lAltRad < lDangerRALT and 1.0 or 0.0) -- (Flag an wenn Hoehe niedriger als 0.14) - -- AltRad {0.0,1.0} - -- DangerRALT {0.0,1.0} - -- Warning_Flag {0, 1} - -- DangerRALT_Lamp {0, 1} - --[[SendData(lExportID, string.format("%.4f;%.4f;%d;%d", - lAltRad, - lDangerRALT, - lWarning_Flag, - lDangerRALT_Lamp)))]] - - ExportScript.Tools.SendData(25, string.format("%.4f", lAltRad)) - ExportScript.Tools.SendData(26, string.format("%.4f", lDangerRALT)) - ExportScript.Tools.SendData(27, lWarning_Flag) - ExportScript.Tools.SendData(28, lDangerRALT_Lamp) -end - --- Radar Altimeter for MiG-29A, MiG-29S -function ExportScript.AF.FC_Russian_RadarAltimeter_1000m(warningflag) - local lWarning_Flag = warningflag or 100 - - local lScaleValue = 1000 - local lAltRad = LoGetAltitudeAboveGroundLevel() -- ALTITUDE GROUND LEVEL (Meter) - - lAltRad = lAltRad / lScaleValue -- (1000 m ist die maximalhoehe des Messgeraetes) - lAltRad = (lAltRad > 1.0 and 1.0 or lAltRad) -- the result is limited to 1.0 - local lDangerRALT = lWarning_Flag / lScaleValue -- 0.14 -- 50m ((50 * 1) / 350) - local lWarning_Flag = (lAltRad == 1.0 and 1.0 or 0.0) -- (Flag an wenn Hoehe auf 1.0 ist) - local lDangerRALT_Lamp = (lAltRad < lDangerRALT and 1.0 or 0.0) -- (Flag an wenn Hoehe niedriger als 0.14) - -- AltRad {0.0,1.0} - -- DangerRALT {0.0,1.0} - -- Warning_Flag {0, 1} - -- DangerRALT_Lamp {0, 1} - --[[SendData(lExportID, string.format("%.4f;%.4f;%d;%d", - lAltRad, - lDangerRALT, - lWarning_Flag, - lDangerRALT_Lamp)))]] - - ExportScript.Tools.SendData(25, string.format("%.4f", lAltRad)) - ExportScript.Tools.SendData(26, string.format("%.4f", lDangerRALT)) - ExportScript.Tools.SendData(27, lWarning_Flag) - ExportScript.Tools.SendData(28, lDangerRALT_Lamp) -end - --- Barometric Altimeter for -function ExportScript.AF.FC_Russian_BarometricAltimeter(exportid) - local lExportID = exportid or 8 - - local lScaleValue = 1000 - local lBasicAtmospherePressure = LoGetBasicAtmospherePressure() -- BAROMETRIC PRESSURE (mm Hg) - local lAltBar = LoGetAltitudeAboveSeaLevel() -- ALTITUDE SEA LEVEL (Meter) - - local lAltCounter = {[0] = 0.0, [1] = 0.11, [2] = 0.22, [3] = 0.33, [4] = 0.44, [5] = 0.55, [6] = 0.66, [7] = 0.77, [8] = 0.88, [9] = 0.99} - local lAltBarTmp = string.format("%03d", lAltBar) - lAltBar = lAltBar + (9.5 * (760 - lBasicAtmospherePressure)) -- 9.5 m per 1mmHg difference , eventuell minus der Differenz - lBasicAtmospherePressure = string.format("%03d", lBasicAtmospherePressure) - - lAltBar = lAltBar / lScaleValue - lAltBar = lAltBar - ExportScript.Tools.round(lAltBar, 0, "floor") - - -- AltBar {0.0,1.0} - -- AltBar_1000 {0.0,1.0} - -- AltBar_100 {0.0,1.0} - -- AltBar_10 {0.0,1.0} - -- BasicAtmospherePressure_1000 {0.0,1.0} - -- BasicAtmospherePressure_100 {0.0,1.0} - -- BasicAtmospherePressure_10 {0.0,1.0} - -- Warning_Flag {0, 1} - SendData(lExportID, string.format("%.4f;%.2f;%.2f;%.2f;%.2f;%.2f;%.2f", - lAltBar, - lAltCounter[tonumber(string.sub(lAltBarTmp, 1, 1))], - lAltCounter[tonumber(string.sub(lAltBarTmp, 2, 2))], - lAltCounter[tonumber(string.sub(lAltBarTmp, 3, 3))], - lAltCounter[tonumber(string.sub(lBasicAtmospherePressure, 1, 1))], - lAltCounter[tonumber(string.sub(lBasicAtmospherePressure, 2, 2))], - lAltCounter[tonumber(string.sub(lBasicAtmospherePressure, 3, 3))], - 0)) -end - --- Barometric Altimeter for -function ExportScript.AF.FC_Russian_BarometricAltimeter(exportid) - local lExportID = exportid or 8 - - local lScaleValue = 1000 - local lBasicAtmospherePressure = LoGetBasicAtmospherePressure() -- BAROMETRIC PRESSURE (mm Hg) - local lAltBar = LoGetAltitudeAboveSeaLevel() -- ALTITUDE SEA LEVEL (Meter) - - local lAltCounter = {[0] = 0.0, [1] = 0.11, [2] = 0.22, [3] = 0.33, [4] = 0.44, [5] = 0.55, [6] = 0.66, [7] = 0.77, [8] = 0.88, [9] = 0.99} - local lAltBarTmp = string.format("%03d", lAltBar) - lAltBar = lAltBar + (9.5 * (760 - lBasicAtmospherePressure)) -- 9.5 m per 1mmHg difference , eventuell minus der Differenz - lBasicAtmospherePressure = string.format("%03d", lBasicAtmospherePressure) - - lAltBar = lAltBar / lScaleValue - lAltBar = lAltBar - ExportScript.Tools.round(lAltBar, 0, "floor") - - -- AltBar {0.0,1.0} - -- AltBar_1000 {0.0,1.0} - -- AltBar_100 {0.0,1.0} - -- AltBar_10 {0.0,1.0} - -- BasicAtmospherePressure_1000 {0.0,1.0} - -- BasicAtmospherePressure_100 {0.0,1.0} - -- BasicAtmospherePressure_10 {0.0,1.0} - -- Warning_Flag {0, 1} - SendData(lExportID, string.format("%.4f;%.2f;%.2f;%.2f;%.2f;%.2f;%.2f", - lAltBar, - lAltCounter[tonumber(string.sub(lAltBarTmp, 1, 1))], - lAltCounter[tonumber(string.sub(lAltBarTmp, 2, 2))], - lAltCounter[tonumber(string.sub(lAltBarTmp, 3, 3))], - lAltCounter[tonumber(string.sub(lBasicAtmospherePressure, 1, 1))], - lAltCounter[tonumber(string.sub(lBasicAtmospherePressure, 2, 2))], - lAltCounter[tonumber(string.sub(lBasicAtmospherePressure, 3, 3))], - 0)) -end - --- Barometric Altimeter for SU-25A, SU25-T -function ExportScript.AF.FC_Russian_BarometricAltimeter_late() - - local lBasicAtmospherePressure = LoGetBasicAtmospherePressure() -- BAROMETRIC PRESSURE (mm Hg) - local lAltBar = LoGetAltitudeAboveSeaLevel() -- ALTITUDE SEA LEVEL (Meter) - local lAltBar_kilometer_needle = 0 - local lAltBar_meter_needle = 0 - - lAltBar = lAltBar - ((9.5 * (760 - lBasicAtmospherePressure)) / 2) -- 9.5 m per 1mmHg difference - - if lAltBar > 10000 then - lAltBar_kilometer_needle = lAltBar / 100000 - else - lAltBar_kilometer_needle = lAltBar / 10000 - end - if lAltBar > 1000 then - lAltBar_meter_needle = lAltBar / 1000 - lAltBar_meter_needle = lAltBar_meter_needle - ExportScript.Tools.round(lAltBar_meter_needle, 0, "floor") - else - lAltBar_meter_needle = lAltBar / 1000 - end - lAltBar = lAltBar / 1000 - - -- AltBar_kilometer_needle {0.0,1.0} - -- AltBar_meter_needle {0.0,1.0} - -- BasicAtmospherePressure {600.0, 800.0} - -- AltBar_kilometer {0.0, 99.9} - --[[SendData(lExportID, string.format("%.4f;%.4f;%.4f;%.4f", - lAltBar_kilometer_needle, - lAltBar_meter_needle, - lBasicAtmospherePressure, - lAltBar))]] - - ExportScript.Tools.SendData(30, string.format("%.4f", lAltBar_kilometer_needle)) - ExportScript.Tools.SendData(31, string.format("%.4f", lAltBar_meter_needle)) - ExportScript.Tools.SendData(32, string.format("%.4f", lBasicAtmospherePressure)) - ExportScript.Tools.SendData(33, string.format("%.4f", lAltBar)) -end - --- Barometric Altimeter for SU-27, SU-33 -function ExportScript.AF.FC_Russian_BarometricAltimeter_20000() - - local lBasicAtmospherePressure = LoGetBasicAtmospherePressure() -- BAROMETRIC PRESSURE (mm Hg) - local lAltBar = LoGetAltitudeAboveSeaLevel() -- ALTITUDE SEA LEVEL (Meter) - local lAltBar_kilometer_needle = 0 - local lAltBar_meter_needle = 0 - - lAltBar = lAltBar - ((9.5 * (760 - lBasicAtmospherePressure)) / 2) -- 9.5 m per 1mmHg difference - - if lAltBar > 10000 then - lAltBar_kilometer_needle = lAltBar / 200000 - else - lAltBar_kilometer_needle = lAltBar / 20000 - end - if lAltBar > 1000 then - lAltBar_meter_needle = lAltBar / 1000 - lAltBar_meter_needle = lAltBar_meter_needle - ExportScript.Tools.round(lAltBar_meter_needle, 0, "floor") - else - lAltBar_meter_needle = lAltBar / 1000 - end - lBasicAtmospherePressure = (lBasicAtmospherePressure - 600) / 200 - - -- AltBar_kilometer_needle {0.0,1.0} - -- AltBar_meter_needle {0.0,1.0} - -- BasicAtmospherePressure {0.0, 1.0}={600.0, 800.0} - --[[SendData(lExportID, string.format("%.4f;%.4f;%.4f", - lAltBar_kilometer_needle, - lAltBar_meter_needle, - lBasicAtmospherePressure))]] - - ExportScript.Tools.SendData(30, string.format("%.4f", lAltBar_kilometer_needle)) - ExportScript.Tools.SendData(31, string.format("%.4f", lAltBar_meter_needle)) - ExportScript.Tools.SendData(32, string.format("%.4f", lBasicAtmospherePressure)) -end - --- Barometric Altimeter for MiG-29A, MiG-29S -function ExportScript.AF.FC_Russian_BarometricAltimeter_30000() - - local lBasicAtmospherePressure = LoGetBasicAtmospherePressure() -- BAROMETRIC PRESSURE (mm Hg) - local lAltBar = LoGetAltitudeAboveSeaLevel() -- ALTITUDE SEA LEVEL (Meter) - local lAltBar_kilometer_needle = 0 - local lAltBar_meter_needle = 0 - - lAltBar = lAltBar - ((9.5 * (760 - lBasicAtmospherePressure)) / 2) -- 9.5 m per 1mmHg difference - - if lAltBar > 10000 then - lAltBar_kilometer_needle = lAltBar / 300000 - else - lAltBar_kilometer_needle = lAltBar / 30000 - end - if lAltBar > 1000 then - lAltBar_meter_needle = lAltBar / 1000 - lAltBar_meter_needle = lAltBar_meter_needle - ExportScript.Tools.round(lAltBar_meter_needle, 0, "floor") - else - lAltBar_meter_needle = lAltBar / 1000 - end - lBasicAtmospherePressure = (lBasicAtmospherePressure - 600) / 200 - - -- AltBar_kilometer_needle {0.0,1.0} - -- AltBar_meter_needle {0.0,1.0} - -- BasicAtmospherePressure {0.0, 1.0}={600.0, 800.0} - --[[SendData(lExportID, string.format("%.4f;%.4f;%.4f", - lBasicAtmospherePressure, - lAltBar_meter_needle, - lAltBar_kilometer_needle))]] - - ExportScript.Tools.SendData(30, string.format("%.4f", lAltBar_kilometer_needle)) - ExportScript.Tools.SendData(31, string.format("%.4f", lAltBar_meter_needle)) - ExportScript.Tools.SendData(32, string.format("%.4f", lBasicAtmospherePressure)) -end - --- Air Speed Indicator for SU-25A, SU-25T -function ExportScript.AF.FC_Russian_AirSpeed_1100hkm() - - local lIAS = LoGetIndicatedAirSpeed() * 3.6 -- INDICATED AIRSPEED (Meter/Second to Km/h) - local lTAS = LoGetTrueAirSpeed() * 3.6 -- TRUE AIRSPEED (Meter/Second to Km/h) - - --[[ - y_min = 0.0 0.09 -- minimaler Ausgabewert - y_max = 0.09 1.0 -- maximaler Ausgabewert - x_min = 0 100 -- minimaler Eingangswert - x_max = 100 1100 -- maximaler Eingangswert - x = 50 700 -- aktueller Eingangswert - - d_y = 0.09 0.91 -- Delta Ausgabewerte (y_max - y_min) - d_x = 100 1000 -- Delta Eingangswerte (x_max - x_min) - m = 0.0009 0.00091 -- Steigung der linearen Funktion (d_y / d_x) - n = 0.0 -0.001 -- Schnittpunkt der Funktion mit y-Achse (y_max - m * x_max) - - y = 0,0171875 0,636 -- Ergebnis (m * x + n) - ]] - if lIAS > 100 then - lIAS = 0.00091 * lIAS + -0.001 - else - lIAS = 0.0009 * lIAS - end - - --[[ - y_min = 0.0 -- minimaler Ausgabewert - y_max = 1.0 -- maximaler Ausgabewert - x_min = 400 -- minimaler Eingangswert - x_max = 1100 -- maximaler Eingangswert - x = 800 -- aktueller Eingangswert - - d_y = 1.0 -- Delta Ausgabewerte (y_max - y_min) - d_x = 700 -- Delta Eingangswerte (x_max - x_min) - m = 0.00142857142857142857142857142857 -- Steigung der linearen Funktion (d_y / d_x) - n = -0.571428571428571428571428571427 -- Schnittpunkt der Funktion mit y-Achse (y_max - m * x_max) - - y = 0.571428571428571428571428571429 -- Ergebnis (m * x + n) - ]] - if lTAS > 400 then - lTAS = 0.00142857142857142857142857142857 * lTAS + -0.571428571428571428571428571427 - else - lTAS = 0.0 - end - - -- IAS {0.0,1.0} - -- TAS {0.0,1.0} - --[[SendData(lExportID, string.format("%.4f;%.4f", lIAS, lTAS))]] - - ExportScript.Tools.SendData(35, string.format("%.4f", lIAS)) - ExportScript.Tools.SendData(36, string.format("%.4f", lTAS)) -end - --- Air Speed Indicator for SU-27, SU-33 -function ExportScript.AF.FC_Russian_AirSpeed_1600hkm() - - local lScaleValueIAS = 1600 - local lScaleValueMach = 3.5 - local lIAS = LoGetIndicatedAirSpeed() * 3.6 -- INDICATED AIRSPEED (Meter/Second to Km/h) - local lMACH = LoGetMachNumber() -- MACH - local lMACHtmp = 0 - local lIAStmp = 0 - - if lIAS > 0 and lIAS <= 100 then - --[[ - y_min = 0.0 -- minimaler Ausgabewert - y_max = 0.03125 -- maximaler Ausgabewert - x_min = 0 -- minimaler Eingangswert - x_max = 100 -- maximaler Eingangswert - x = 55 -- aktueller Eingangswert - - d_y = 0.03125 -- Delta Ausgabewerte (y_max - y_min) - d_x = 100 -- Delta Eingangswerte (x_max - x_min) - m = 0.0003125 -- Steigung der linearen Funktion (d_y / d_x) - n = 0.0 -- Schnittpunkt der Funktion mit y-Achse (y_max - m * x_max) - - y = 0,0171875 -- Ergebnis (m * x + n) - ]] - lIAStmp = 0.0003125 * lIAS - elseif lIAS > 100 and lIAS <= 500 then - --[[ - y_min = 0.03125 -- minimaler Ausgabewert - y_max = 0.427 -- maximaler Ausgabewert - x_min = 100 -- minimaler Eingangswert - x_max = 500 -- maximaler Eingangswert - x = 250 -- aktueller Eingangswert - - d_y = 0.39575 -- Delta Ausgabewerte (y_max - y_min) - d_x = 400 -- Delta Eingangswerte (x_max - x_min) - m = 0.000989375 -- Steigung der linearen Funktion (d_y / d_x) - n = -0.0676875 -- Schnittpunkt der Funktion mit y-Achse (y_max - m * x_max) - - y = 0,0171875 -- Ergebnis (m * x + n) - ]] - lIAStmp = 0.000989375 * lIAS + -0.0676875 - elseif lIAS > 500 and lIAS <= 600 then - --[[ - y_min = 0.427 -- minimaler Ausgabewert - y_max = 0.51 -- maximaler Ausgabewert - x_min = 500 -- minimaler Eingangswert - x_max = 600 -- maximaler Eingangswert - x = 550 -- aktueller Eingangswert - - d_y = 0.083 -- Delta Ausgabewerte (y_max - y_min) - d_x = 100 -- Delta Eingangswerte (x_max - x_min) - m = 0.00083 -- Steigung der linearen Funktion (d_y / d_x) - n = 0.012 -- Schnittpunkt der Funktion mit y-Achse (y_max - m * x_max) - - y = 0.4685 -- Ergebnis (m * x + n) - ]] - lIAStmp = 0.00083 * lIAS + 0.012 - elseif lIAS > 600 and lIAS <= 1000 then - --[[ - y_min = 0.51 -- minimaler Ausgabewert - y_max = 0.753 -- maximaler Ausgabewert - x_min = 600 -- minimaler Eingangswert - x_max = 1000 -- maximaler Eingangswert - x = 800 -- aktueller Eingangswert - - d_y = 0.243 -- Delta Ausgabewerte (y_max - y_min) - d_x = 400 -- Delta Eingangswerte (x_max - x_min) - m = 0.0006075 -- Steigung der linearen Funktion (d_y / d_x) - n = 0.1455 -- Schnittpunkt der Funktion mit y-Achse (y_max - m * x_max) - - y = 0.6315 -- Ergebnis (m * x + n) - ]] - lIAStmp = 0.0006075 * lIAS + 0.1455 - elseif lIAS > 1000 and lIAS <= 1200 then - --[[ - y_min = 0.753 -- minimaler Ausgabewert - y_max = 0.84375 -- maximaler Ausgabewert - x_min = 1000 -- minimaler Eingangswert - x_max = 1200 -- maximaler Eingangswert - x = 1100 -- aktueller Eingangswert - - d_y = 0.09075 -- Delta Ausgabewerte (y_max - y_min) - d_x = 200 -- Delta Eingangswerte (x_max - x_min) - m = 0.00045375 -- Steigung der linearen Funktion (d_y / d_x) - n = 0.29925 -- Schnittpunkt der Funktion mit y-Achse (y_max - m * x_max) - - y = 0.798375 -- Ergebnis (m * x + n) - ]] - lIAStmp = 0.00045375 * lIAS + 0.29925 - elseif lIAS > 1200 and lIAS <= 1600 then - --[[ - y_min = 0.84375 -- minimaler Ausgabewert - y_max = 1.0 -- maximaler Ausgabewert - x_min = 1200 -- minimaler Eingangswert - x_max = 1600 -- maximaler Eingangswert - x = 1400 -- aktueller Eingangswert - - d_y = 0.15625 -- Delta Ausgabewerte (y_max - y_min) - d_x = 400 -- Delta Eingangswerte (x_max - x_min) - m = 0.000390625 -- Steigung der linearen Funktion (d_y / d_x) - n = 0.375 -- Schnittpunkt der Funktion mit y-Achse (y_max - m * x_max) - - y = 0.921875 -- Ergebnis (m * x + n) - ]] - lIAStmp = 0.000390625 * lIAS + 0.375 - end - - if lMACH > 0.6 and lMACH <= 0.9 then - --[[ - y_min = 0.0 -- minimaler Ausgabewert - y_max = 0.273 -- maximaler Ausgabewert - x_min = 0.6 -- minimaler Eingangswert - x_max = 0.9 -- maximaler Eingangswert - x = 0.75 -- aktueller Eingangswert - - d_y = 0.273 -- Delta Ausgabewerte (y_max - y_min) - d_x = 0.3 -- Delta Eingangswerte (x_max - x_min) - m = 0.91 -- Steigung der linearen Funktion (d_y / d_x) - n = -0.546 -- Schnittpunkt der Funktion mit y-Achse (y_max - m * x_max) - - y = 0.1365 -- Ergebnis (m * x + n) - ]] - lMACHtmp = 0.91 * lMACH + -0.546 - elseif lMACH > 0.9 and lMACH <= 1.5 then - --[[ - y_min = 0.273 -- minimaler Ausgabewert - y_max = 0.545 -- maximaler Ausgabewert - x_min = 0.9 -- minimaler Eingangswert - x_max = 1.5 -- maximaler Eingangswert - x = 1.3 -- aktueller Eingangswert - - d_y = 0.272 -- Delta Ausgabewerte (y_max - y_min) - d_x = 0.6 -- Delta Eingangswerte (x_max - x_min) - m = 0.45333333333333333333333333333333 -- Steigung der linearen Funktion (d_y / d_x) - n = -0.135 -- Schnittpunkt der Funktion mit y-Achse (y_max - m * x_max) - - y = 0.45433333333333333333333333333333 -- Ergebnis (m * x + n) - ]] - lMACHtmp = 0.45333333333333333333333333333333 * lMACH + -0.135 - elseif lMACH > 1.5 and lMACH <= 3.5 then - --[[ - y_min = 0.545 -- minimaler Ausgabewert - y_max = 1.0 -- maximaler Ausgabewert - x_min = 1.5 -- minimaler Eingangswert - x_max = 3.5 -- maximaler Eingangswert - x = 2.3 -- aktueller Eingangswert - - d_y = 0.455 -- Delta Ausgabewerte (y_max - y_min) - d_x = 2.0 -- Delta Eingangswerte (x_max - x_min) - m = 0.2275 -- Steigung der linearen Funktion (d_y / d_x) - n = 0.20375 -- Schnittpunkt der Funktion mit y-Achse (y_max - m * x_max) - - y = 0.727 -- Ergebnis (m * x + n) - ]] - lMACHtmp = 0.2275 * lMACH + 0.20375 - end - - -- IAS {0.0,1.0} - -- MACH {0.0,1.0} - --[[SendData(lExportID, string.format("%.4f;%.4f", lIAStmp, lMACHtmp))]] - - ExportScript.Tools.SendData(35, string.format("%.4f", lIAStmp)) - ExportScript.Tools.SendData(36, string.format("%.4f", lMACHtmp)) -end - --- Air Speed Indicator for MiG-29A, MiG-29S -function ExportScript.AF.FC_Russian_AirSpeed_1000hkm() - - local lIAS = LoGetIndicatedAirSpeed() * 3.6 -- INDICATED AIRSPEED (Meter/Second to Km/h) - local lThousand = 0.0 - - if lIAS > 1000 then - lThousand = 1.0 - elseif lIAS > 950 then - --[[ - y_min = 0.0 -- minimaler Ausgabewert - y_max = 1.0 -- maximaler Ausgabewert - x_min = 950 -- minimaler Eingangswert - x_max = 1001 -- maximaler Eingangswert - x = 980 -- aktueller Eingangswert - - d_y = 1.0 -- Delta Ausgabewerte (y_max - y_min) - d_x = 51.0 -- Delta Eingangswerte (x_max - x_min) - m = 0.01960784313725490196078431372549 -- Steigung der linearen Funktion (d_y / d_x) - n = -18.627450980392156862745098039215 -- Schnittpunkt der Funktion mit y-Achse (y_max - m * x_max) - - y = 0.5882352941176470588235294117652 -- Ergebnis (m * x + n) - ]] - lThousand = 0.01960784313725490196078431372549 * lIAS + -18.627450980392156862745098039215 - end - --[[ - y_min = 0.0 -- minimaler Ausgabewert - y_max = 1.0 -- maximaler Ausgabewert - x_min = 0.0 -- minimaler Eingangswert - x_max = 1000 -- maximaler Eingangswert - x = 880 -- aktueller Eingangswert - - d_y = 1.0 -- Delta Ausgabewerte (y_max - y_min) - d_x = 1000.0 -- Delta Eingangswerte (x_max - x_min) - m = 0.001 -- Steigung der linearen Funktion (d_y / d_x) - n = 0.0 -- Schnittpunkt der Funktion mit y-Achse (y_max - m * x_max) - - y = 0.88 -- Ergebnis (m * x + n) - ]] - lIAS = 0.001 * lIAS - lIAS = (lIAS > 1.0 and 1.0 or lIAS) -- the result is limited to 1.0 - - -- IAS {0.0,1.0} - -- Thousand {0.0,1.0} - --[[SendData(lExportID, string.format("%.4f;%.4f", lIAS, lThousand))]] - - ExportScript.Tools.SendData(35, string.format("%.4f", lIAS)) - ExportScript.Tools.SendData(36, string.format("%.4f", lThousand)) -end - --- Vertical Velocity Indicator (Old Style) for SU-25, SU25T, SU-27, MIG-29A and MIG-29S -function ExportScript.AF.FC_Russian_VVI_Old() - - local lVVI = LoGetVerticalVelocity() -- VERTICAL SPEED (Meter/Second) - local lPitch, lBank, lYaw = LoGetADIPitchBankYaw() -- PITCH, BANK, YAW (Radian) - lBank = math.deg(lBank) - local lSlipBallPosition = LoGetSlipBallPosition() -- SLIP BALL (-1 +1) - --local lTAS = LoGetTrueAirSpeed() -- TRUE AIRSPEED (Meter/Second) - --local lTurn = 0 - - if lVVI >= 0.0 then - lVVI = lVVI / 200 - lVVI = (lVVI > 1.0 and 1.0 or lVVI) -- the result is limited to 1.0 - else - lVVI = lVVI / 200 - lVVI = (lVVI < -1.0 and -1.0 or lVVI) -- the result is limited to -1.0 - end - - if lBank >= 0.0 then - lBank = lBank / 45 - lBank = (lBank > 1.0 and 1.0 or lBank) -- the result is limited to 1.0 - else - lBank = lBank / 45 - lBank = (lBank < -1.0 and -1.0 or lBank) -- the result is limited to -1.0 - end - --lTurn = lTAS / 187.628865979 -- TRUE AIRSPEED (Meter/Second) / 187.628865979 m/s = Turn-Winkel or True Airspeed in Knots/min / 364 Knots - --WriteToLog('lTurn: '..dump(lTurn)) - --WriteToLog('lVVI: '..dump(lVVI)..', lBank :'..dump(lBank)) - -- lVVI {-1.0, 0.0, 1.0} {0.0=0, 0.05=10, 0.10=20, 0.24=50, 0.49=100, 0.74=150, 1.0=200} - -- lBank {-1.0, 0.0,1.0} - -- lSlipBallPosition {0.0,1.0} - --[[SendData(lExportID, string.format("%.4f;%.4f;%.4f", - lVVI, - lBank, - lSlipBallPosition))]] - - ExportScript.Tools.SendData(40, string.format("%.4f", lVVI)) - ExportScript.Tools.SendData(41, string.format("%.4f", lBank)) - ExportScript.Tools.SendData(42, string.format("%.4f", lSlipBallPosition)) -end - --- VVI for SU-33 -function ExportScript.AF.FC_Russian_VVI_New() - - local lVVI = LoGetVerticalVelocity() -- VERTICAL SPEED (Meter/Second) - - --[[ - y_min = 0.0 0.325 -- minimaler Ausgabewert - y_max = 0.325 1.0 -- maximaler Ausgabewert - x_min = 0.0 20.0 -- minimaler Eingangswert - x_max = 20.0 60.0 -- maximaler Eingangswert - x = 5.0 40.0 -- aktueller Eingangswert - - d_y = 0.325 0.675 -- Delta Ausgabewerte (y_max - y_min) - d_x = 20.0 40.0 -- Delta Eingangswerte (x_max - x_min) - m = 0.01625 0.016875 -- Steigung der linearen Funktion (d_y / d_x) - n = 0.0 -0.0125 -- Schnittpunkt der Funktion mit y-Achse (y_max - m * x_max) - - y = 0.08125 0,6625 -- Ergebnis (m * x + n) - ]] - - if lVVI >= 0.0 then - if lVVI >= 0.0 and lVVI < 20.0 then - lVVI = 0.01625 * lVVI - else - lVVI = 0.016875 * lVVI + -0.0125 - end - lVVI = (lVVI > 1.0 and 1.0 or lVVI) - else - if lVVI <= 0.0 and lVVI < -20.0 then - lVVI = 0.01625 * lVVI - else - lVVI = 0.016875 * lVVI + -0.0125 - end - lVVI = (lVVI < -1.0 and -1.0 or lVVI) - end - - --[[SendData(lExportID, string.format("%.4f", lVVI))]] - - ExportScript.Tools.SendData(40, string.format("%.4f", lVVI)) -end - --- Airintake for SU-27 and SU-33 -function ExportScript.AF.FC_Russian_AirIntake() - - local lAirI = LoGetMechInfo().airintake.value - - --[[SendData(lExportID, string.format("%.4f;%.4f", lAirI, lAirI))]] - - ExportScript.Tools.SendData(45, string.format("%.4f", lAirI)) - ExportScript.Tools.SendData(46, string.format("%.4f", lAirI)) -end - --- AOA Indicator and Accelerometer (AOA, GLoad) for SU-25, SU25T -function ExportScript.AF.FC_Russian_AOA_Su25() - - local lAoA = LoGetAngleOfAttack() -- ANGLE OF ATTACK AoA (Radian) - local lAccelerationUnits = LoGetAccelerationUnits().y -- G-LOAD - - -- AOA Indicator and Accelerometer (AOA, GLoad) - if lAoA > 0.0 then -- positive AOA - --[[ - y_min = 0.0 -- minimaler Ausgabewert - y_max = 1.0 -- maximaler Ausgabewert - x_min = 0.0 -- minimaler Eingangswert - x_max = 40.0 -- maximaler Eingangswert - x = 1.4 -- aktueller Eingangswert - - d_y = 1.0 -- Delta Ausgabewerte (y_max - y_min) - d_x = 40.0 -- Delta Eingangswerte (x_max - x_min) - m = 0.025 -- Steigung der linearen Funktion (d_y / d_x) - n = 0.0 -- Schnittpunkt der Funktion mit y-Achse (y_max - m * x_max) - - y = 0.035 -- Ergebnis (m * x + n) - ]] - lAoA = 0.025 * lAoA - else - --[[ - y_min = 0.0 -- minimaler Ausgabewert - y_max = -0.28 -- maximaler Ausgabewert - x_min = 0.0 -- minimaler Eingangswert - x_max = -10.0 -- maximaler Eingangswert - x = -3.2 -- aktueller Eingangswert - - d_y = -0.28 -- Delta Ausgabewerte (y_max - y_min) - d_x = -10.0 -- Delta Eingangswerte (x_max - x_min) - m = 0.028 -- Steigung der linearen Funktion (d_y / d_x) - n = 0.0 -- Schnittpunkt der Funktion mit y-Achse (y_max - m * x_max) - - y = -0.0896 -- Ergebnis (m * x + n) - ]] --0.14 - lAoA = 0.028 * lAoA - end - - if lAccelerationUnits > 0.0 then -- positive AOA - --[[ - y_min = 0.0 -- minimaler Ausgabewert - y_max = 1.0 -- maximaler Ausgabewert - x_min = 0.0 -- minimaler Eingangswert - x_max = 11.0 -- maximaler Eingangswert - x = 2.5 -- aktueller Eingangswert - - d_y = 1.0 -- Delta Ausgabewerte (y_max - y_min) - d_x = 11.0 -- Delta Eingangswerte (x_max - x_min) - m = 0.09090909090909090909090909090909 -- Steigung der linearen Funktion (d_y / d_x) - n = 0.0 -- Schnittpunkt der Funktion mit y-Achse (y_max - m * x_max) - - y = 0,22727272727272727272727272727273 -- Ergebnis (m * x + n) - ]] - lAccelerationUnits = 0.09090909090909090909090909090909 * lAccelerationUnits - else - --[[ - y_min = 0.0 -- minimaler Ausgabewert - y_max = -0.40625 -- maximaler Ausgabewert - x_min = 0.0 -- minimaler Eingangswert - x_max = -2.2125720977783 -- maximaler Eingangswert - x = -0.5 -- aktueller Eingangswert - - d_y = -0.40625 -- Delta Ausgabewerte (y_max - y_min) - d_x = -2.2125720977783 -- Delta Eingangswerte (x_max - x_min) - m = 0.18360983599491558834620754850374 -- Steigung der linearen Funktion (d_y / d_x) - n = 2.559143240842e-33 -- Schnittpunkt der Funktion mit y-Achse (y_max - m * x_max) - - y = -0.09180491799745779417310377425187 -- Ergebnis (m * x + n) - ]] - lAccelerationUnits = 0.18360983599491558834620754850374 * lAccelerationUnits + 2.559143240842e-33 - end - - --[[SendData(lExportID, string.format("%.4f;%.4f", - lAoA, - lAccelerationUnits) )]] - - ExportScript.Tools.SendData(50, string.format("%.4f", lAoA)) - ExportScript.Tools.SendData(51, string.format("%.4f", lAccelerationUnits)) -end - --- AOA Indicator and Accelerometer (AOA, GLoad) for SU-27, SU33 -function ExportScript.AF.FC_Russian_AOA_Su2733() - - local lAoA = LoGetAngleOfAttack() -- ANGLE OF ATTACK AoA (Radian) - local lAccelerationUnits = LoGetAccelerationUnits().y -- G-LOAD - - if lAoA > 0.0 then -- positive AOA - --[[ - y_min = 0.0 -- minimaler Ausgabewert - y_max = 1.0 -- maximaler Ausgabewert - x_min = 0.0 -- minimaler Eingangswert - x_max = 40.0 -- maximaler Eingangswert - x = 1.4 -- aktueller Eingangswert - - d_y = 1.0 -- Delta Ausgabewerte (y_max - y_min) - d_x = 40.0 -- Delta Eingangswerte (x_max - x_min) - m = 0.025 -- Steigung der linearen Funktion (d_y / d_x) - n = 0.0 -- Schnittpunkt der Funktion mit y-Achse (y_max - m * x_max) - - y = 0.035 -- Ergebnis (m * x + n) - ]] - lAoA = 0.025 * lAoA - else - --[[ - y_min = 0.0 -- minimaler Ausgabewert - y_max = -0.28 -- maximaler Ausgabewert - x_min = 0.0 -- minimaler Eingangswert - x_max = -10.0 -- maximaler Eingangswert - x = -3.2 -- aktueller Eingangswert - - d_y = -0.28 -- Delta Ausgabewerte (y_max - y_min) - d_x = -10.0 -- Delta Eingangswerte (x_max - x_min) - m = 0.028 -- Steigung der linearen Funktion (d_y / d_x) - n = 0.0 -- Schnittpunkt der Funktion mit y-Achse (y_max - m * x_max) - - y = -0.0896 -- Ergebnis (m * x + n) - ]] --0.14 - lAoA = 0.028 * lAoA - end - - if lAccelerationUnits > 0.0 then -- positive AOA - --[[ - y_min = 0.0 -- minimaler Ausgabewert - y_max = 1.0 -- maximaler Ausgabewert - x_min = 0.0 -- minimaler Eingangswert - x_max = 11.0 -- maximaler Eingangswert - x = 2.5 -- aktueller Eingangswert - - d_y = 1.0 -- Delta Ausgabewerte (y_max - y_min) - d_x = 11.0 -- Delta Eingangswerte (x_max - x_min) - m = 0.09090909090909090909090909090909 -- Steigung der linearen Funktion (d_y / d_x) - n = 0.0 -- Schnittpunkt der Funktion mit y-Achse (y_max - m * x_max) - - y = 0.22727272727272727272727272727273 -- Ergebnis (m * x + n) - ]] - lAccelerationUnits = 0.09090909090909090909090909090909 * lAccelerationUnits - else - --[[ - y_min = 0.0 -- minimaler Ausgabewert - y_max = -0.40625 -- maximaler Ausgabewert - x_min = 0.0 -- minimaler Eingangswert - x_max = -4.2 -- maximaler Eingangswert - x = -0.5 -- aktueller Eingangswert - - d_y = -0.40625 -- Delta Ausgabewerte (y_max - y_min) - d_x = -4.2 -- Delta Eingangswerte (x_max - x_min) - m = 0.09672619047619047619047619047619 -- Steigung der linearen Funktion (d_y / d_x) - n = 0.0 -- Schnittpunkt der Funktion mit y-Achse (y_max - m * x_max) - - y = -0.09180491799745779417310377425187 -- Ergebnis (m * x + n) - ]] - lAccelerationUnits = 0.09672619047619047619047619047619 * lAccelerationUnits - end - - --[[SendData(lExportID, string.format("%.4f;%.4f", - lAoA, - lAccelerationUnits) )]] - - ExportScript.Tools.SendData(50, string.format("%.4f", lAoA)) - ExportScript.Tools.SendData(51, string.format("%.4f", lAccelerationUnits)) -end - --- AOA Indicator and Accelerometer (AOA, GLoad) for MiG-29A, MiG-29S -function ExportScript.AF.FC_Russian_AOA_MiG29() - - local lAoA = LoGetAngleOfAttack() -- ANGLE OF ATTACK AoA (Radian) - local lAccelerationUnits = LoGetAccelerationUnits().y -- G-LOAD - - if lAoA > 0.0 then -- positive AOA - --[[ - y_min = 0.0 -- minimaler Ausgabewert - y_max = 0.7812 -- maximaler Ausgabewert - x_min = 0.0 -- minimaler Eingangswert - x_max = 30.0 -- maximaler Eingangswert - x = 5.4 -- aktueller Eingangswert - - d_y = 0.7812 -- Delta Ausgabewerte (y_max - y_min) - d_x = 30.0 -- Delta Eingangswerte (x_max - x_min) - m = 0.02604 -- Steigung der linearen Funktion (d_y / d_x) - n = 0.0 -- Schnittpunkt der Funktion mit y-Achse (y_max - m * x_max) - - y = 0.1406 -- Ergebnis (m * x + n) - ]] - lAoA = 0.03333333333333333333333333333333 * lAoA - else - --[[ - y_min = 0.0 -- minimaler Ausgabewert - y_max = -0.28 -- maximaler Ausgabewert - x_min = 0.0 -- minimaler Eingangswert - x_max = -5.5 -- maximaler Eingangswert - x = -2.1 -- aktueller Eingangswert - - d_y = -0.28 -- Delta Ausgabewerte (y_max - y_min) - d_x = -5.5 -- Delta Eingangswerte (x_max - x_min) - m = 0,05090909090909090909090909090909 -- Steigung der linearen Funktion (d_y / d_x) - n = 0 -- Schnittpunkt der Funktion mit y-Achse (y_max - m * x_max) - - y = -0.10691 -- Ergebnis (m * x + n) - ]] - lAoA = 0.05090909090909090909090909090909 * lAoA - end - - if lAccelerationUnits > 0.0 then -- positive AOA - --[[ - y_min = 0.0 -- minimaler Ausgabewert - y_max = 1.0 -- maximaler Ausgabewert - x_min = 0.0 -- minimaler Eingangswert - x_max = 11.0 -- maximaler Eingangswert - x = 2.5 -- aktueller Eingangswert - - d_y = 1.0 -- Delta Ausgabewerte (y_max - y_min) - d_x = 11.0 -- Delta Eingangswerte (x_max - x_min) - m = 0.09090909090909090909090909090909 -- Steigung der linearen Funktion (d_y / d_x) - n = 0.0 -- Schnittpunkt der Funktion mit y-Achse (y_max - m * x_max) - - y = 0.22727272727272727272727272727273 -- Ergebnis (m * x + n) - ]] - lAccelerationUnits = 0.09090909090909090909090909090909 * lAccelerationUnits - else - --[[ - y_min = 0.0 -- minimaler Ausgabewert - y_max = -0.40625 -- maximaler Ausgabewert - x_min = 0.0 -- minimaler Eingangswert - x_max = -4.2 -- maximaler Eingangswert - x = -0.5 -- aktueller Eingangswert - - d_y = -0.40625 -- Delta Ausgabewerte (y_max - y_min) - d_x = -4.2 -- Delta Eingangswerte (x_max - x_min) - m = 0.09672619047619047619047619047619 -- Steigung der linearen Funktion (d_y / d_x) - n = 0.0 -- Schnittpunkt der Funktion mit y-Achse (y_max - m * x_max) - - y = -0.09180491799745779417310377425187 -- Ergebnis (m * x + n) - ]] - lAccelerationUnits = 0.09672619047619047619047619047619 * lAccelerationUnits - end - - --[[SendData(lExportID, string.format("%.4f;%.4f", - lAoA, - lAccelerationUnits) )]] - - ExportScript.Tools.SendData(50, string.format("%.4f", lAoA)) - ExportScript.Tools.SendData(51, string.format("%.4f", lAccelerationUnits)) -end - --- Russian Clock ACS-1 for KA-50, SU-25A, MIG-29A , MIG-29S -function ExportScript.AF.FC_Russian_Clock_ACS1() - - local lDefaultOne = 1.0 - local lDefaultNull = 0.0 - - local lCurrentClock = LoGetMissionStartTime() + LoGetModelTime() -- in seconds - local lCurrentHours = lCurrentClock / 43200 -- (3600 * 12) - lCurrentHours = lCurrentHours - ExportScript.Tools.round(lCurrentHours, 0, "floor") - local lCurrentMinutes = lCurrentClock / 3600 -- (60 * 60) - lCurrentMinutes = lCurrentMinutes - ExportScript.Tools.round(lCurrentMinutes, 0, "floor") - local lCurrentSeconds = lCurrentClock / 60 - lCurrentSeconds = lCurrentSeconds - ExportScript.Tools.round(lCurrentSeconds, 0, "floor") - local lFlightTimeHours = LoGetModelTime() / 43200 - lFlightTimeHours = lFlightTimeHours - ExportScript.Tools.round(lFlightTimeHours, 0, "floor") - local lFlightTimeMinutes = LoGetModelTime() / 3600 - lFlightTimeMinutes = lFlightTimeMinutes - ExportScript.Tools.round(lFlightTimeMinutes, 0, "floor") - -- currtime_hours {0.0,1.0} - -- currtime_minutes {0.0,1.0} - -- currtime_seconds {0.0,1.0} - -- flight_time_meter_status{0.0,0.2} - -- flight_hours {0.0,1.0} - -- flight_minutes {0.0,1.0} - -- seconds_meter_time_minutes {0.0,1.0} - -- seconds_meter_time_seconds {0.0,1.0} - --[[SendData(lExportID, string.format("%.4f;%.4f;%.4f;%.1f;%.4f;%.4f;%.4f;%.4f", - lCurrentHours, - lCurrentMinutes, - lCurrentSeconds, - lDefaultNull, -- red/white flag - lFlightTimeHours, - lFlightTimeMinutes, - lDefaultNull, - lDefaultNull))]] - - ExportScript.Tools.SendData(55, string.format("%.4f", lCurrentHours)) - ExportScript.Tools.SendData(56, string.format("%.4f", lCurrentMinutes)) - ExportScript.Tools.SendData(57, string.format("%.4f", lCurrentSeconds)) - ExportScript.Tools.SendData(58, lDefaultNull) -- red/white flag - ExportScript.Tools.SendData(59, string.format("%.4f", lFlightTimeHours)) - ExportScript.Tools.SendData(60, string.format("%.4f", lFlightTimeMinutes)) - ExportScript.Tools.SendData(61, lDefaultNull) - ExportScript.Tools.SendData(62, lDefaultNull) -end - --- Russian Clock (latest Model) for SU-25T, SU-27, SU-33 -function ExportScript.AF.FC_Russian_Clock_late() - - local lDefaultOne = 1.0 - local lDefaultNull = 0.0 - - local lCurrentClock = LoGetMissionStartTime() + LoGetModelTime() -- in seconds - local lCurrentHours = lCurrentClock / 43200 -- (3600 * 12) - lCurrentHours = lCurrentHours - ExportScript.Tools.round(lCurrentHours, 0, "floor") - local lCurrentMinutes = lCurrentClock / 3600 -- (60 * 60) - lCurrentMinutes = lCurrentMinutes - ExportScript.Tools.round(lCurrentMinutes, 0, "floor") - local lCurrentSeconds = lCurrentClock / 60 - lCurrentSeconds = lCurrentSeconds - ExportScript.Tools.round(lCurrentSeconds, 0, "floor") - local lFlightTimeHours = LoGetModelTime() / 43200 - lFlightTimeHours = lFlightTimeHours - ExportScript.Tools.round(lFlightTimeHours, 0, "floor") - local lFlightTimeMinutes = LoGetModelTime() / 3600 - lFlightTimeMinutes = lFlightTimeMinutes - ExportScript.Tools.round(lFlightTimeMinutes, 0, "floor") - -- currtime_hours {0.0,1.0} - -- currtime_minutes {0.0,1.0} - -- currtime_seconds {0.0,1.0} - -- flight_time_meter_status{0.0,0.2} - -- flight_hours {0.0,1.0} - -- flight_minutes {0.0,1.0} - -- seconds_meter_time_seconds {0.0,1.0} - --[[SendData(lExportID, string.format("%.4f;%.4f;%.4f;%.1f;%.4f;%.4f;%.4f", - lCurrentHours, - lCurrentMinutes, - lCurrentSeconds, - lDefaultNull, -- red/white flag - lFlightTimeHours, - lFlightTimeMinutes, - lCurrentSeconds))]] - - ExportScript.Tools.SendData(55, string.format("%.4f", lCurrentHours)) - ExportScript.Tools.SendData(56, string.format("%.4f", lCurrentMinutes)) - ExportScript.Tools.SendData(57, string.format("%.4f", lCurrentSeconds)) - ExportScript.Tools.SendData(58, lDefaultNull) -- red/white flag - ExportScript.Tools.SendData(59, string.format("%.4f", lFlightTimeHours)) - ExportScript.Tools.SendData(60, string.format("%.4f", lFlightTimeMinutes)) - ExportScript.Tools.SendData(61, string.format("%.4f", lCurrentSeconds)) -end - --- Russian Enging RPM (Tachometer) for SU-25A+T, SU-27, SU-33, MIG-29 -function ExportScript.AF.FC_Russian_EngineRPM() - - local lScaleValue = 110 - local lEngineRPMleft = LoGetEngineInfo().RPM.left -- ENG1 RPM % - local lEngineRPMright = LoGetEngineInfo().RPM.right -- ENG2 RPM % - - lEngineRPMleft = lEngineRPMleft / lScaleValue - lEngineRPMleft = (lEngineRPMleft > 1.0 and 1.0 or lEngineRPMleft) -- the result is limited to 1.0 - lEngineRPMright = lEngineRPMright / lScaleValue - lEngineRPMright = (lEngineRPMright > 1.0 and 1.0 or lEngineRPMright) -- the result is limited to 1.0 - -- EngineRPMleft {0.0,1.0} - -- EngineRPMright {0.0,1.0} - --[[SendData(lExportID, string.format("%.4f;%.4f", lEngineRPMleft, lEngineRPMright))]] - - ExportScript.Tools.SendData(65, string.format("%.4f", lEngineRPMleft)) - ExportScript.Tools.SendData(66, string.format("%.4f", lEngineRPMright)) -end - --- Russian Exthaus Gas Temperature 1.000GradC for SU-25A, SU25T, MIG-29 -function ExportScript.AF.FC_Russian_EGT_1000gc(egttemp, exportid) - local lEGTtemp = egttemp or 1 - local lExportID = exportid or 70 - - --[[ - y_min = 0.0 0.068 -- minimaler Ausgabewert - y_max = 0.068 1.0 -- maximaler Ausgabewert - x_min = 0 200 -- minimaler Eingangswert - x_max = 200 1080 -- maximaler Eingangswert - x = 100 650 -- aktueller Eingangswert - - d_y = 0.068 0.932 -- Delta Ausgabewerte (y_max - y_min) - d_x = 200 880 -- Delta Eingangswerte (x_max - x_min) - m = 0.00034 0.00105909090909090909090909090909 -- Steigung der linearen Funktion (d_y / d_x) - n = 0 -0.1438181818181818181818181818172 -- Schnittpunkt der Funktion mit y-Achse (y_max - m * x_max) - - y = 0.034 0.5445909090909090909090909090913 -- Ergebnis (m * x + n) - ]] - - if lEGTtemp < 200 then - lEGTtemp = 0.00034 * lEGTtemp - else - lEGTtemp = 0.00105909090909090909090909090909 * lEGTtemp + -0.1438181818181818181818181818172 - end - - -- ExthausGasTemperature {0.0,1.0} - ExportScript.Tools.SendData(lExportID, string.format("%.4f", lEGTtemp)) -end - --- Russian Mechanical Device Indicator for SU-25A+T -function ExportScript.AF.FC_Russian_MDI_SU25(FunctionTyp) - local lFunctionTyp = FunctionTyp or "Ikarus" - - local lMechInfo = LoGetMechInfo() -- mechanical components, e.g. Flaps, Wheelbrakes,... - if lMechInfo == nil then - return - end - local lTrueAirSpeed = LoGetTrueAirSpeed() - if lTrueAirSpeed == nil then - return - end - - local lWarningLight = 0.0 - lWarningLight = ((lMechInfo.flaps.value > 0.93 and lTrueAirSpeed > 340) and 1.0 or 0.0) -- Speed Warning for Flaps, same light as gear warning light, but blinking light - lWarningLight = (((lMechInfo.gear.status == 1 and lMechInfo.gear.value < 1) or (lMechInfo.gear.status == 0 and lMechInfo.gear.value > 0)) and 1.0 or lWarningLight ) -- gear warning light - -- WarningLight {0.0 = Off, 0.1 = blinking light, 0.2 = on} - -- WarningLight {0.0 = Off, no blinking light, 1.0 = on} - -- nose gear {0, 1} - -- left gear {0, 1} - -- right gear {0, 1} - -- speedbreakes on {0, 1} - -- flap 1. position {0, 1} - -- flap 2. position {0, 1} - --[[SendData(lExportID, string.format("%.1f;%d;%d;%d;%d;%d;%d", - lWarningLight, - (lMechInfo.gear.value > 0.85 and 1 or 0), -- nose gear - (lMechInfo.gear.value > 0.95 and 1 or 0), -- left gear - (lMechInfo.gear.value == 1 and 1 or 0), -- right gear - (lMechInfo.speedbrakes.value > 0.1 and 1 or 0), -- speedbreakes on > 0.1 (0 - 1) - (lMechInfo.flaps.value > 0.25 and 1 or 0), -- flap 1. position - (lMechInfo.flaps.value > 0.93 and 1 or 0))) -- flap 2. position]] - - if ExportScript.Config.IkarusExport and lFunctionTyp == "Ikarus" then - ExportScript.Tools.SendData(500, string.format("%.1f", lWarningLight)) - ExportScript.Tools.SendData(501, (lMechInfo.gear.value > 0.85 and 1 or 0)) -- nose gear - ExportScript.Tools.SendData(502, (lMechInfo.gear.value > 0.95 and 1 or 0)) -- left gear - ExportScript.Tools.SendData(503, (lMechInfo.gear.value == 1 and 1 or 0)) -- right gear - ExportScript.Tools.SendData(510, (lMechInfo.speedbrakes.value > 0.1 and 1 or 0)) -- speedbreakes on > 0.1 (0 - 1) - ExportScript.Tools.SendData(531, (lMechInfo.flaps.value > 0.25 and 1 or 0)) -- flap 1. position - ExportScript.Tools.SendData(532, (lMechInfo.flaps.value > 0.93 and 1 or 0)) -- flap 2. position - end - - if ExportScript.Config.DACExport and lFunctionTyp == "DAC" then - ExportScript.Tools.SendDataDAC(500, (((lMechInfo.gear.status == 1 and lMechInfo.gear.value < 1) or (lMechInfo.gear.status == 0 and lMechInfo.gear.value > 0)) and 1 or 0 )) - ExportScript.Tools.SendDataDAC(501, (lMechInfo.gear.value > 0.85 and 1 or 0)) -- nose gear - ExportScript.Tools.SendDataDAC(502, (lMechInfo.gear.value > 0.95 and 1 or 0)) -- left gear - ExportScript.Tools.SendDataDAC(503, (lMechInfo.gear.value == 1 and 1 or 0)) -- right gear - ExportScript.Tools.SendDataDAC(510, (lMechInfo.speedbrakes.value > 0.1 and 1 or 0)) -- speedbreakes on > 0.1 (0 - 1) - ExportScript.Tools.SendDataDAC(531, (lMechInfo.flaps.value > 0.25 and 1 or 0)) -- flap 1. position - ExportScript.Tools.SendDataDAC(532, (lMechInfo.flaps.value > 0.93 and 1 or 0)) -- flap 2. position - ExportScript.Tools.SendDataDAC(533, ((lMechInfo.flaps.value > 0.93 and lTrueAirSpeed > 340) and 1 or 0)) -- Speed Warning for Flaps, same light as gear warning light, but blinking light - end -end - --- Russian System Test EKRAN -function ExportScript.AF.FC_EKRAN() - - local lMCPState = LoGetMCPState() -- Warning Lights - if lMCPState == nil then - return - end - local lDisplayWindow = "" -- Message - local lFAILlight = "" -- FAILURE - local lMEMORYlight = "" -- MEMORY - local lTURNlight = "" -- TURN - if gDisplayWindow == nil then - gFC_EKRAN_active = {false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false} - gDisplayWindow = "" - end - - if lMCPState.LeftTailPlaneFailure and not gFC_EKRAN_active[1] then - lDisplayWindow = "LEFT\nTAIL\nPLANE\nFAILURE" - gFC_EKRAN_active[1] = true - elseif lMCPState.RightTailPlaneFailure and not gFC_EKRAN_active[2] then - lDisplayWindow = "RIGHT\nTAIL\nPLANE\nFAILURE" - gFC_EKRAN_active[2] = true - elseif lMCPState.MasterWarning and not gFC_EKRAN_active[3] then - ---lDisplayWindow = "MASTER\nWARNING" -- don't display - gFC_EKRAN_active[3] = true - elseif lMCPState.LeftEngineFailure and not gFC_EKRAN_active[4] then - lDisplayWindow = "LEFT\nENGINE\nFAILURE" - gFC_EKRAN_active[4] = true - elseif lMCPState.RightEngineFailure and not gFC_EKRAN_active[5] then - lDisplayWindow = "RIGHT\nENGINE\nFAILURE" - gFC_EKRAN_active[5] = true - elseif lMCPState.RightAileronFailure and not gFC_EKRAN_active[6] then - lDisplayWindow = "RIGHT\nAILERON\nFAILURE" - gFC_EKRAN_active[6] = true - elseif lMCPState.LeftMainPumpFailure and not gFC_EKRAN_active[7] then - lDisplayWindow = "LEFT\nMAIN\nPUMP\nFAILURE" - gFC_EKRAN_active[7] = true - elseif lMCPState.RightMainPumpFailure and not gFC_EKRAN_active[8] then - lDisplayWindow = "RIGHT\nMAIN\nPUMP\nFAILURE" - gFC_EKRAN_active[8] = true - elseif lMCPState.LeftWingPumpFailure and not gFC_EKRAN_active[9] then - lDisplayWindow = "LEFT\nWING\nPUMP\nFAILURE" - gFC_EKRAN_active[10] = true - elseif lMCPState.RightWingPumpFailure and not gFC_EKRAN_active[10] then - lDisplayWindow = "RIGHT\nWING\nPUMP\nFAILURE" - gFC_EKRAN_active[10] = true - elseif lMCPState.EOSFailure and not gFC_EKRAN_active[11] then - lDisplayWindow = "EOS\nFAILURE" - gFC_EKRAN_active[11] = true - elseif lMCPState.ECMFailure and not gFC_EKRAN_active[12] then - lDisplayWindow = "ECM\nFAILURE" - gFC_EKRAN_active[12] = true - elseif lMCPState.CannonFailure and not gFC_EKRAN_active[13] then - lDisplayWindow = "CANNON\nFAILURE" - gFC_EKRAN_active[13] = true - elseif lMCPState.MLWSFailure and not gFC_EKRAN_active[14] then - lDisplayWindow = "MLWS\nFAILURE" - gFC_EKRAN_active[14] = true - elseif lMCPState.ACSFailure and not gFC_EKRAN_active[15] then - lDisplayWindow = "ACS\nFAILURE" - gFC_EKRAN_active[15] = true - elseif lMCPState.RadarFailure and not gFC_EKRAN_active[16] then - lDisplayWindow = "RADAR\nFAILURE" - gFC_EKRAN_active[16] = true - elseif lMCPState.HelmetFailure and not gFC_EKRAN_active[17] then - lDisplayWindow = "HELMET\nFAILURE" - gFC_EKRAN_active[17] = true - elseif lMCPState.HUDFailure and not gFC_EKRAN_active[18] then - lDisplayWindow = "HUD\nFAILURE" - gFC_EKRAN_active[18] = true - elseif lMCPState.MFDFailure and not gFC_EKRAN_active[19] then - lDisplayWindow = "MFD\nFAILURE" - gFC_EKRAN_active[19] = true - elseif lMCPState.RWSFailure and not gFC_EKRAN_active[20] then - lDisplayWindow = "RWS\nFAILURE" - gFC_EKRAN_active[20] = true - elseif lMCPState.GearFailure and not gFC_EKRAN_active[21] then - lDisplayWindow = "GEAR\nFAILURE" - gFC_EKRAN_active[21] = true - elseif lMCPState.HydraulicsFailure and not gFC_EKRAN_active[22] then - lDisplayWindow = "HYDRAULICS\nFAILURE" - gFC_EKRAN_active[22] = true - elseif lMCPState.AutopilotFailure and not gFC_EKRAN_active[23] then - --lDisplayWindow = "AUTOPILOT\nFAILURE" -- bug in DCS, error is always active - gFC_EKRAN_active[23] = true - elseif lMCPState.FuelTankDamage and not gFC_EKRAN_active[24] then - lDisplayWindow = "FUEL\nTANK\nDAMAGE" - gFC_EKRAN_active[24] = true - end - - if lDisplayWindow ~= "" then - gDisplayWindow = lDisplayWindow - end - if gDisplayWindow ~= "" then - lFAILlight = " FAILURE" - end - -- DisplayWindow (main message) - -- FAILlight (failure text) - -- MEMORYlight (memmory text) - -- TURNlight (turn text) - --[[SendData(lExportID, string.format("%s;%s;%s;%s", - gDisplayWindow, - lFAILlight, - lMEMORYlight, - lTURNlight))]] - - ExportScript.Tools.SendData(80, string.format("%s;", gDisplayWindow)) - ExportScript.Tools.SendData(81, string.format("%s;", lFAILlight)) - ExportScript.Tools.SendData(82, string.format("%s;", lMEMORYlight)) - ExportScript.Tools.SendData(83, string.format("%s;", lTURNlight)) -end - --- ADI for A-10A, F-15C -function ExportScript.AF.FC_US_ADI(exportid) - local lExportID = exportid or 20 - - local lDefaultNull = 0.0 - local lRadToDCSsignd = math.pi - local lNavInfoPitch = LoGetNavigationInfo().Requirements.pitch -- AP REQUIRED PITCH (Radian) - local lNavInfoRoll = LoGetNavigationInfo().Requirements.roll -- AP REQUIRED BANK (Radian) - local lPitch, lBank, lYaw = LoGetADIPitchBankYaw() -- PITCH, BANK, YAW (Radian) - local lSlipBallPosition = LoGetSlipBallPosition() -- SLIP BALL (-1 +1) - local lGlide = LoGetGlideDeviation() -- VOR1 HORIZONTAL DEFLECTION (-1 +1) - --local lSide = LoGetSideDeviation() -- VOR1 VERTICAL DEFLECTION (-1 +1) - --[[ ADI from A-10C - [17] = "%.4f", -- ADI Pitch - [18] = "%.4f", -- ADI Bank - [24] = "%.4f", -- ADI Slip Ball - [20] = "%.4f", -- ADI Bank Steering Bar - [21] = "%.4f", -- ADI Pitch Steering Bar - [23] = "%.4f", -- ADI Turn Needle - [27] = "%.4f", -- ADI Glide-Slope Indicator - [26] = "%0.1f", -- ADI Glide-Slope Warning Flag - [25] = "%0.1f", -- ADI Attitude Warning Flag - [19] = "%0.1f", -- ADI Course Warning Flag - ]] - lNavInfoPitch = lNavInfoPitch / lRadToDCSsignd - lNavInfoRoll = lNavInfoRoll / lRadToDCSsignd - lNavInfoPitch = (lNavInfoPitch > 0.0 and (0 - lNavInfoPitch) or (lNavInfoPitch - lNavInfoPitch - lNavInfoPitch)) - lPitch = lPitch / (lRadToDCSsignd / 1.5) - lPitch = (lPitch > 0.0 and (0 - lPitch) or (lPitch - lPitch - lPitch)) -- pitch muss negiert werden - lBank = lBank / lRadToDCSsignd - SendData(lExportID, string.format("%.4f;%.4f;%.1f;%.1f;%.4f;%.4f;%.4f;%.1f;%.1f;%.1f", - lPitch, - lBank, - lSlipBallPosition, - lNavInfoRoll, - lNavInfoPitch, - lBank, -- as Turn Needle - lGlide, - lDefaultNull, - lDefaultNull, - lDefaultNull)) -end - --- Standby ADI for A-10A, F-15C -function ExportScript.AF.FC_US_stbyADI(exportid) - local lExportID = exportid or 21 - - local lDefaultNull = 0.0 - local lRadToDCSsignd = math.pi - local lPitch, lBank, lYaw = LoGetADIPitchBankYaw() -- PITCH, BANK, YAW (Radian) - --local lSide = LoGetSideDeviation() -- VOR1 VERTICAL DEFLECTION (-1 +1) - -- [63] = "%.4f", -- Standby Attitude Indicator pitch {-1.0, 1.0} - -- [64] = "%.4f", -- Standby Attitude Indicator bank {-1.0, 1.0} - -- [65] = "%0.1f", -- Standby Attitude Indicator warning flag {0.0, 1.0} - lPitch = lPitch / (lRadToDCSsignd / 1.5) - --lPitch = (lPitch > 0.0 and (0 - lPitch) or (lPitch + lPitch + lPitch)) -- pitch muss negiert werden - lBank = lBank / lRadToDCSsignd - lBank = (lBank > 0.0 and (0 - lBank) or (lBank - lBank - lBank)) -- Bank muss negiert werden - SendData(lExportID, string.format("%.4f;%.4f;%.1f", - lPitch, - lBank, - lDefaultNull)) -end - --- HSI for A-10A, F-15C -function ExportScript.AF.FC_US_HSI(distancetoway, exportid) - local lDistanceToWay = distancetoway or 999 - local lExportID = exportid or 22 - - local lDefaultOne = 1.0 - local lDefaultNull = 0.0 - local lRadToDCSunsignd = math.pi * 2 - local lPitch,lBank,lYaw = LoGetADIPitchBankYaw() -- PITCH, BANK, YAW (Radian) - local lHSI_RMI = LoGetControlPanel_HSI().RMI_raw -- VOR1 OBS (Radian) - local lHSI_ADF = LoGetControlPanel_HSI().ADF_raw -- ADF OBS (Radian) - local lHSI_Curse = LoGetControlPanel_HSI().Course -- HSI Course (Radian) - local lHeading = LoGetSelfData().Heading -- HEADING (Radian) - lPitch, lBank = nil ---[[ - [Course] = number: "0.76548692098835" - [CourseDeviation] = number: "0" - [ADF_raw] = number: "5.5811524391174" - [BearingPointer] = number: "0.80134677481978" - [RMI_raw] = number: "5.4092655181885" - [HeadingPointer] = number: "0.098191173578347" - [Heading_raw] = number: "6.2831854820251" - ]] - --[[ HSI A-10C - [34] = "%.4f", -- HSI Heading - [33] = "%.4f", -- HSI Bearing #1 - [35] = "%.4f", -- HSI Bearing #2 - [36] = "%.4f", -- HSI Heading Marker - [47] = "%.4f", -- HSI Course Arrow - [41] = "%.4f", -- HSI Deviation - [29] = "%.2f", -- HSI range_counter_100 - [30] = "%.2f", -- HSI range_counter_10 - [31] = "%.2f", -- HSI range_counter_1 - [42] = "%0.1f", -- HSI Bearing to_from_1 - [43] = "%0.1f", -- HSI Bearing to_from_2 - [46] = "%0.1f", -- HSI Bearing Flag - [40] = "%0.1f", -- HSI Power Flag - [32] = "%0.1f", -- HSI Range Flag - ]] - lDistanceToWay = lDistanceToWay * 0.00062136994937697 -- meter to miles - --lDistanceToWay = ExportScript.Tools.round(lDistanceToWay / 1000, 1) - local lRangeCounter1 = 0 - local lRangeCounter2 = 0 - local lRangeCounter3 = 0 - if lDistanceToWay > 100 then - lRangeCounter1 = ExportScript.Tools.round((lDistanceToWay / 100), 0, "floor") * 0.11 - lRangeCounter1 = lRangeCounter1 - ExportScript.Tools.round(lRangeCounter1, 0, "floor") - end - if lDistanceToWay > 10 then - if lDistanceToWay > 100 then - lRangeCounter2 = (ExportScript.Tools.round((lDistanceToWay - (ExportScript.Tools.round(lDistanceToWay / 100, 0, "floor") * 100)), 0, "floor") / 10) * 0.11 - else - lRangeCounter2 = (lDistanceToWay / 10) * 0.11 - lRangeCounter2 = lRangeCounter2 - ExportScript.Tools.round(lRangeCounter2, 0, "floor") - end - end - if lDistanceToWay > 10 then - lRangeCounter3 = (lDistanceToWay - (ExportScript.Tools.round(lDistanceToWay / 10, 0, "floor") * 10)) * 0.11 - else - lRangeCounter3 = lDistanceToWay * 0.11 - end - - lHeading = 1.0 - (lHeading / lRadToDCSunsignd) - lHSI_Curse = (lHSI_Curse / lRadToDCSunsignd) - lHSI_ADF = (lHSI_ADF / lRadToDCSunsignd) - -- HSI Heading {0.0, 1.0} - -- HSI Bearing #1 {0.0, 1.0} - -- HSI Bearing #2 {0.0, 1.0} - -- HSI Heading Marker {0.0, 1.0} - -- HSI Course Arrow {0.0, 1.0} - -- HSI Deviation {0.0, 1.0} - -- HSI range_counter_100 - -- HSI range_counter_10 - -- HSI range_counter_1 - -- HSI Bearing to_from_1 - -- HSI Bearing to_from_2 - -- HSI Bearing Flag - -- HSI Power Flag - -- HSI Range Flag - SendData(lExportID, string.format("%.4f;%.1f;%.1f;%.1f;%.4f;%.4f;%.3f;%.3f;%.3f;%.1f;%.1f;%.1f;%.1f;%.1f", - lHeading, -- compass card - lHSI_Curse, -- Bearing #1 - lHSI_Curse, -- Bearing #2 - lDefaultNull, - lHSI_Curse, - lHSI_ADF, - lRangeCounter1, - lRangeCounter2, - lRangeCounter3, - lDefaultNull, - lDefaultNull, - lDefaultNull, - lDefaultNull, - lDefaultNull)) -- deaktiviert die Course Anzeige -end - --- VVI for A-10A, F-15C -function ExportScript.AF.FC_US_VVI(exportid) - local lExportID = exportid or 15 - local lVVITmp = LoGetVerticalVelocity() * 196.8504 -- VERTICAL SPEED (Meter/Second to Foots/Minute) - -- {-1.0, -0.5, -0.29, 0.29, 0.5, 1.0} - --{-6000, -2000, -1000, 1000, 2000, 6000} - --WriteToLog('lVVITmp 1: '..dump(lVVITmp)) - if lVVITmp >= 0.0 then - --[[ - y_min = 0.0 0.29 0.503 0.765 -- minimaler Ausgabewert - y_max = 0.29 0.503 0.765 1.0 -- maximaler Ausgabewert - x_min = 0.0 1000.0 2000.0 4000.0 -- minimaler Eingangswert - x_max = 1000.0 2000.0 4000.0 6000.0 -- maximaler Eingangswert - x = 500.0 1600.0 2250.0 5500.0 -- aktueller Eingangswert - - d_y = 0.29 0.213 0.262 0.235 -- Delta Ausgabewerte (y_max - y_min) - d_x = 1000.0 1000.0 2000.0 2000.0 -- Delta Eingangswerte (x_max - x_min) - m = 0.00029 0.000213 0.000131 0.0001175 -- Steigung der linearen Funktion (d_y / d_x) - n = 0.0 0.077 0.241 0.295 -- Schnittpunkt der Funktion mit y-Achse (y_max - m * x_max) - - y = 0.145 0.4178 0.53575 0.94125 -- Ergebnis (m * x + n) - ]] - if lVVITmp >= 4000 then - lVVITmp = 0.0001175 * lVVITmp + 0.295 - elseif lVVITmp >= 2000 then - lVVITmp = 0.000131 * lVVITmp + 0.241 - elseif lVVITmp >= 1000 then - lVVITmp = 0.000213 * lVVITmp + 0.077 - else - lVVITmp = 0.00029 * lVVITmp - end - lVVITmp = (lVVITmp > 1.0 and 1.0 or lVVITmp) -- the result is limited to 1.0 - else - --[[ - y_min = -0.0 -0.29 -0.503 -0.765 -- minimaler Ausgabewert - y_max = -0.29 -0.503 -0.765 -1.0 -- maximaler Ausgabewert - x_min = -0.0 -1000.0 -2000.0 -4000.0 -- minimaler Eingangswert - x_max = -1000.0 -2000.0 -4000.0 -6000.0 -- maximaler Eingangswert - x = -500.0 -1600.0 -2250.0 -5500.0 -- aktueller Eingangswert - - d_y = -0.29 -0.213 -0.262 -0.235 -- Delta Ausgabewerte (y_max - y_min) - d_x = -1000.0 -1000.0 -2000.0 -2000.0 -- Delta Eingangswerte (x_max - x_min) - m = 0.00029 0.000213 0.000131 0.0001175 -- Steigung der linearen Funktion (d_y / d_x) - n = 0.0 -0.077 -0.241 -0.295 -- Schnittpunkt der Funktion mit y-Achse (y_max - m * x_max) - - y = -0.145 -0.4178 -0.53575 -0.94125 -- Ergebnis (m * x + n) - ]] - if lVVITmp <= 0 and lVVITmp > -1000 then - lVVITmp = 0.00029 * lVVITmp - elseif lVVITmp <= -1000 and lVVITmp > -2000 then - lVVITmp = 0.000213 * lVVITmp + -0.077 - elseif lVVITmp <= -2000 and lVVITmp > -4000 then - lVVITmp = 0.000131 * lVVITmp + -0.241 - else - lVVITmp = 0.0001175 * lVVITmp + -0.295 - end - - lVVITmp = (lVVITmp < -1.0 and -1.0 or lVVITmp) -- the result is limited to -1.0 - end - SendData(lExportID, string.format("%.4f", lVVITmp)) -end - --- AOA Indicator (AOA) for A-10A, F-15C -function ExportScript.AF.FC_US_AOA(exportid) - local lExportID = exportid or 16 - local lRadToDCSsignd = math.pi - local lAoA = LoGetAngleOfAttack() -- ANGLE OF ATTACK AoA (Radian) ---WriteToLog('lAoA 1: '..dump(lAoA)) - lAoA = (lAoA / 0.3) + 0.38 - --lAoA = ((lAoA / lRadToDCSsignd) * 10) + 0.38 - --[[ - lAoA = lAoA / (lRadToDCSsignd / 10) - if lAoA >= 0.0 then - lAoA = lAoA + 0.4 - lAoA = lAoA / 18 - else - lAoA = lAoA + 0.4 - lAoA = lAoA / 12 - end - ]] ---WriteToLog('lAoA 2: '..dump(lAoA)) - SendData(lExportID, string.format("%.4f", lAoA) ) -end - --- Accelerometer (GLoad) for A-10A, F-15C -function ExportScript.AF.FC_US_GLOAD(exportid) - local lExportID = exportid or 17 - - local lAccelerationUnits = LoGetAccelerationUnits().y -- G-LOAD - - lAccelerationUnits = (lAccelerationUnits / 15) + 0.33 - - SendData(lExportID, string.format("%.4f;0;0", lAccelerationUnits) ) -end - --- US Clock for A-10A, F-15C -function ExportScript.AF.FC_US_Clock(exportid) - local lExportID = exportid or 18 - - local lDefaultOne = 1.0 - local lDefaultNull = 0.0 - - local lCurrentClock = LoGetMissionStartTime() + LoGetModelTime() -- in seconds - local lCurrentHours = lCurrentClock / 43200 -- (3600 * 12) - lCurrentHours = lCurrentHours - ExportScript.Tools.round(lCurrentHours, 0, "floor") - local lCurrentMinutes = lCurrentClock / 3600 -- (60 * 60) - lCurrentMinutes = lCurrentMinutes - ExportScript.Tools.round(lCurrentMinutes, 0, "floor") - local lCurrentSeconds = lCurrentClock / 60 - lCurrentSeconds = lCurrentSeconds - ExportScript.Tools.round(lCurrentSeconds, 0, "floor") - -- currtime_hours {0.0,1.0} - -- currtime_minutes {0.0,1.0} - -- currtime_seconds {0.0,1.0} - SendData(lExportID, string.format("%.4f;%.4f;%.4f", - lCurrentHours, - lCurrentMinutes, - lCurrentSeconds)) -end - --- US Standby Compass for A-10A, F-15C -function ExportScript.AF.FC_US_Compass(exportid) - local lExportID = exportid or 19 - - local lDefaultNull = 0.0 - local lHeading = math.deg(LoGetSelfData().Heading) -- HEADING (Radian to Grad) - --local lHeading = math.deg(LoGetMagneticYaw()) -- HEADING (Radian to Grad) - --lHeading = 360 - lHeading -- muss umgerechnet werden?? - - --[[ - y_min = 1.0 -- minimaler Ausgabewert - y_max = -1.0 -- maximaler Ausgabewert - x_min = 0.0 -- minimaler Eingangswert - x_max = 360.00 -- maximaler Eingangswert - x = 185.5 -- aktueller Eingangswert - - d_y = -2.0 -- Delta Ausgabewerte (y_max - y_min) - d_x = 360.0 -- Delta Eingangswerte (x_max - x_min) - m = -0,00555555555555555555555555555556 -- Steigung der linearen Funktion (d_y / d_x) - n = 1.0 -- Schnittpunkt der Funktion mit y-Achse (y_max - m * x_max) - - y = 0.4995680345615518 -- Ergebnis (m * x + n) - ]] - lHeading = -0.00555555555555555555555555555556 * lHeading + 1.0 - - SendData(lExportID, string.format("%0.4f;%0.4f;%0.4f", - lHeading, -- heading - lDefaultNull, -- pitch - lDefaultNull)) -- bank -end - --- US F-15C Exaust Gas Temperature -function ExportScript.AF.FC_F15C_ExaustGasTemp(value, exportid) - local lValue = value or 1 - local lExportID = exportid or 1 - local lValueTmp = lValue - - local lCounter = {[0] = 0.0, [1] = 0.1, [2] = 0.2, [3] = 0.3, [4] = 0.4, [5] = 0.5, [6] = 0.6, [7] = 0.7, [8] = 0.8, [9] = 0.9} - local lCounter3 = 0 - local lValueTmp2 = lValueTmp - - lValueTmp2 = lValueTmp2 / 100 - lValueTmp2 = string.format("%02d", lValueTmp2) - - if lValueTmp > 100 then - lCounter3 = (lValueTmp - (ExportScript.Tools.round(lValueTmp / 100, 0, "floor") * 100)) * 0.01 - else - lCounter3 = lValueTmp * 0.01 - end - - --[[ - y_min = 0.0 0.08 -- minimaler Ausgabewert - y_max = 0.08 1.0 -- maximaler Ausgabewert - x_min = 0 200 -- minimaler Eingangswert - x_max = 200 1400 -- maximaler Eingangswert - x = 100 650 -- aktueller Eingangswert - - d_y = 0.08 0.92 -- Delta Ausgabewerte (y_max - y_min) - d_x = 200 1200 -- Delta Eingangswerte (x_max - x_min) - m = 0.0004 7.6666666666666666666666666666667e-4 -- Steigung der linearen Funktion (d_y / d_x) - n = 0 -0.07333333333333333333333333333333 -- Schnittpunkt der Funktion mit y-Achse (y_max - m * x_max) - - y = 0.04 0,425 -- Ergebnis (m * x + n) - ]] - - if lValueTmp > 200 then - lValue = 7.6666666666666666666666666666667e-4 * lValueTmp + -0.07333333333333333333333333333333 - else - lValue = 0.0004 * lValueTmp - end - - SendData(lExportID, string.format("%.4f;%.2f;%.2f;%.2f", - lValue, - lCounter[tonumber(string.sub(lValueTmp2, 1, 1))], - lCounter[tonumber(string.sub(lValueTmp2, 2, 2))], - lCounter3)) -end - --- A-10A Exaust Gas Temperature -function ExportScript.AF.FC_A10A_ExaustGasTemp(value, exportid) - local lValue = value or 1 - local lExportID = exportid or 1 - local lValueTmp = lValue - - --[[ - y_min = 0.0 -- minimaler Ausgabewert - y_max = 1.0 -- maximaler Ausgabewert - x_min = 100.0 -- minimaler Eingangswert - x_max = 1100.00 -- maximaler Eingangswert - x = 605.5 -- aktueller Eingangswert - - d_y = 1.0 -- Delta Ausgabewerte (y_max - y_min) - d_x = 1000.0 -- Delta Eingangswerte (x_max - x_min) - m = 0.001 -- Steigung der linearen Funktion (d_y / d_x) - n = -0.1 -- Schnittpunkt der Funktion mit y-Achse (y_max - m * x_max) - - y = 0.5055 -- Ergebnis (m * x + n) - ]] - lValue = 0.001 * lValue + -0.1 - - local lv1, lValueTmp = math.modf(lValueTmp / 100) -- 100 = Secound Scala - - SendData(lExportID, string.format("%.4f;%.4f", lValue, lValueTmp)) -end - --- Gauges with 2 needles (small and large), --- for example: --- A-10A RPM Engine --- Su-27/33 Exthaus Gas Temperature 1.200GradC -function ExportScript.AF.FC_TwoNeedlesGauge(value, mainscala, secondscale, exportid) - local lValue = value or 1 - local lMainScala = mainscala or 100 - local lSecondScale = secondscale or 10 - local lExportID = exportid or 1 - local lValueTmp = lValue - - lValue = lValue / lMainScala - lValue = (lValue > 1.0 and 1.0 or lValue) -- the result is limited to 1.0 - - --lValueTmp = lValueTmp - (ExportScript.Tools.round((lValueTmp / lSecondScale), 0, "floor") * lSecondScale) - --lValueTmp = lValueTmp / lSecondScale - --lValueTmp = (lValueTmp > 1.0 and 1.0 or lValueTmp) -- the result is limited to 1.0 - local lv1, lValueTmp = math.modf(lValueTmp / lSecondScale) - - SendData(lExportID, string.format("%.4f;%.4f", lValue, lValueTmp)) -end - --- Gauges with 1 needle, --- for example: --- A-10A RPM FAN, RPM APU, Exaust Gas Temperature APU, Fuel Flow, Oil Pressure, Hydraulic Pressure --- F-15C Oil Pressure, Hydraulic Pressure, Engine Exhaust Nozzle Position Indicator --- Su-25A/T, Russian Hydraulic Pressure Gauges -function ExportScript.AF.FC_OneNeedleGauge(value, scala, exportid) - local lValue = value or 1 - local lScala = scala or 100 - local lExportID = exportid or 1 - - lValue = lValue / lScala - lValue = (lValue > 1.0 and 1.0 or lValue) -- the result is limited to 1.0 - - ExportScript.Tools.SendData(lExportID, string.format("%.4f", lValue)) -end - --- Gauges with 1 needle and 2 digits display --- for example: --- -function ExportScript.AF.FC_OneNeedleGauge2Digits(value, scala, fixdigits, exportid) - local lValue = value or 1 - local lScala = scala or 100 - local lExportID = exportid or 1 - local lFixDigits = fixdigits or 0 - local lValueTmp = lValue - - --local lCounter = {[0] = 0.0, [1] = 0.11, [2] = 0.22, [3] = 0.33, [4] = 0.44, [5] = 0.55, [6] = 0.66, [7] = 0.77, [8] = 0.88, [9] = 0.99} - local lCounter = {[0] = 0.0, [1] = 0.1, [2] = 0.2, [3] = 0.3, [4] = 0.4, [5] = 0.5, [6] = 0.6, [7] = 0.7, [8] = 0.8, [9] = 0.9} - - local lCounter1 = 0 - local lCounter2 = 0 - local lFormat = 2 - lFixDigits - lFormat = "%0"..lFormat.."d" - - local lValueTmp2 = string.format(lFormat, lValueTmp) - --[[ - if lValueTmp > 10 then - if lValueTmp > 100 then - lCounter1 = (ExportScript.Tools.round((lValueTmp - (ExportScript.Tools.round(lValueTmp / 100, 0, "floor") * 100)), 0, "floor") / 10) * 0.1 - else - lCounter1 = (lValueTmp / 10) * 0.1 - lCounter1 = lCounter2 - ExportScript.Tools.round(lCounter2, 0, "floor") - end - end]] - if lValueTmp > 10 then - lCounter2 = (lValueTmp - (ExportScript.Tools.round(lValueTmp / 10, 0, "floor") * 10)) * 0.1 - else - lCounter2 = lValueTmp * 0.1 - end - - - lValue = lValue / lScala - lValue = (lValue > 1.0 and 1.0 or lValue) -- the result is limited to 1.0 - - SendData(lExportID, string.format("%.4f;%.2f;%.2f", - lValue, - lCounter[tonumber(string.sub(lValueTmp2, 1, 1))], - lCounter2)) -end - --- Gauges with 1 needle and 3 digits display --- for example: --- F-15C RPM, Fuel Flow -function ExportScript.AF.FC_OneNeedleGauge3Digits_alt(value, scala, fixdigits, exportid) - local lValue = value or 1 - local lScala = scala or 100 - local lExportID = exportid or 1 - local lFixDigits = fixdigits or 0 - local lValueTmp = lValue - - local lCounter = {[0] = 0.0, [1] = 0.11, [2] = 0.22, [3] = 0.33, [4] = 0.44, [5] = 0.55, [6] = 0.66, [7] = 0.77, [8] = 0.88, [9] = 0.99} - --local lCounter = {[0] = 0.0, [1] = 0.1, [2] = 0.2, [3] = 0.3, [4] = 0.4, [5] = 0.5, [6] = 0.6, [7] = 0.7, [8] = 0.8, [9] = 0.9} - - local lCounter3 = 0 - local lValueTmp2 = lValueTmp - - if lFixDigits > 0 then - lValueTmp2 = lValueTmp2 / math.pow(10, lFixDigits) - end - - lValueTmp2 = string.format("%03d", lValueTmp2) - - if lValueTmp > 1000 then - lCounter3 = (lValueTmp - (ExportScript.Tools.round(lValueTmp / 1000, 0, "floor") * 1000)) * math.pow(0.1, lFixDigits + 1) --0.1 - else - lCounter3 = lValueTmp * math.pow(0.1, lFixDigits + 1) --0.1 - end - - lValue = lValue / lScala - lValue = (lValue > 1.0 and 1.0 or lValue) -- the result is limited to 1.0 - - SendData(lExportID, string.format("%.4f;%.2f;%.2f;%.2f", - lValue, - lCounter[tonumber(string.sub(lValueTmp2, 1, 1))], - lCounter[tonumber(string.sub(lValueTmp2, 2, 2))], - lCounter3)) -end - --- Gauges with 1 needle and 3 digits display --- for example: --- F-15C RPM, Fuel Flow -function ExportScript.AF.FC_OneNeedleGauge3Digits(value, scala, fixdigits, exportid) - local lValue = value or 1 - local lScala = scala or 100 - local lExportID = exportid or 1 - local lFixDigits = fixdigits or 0 - local lValueTmp = lValue - local lFactor = string.len(tostring(lScala)) - 2 - lFactor = math.pow(10, lFactor) - - local lCounter = {[0] = 0.0, [1] = 0.1, [2] = 0.2, [3] = 0.3, [4] = 0.4, [5] = 0.5, [6] = 0.6, [7] = 0.7, [8] = 0.8, [9] = 0.9} - - local lValueTmp2 = lValueTmp - - if lFixDigits > 0 then - lValueTmp2 = lValueTmp2 / math.pow(10, lFixDigits) - end - - lValueTmp2 = string.format("%03d", lValueTmp2) - - local lv1, lCounter3 = math.modf(lValueTmp / lFactor) - - lValue = lValue / lScala - lValue = (lValue > 1.0 and 1.0 or lValue) -- the result is limited to 1.0 - - SendData(lExportID, string.format("%.4f;%.2f;%.2f;%.2f", - lValue, - lCounter[tonumber(string.sub(lValueTmp2, 1, 1))], - lCounter[tonumber(string.sub(lValueTmp2, 2, 2))], - lCounter3)) -end - --- Gauges with 1 needle and 4 digits display --- for example: --- -function ExportScript.AF.FC_OneNeedleGauge4Digits(value, scala, fixdigits, exportid) - local lValue = value or 1 - local lScala = scala or 100 - local lExportID = exportid or 1 - local lFixDigits = fixdigits or 0 - local lValueTmp = lValue - - --local lCounter = {[0] = 0.0, [1] = 0.11, [2] = 0.22, [3] = 0.33, [4] = 0.44, [5] = 0.55, [6] = 0.66, [7] = 0.77, [8] = 0.88, [9] = 0.99} - local lCounter = {[0] = 0.0, [1] = 0.1, [2] = 0.2, [3] = 0.3, [4] = 0.4, [5] = 0.5, [6] = 0.6, [7] = 0.7, [8] = 0.8, [9] = 0.9} - - local lCounter1 = 0 - local lCounter2 = 0 - local lCounter3 = 0 - local lCounter4 = 0 - local lValueTmp2 = lValueTmp - if lFixDigits > 0 then - lValueTmp2 = lValueTmp2 / math.pow(10, lFixDigits) - end - lValueTmp2 = string.format("%04d", lValueTmp2) - --[[ - if lValueTmp > 10000 then - lCounter1 = ExportScript.Tools.round((lValueTmp / 1000), 0, "floor") * 0.1 - lCounter1 = lCounter1 - ExportScript.Tools.round(lCounter1, 0, "floor") - end - if lValueTmp > 1000 then - if lValueTmp > 100 then - lCounter2 = (ExportScript.Tools.round((lValueTmp - (ExportScript.Tools.round(lValueTmp / 100, 0, "floor") * 100)), 0, "floor") / 10) * 0.1 - else - lCounter2 = (lValueTmp / 10) * 0.1 - lCounter2 = lCounter2 - ExportScript.Tools.round(lCounter2, 0, "floor") - end - end - if lValueTmp > 100 then - if lValueTmp > 10 then - lCounter3 = (ExportScript.Tools.round((lValueTmp - (ExportScript.Tools.round(lValueTmp / 100, 0, "floor") * 100)), 0, "floor") / 10) * 0.1 - else - lCounter3 = (lValueTmp / 10) * 0.1 - lCounter3 = lCounter3 - ExportScript.Tools.round(lCounter3, 0, "floor") - end - end]] - if lValueTmp > 10 then - lCounter4 = (lValueTmp - (ExportScript.Tools.round(lValueTmp / 10, 0, "floor") * 10)) * 0.1 - else - lCounter4 = lValueTmp * 0.1 - end - - - lValue = lValue / lScala - lValue = (lValue > 1.0 and 1.0 or lValue) -- the result is limited to 1.0 - - SendData(lExportID, string.format("%.4f;%.2f;%.2f;%.2f;%.2f", - lValue, - lCounter[tonumber(string.sub(lValueTmp2, 1, 1))], - lCounter[tonumber(string.sub(lValueTmp2, 2, 2))], - lCounter[tonumber(string.sub(lValueTmp2, 3, 3))], - lCounter4)) -end - - --- Auxiliary Functions for Hardware export - -function ExportScript.AF.SPO15RWR(FunctionTyp) --- The RWR display indicates any threat radars illuminating ("painting") the aircraft. --- Information is presented as symbols representing the type and direction to the threat. --- Six illuminated symbols at the bottom of the display notify the pilot of the threat radar type. --- The system indicates both enemy and friendly radars --- ---[[ -LoGetTWSInfo() -- return Threat Warning System status (result the table ) -result_of_LoGetTWSInfo = -{ - Mode = , -- current mode (0 - all ,1 - lock only,2 - launch only - Emitters = {table of emitters} -} -emitter_table = -{ - ID =, -- world ID - Type = {level1,level2,level3,level4}, -- world database classification of emitter - Power =, -- power of signal - Azimuth =, - Priority =,-- priority of emitter (int) - SignalType =, -- string with vlues: "scan" ,"lock", "missile_radio_guided","track_while_scan"; -}]] - - local lFunctionTyp = FunctionTyp or "Ikarus" - local lTWSInfo = LoGetTWSInfo() -- SPO15 Information - if lTWSInfo == nil then - return - end - --ExportScript.Tools.WriteToLog('lTWSInfo: '..ExportScript.Tools.dump(lTWSInfo)) - --[[ - [Emitters] = { - [1] = { - [Type] = { - [level3] = number: "105" - [level1] = number: "2" - [level4] = number: "46" - [level2] = number: "16" - } - [Azimuth] = number: "1.8300691843033" - [Power] = number: "0.92326503992081" - [ID] = number: "16777472" - [Priority] = number: "230.92445373535" - [SignalType] = string: "lock" - } - [2] = { - [Type] = { - [level3] = number: "101" - [level1] = number: "2" - [level4] = number: "39" - [level2] = number: "16" - } - [Azimuth] = number: "2.6759564876556" - [Power] = number: "0.90609884262085" - [ID] = number: "16777728" - [Priority] = number: "140.90609741211" - [SignalType] = string: "scan" - } - } - [Mode] = number: "0" - ]] - - --if(ExportScript.AF.EventNumberOLD < ExportScript.AF.EventNumber) then - local lPriorityTmp = 0 - local lPrimaryThreatTmp = 0 - local lActiveLamp = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0} -- 10 x for direction - if ExportScript.AF.SPO15RWRData == nil then - ExportScript.AF.SPO15RWRData = {} - - ExportScript.AF.SPO15RWRData[400] = 1 -- Power light - end - - if ExportScript.AF.SPO15RWRDataIkarus == nil then - ExportScript.AF.SPO15RWRDataIkarus = {} - - ExportScript.AF.SPO15RWRDataIkarus[400] = 1 -- Power light - end - - if(#lTWSInfo.Emitters > 0) then - - ExportScript.AF.SPO15_FoundErmitter = true - - for EmitterIndex = 1, #lTWSInfo.Emitters, 1 do - if(lTWSInfo.Emitters[EmitterIndex].Priority > lPriorityTmp) then - lPriorityTmp = lTWSInfo.Emitters[EmitterIndex].Priority - lPrimaryThreatTmp = EmitterIndex - end - end - - for EmitterIndex = 1, #lTWSInfo.Emitters, 1 do - - local lAzimut = ExportScript.Tools.round(lTWSInfo.Emitters[EmitterIndex].Azimuth * 90, 1) - - if EmitterIndex == lPrimaryThreatTmp then - -- primary threat - -- direction to the threat - ExportScript.AF.SPO15RWRData[401] = (lAzimut <= -170.0 and 1 or 0) -- left back side - ExportScript.AF.SPO15RWRData[402] = ((lAzimut <= -90.0 and lAzimut >= -170.0 ) and 1 or 0) -- left 90 degree - ExportScript.AF.SPO15RWRData[403] = ((lAzimut <= -55.0 and lAzimut >= -125.0 ) and 1 or 0) -- left 50 degree - ExportScript.AF.SPO15RWRData[404] = ((lAzimut <= -30.0 and lAzimut >= -70.0 ) and 1 or 0) -- left 30 degree - ExportScript.AF.SPO15RWRData[405] = ((lAzimut <= 5.0 and lAzimut >= -40.0 ) and 1 or 0) -- left 10 degree - ExportScript.AF.SPO15RWRData[406] = ((lAzimut >= -5.0 and lAzimut <= 40.0 ) and 1 or 0) -- right 10 degree - ExportScript.AF.SPO15RWRData[407] = ((lAzimut >= 30.0 and lAzimut <= 70.0 ) and 1 or 0) -- right 30 degree - ExportScript.AF.SPO15RWRData[408] = ((lAzimut >= 55.0 and lAzimut <= 125.0 ) and 1 or 0) -- right 50 degree - ExportScript.AF.SPO15RWRData[409] = ((lAzimut >= 90.0 and lAzimut <= 170.0 ) and 1 or 0) -- right 90 degree - ExportScript.AF.SPO15RWRData[410] = (lAzimut >= 170.0 and 1 or 0) -- right back side - - -- power of the threat - local lPower = ExportScript.Tools.round(lTWSInfo.Emitters[EmitterIndex].Power * 15, 0, "ceil") + 1 - --WriteToLog("lPower: "..lPower) - ExportScript.AF.SPO15RWRData[411] = (lPower <= 1 and 0 or 1) -- 1. power lamp - ExportScript.AF.SPO15RWRData[412] = (lPower <= 2 and 0 or 1) -- 2. power lamp - ExportScript.AF.SPO15RWRData[413] = (lPower <= 3 and 0 or 1) -- 3. power lamp - ExportScript.AF.SPO15RWRData[414] = (lPower <= 4 and 0 or 1) -- 4. power lamp - ExportScript.AF.SPO15RWRData[415] = (lPower <= 5 and 0 or 1) -- 5. power lamp - ExportScript.AF.SPO15RWRData[416] = (lPower <= 6 and 0 or 1) -- 6. power lamp - ExportScript.AF.SPO15RWRData[417] = (lPower <= 7 and 0 or 1) -- 7. power lamp - ExportScript.AF.SPO15RWRData[418] = (lPower <= 8 and 0 or 1) -- 8. power lamp - ExportScript.AF.SPO15RWRData[419] = (lPower <= 9 and 0 or 1) -- 9. power lamp - ExportScript.AF.SPO15RWRData[420] = (lPower <= 10 and 0 or 1) -- 10. power lamp - ExportScript.AF.SPO15RWRData[421] = (lPower <= 11 and 0 or 1) -- 11. power lamp - ExportScript.AF.SPO15RWRData[422] = (lPower <= 12 and 0 or 1) -- 12. power lamp - ExportScript.AF.SPO15RWRData[423] = (lPower <= 13 and 0 or 1) -- 13. power lamp - ExportScript.AF.SPO15RWRData[424] = (lPower <= 14 and 0 or 1) -- 14. power lamp - ExportScript.AF.SPO15RWRData[425] = (lPower <= 15 and 0 or 1) -- 15. power lamp - - -- type of the threat - local lPrimaryTypeTmp = ExportScript.AF.FindRadarTypeForSPO15(lTWSInfo, lPrimaryThreatTmp) - ExportScript.AF.SPO15RWRData[430] = (lPrimaryTypeTmp.AIR == 1 and 1 or 0) -- primary Air or Weapon - ExportScript.AF.SPO15RWRData[431] = (lPrimaryTypeTmp.LRR == 1 and 1 or 0) -- long range radar - ExportScript.AF.SPO15RWRData[432] = (lPrimaryTypeTmp.MRR == 1 and 1 or 0) -- mid range radar - ExportScript.AF.SPO15RWRData[433] = (lPrimaryTypeTmp.SRR == 1 and 1 or 0) -- short range radar - ExportScript.AF.SPO15RWRData[434] = (lPrimaryTypeTmp.EWR == 1 and 1 or 0) -- EWR - ExportScript.AF.SPO15RWRData[435] = (lPrimaryTypeTmp.AWACS == 1 and 1 or 0) -- AWACS - - -- look or missil on air - if lPrimaryTypeTmp.Lock == 0.1 then - ExportScript.AF.SPO15RWRData[440] = 0 - ExportScript.AF.SPO15RWRData[441] = 1 -- blinking lights on - elseif lPrimaryTypeTmp.Lock == 0.2 then - ExportScript.AF.SPO15RWRData[440] = 1 - ExportScript.AF.SPO15RWRData[441] = 0 -- blinking lights off - end - -- hemisphere - ExportScript.AF.SPO15RWRData[442] = lPrimaryTypeTmp.TopHemisphere -- top hemisphere - ExportScript.AF.SPO15RWRData[443] = lPrimaryTypeTmp.BottomHemisphere -- bottom hemisphere - - lPrimaryTypeTmp = nil - - end - - -- secondary threat - lActiveLamp = ExportScript.AF.SPO15RWR_SendDataHW(lActiveLamp, 1, 451, lAzimut <= -170.0) -- left back side - lActiveLamp = ExportScript.AF.SPO15RWR_SendDataHW(lActiveLamp, 2, 452, (lAzimut <= -90.0 and lAzimut >= -170.0 )) -- left 90 degree - lActiveLamp = ExportScript.AF.SPO15RWR_SendDataHW(lActiveLamp, 3, 453, (lAzimut <= -55.0 and lAzimut >= -125.0 )) -- left 50 degree - lActiveLamp = ExportScript.AF.SPO15RWR_SendDataHW(lActiveLamp, 4, 454, (lAzimut <= -30.0 and lAzimut >= -70.0 )) -- left 30 degree - lActiveLamp = ExportScript.AF.SPO15RWR_SendDataHW(lActiveLamp, 5, 455, (lAzimut <= 5.0 and lAzimut >= -40.0 )) -- left 10 degree - lActiveLamp = ExportScript.AF.SPO15RWR_SendDataHW(lActiveLamp, 6, 456, (lAzimut >= -5.0 and lAzimut <= 40.0 )) -- right 10 degree - lActiveLamp = ExportScript.AF.SPO15RWR_SendDataHW(lActiveLamp, 7, 457, (lAzimut >= 30.0 and lAzimut <= 70.0 )) -- right 30 degree - lActiveLamp = ExportScript.AF.SPO15RWR_SendDataHW(lActiveLamp, 8, 458, (lAzimut >= 55.0 and lAzimut <= 125.0 )) -- right 50 degree - lActiveLamp = ExportScript.AF.SPO15RWR_SendDataHW(lActiveLamp, 9, 459, (lAzimut >= 90.0 and lAzimut <= 170.0 )) -- right 90 degree - lActiveLamp = ExportScript.AF.SPO15RWR_SendDataHW(lActiveLamp, 10, 460, lAzimut >= 170.0) -- right back side - - end - - -- type of the secondary threat - local lSecondaryTypeTmp = ExportScript.AF.FindRadarTypeForSPO15(lTWSInfo) - ExportScript.AF.SPO15RWRData[470] = (lSecondaryTypeTmp.AIR == 1 and 1 or 0) -- secondary Air or Weapon - ExportScript.AF.SPO15RWRData[471] = (lSecondaryTypeTmp.LRR == 1 and 1 or 0) -- long range radar - ExportScript.AF.SPO15RWRData[472] = (lSecondaryTypeTmp.MRR == 1 and 1 or 0) -- mid range radar - ExportScript.AF.SPO15RWRData[473] = (lSecondaryTypeTmp.SRR == 1 and 1 or 0) -- short range radar - ExportScript.AF.SPO15RWRData[474] = (lSecondaryTypeTmp.EWR == 1 and 1 or 0) -- EWR - ExportScript.AF.SPO15RWRData[475] = (lSecondaryTypeTmp.AWACS == 1 and 1 or 0) -- AWACS - lSecondaryTypeTmp = nil - - - if ExportScript.Config.IkarusExport then - -- all data conditioned for Ikarus - ExportScript.AF.SPO15RWRDataIkarus = {[400]=1,[401]=0,[402]=0,[403]=0,[404]=0,[405]=0,[406]=0,[407]=0,[408]=0,[409]=0,[410]=0,[411]=0,[412]=0,[413]=0,[414]=0,[415]=0,[416]=0,[417]=0,[418]=0,[419]=0,[420]=0,[421]=0,[422]=0} - - -- Primary threat Light 1/2 - local lTmp = 0.1 - for Index=401, 410, 1 do - if ExportScript.AF.SPO15RWRData[Index] == 1 and ExportScript.AF.SPO15RWRDataIkarus[401] == 0 then - ExportScript.AF.SPO15RWRDataIkarus[401] = lTmp -- Primary threat Light 1 - end - if ExportScript.AF.SPO15RWRData[Index] == 1 and ExportScript.AF.SPO15RWRDataIkarus[402] == 0 and ExportScript.AF.SPO15RWRDataIkarus[401] ~= lTmp then - ExportScript.AF.SPO15RWRDataIkarus[402] = lTmp -- Primary threat Light 2 - break - end - lTmp = lTmp + 0.1 - end - - -- Primary threat Type - for Index=430, 435, 1 do - if ExportScript.AF.SPO15RWRData[Index] == 1 then - ExportScript.AF.SPO15RWRDataIkarus[403] = ((Index - 430) / 10) + 0.1 -- 0.1=primary Air or Weapon, 0.2=long range radar, 0.3=mid range radar, 0.4=short range radar, 0.5=EWR, 0.6=AWACS - break - end - end - - -- Hemisphere - if ExportScript.AF.SPO15RWRData[442] == 1 and ExportScript.AF.SPO15RWRData[443] == 1 then - ExportScript.AF.SPO15RWRDataIkarus[404] = 0.3 -- top and bottom hemisphere - elseif ExportScript.AF.SPO15RWRData[442] == 0 and ExportScript.AF.SPO15RWRData[443] == 1 then - ExportScript.AF.SPO15RWRDataIkarus[404] = 0.2 -- bottom hemisphere - elseif ExportScript.AF.SPO15RWRData[442] == 1 and ExportScript.AF.SPO15RWRData[443] == 0 then - ExportScript.AF.SPO15RWRDataIkarus[404] = 0.1 -- top hemisphere - end - - -- Lock - if ExportScript.AF.SPO15RWRData[440] == 1 then - ExportScript.AF.SPO15RWRDataIkarus[405] = 0.1 -- Lock - elseif ExportScript.AF.SPO15RWRData[441] == 1 then - ExportScript.AF.SPO15RWRDataIkarus[405] = 0.2 -- Missle on air - end - - -- Ermitter power - for Index=411, 425, 1 do - if ExportScript.AF.SPO15RWRData[Index] == 1 then - ExportScript.AF.SPO15RWRDataIkarus[406] = ExportScript.AF.SPO15RWRDataIkarus[406] + 0.01 -- Ermitter power 0.0 off, 0.01=first lamp - 0.15=last lamp - else - break - end - end - - -- Secondary thread - lTmp = 407 -- to 416 - for Index=451, 460, 1 do - if ExportScript.AF.SPO15RWRData[Index] == 1 then - ExportScript.AF.SPO15RWRDataIkarus[lTmp] = 1 - end - lTmp = lTmp + 1 - end - - -- type of the secondary threat - if ExportScript.AF.SPO15RWRData[470] == 1 then - ExportScript.AF.SPO15RWRDataIkarus[417] = 1 -- secondary Air or Weapon - end - if ExportScript.AF.SPO15RWRData[471] == 1 then - ExportScript.AF.SPO15RWRDataIkarus[418] = 1 -- long range radar - end - if ExportScript.AF.SPO15RWRData[472] == 1 then - ExportScript.AF.SPO15RWRDataIkarus[419] = 1 -- mid range radar - end - if ExportScript.AF.SPO15RWRData[473] == 1 then - ExportScript.AF.SPO15RWRDataIkarus[420] = 1 -- short range radar - end - if ExportScript.AF.SPO15RWRData[474] == 1 then - ExportScript.AF.SPO15RWRDataIkarus[421] = 1 -- EWR - end - if ExportScript.AF.SPO15RWRData[475] == 1 then - ExportScript.AF.SPO15RWRDataIkarus[422] = 1 -- AWACS - end - end - - else - lPriorityTmp = 0 - lPrimaryThreatTmp = 0 - - if ExportScript.AF.SPO15_FoundErmitter == nil or ExportScript.AF.SPO15_FoundErmitter then - ExportScript.AF.SPO15RWR_Reset(401, 480) - - ExportScript.AF.SPO15RWRDataIkarus = {[400]=1,[401]=0,[402]=0,[403]=0,[404]=0,[405]=0,[406]=0,[407]=0,[408]=0,[409]=0,[410]=0,[411]=0,[412]=0,[413]=0,[414]=0,[415]=0,[416]=0,[417]=0,[418]=0,[419]=0,[420]=0,[421]=0,[422]=0} - end - end - --end - - if ExportScript.Config.IkarusExport and lFunctionTyp == "Ikarus" then - if ExportScript.AF.SPO15RWRDataIkarus ~= nil then - for key, value in pairs(ExportScript.AF.SPO15RWRDataIkarus) do - ExportScript.Tools.SendData(key, value) - end - end - end - - if ExportScript.Config.DACExport and lFunctionTyp == "DAC" then - if ExportScript.AF.SPO15RWRData ~= nil then - for key, value in pairs(ExportScript.AF.SPO15RWRData) do - ExportScript.Tools.SendDataDAC(key, value) - end - end - end - - --[[ -level: 2, 16, 101, 39 -lNameByType: string: "hawk sr" - -alle Level -> wsTypes.lua -oder -Nummer 101 -> AN-MPQ-51 HAWK SR.lua -Nummer 39 -> TechnicsTable.sht - -lNameByType: string: "hawk sr" -> db_sensors.lua - - ]] -end - - --- Auxiliary Functions - -function ExportScript.AF.FindRadarTypeForSPO15(lTWSInfo, PrimaryThreat) - local lPrimaryThreat = PrimaryThreat or 0 - local lReturn = {AIR = 0, LRR = 0, MRR = 0, SRR = 0, EWR = 0, AWACS = 0, Lock = 0, TopHemisphere = 0, BottomHemisphere = 0} - - for EmitterIndex = 1, #lTWSInfo.Emitters, 1 do - if lPrimaryThreat ~= 0 then - EmitterIndex = lPrimaryThreat - end - local lType = lTWSInfo.Emitters[EmitterIndex].Type - --ExportScript.Tools.WriteToLog('level: '..lType.level1..', '..lType.level2..', '..lType.level3..', '..lType.level4) - local lNameByType = LoGetNameByType(lType.level1, lType.level2, lType.level3, lType.level4) -- world database classification of emitter, args 4 (number : level1,level2,level3,level4), result string - --ExportScript.Tools.WriteToLog('lNameByType: '..ExportScript.Tools.dump(lNameByType)) - - -- threat type - if (lType.level1 == 1 or lType.level1 == 4) and - not(lType.level4 == 26 or -- level4 26: A-50 - lType.level4 == 27 or -- level4 27: E-3 - lType.level4 == 41) then -- level4 41: E-2C - lReturn.AIR = 1 -- primary Air or Weapon - end - - if lType.level1 == 2 or lType.level1 == 3 then - -- ground or navy - if lType.level2 == 16 then - local lAn, lEn - -- Ground SAM - lAn, lEn = string.find("s300 sr,s300 tr,an/mpq-53", lNameByType, 0, true) - -- long range radar - if lAn ~= nil then - lReturn.LRR = 1 - end - - lAn, lEn = string.find("p19,snr-125,kub,hawk sr,hawk tr,buk sr,buk tr,5n66m sr", lNameByType, 0, true) - -- mid range radar - if lAn ~= nil then - lReturn.MRR = 1 - end - - lAn, lEn = string.find("M163 Vulcan,shilka zsu-23-4,gepard,roland ads,roland radar,osa 9a33 ln,2c6m,9a331,Dog Ear Radar", lNameByType, 0, true) - -- short range radar - if lAn ~= nil then - lReturn.SRR = 1 - end ---[[ if lType.level4 == 27 or -- Dog Ear Radar - lType.level4 == 31 or -- roland ads - lType.level4 == 32 or -- roland radar - lType.level4 == 38 then -- gepard - lReturn.SRR = 1 - end -]] - lAn, lEn = string.find("1l13 ewr station,55G6", lNameByType, 0, true) - -- EWR - if lAn ~= nil then - lReturn.EWR = 1 - end - - elseif lType.level2 == 12 then - local lAn, lEn - -- Ship - lAn, lEn = string.find("FFG-7 Oliver H. Perry class,SG-47 Ticonderoga class", lNameByType, 0, true) - -- long range radar - if lAn ~= nil then - lReturn.LRR = 1 - end - - lAn, lEn = string.find("CVN-70 Vinson", lNameByType, 0, true) - -- short range radar - if lAn ~= nil then - lReturn.SRR = 1 - end - end - elseif lType.level1 == 1 and lType.level2 == 1 and lType.level3 == 5 then - if lType.level4 == 26 or lType.level4 == 27 or lType.level4 == 41 then - -- AWACS - -- level4 26: A-50 - -- level4 27: E-3 - -- level4 41: E-2C - lReturn.AWACS = 1 - end - end - -- primary threat handling only - if lPrimaryThreat ~= 0 then - if lTWSInfo.Emitters[lPrimaryThreat].SignalType == "lock" then - -- look - lReturn.Lock = 0.2 - - lReturn.TopHemisphere = 1 -- top hemisphere - lReturn.BottomHemisphere = 1 -- bottom hemisphere - elseif lTWSInfo.Emitters[lPrimaryThreat].SignalType == "missile_radio_guided" then - -- Rocket on air - lReturn.Lock = 0.1 - elseif lTWSInfo.Emitters[lPrimaryThreat].SignalType == "scan" then - -- beep - elseif lTWSInfo.Emitters[lPrimaryThreat].SignalType == "track_while_scan" then - -- ??? - else - lReturn.Lock = 0 - end - - local lErmitterObject = LoGetObjectById(lTWSInfo.Emitters[lPrimaryThreat].ID) - local lErmitterObjectAlt = 0 - - if lErmitterObject then - lErmitterObjectAlt = lErmitterObject.LatLongAlt.Alt - end - - local lSelfData = LoGetSelfData() - local lSelfDataAlt = ExportScript.Tools.round(lSelfData.LatLongAlt.Alt, 0) - - if lErmitterObjectAlt and lSelfDataAlt then - --ExportScript.Tools.WriteToLog('lErmitterObjectAlt: '..lErmitterObjectAlt..', lSelfDataAlt: '..lSelfDataAlt) - if lErmitterObjectAlt > (lSelfDataAlt + 400) then - lReturn.TopHemisphere = 1 -- top hemisphere - elseif lErmitterObjectAlt < (lSelfDataAlt - 400) then - lReturn.BottomHemisphere = 1 -- bottom hemisphere - else - lReturn.TopHemisphere = 1 -- top hemisphere - lReturn.BottomHemisphere = 1 -- bottom hemisphere - end - end - - lErmitterObject, lErmitterObjectAlt, lSelfData, lSelfDataAlt = nil - - break - end - end - - return lReturn -end - -function ExportScript.AF.WeaponStatusPanel_selectCurrentPayloadStation(_index) - if ExportScript.AF.PayloadInfo.Stations[ExportScript.AF.PayloadInfo.CurrentStation].CLSID == ExportScript.AF.PayloadInfo.Stations[_index].CLSID and ExportScript.AF.PayloadInfo.CurrentStation ~= _index then - SendDataHW(ExportScript.AF.TmpStationToPanel[_index].CurrentID, 1, ExportScript.AF.TmpStationToPanel[_index].HardwareID) - end -end - -function ExportScript.AF.SPO15RWR_Reset(lMinId, lMaxID) ---ExportScript.Tools.WriteToLog('SPO15RWR_Reset') - for lCounter = lMinId, lMaxID, 1 do - ExportScript.AF.SPO15RWRData[lCounter] = 0 - end - - ExportScript.AF.SPO15_FoundErmitter = false -end - -function ExportScript.AF.SPO15RWR_SendDataHW(lActiveLamp, lLamp, lKey, lValue) ---ExportScript.Tools.WriteToLog('SPO15RWR_SendDataHW: '..ExportScript.Tools.dump(lActiveLamp)..', '..ExportScript.Tools.dump(lLamp)..', '..ExportScript.Tools.dump(lKey)..', '..ExportScript.Tools.dump(lValue)) - if lActiveLamp[lLamp] == 0 then - if lValue then - ExportScript.AF.SPO15RWRData[lKey] = 1 - lActiveLamp[lLamp] = 1 - end - end - - return lActiveLamp -end - -function ExportScript.AF.WeaponStatusPanel_Reset(lMinId, lMaxID, lHardware) ---ExportScript.Tools.WriteToLog('WeaponStatusPanel_Reset') - for lCounter = lMinId, lMaxID, 1 do - SendDataHW(lCounter, 0, lHardware) - end -end - -function ExportScript.AF.WeaponStatusPanel_selectCurrentPayloadStationGlassCockpit(_index) - if ExportScript.AF.PayloadInfo.Stations[ExportScript.AF.PayloadInfo.CurrentStation].CLSID == ExportScript.AF.PayloadInfo.Stations[_index].CLSID and ExportScript.AF.PayloadInfo.CurrentStation ~= _index then - ExportScript.AF.TmpWeaponPanelActive[ExportScript.AF.TmpStationToPanel[_index].CurrentID] = 1 - end -end - -function ExportScript.AF.WeaponStatusPanel_FindCannonContainer(_index) - if ExportScript.AF.PayloadInfo.Stations[_index].weapon.level1 == 4 and -- weapon - ExportScript.AF.PayloadInfo.Stations[_index].weapon.level2 == 6 then -- Shell - ExportScript.AF.CannonContainer[_index] = ExportScript.AF.PayloadInfo.Stations[_index].CLSID - ExportScript.AF.CannonContainer.counter = ExportScript.AF.CannonContainer.counter + 1 - end -end +-- Flaming Cliffs Auxiliary Functons +-- Version 1.0.0 + +-- Weapon Panel for Su-25A and Su-25T +function ExportScript.AF.FC_WeaponPanel_SU25(FunctionTyp) + local lFunctionTyp = FunctionTyp or "Ikarus" + + if ExportScript.AF.TmpWeaponPanelPresend == nil then + ExportScript.AF.TmpWeaponPanelPresend = {[101] = 0, [102] = 0, [103] = 0, [104] = 0, [105] = 0, [106] = 0, [107] = 0, [108] = 0, [109] = 0, [110] = 0} + end + + if ExportScript.AF.TmpWeaponPanelActive == nil then + ExportScript.AF.TmpWeaponPanelActive = {[201] = 0, [202] = 0, [203] = 0, [204] = 0, [205] = 0, [206] = 0, [207] = 0, [208] = 0, [209] = 0, [210] = 0} + end + + if ExportScript.AF.TmpWeaponPanel == nil then + ExportScript.AF.TmpWeaponPanel = {[231] = 0, [232] = 0, [233] = 0, [234] = 0, [235] = 0} + end + + if ExportScript.AF.EventNumberFC_WeaponPanel == nil then + ExportScript.AF.EventNumberFC_WeaponPanel = 0 + end + + if(ExportScript.AF.EventNumberFC_WeaponPanel < ExportScript.AF.EventNumber) then + ExportScript.AF.EventNumberFC_WeaponPanel = ExportScript.AF.EventNumber + -- defination + ExportScript.AF.PayloadInfo = LoGetPayloadInfo() + if ExportScript.AF.PayloadInfo ~= nil then + if ExportScript.AF.CurrentStationTmp == nil then + ExportScript.AF.CurrentStationTmp = -1 + end + if ExportScript.AF.CannonContainer == nil then -- Find Cannon-Containers, aka SPPU_22 + ExportScript.AF.CannonContainer = {} + ExportScript.AF.CannonContainer.counter = 0 + table.foreach(ExportScript.AF.PayloadInfo.Stations, ExportScript.AF.WeaponStatusPanel_FindCannonContainer) + end + + if ExportScript.AF.PayloadInfo.CurrentStation > 0 and + ExportScript.AF.CurrentStationTmp ~= ExportScript.AF.PayloadInfo.CurrentStation then + ExportScript.AF.CurrentStationTmp = ExportScript.AF.PayloadInfo.CurrentStation + + ExportScript.AF.TmpStationToPanel = {} + ExportScript.AF.TmpStationToPanel[1] = {Panel = 1, StationID = 101, CurrentID = 201 } -- left + ExportScript.AF.TmpStationToPanel[2] = {Panel = 10, StationID = 110, CurrentID = 210 } -- right + ExportScript.AF.TmpStationToPanel[3] = {Panel = 2, StationID = 102, CurrentID = 202 } + ExportScript.AF.TmpStationToPanel[4] = {Panel = 9, StationID = 109, CurrentID = 209 } + ExportScript.AF.TmpStationToPanel[5] = {Panel = 3, StationID = 103, CurrentID = 203 } + ExportScript.AF.TmpStationToPanel[6] = {Panel = 8, StationID = 108, CurrentID = 208 } + ExportScript.AF.TmpStationToPanel[7] = {Panel = 4, StationID = 104, CurrentID = 204 } + ExportScript.AF.TmpStationToPanel[8] = {Panel = 7, StationID = 107, CurrentID = 207 } + ExportScript.AF.TmpStationToPanel[9] = {Panel = 5, StationID = 105, CurrentID = 205 } + ExportScript.AF.TmpStationToPanel[10] = {Panel = 6, StationID = 106, CurrentID = 206 } + + -- ExportScript.AF.TmpWeaponPanelActive reset + for i = 201, 210, 1 do + ExportScript.AF.TmpWeaponPanelActive[i] = 0 + end + + if ExportScript.AF.TmpStationToPanel[ExportScript.AF.PayloadInfo.CurrentStation] ~= nil then + ExportScript.AF.TmpWeaponPanelActive[ExportScript.AF.TmpStationToPanel[ExportScript.AF.PayloadInfo.CurrentStation].CurrentID] = 1 -- currrent value + + table.foreach(ExportScript.AF.PayloadInfo.Stations, ExportScript.AF.WeaponStatusPanel_selectCurrentPayloadStation) -- corresponding station + end + + end + + local lMainGun = 1.0 -- Full max 250 Rounds "F" + local lReserve = 1.0 + if ExportScript.AF.PayloadInfo.Cannon.shells == 0 then + lMainGun = 0.0 -- transversely striped + lReserve = 0.0 -- transversely striped + elseif ExportScript.AF.PayloadInfo.Cannon.shells < 65 then + lMainGun = 0.1 -- "E" + elseif ExportScript.AF.PayloadInfo.Cannon.shells < 125 then + lMainGun = 0.3 -- "1/2" -- "3/4" + elseif ExportScript.AF.PayloadInfo.Cannon.shells < 187 then + lMainGun = 0.6 -- "1/4" + end + + local lWeaponType = 0.0 -- transversely striped + if ExportScript.AF.PayloadInfo.CurrentStation > 0 then + if ExportScript.AF.PayloadInfo.Stations[ExportScript.AF.PayloadInfo.CurrentStation].weapon.level1 == 4 then + if ExportScript.AF.PayloadInfo.Stations[ExportScript.AF.PayloadInfo.CurrentStation].weapon.level2 == 4 then -- Weapon type Missle + lWeaponType = 0.1 -- MSL + elseif ExportScript.AF.PayloadInfo.Stations[ExportScript.AF.PayloadInfo.CurrentStation].weapon.level2 == 7 then -- Weapon type NURS with Container + if ExportScript.AF.PayloadInfo.Stations[ExportScript.AF.PayloadInfo.CurrentStation].weapon.level3 == 33 then -- Weapon type Rocket + lWeaponType = 0.2 -- RCT + end + elseif ExportScript.AF.PayloadInfo.Stations[ExportScript.AF.PayloadInfo.CurrentStation].weapon.level2 == 5 then -- Weapon type Bomb + lWeaponType = 0.3 -- BB + end + end + end + + local lOuterCannon = 0.0 -- transversely striped + local lInnerCannon = 0.0 -- transversely striped + if ExportScript.AF.CannonContainer.counter > 0 then + for i = 7, 10, 1 do + if ExportScript.AF.CannonContainer[i] == "{E92CBFE5-C153-11d8-9897-000476191836}" then -- SPPU_22 with 260 rounds + if i == 7 or i == 8 then + lOuterCannon = 1.0 -- Full max 260 Rounds "F" + if ExportScript.AF.PayloadInfo.Stations[i].count == 0 then + lOuterCannon = 0.0 -- transversely striped + ExportScript.AF.CannonContainer[i] = "empty" -- do not check + elseif ExportScript.AF.PayloadInfo.Stations[i].count < 65 then + lOuterCannon = 0.1 -- "E" + elseif ExportScript.AF.PayloadInfo.Stations[i].count < 130 then + lOuterCannon = 0.3 -- "3/4" -- "1/2" + elseif ExportScript.AF.PayloadInfo.Stations[i].count < 195 then + lOuterCannon = 0.6 -- "1/4" + end + else + lInnerCannon = 1.0 -- Full max 260 Rounds "F" + if ExportScript.AF.PayloadInfo.Stations[i].count == 0 then + lInnerCannon = 0.0 -- transversely striped + ExportScript.AF.CannonContainer[i] = "empty" -- do not check + elseif ExportScript.AF.PayloadInfo.Stations[i].count < 65 then + lInnerCannon = 0.1 -- "E" + elseif ExportScript.AF.PayloadInfo.Stations[i].count < 130 then + lInnerCannon = 0.3 -- "3/4" -- "1/2" + elseif ExportScript.AF.PayloadInfo.Stations[i].count < 195 then + lInnerCannon = 0.6 -- "1/4" + end + end + end + end + end + + --[[ + Weapon Panel + | + --------------------------------------------------- + | | | | | | | | | | | + 1 2 3 4 5 C 6 7 8 9 10 -- display + 1 3 5 7 9 10 8 6 4 2 -- Payload ID + ]] + -- Payload Info + -- weapon stations (panel) 1 (left) - 10 (right), no lamp for center station + + -- WeaponPresend1 {0, 1} + -- WeaponPresend2 {0, 1} + -- WeaponPresend3 {0, 1} + -- WeaponPresend4 {0, 1} + -- WeaponPresend5 {0, 1} + -- WeaponPresend6 {0, 1} + -- WeaponPresend7 {0, 1} + -- WeaponPresend8 {0, 1} + -- WeaponPresend9 {0, 1} + -- WeaponPresend10 {0, 1} + -- WeaponActive1 {0, 1} + -- WeaponActive2 {0, 1} + -- WeaponActive3 {0, 1} + -- WeaponActive4 {0, 1} + -- WeaponActive5 {0, 1} + -- WeaponActive6 {0, 1} + -- WeaponActive7 {0, 1} + -- WeaponActive8 {0, 1} + -- WeaponActive9 {0, 1} + -- WeaponActive10 {0, 1} + -- MainCannon {transversely striped = 0.0, 1/4 = 01, 1/2 = 03, 3/4 = 0.6, Full = 1.0} + -- WeaponType {transversely striped = 0.0, Missle = 0.1, Rocket = 0.2, Bomb = 0.3} + -- OuterCannon {transversely striped = 0.0, 1/4 = 01, 1/2 = 03, 3/4 = 0.6, Full = 1.0} + -- InnerCannon {transversely striped = 0.0, 1/4 = 01, 1/2 = 03, 3/4 = 0.6, Full = 1.0} + -- ReserveWeapon {transversely striped = 0.0, Gun = 1.0} + + ExportScript.AF.TmpWeaponPanel = {} + ExportScript.AF.TmpWeaponPanel[231] = lMainGun -- main cannon shells + ExportScript.AF.TmpWeaponPanelPresend[101] = (ExportScript.AF.PayloadInfo.Stations[1].count > 0 and 1 or 0) -- weapon presend panel 1 + ExportScript.AF.TmpWeaponPanelPresend[102] = (ExportScript.AF.PayloadInfo.Stations[3].count > 0 and 1 or 0) -- weapon presend panel 2 + ExportScript.AF.TmpWeaponPanelPresend[103] = (ExportScript.AF.PayloadInfo.Stations[5].count > 0 and 1 or 0) -- weapon presend panel 3 + ExportScript.AF.TmpWeaponPanelPresend[104] = (ExportScript.AF.PayloadInfo.Stations[7].count > 0 and 1 or 0) -- weapon presend panel 4 + ExportScript.AF.TmpWeaponPanelPresend[105] = (ExportScript.AF.PayloadInfo.Stations[9].count > 0 and 1 or 0) -- weapon presend panel 5 + ExportScript.AF.TmpWeaponPanelPresend[106] = (ExportScript.AF.PayloadInfo.Stations[10].count > 0 and 1 or 0) -- weapon presend panel 6 + ExportScript.AF.TmpWeaponPanelPresend[107] = (ExportScript.AF.PayloadInfo.Stations[8].count > 0 and 1 or 0) -- weapon presend panel 7 + ExportScript.AF.TmpWeaponPanelPresend[108] = (ExportScript.AF.PayloadInfo.Stations[6].count > 0 and 1 or 0) -- weapon presend panel 8 + ExportScript.AF.TmpWeaponPanelPresend[109] = (ExportScript.AF.PayloadInfo.Stations[4].count > 0 and 1 or 0) -- weapon presend panel 9 + ExportScript.AF.TmpWeaponPanelPresend[110] = (ExportScript.AF.PayloadInfo.Stations[2].count > 0 and 1 or 0) -- weapon presend panel 10 + --ExportScript.AF.TmpWeaponPanelActive[201] -- weapon active panel 1 + --ExportScript.AF.TmpWeaponPanelActive[202] -- weapon active panel 2 + --ExportScript.AF.TmpWeaponPanelActive[203] -- weapon active panel 3 + --ExportScript.AF.TmpWeaponPanelActive[204] -- weapon active panel 4 + --ExportScript.AF.TmpWeaponPanelActive[205] -- weapon active panel 5 + --ExportScript.AF.TmpWeaponPanelActive[206] -- weapon active panel 6 + --ExportScript.AF.TmpWeaponPanelActive[207] -- weapon active panel 7 + --ExportScript.AF.TmpWeaponPanelActive[208] -- weapon active panel 8 + --ExportScript.AF.TmpWeaponPanelActive[209] -- weapon active panel 9 + --ExportScript.AF.TmpWeaponPanelActive[210] -- weapon active panel 10 + ExportScript.AF.TmpWeaponPanel[232] = lWeaponType -- current weapon type + ExportScript.AF.TmpWeaponPanel[233] = lOuterCannon -- outer cannon shells + ExportScript.AF.TmpWeaponPanel[234] = lInnerCannon -- inner cannon shells + ExportScript.AF.TmpWeaponPanel[235] = lReserve -- reserve weapon + end + end + + if ExportScript.Config.IkarusExport and lFunctionTyp == "Ikarus" then + for key, value in pairs(ExportScript.AF.TmpWeaponPanelPresend) do + ExportScript.Tools.SendData(key, value) + end + for key, value in pairs(ExportScript.AF.TmpWeaponPanelActive) do + ExportScript.Tools.SendData(key, value) + end + for key, value in pairs(ExportScript.AF.TmpWeaponPanel) do + ExportScript.Tools.SendData(key, value) + end + end + + if ExportScript.Config.DACExport and lFunctionTyp == "DAC" then + for key, value in pairs(ExportScript.AF.TmpWeaponPanelPresend) do + ExportScript.Tools.SendDataDAC(key, value) + end + for key, value in pairs(ExportScript.AF.TmpWeaponPanelActive) do + ExportScript.Tools.SendDataDAC(key, value) + end + end +end + +-- Weapon Panel for MiG-29A and MiG-29S +function ExportScript.AF.FC_WeaponPanel_MiG29(FunctionTyp) + local lFunctionTyp = FunctionTyp or "Ikarus" +-- The weapon status panel, quantity and readiness of the currently selected weapon and the remaining gun ammunition are indicated. + if ExportScript.AF.TmpWeaponPanelPresend == nil then + ExportScript.AF.TmpWeaponPanelPresend = {[100] = 0, [101] = 0, [102] = 0, [103] = 0, [104] = 0, [105] = 0, [106] = 0} + end + + if ExportScript.AF.TmpWeaponPanelActive == nil then + ExportScript.AF.TmpWeaponPanelActive = {[201] = 0, [202] = 0, [203] = 0, [204] = 0, [205] = 0, [206] = 0} + end + + if ExportScript.AF.EventNumberFC_WeaponPanel == nil then + ExportScript.AF.EventNumberFC_WeaponPanel = 0 + end + + if(ExportScript.AF.EventNumberFC_WeaponPanel < ExportScript.AF.EventNumber) then + ExportScript.AF.EventNumberFC_WeaponPanel = ExportScript.AF.EventNumber + + -- defination + ExportScript.AF.PayloadInfo = LoGetPayloadInfo() + if ExportScript.AF.PayloadInfo ~= nil then + if ExportScript.AF.CurrentStationTmp == nil then + ExportScript.AF.CurrentStationTmp = -1 + end + + if ExportScript.AF.PayloadInfo.CurrentStation > 0 and + ExportScript.AF.CurrentStationTmp ~= ExportScript.AF.PayloadInfo.CurrentStation then + ExportScript.AF.CurrentStationTmp = ExportScript.AF.PayloadInfo.CurrentStation + + ExportScript.AF.TmpStationToPanel = {} + ExportScript.AF.TmpStationToPanel[1] = {Panel = 1, StationID = 101, CurrentID = 201 } -- left + ExportScript.AF.TmpStationToPanel[3] = {Panel = 2, StationID = 102, CurrentID = 202 } + ExportScript.AF.TmpStationToPanel[5] = {Panel = 3, StationID = 103, CurrentID = 203 } + ExportScript.AF.TmpStationToPanel[6] = {Panel = 4, StationID = 104, CurrentID = 204 } + ExportScript.AF.TmpStationToPanel[4] = {Panel = 5, StationID = 105, CurrentID = 205 } + ExportScript.AF.TmpStationToPanel[2] = {Panel = 6, StationID = 106, CurrentID = 206 } -- right + + -- ExportScript.AF.TmpWeaponPanelActive reset + for i = 201, 206, 1 do + ExportScript.AF.TmpWeaponPanelActive[i] = 0 + end + + if ExportScript.AF.TmpStationToPanel[ExportScript.AF.PayloadInfo.CurrentStation] ~= nil then + ExportScript.AF.TmpWeaponPanelActive[ExportScript.AF.TmpStationToPanel[ExportScript.AF.PayloadInfo.CurrentStation].CurrentID] = 1 -- currrent value + + table.foreach(ExportScript.AF.PayloadInfo.Stations, ExportScript.AF.WeaponStatusPanel_selectCurrentPayloadStation) -- corresponding station + end + end + --[[ + Weapon Panel + | + ------------------------------- + | | | | | | | + 1 2 3 C 4 5 6 + ]] + ExportScript.AF.TmpWeaponPanelPresend[100] = ExportScript.AF.PayloadInfo.Cannon.shells + ExportScript.AF.TmpWeaponPanelPresend[101] = (ExportScript.AF.PayloadInfo.Stations[1].count > 0 and 1 or 0) -- weapon presend panel 1 + ExportScript.AF.TmpWeaponPanelPresend[102] = (ExportScript.AF.PayloadInfo.Stations[3].count > 0 and 1 or 0) -- weapon presend panel 2 + ExportScript.AF.TmpWeaponPanelPresend[103] = (ExportScript.AF.PayloadInfo.Stations[5].count > 0 and 1 or 0) -- weapon presend panel 3 + ExportScript.AF.TmpWeaponPanelPresend[104] = (ExportScript.AF.PayloadInfo.Stations[6].count > 0 and 1 or 0) -- weapon presend panel 4 + ExportScript.AF.TmpWeaponPanelPresend[105] = (ExportScript.AF.PayloadInfo.Stations[4].count > 0 and 1 or 0) -- weapon presend panel 5 + ExportScript.AF.TmpWeaponPanelPresend[106] = (ExportScript.AF.PayloadInfo.Stations[2].count > 0 and 1 or 0) -- weapon presend panel 6 + --ExportScript.AF.TmpWeaponPanelActive[201] -- weapon active panel 1 + --ExportScript.AF.TmpWeaponPanelActive[202] -- weapon active panel 2 + --ExportScript.AF.TmpWeaponPanelActive[203] -- weapon active panel 3 + --ExportScript.AF.TmpWeaponPanelActive[204] -- weapon active panel 4 + --ExportScript.AF.TmpWeaponPanelActive[205] -- weapon active panel 5 + --ExportScript.AF.TmpWeaponPanelActive[206] -- weapon active panel 6 + end + end + + if ExportScript.Config.IkarusExport and lFunctionTyp == "Ikarus" then + for key, value in pairs(ExportScript.AF.TmpWeaponPanelPresend) do + ExportScript.Tools.SendData(key, value) + end + for key, value in pairs(ExportScript.AF.TmpWeaponPanelActive) do + ExportScript.Tools.SendData(key, value) + end + end + + if ExportScript.Config.DACExport and lFunctionTyp == "DAC" then + for key, value in pairs(ExportScript.AF.TmpWeaponPanelPresend) do + ExportScript.Tools.SendDataDAC(key, value) + end + for key, value in pairs(ExportScript.AF.TmpWeaponPanelActive) do + ExportScript.Tools.SendDataDAC(key, value) + end + end +end + +-- HSI for SU25T, SU-27, SU-33, MIG-29 +function ExportScript.AF.FC_Russian_HSI(distancetoway) + local lDistanceToWay = distancetoway or 999 + + local lDefaultOne = 1.0 + local lDefaultNull = 0.0 + local lRadToDCSunsignd = math.pi * 2 + local lPitch,lBank,lYaw = LoGetADIPitchBankYaw() -- PITCH, BANK, YAW (Radian) + local lHSI_RMI = LoGetControlPanel_HSI().RMI_raw -- VOR1 OBS (Radian) + local lHSI_ADF = LoGetControlPanel_HSI().ADF_raw -- ADF OBS (Radian) + local lHSI_Curse = LoGetControlPanel_HSI().Course -- HSI Course (Radian) + local lGlide = LoGetGlideDeviation() -- VOR1 HORIZONTAL DEFLECTION (-1 +1) + local lSide = LoGetSideDeviation() -- VOR1 VERTICAL DEFLECTION (-1 +1) + local lHeading = LoGetSelfData().Heading -- HEADING (Radian) + lPitch, lBank = nil +--[[ + [Course] = number: "0.76548692098835" + [CourseDeviation] = number: "0" + [ADF_raw] = number: "5.5811524391174" + [BearingPointer] = number: "0.80134677481978" + [RMI_raw] = number: "5.4092655181885" + [HeadingPointer] = number: "0.098191173578347" + [Heading_raw] = number: "6.2831854820251" + ]] + --[[ + Ka-50 HSI + [112] = "%.4f", -- HSI_heading {0.0, 1.0} + [118] = "%.4f", -- HSI_commanded_course_needle {0.0, 1.0} + [124] = "%.4f", -- HSI_commanded_heading_needle {0.0, 1.0} + [115] = "%.4f", -- HSI_bearing_needle {0.0, 1.0} + [119] = "%0.1f", -- HSI_heading_warning_flag{0.0,1.0} + [114] = "%0.1f", -- HSI_course_warning_flag{0.0, 1.0} + [125] = "%0.1f", -- HSI_glideslope_warning_flag{0.0, 1.0} + [117] = "%0.4f", -- HSI_range_counter_100 {0.0,1.0} + [527] = "%0.4f", -- HSI_range_counter_10 {0.0,1.0} + [528] = "%0.4f", -- HSI_range_counter_1 {0.0,1.0} + [127] = "%.4f", -- HSI_longitudinal_deviation{-1.0, 1.0} + [128] = "%.4f", -- HSI_lateral_deviation{-1.0, 1.0} + [116] = "%0.1f", -- HSI_range_unavailable_flag{0.0, 1.0} + [121] = "%0.1f", -- HSI_course_unavailable_flag{0.0, 1.0} + ]] + local lAltCounter = {[0] = 0.0, [1] = 0.11, [2] = 0.22, [3] = 0.33, [4] = 0.44, [5] = 0.55, [6] = 0.66, [7] = 0.77, [8] = 0.88, [9] = 0.99} + lDistanceToWay = ExportScript.Tools.round(lDistanceToWay / 1000, 1) + local lDistanceToWayTmp = string.format("%03d", lDistanceToWay) + local lRangeCounter1 = 0 + local lRangeCounter2 = 0 + local lRangeCounter3 = 0 + if lDistanceToWay > 100 then + lRangeCounter1 = ExportScript.Tools.round((lDistanceToWay / 100), 0, "floor") * 0.11 + lRangeCounter1 = lRangeCounter1 - ExportScript.Tools.round(lRangeCounter1, 0, "floor") + end + if lDistanceToWay > 10 then + if lDistanceToWay > 100 then + lRangeCounter2 = (ExportScript.Tools.round((lDistanceToWay - (ExportScript.Tools.round(lDistanceToWay / 100, 0, "floor") * 100)), 0, "floor") / 10) * 0.11 + else + lRangeCounter2 = (lDistanceToWay / 10) * 0.11 + lRangeCounter2 = lRangeCounter2 - ExportScript.Tools.round(lRangeCounter2, 0, "floor") + end + end + if lDistanceToWay > 10 then + lRangeCounter3 = (lDistanceToWay - (ExportScript.Tools.round(lDistanceToWay / 10, 0, "floor") * 10)) * 0.11 + else + lRangeCounter3 = lDistanceToWay * 0.11 + end + + lHeading = (lHeading / lRadToDCSunsignd) + -- HSI_heading {0.0, 1.0} + -- HSI_commanded_course_needle {0.0, 1.0} + -- HSI_commanded_heading_needle {0.0, 1.0} + -- HSI_bearing_needle {0.0, 1.0} + -- HSI_heading_warning_flag{0.0,1.0} + -- HSI_course_warning_flag{0.0, 1.0} + -- HSI_glideslope_warning_flag{0.0, 1.0} + -- HSI_range_counter_100 {0.0,1.0} + -- HSI_range_counter_10 {0.0,1.0} + -- HSI_range_counter_1 {0.0,1.0} + -- HSI_longitudinal_deviation{-1.0, 1.0} + -- HSI_lateral_deviation{-1.0, 1.0} + -- HSI_range_unavailable_flag{0.0, 1.0} + -- HSI_course_unavailable_flag{0.0, 1.0} + + ExportScript.Tools.SendData(11, string.format("%.4f", lHeading)) -- compass card + ExportScript.Tools.SendData(12, string.format("%.4f", ((lHeading + (lHSI_Curse / lRadToDCSunsignd)) - 1))) -- double arrow + ExportScript.Tools.SendData(13, string.format("%.4f", lHeading)) -- yellow triangle + ExportScript.Tools.SendData(14, string.format("%.4f", (0 - (lHeading + (lHSI_ADF / lRadToDCSunsignd))))) -- yellow arrow + ExportScript.Tools.SendData(15, lDefaultNull) -- KC Flag + ExportScript.Tools.SendData(16, lDefaultOne) -- K Flag + ExportScript.Tools.SendData(17, lDefaultOne) -- L Flag + ExportScript.Tools.SendData(18, string.format("%.4f", lAltCounter[tonumber(string.sub(lDistanceToWayTmp, 1, 1))])) + ExportScript.Tools.SendData(19, string.format("%.4f", lAltCounter[tonumber(string.sub(lDistanceToWayTmp, 2, 2))])) + ExportScript.Tools.SendData(20, string.format("%.4f", lRangeCounter3)) + ExportScript.Tools.SendData(21, string.format("%.4f", lGlide)) + ExportScript.Tools.SendData(22, string.format("%.4f", lSide)) + ExportScript.Tools.SendData(23, lDefaultNull) + ExportScript.Tools.SendData(24, lDefaultNull) +end + +-- HSI for SU25A +function ExportScript.AF.FC_Russian_HSI_old() + + local lDefaultOne = 1.0 + local lDefaultNull = 0.0 + local lRadToDCSsignd = math.pi + local lRadToDCSunsignd = math.pi * 2 + local lHSI_ADF = LoGetControlPanel_HSI().ADF_raw -- ADF OBS (Radian) + local lHSI_Curse = LoGetControlPanel_HSI().Course -- HSI Course (Radian) + local lGlide = LoGetGlideDeviation() -- VOR1 HORIZONTAL DEFLECTION (-1 +1) + local lSide = LoGetSideDeviation() -- VOR1 VERTICAL DEFLECTION (-1 +1) + local lHeading = LoGetSelfData().Heading -- HEADING (Radian) +--[[ + [Course] = number: "0.76548692098835" + [CourseDeviation] = number: "0" + [ADF_raw] = number: "5.5811524391174" + [BearingPointer] = number: "0.80134677481978" + [RMI_raw] = number: "5.4092655181885" + [HeadingPointer] = number: "0.098191173578347" + [Heading_raw] = number: "6.2831854820251" + ]] + + lHeading = (lHeading / lRadToDCSunsignd) + -- HSI_heading {0.0, 1.0} compass card + -- HSI_commanded_course_needle {0.0, 1.0} (Required heading) white needle + -- HSI_bearing_needle {0.0, 1.0} (RMI bearing) yellow needle + -- Flag Г (T){0.0,1.0} + -- Flag К (K){0.0,1.0} + -- ILS needle horizontal{-1.0, 1.0} + -- ILS needle vertical{-1.0, 1.0} + + ExportScript.Tools.SendData(11, string.format("%.4f", lHeading)) -- compass card + ExportScript.Tools.SendData(12, string.format("%.4f", ((lHeading + (lHSI_Curse / lRadToDCSunsignd)) - 0.5))) -- white needle + --ExportScript.Tools.SendData(12, string.format("%.4f", ((lHeading + (lHSI_Curse / lRadToDCSunsignd)) - 1))) -- white needle + --ExportScript.Tools.SendData(12, string.format("%.4f", (lHeading + (lHSI_Curse / lRadToDCSsignd)))) -- white needle + --ExportScript.Tools.SendData(13, string.format("%.4f", (0 - (lHeading + (lHSI_ADF / lRadToDCSunsignd))))) -- yellow needle + --ExportScript.Tools.SendData(13, string.format("%.4f", (0 - (lHeading + (lHSI_ADF / lRadToDCSsignd))))) -- yellow needle + ExportScript.Tools.SendData(13, string.format("%.4f", (0 - (lHSI_ADF / lRadToDCSunsignd)))) -- yellow needle + ExportScript.Tools.SendData(16, lDefaultOne) -- T Flag + ExportScript.Tools.SendData(17, lDefaultOne) -- K Flag + ExportScript.Tools.SendData(21, string.format("%.4f", lGlide)) + ExportScript.Tools.SendData(22, string.format("%.4f", lSide)) +end + +-- HSI-Distance for SU25A +function ExportScript.AF.FC_Russian_HSI_Distance_old(distancetoway) + local lDistanceToWay = distancetoway or 999 + + local lAltCounter = {[0] = 0.0, [1] = 0.11, [2] = 0.22, [3] = 0.33, [4] = 0.44, [5] = 0.55, [6] = 0.66, [7] = 0.77, [8] = 0.88, [9] = 0.99} + lDistanceToWay = ExportScript.Tools.round(lDistanceToWay / 1000, 1) + local lDistanceToWayTmp = string.format("%03d", lDistanceToWay) + local lRangeCounter1 = 0 + local lRangeCounter2 = 0 + local lRangeCounter3 = 0 + if lDistanceToWay > 100 then + lRangeCounter1 = ExportScript.Tools.round((lDistanceToWay / 100), 0, "floor") * 0.11 + lRangeCounter1 = lRangeCounter1 - ExportScript.Tools.round(lRangeCounter1, 0, "floor") + end + if lDistanceToWay > 10 then + if lDistanceToWay > 100 then + lRangeCounter2 = (ExportScript.Tools.round((lDistanceToWay - (ExportScript.Tools.round(lDistanceToWay / 100, 0, "floor") * 100)), 0, "floor") / 10) * 0.11 + else + lRangeCounter2 = (lDistanceToWay / 10) * 0.11 + lRangeCounter2 = lRangeCounter2 - ExportScript.Tools.round(lRangeCounter2, 0, "floor") + end + end + if lDistanceToWay > 10 then + lRangeCounter3 = (lDistanceToWay - (ExportScript.Tools.round(lDistanceToWay / 10, 0, "floor") * 10)) * 0.11 + else + lRangeCounter3 = lDistanceToWay * 0.11 + end + + ExportScript.Tools.SendData(18, string.format("%.4f", lAltCounter[tonumber(string.sub(lDistanceToWayTmp, 1, 1))])) + ExportScript.Tools.SendData(19, string.format("%.4f", lAltCounter[tonumber(string.sub(lDistanceToWayTmp, 2, 2))])) + ExportScript.Tools.SendData(20, string.format("%.4f", lRangeCounter3)) +end + +-- ADI for SU-25, SU25T, SU-27, MIG-29A and MIG-29S +function ExportScript.AF.FC_Russian_ADI_Old() + + local lDefaultNull = 0.0 + local lRadToDCSsignd = math.pi + local lNavInfoPitch = LoGetNavigationInfo().Requirements.pitch -- AP REQUIRED PITCH (Radian) + local lNavInfoRoll = LoGetNavigationInfo().Requirements.roll -- AP REQUIRED BANK (Radian) + local lPitch, lBank, lYaw = LoGetADIPitchBankYaw() -- PITCH, BANK, YAW (Radian) + local lSlipBallPosition = LoGetSlipBallPosition() -- SLIP BALL (-1 +1) +-- ADI (IKP-81) + --------------------------------------------------- + --[[ + [100] = "%.4f", -- ADI_Roll {-1.0,1.0} + [101] = "%.4f", -- ADI_Pitch {-math.pi/2.0,math.pi/2.0}{1.0,-1.0} + [102] = "%0.1f", -- ADI_steering_warning_flag {0.0,1.0} + [109] = "%0.1f", -- ADI_attitude_warning_flag {0.0,1.0} + [107] = "%.4f", -- ADI_bank_steering {-1.0,1.0} + [106] = "%.4f", -- ADI_pitch_steering {-1.0,1.0} + [111] = "%.4f", -- ADI_airspeed_deviation {-1.0,1.0} + [103] = "%.4f", -- ADI_track_deviation {-1.0,1.0} + [526] = "%.4f", -- ADI_height_deviation {-1.0,1.0} + [108] = "%.4f", -- ADI_sideslip {-1.0,1.0} + ]] + lNavInfoPitch = lNavInfoPitch / lRadToDCSsignd + lNavInfoRoll = lNavInfoRoll / lRadToDCSsignd + lPitch = lPitch / (lRadToDCSsignd / 2) + lPitch = (lPitch > 0.0 and (0 - lPitch) or (lPitch + lPitch + lPitch)) -- pitch muss negiert werden + --lBank = lBank / (lRadToDCSsignd / 2) + lBank = lBank / lRadToDCSsignd + + ExportScript.Tools.SendData(1, string.format("%.4f", lBank)) + ExportScript.Tools.SendData(2, string.format("%.4f", lPitch)) + ExportScript.Tools.SendData(3, lDefaultNull) + ExportScript.Tools.SendData(4, lDefaultNull) + ExportScript.Tools.SendData(5, string.format("%.4f", lNavInfoRoll)) + ExportScript.Tools.SendData(6, string.format("%.4f", lNavInfoPitch)) + ExportScript.Tools.SendData(7, lDefaultNull) + ExportScript.Tools.SendData(8, lDefaultNull) + ExportScript.Tools.SendData(9, lDefaultNull) + ExportScript.Tools.SendData(10, string.format("%.4f", lSlipBallPosition)) +end + +-- ADI for SU-33 +function ExportScript.AF.FC_Russian_ADI_New() + + local lDefaultNull = 0.0 + local lRadToDCSsignd = math.pi + local lNavInfoPitch = LoGetNavigationInfo().Requirements.pitch -- AP REQUIRED PITCH (Radian) + local lNavInfoRoll = LoGetNavigationInfo().Requirements.roll -- AP REQUIRED BANK (Radian) + local lPitch, lBank, lYaw = LoGetADIPitchBankYaw() -- PITCH, BANK, YAW (Radian) + local lSlipBallPosition = LoGetSlipBallPosition() -- SLIP BALL (-1 +1) +-- ADI + --------------------------------------------------- + --[[ + [100] = "%.4f", -- ADI_Roll {-1.0,1.0} + [101] = "%.4f", -- ADI_Pitch {-math.pi/2.0,math.pi/2.0}{1.0,-1.0} + [102] = "%0.1f", -- ADI_steering_warning_flag {0.0,1.0} + [109] = "%0.1f", -- ADI_attitude_warning_flag {0.0,1.0} + [107] = "%.4f", -- ADI_bank_steering {-1.0,1.0} + [106] = "%.4f", -- ADI_pitch_steering {-1.0,1.0} + [111] = "%.4f", -- ADI_airspeed_deviation {-1.0,1.0} + [103] = "%.4f", -- ADI_track_deviation {-1.0,1.0} + [526] = "%.4f", -- ADI_height_deviation {-1.0,1.0} + [108] = "%.4f", -- ADI_sideslip {-1.0,1.0} + ]] + lNavInfoPitch = lNavInfoPitch / lRadToDCSsignd + lNavInfoRoll = lNavInfoRoll / lRadToDCSsignd + lPitch = lPitch / (lRadToDCSsignd / 2) + lPitch = (lPitch > 0.0 and (0 - lPitch) or (lPitch + lPitch + lPitch)) -- pitch muss negiert werden + lBank = lBank / lRadToDCSsignd --(lRadToDCSsignd / 2) + + ExportScript.Tools.SendData(1, string.format("%.4f", lBank)) + ExportScript.Tools.SendData(2, string.format("%.4f", lPitch)) + ExportScript.Tools.SendData(3, lDefaultNull) + ExportScript.Tools.SendData(4, lDefaultNull) + ExportScript.Tools.SendData(5, string.format("%.4f", lNavInfoRoll)) + ExportScript.Tools.SendData(6, string.format("%.4f", lNavInfoPitch)) + ExportScript.Tools.SendData(7, lDefaultNull) + ExportScript.Tools.SendData(8, lDefaultNull) + ExportScript.Tools.SendData(9, lDefaultNull) + ExportScript.Tools.SendData(10, string.format("%.4f", lSlipBallPosition)) +end + +-- Radar Altimeter for SU-25A, SU25-T, SU-27, SU-33 +function ExportScript.AF.FC_Russian_RadarAltimeter_1500m(warningflag) + local lWarning_Flag = warningflag or 100 + + local lScaleValue = 1500 + local lAltRad = LoGetAltitudeAboveGroundLevel() -- ALTITUDE GROUND LEVEL (Meter) + + lAltRad = lAltRad / lScaleValue -- (1500 m ist die maximalhoehe des Messgeraetes) + lAltRad = (lAltRad > 1.0 and 1.0 or lAltRad) -- the result is limited to 1.0 + local lDangerRALT = lWarning_Flag / lScaleValue -- 0.14 -- 50m ((50 * 1) / 350) + local lWarning_Flag = (lAltRad == 1.0 and 1.0 or 0.0) -- (Flag an wenn Hoehe auf 1.0 ist) + local lDangerRALT_Lamp = (lAltRad < lDangerRALT and 1.0 or 0.0) -- (Flag an wenn Hoehe niedriger als 0.14) + -- AltRad {0.0,1.0} + -- DangerRALT {0.0,1.0} + -- Warning_Flag {0, 1} + -- DangerRALT_Lamp {0, 1} + + ExportScript.Tools.SendData(25, string.format("%.4f", lAltRad)) + ExportScript.Tools.SendData(26, string.format("%.4f", lDangerRALT)) + ExportScript.Tools.SendData(27, lWarning_Flag) + ExportScript.Tools.SendData(28, lDangerRALT_Lamp) +end + +-- Radar Altimeter for MiG-29A, MiG-29S +function ExportScript.AF.FC_Russian_RadarAltimeter_1000m(warningflag) + local lWarning_Flag = warningflag or 100 + + local lScaleValue = 1000 + local lAltRad = LoGetAltitudeAboveGroundLevel() -- ALTITUDE GROUND LEVEL (Meter) + + lAltRad = lAltRad / lScaleValue -- (1000 m ist die maximalhoehe des Messgeraetes) + lAltRad = (lAltRad > 1.0 and 1.0 or lAltRad) -- the result is limited to 1.0 + local lDangerRALT = lWarning_Flag / lScaleValue -- 0.14 -- 50m ((50 * 1) / 350) + local lWarning_Flag = (lAltRad == 1.0 and 1.0 or 0.0) -- (Flag an wenn Hoehe auf 1.0 ist) + local lDangerRALT_Lamp = (lAltRad < lDangerRALT and 1.0 or 0.0) -- (Flag an wenn Hoehe niedriger als 0.14) + -- AltRad {0.0,1.0} + -- DangerRALT {0.0,1.0} + -- Warning_Flag {0, 1} + -- DangerRALT_Lamp {0, 1} + + ExportScript.Tools.SendData(25, string.format("%.4f", lAltRad)) + ExportScript.Tools.SendData(26, string.format("%.4f", lDangerRALT)) + ExportScript.Tools.SendData(27, lWarning_Flag) + ExportScript.Tools.SendData(28, lDangerRALT_Lamp) +end + +-- Barometric Altimeter for SU-25A, SU25-T +function ExportScript.AF.FC_Russian_BarometricAltimeter_late() + + local lBasicAtmospherePressure = LoGetBasicAtmospherePressure() -- BAROMETRIC PRESSURE (mm Hg) + local lAltBar = LoGetAltitudeAboveSeaLevel() -- ALTITUDE SEA LEVEL (Meter) + local lAltBar_kilometer_needle = 0 + local lAltBar_meter_needle = 0 + + lAltBar = lAltBar - ((9.5 * (760 - lBasicAtmospherePressure)) / 2) -- 9.5 m per 1mmHg difference + + if lAltBar > 10000 then + lAltBar_kilometer_needle = lAltBar / 100000 + else + lAltBar_kilometer_needle = lAltBar / 10000 + end + if lAltBar > 1000 then + lAltBar_meter_needle = lAltBar / 1000 + lAltBar_meter_needle = lAltBar_meter_needle - ExportScript.Tools.round(lAltBar_meter_needle, 0, "floor") + else + lAltBar_meter_needle = lAltBar / 1000 + end + lAltBar = lAltBar / 1000 + + -- AltBar_kilometer_needle {0.0,1.0} + -- AltBar_meter_needle {0.0,1.0} + -- BasicAtmospherePressure {600.0, 800.0} + -- AltBar_kilometer {0.0, 99.9} + + ExportScript.Tools.SendData(30, string.format("%.4f", lAltBar_kilometer_needle)) + ExportScript.Tools.SendData(31, string.format("%.4f", lAltBar_meter_needle)) + ExportScript.Tools.SendData(32, string.format("%.4f", lBasicAtmospherePressure)) + ExportScript.Tools.SendData(33, string.format("%.4f", lAltBar)) +end + +-- Barometric Altimeter for SU-27, SU-33 +function ExportScript.AF.FC_Russian_BarometricAltimeter_20000() + + local lBasicAtmospherePressure = LoGetBasicAtmospherePressure() -- BAROMETRIC PRESSURE (mm Hg) + local lAltBar = LoGetAltitudeAboveSeaLevel() -- ALTITUDE SEA LEVEL (Meter) + local lAltBar_kilometer_needle = 0 + local lAltBar_meter_needle = 0 + + lAltBar = lAltBar - ((9.5 * (760 - lBasicAtmospherePressure)) / 2) -- 9.5 m per 1mmHg difference + + if lAltBar > 10000 then + lAltBar_kilometer_needle = lAltBar / 200000 + else + lAltBar_kilometer_needle = lAltBar / 20000 + end + if lAltBar > 1000 then + lAltBar_meter_needle = lAltBar / 1000 + lAltBar_meter_needle = lAltBar_meter_needle - ExportScript.Tools.round(lAltBar_meter_needle, 0, "floor") + else + lAltBar_meter_needle = lAltBar / 1000 + end + lBasicAtmospherePressure = (lBasicAtmospherePressure - 600) / 200 + + -- AltBar_kilometer_needle {0.0,1.0} + -- AltBar_meter_needle {0.0,1.0} + -- BasicAtmospherePressure {0.0, 1.0}={600.0, 800.0} + + ExportScript.Tools.SendData(30, string.format("%.4f", lAltBar_kilometer_needle)) + ExportScript.Tools.SendData(31, string.format("%.4f", lAltBar_meter_needle)) + ExportScript.Tools.SendData(32, string.format("%.4f", lBasicAtmospherePressure)) +end + +-- Barometric Altimeter for MiG-29A, MiG-29S +function ExportScript.AF.FC_Russian_BarometricAltimeter_30000() + + local lBasicAtmospherePressure = LoGetBasicAtmospherePressure() -- BAROMETRIC PRESSURE (mm Hg) + local lAltBar = LoGetAltitudeAboveSeaLevel() -- ALTITUDE SEA LEVEL (Meter) + local lAltBar_kilometer_needle = 0 + local lAltBar_meter_needle = 0 + + lAltBar = lAltBar - ((9.5 * (760 - lBasicAtmospherePressure)) / 2) -- 9.5 m per 1mmHg difference + + if lAltBar > 10000 then + lAltBar_kilometer_needle = lAltBar / 300000 + else + lAltBar_kilometer_needle = lAltBar / 30000 + end + if lAltBar > 1000 then + lAltBar_meter_needle = lAltBar / 1000 + lAltBar_meter_needle = lAltBar_meter_needle - ExportScript.Tools.round(lAltBar_meter_needle, 0, "floor") + else + lAltBar_meter_needle = lAltBar / 1000 + end + lBasicAtmospherePressure = (lBasicAtmospherePressure - 600) / 200 + + -- AltBar_kilometer_needle {0.0,1.0} + -- AltBar_meter_needle {0.0,1.0} + -- BasicAtmospherePressure {0.0, 1.0}={600.0, 800.0} + + ExportScript.Tools.SendData(30, string.format("%.4f", lAltBar_kilometer_needle)) + ExportScript.Tools.SendData(31, string.format("%.4f", lAltBar_meter_needle)) + ExportScript.Tools.SendData(32, string.format("%.4f", lBasicAtmospherePressure)) +end + +-- Air Speed Indicator for SU-25A, SU-25T +function ExportScript.AF.FC_Russian_AirSpeed_1100hkm() + + local lIAS = LoGetIndicatedAirSpeed() * 3.6 -- INDICATED AIRSPEED (Meter/Second to Km/h) + local lTAS = LoGetTrueAirSpeed() * 3.6 -- TRUE AIRSPEED (Meter/Second to Km/h) + + --[[ + y_min = 0.0 0.09 -- minimaler Ausgabewert + y_max = 0.09 1.0 -- maximaler Ausgabewert + x_min = 0 100 -- minimaler Eingangswert + x_max = 100 1100 -- maximaler Eingangswert + x = 50 700 -- aktueller Eingangswert + + d_y = 0.09 0.91 -- Delta Ausgabewerte (y_max - y_min) + d_x = 100 1000 -- Delta Eingangswerte (x_max - x_min) + m = 0.0009 0.00091 -- Steigung der linearen Funktion (d_y / d_x) + n = 0.0 -0.001 -- Schnittpunkt der Funktion mit y-Achse (y_max - m * x_max) + + y = 0,0171875 0,636 -- Ergebnis (m * x + n) + ]] + if lIAS > 100 then + lIAS = 0.00091 * lIAS + -0.001 + else + lIAS = 0.0009 * lIAS + end + + --[[ + y_min = 0.0 -- minimaler Ausgabewert + y_max = 1.0 -- maximaler Ausgabewert + x_min = 400 -- minimaler Eingangswert + x_max = 1100 -- maximaler Eingangswert + x = 800 -- aktueller Eingangswert + + d_y = 1.0 -- Delta Ausgabewerte (y_max - y_min) + d_x = 700 -- Delta Eingangswerte (x_max - x_min) + m = 0.00142857142857142857142857142857 -- Steigung der linearen Funktion (d_y / d_x) + n = -0.571428571428571428571428571427 -- Schnittpunkt der Funktion mit y-Achse (y_max - m * x_max) + + y = 0.571428571428571428571428571429 -- Ergebnis (m * x + n) + ]] + if lTAS > 400 then + lTAS = 0.00142857142857142857142857142857 * lTAS + -0.571428571428571428571428571427 + else + lTAS = 0.0 + end + + -- IAS {0.0,1.0} + -- TAS {0.0,1.0} + + ExportScript.Tools.SendData(35, string.format("%.4f", lIAS)) + ExportScript.Tools.SendData(36, string.format("%.4f", lTAS)) +end + +-- Air Speed Indicator for SU-27, SU-33 +function ExportScript.AF.FC_Russian_AirSpeed_1600hkm() + + local lScaleValueIAS = 1600 + local lScaleValueMach = 3.5 + local lIAS = LoGetIndicatedAirSpeed() * 3.6 -- INDICATED AIRSPEED (Meter/Second to Km/h) + local lMACH = LoGetMachNumber() -- MACH + local lMACHtmp = 0 + local lIAStmp = 0 + + if lIAS > 0 and lIAS <= 100 then + --[[ + y_min = 0.0 -- minimaler Ausgabewert + y_max = 0.03125 -- maximaler Ausgabewert + x_min = 0 -- minimaler Eingangswert + x_max = 100 -- maximaler Eingangswert + x = 55 -- aktueller Eingangswert + + d_y = 0.03125 -- Delta Ausgabewerte (y_max - y_min) + d_x = 100 -- Delta Eingangswerte (x_max - x_min) + m = 0.0003125 -- Steigung der linearen Funktion (d_y / d_x) + n = 0.0 -- Schnittpunkt der Funktion mit y-Achse (y_max - m * x_max) + + y = 0,0171875 -- Ergebnis (m * x + n) + ]] + lIAStmp = 0.0003125 * lIAS + elseif lIAS > 100 and lIAS <= 500 then + --[[ + y_min = 0.03125 -- minimaler Ausgabewert + y_max = 0.427 -- maximaler Ausgabewert + x_min = 100 -- minimaler Eingangswert + x_max = 500 -- maximaler Eingangswert + x = 250 -- aktueller Eingangswert + + d_y = 0.39575 -- Delta Ausgabewerte (y_max - y_min) + d_x = 400 -- Delta Eingangswerte (x_max - x_min) + m = 0.000989375 -- Steigung der linearen Funktion (d_y / d_x) + n = -0.0676875 -- Schnittpunkt der Funktion mit y-Achse (y_max - m * x_max) + + y = 0,0171875 -- Ergebnis (m * x + n) + ]] + lIAStmp = 0.000989375 * lIAS + -0.0676875 + elseif lIAS > 500 and lIAS <= 600 then + --[[ + y_min = 0.427 -- minimaler Ausgabewert + y_max = 0.51 -- maximaler Ausgabewert + x_min = 500 -- minimaler Eingangswert + x_max = 600 -- maximaler Eingangswert + x = 550 -- aktueller Eingangswert + + d_y = 0.083 -- Delta Ausgabewerte (y_max - y_min) + d_x = 100 -- Delta Eingangswerte (x_max - x_min) + m = 0.00083 -- Steigung der linearen Funktion (d_y / d_x) + n = 0.012 -- Schnittpunkt der Funktion mit y-Achse (y_max - m * x_max) + + y = 0.4685 -- Ergebnis (m * x + n) + ]] + lIAStmp = 0.00083 * lIAS + 0.012 + elseif lIAS > 600 and lIAS <= 1000 then + --[[ + y_min = 0.51 -- minimaler Ausgabewert + y_max = 0.753 -- maximaler Ausgabewert + x_min = 600 -- minimaler Eingangswert + x_max = 1000 -- maximaler Eingangswert + x = 800 -- aktueller Eingangswert + + d_y = 0.243 -- Delta Ausgabewerte (y_max - y_min) + d_x = 400 -- Delta Eingangswerte (x_max - x_min) + m = 0.0006075 -- Steigung der linearen Funktion (d_y / d_x) + n = 0.1455 -- Schnittpunkt der Funktion mit y-Achse (y_max - m * x_max) + + y = 0.6315 -- Ergebnis (m * x + n) + ]] + lIAStmp = 0.0006075 * lIAS + 0.1455 + elseif lIAS > 1000 and lIAS <= 1200 then + --[[ + y_min = 0.753 -- minimaler Ausgabewert + y_max = 0.84375 -- maximaler Ausgabewert + x_min = 1000 -- minimaler Eingangswert + x_max = 1200 -- maximaler Eingangswert + x = 1100 -- aktueller Eingangswert + + d_y = 0.09075 -- Delta Ausgabewerte (y_max - y_min) + d_x = 200 -- Delta Eingangswerte (x_max - x_min) + m = 0.00045375 -- Steigung der linearen Funktion (d_y / d_x) + n = 0.29925 -- Schnittpunkt der Funktion mit y-Achse (y_max - m * x_max) + + y = 0.798375 -- Ergebnis (m * x + n) + ]] + lIAStmp = 0.00045375 * lIAS + 0.29925 + elseif lIAS > 1200 and lIAS <= 1600 then + --[[ + y_min = 0.84375 -- minimaler Ausgabewert + y_max = 1.0 -- maximaler Ausgabewert + x_min = 1200 -- minimaler Eingangswert + x_max = 1600 -- maximaler Eingangswert + x = 1400 -- aktueller Eingangswert + + d_y = 0.15625 -- Delta Ausgabewerte (y_max - y_min) + d_x = 400 -- Delta Eingangswerte (x_max - x_min) + m = 0.000390625 -- Steigung der linearen Funktion (d_y / d_x) + n = 0.375 -- Schnittpunkt der Funktion mit y-Achse (y_max - m * x_max) + + y = 0.921875 -- Ergebnis (m * x + n) + ]] + lIAStmp = 0.000390625 * lIAS + 0.375 + end + + if lMACH > 0.6 and lMACH <= 0.9 then + --[[ + y_min = 0.0 -- minimaler Ausgabewert + y_max = 0.273 -- maximaler Ausgabewert + x_min = 0.6 -- minimaler Eingangswert + x_max = 0.9 -- maximaler Eingangswert + x = 0.75 -- aktueller Eingangswert + + d_y = 0.273 -- Delta Ausgabewerte (y_max - y_min) + d_x = 0.3 -- Delta Eingangswerte (x_max - x_min) + m = 0.91 -- Steigung der linearen Funktion (d_y / d_x) + n = -0.546 -- Schnittpunkt der Funktion mit y-Achse (y_max - m * x_max) + + y = 0.1365 -- Ergebnis (m * x + n) + ]] + lMACHtmp = 0.91 * lMACH + -0.546 + elseif lMACH > 0.9 and lMACH <= 1.5 then + --[[ + y_min = 0.273 -- minimaler Ausgabewert + y_max = 0.545 -- maximaler Ausgabewert + x_min = 0.9 -- minimaler Eingangswert + x_max = 1.5 -- maximaler Eingangswert + x = 1.3 -- aktueller Eingangswert + + d_y = 0.272 -- Delta Ausgabewerte (y_max - y_min) + d_x = 0.6 -- Delta Eingangswerte (x_max - x_min) + m = 0.45333333333333333333333333333333 -- Steigung der linearen Funktion (d_y / d_x) + n = -0.135 -- Schnittpunkt der Funktion mit y-Achse (y_max - m * x_max) + + y = 0.45433333333333333333333333333333 -- Ergebnis (m * x + n) + ]] + lMACHtmp = 0.45333333333333333333333333333333 * lMACH + -0.135 + elseif lMACH > 1.5 and lMACH <= 3.5 then + --[[ + y_min = 0.545 -- minimaler Ausgabewert + y_max = 1.0 -- maximaler Ausgabewert + x_min = 1.5 -- minimaler Eingangswert + x_max = 3.5 -- maximaler Eingangswert + x = 2.3 -- aktueller Eingangswert + + d_y = 0.455 -- Delta Ausgabewerte (y_max - y_min) + d_x = 2.0 -- Delta Eingangswerte (x_max - x_min) + m = 0.2275 -- Steigung der linearen Funktion (d_y / d_x) + n = 0.20375 -- Schnittpunkt der Funktion mit y-Achse (y_max - m * x_max) + + y = 0.727 -- Ergebnis (m * x + n) + ]] + lMACHtmp = 0.2275 * lMACH + 0.20375 + end + + -- IAS {0.0,1.0} + -- MACH {0.0,1.0} + + ExportScript.Tools.SendData(35, string.format("%.4f", lIAStmp)) + ExportScript.Tools.SendData(36, string.format("%.4f", lMACHtmp)) +end + +-- Air Speed Indicator for MiG-29A, MiG-29S +function ExportScript.AF.FC_Russian_AirSpeed_1000hkm() + + local lIAS = LoGetIndicatedAirSpeed() * 3.6 -- INDICATED AIRSPEED (Meter/Second to Km/h) + local lThousand = 0.0 + + if lIAS > 1000 then + lThousand = 1.0 + elseif lIAS > 950 then + --[[ + y_min = 0.0 -- minimaler Ausgabewert + y_max = 1.0 -- maximaler Ausgabewert + x_min = 950 -- minimaler Eingangswert + x_max = 1001 -- maximaler Eingangswert + x = 980 -- aktueller Eingangswert + + d_y = 1.0 -- Delta Ausgabewerte (y_max - y_min) + d_x = 51.0 -- Delta Eingangswerte (x_max - x_min) + m = 0.01960784313725490196078431372549 -- Steigung der linearen Funktion (d_y / d_x) + n = -18.627450980392156862745098039215 -- Schnittpunkt der Funktion mit y-Achse (y_max - m * x_max) + + y = 0.5882352941176470588235294117652 -- Ergebnis (m * x + n) + ]] + lThousand = 0.01960784313725490196078431372549 * lIAS + -18.627450980392156862745098039215 + end + --[[ + y_min = 0.0 -- minimaler Ausgabewert + y_max = 1.0 -- maximaler Ausgabewert + x_min = 0.0 -- minimaler Eingangswert + x_max = 1000 -- maximaler Eingangswert + x = 880 -- aktueller Eingangswert + + d_y = 1.0 -- Delta Ausgabewerte (y_max - y_min) + d_x = 1000.0 -- Delta Eingangswerte (x_max - x_min) + m = 0.001 -- Steigung der linearen Funktion (d_y / d_x) + n = 0.0 -- Schnittpunkt der Funktion mit y-Achse (y_max - m * x_max) + + y = 0.88 -- Ergebnis (m * x + n) + ]] + lIAS = 0.001 * lIAS + lIAS = (lIAS > 1.0 and 1.0 or lIAS) -- the result is limited to 1.0 + + -- IAS {0.0,1.0} + -- Thousand {0.0,1.0} + + ExportScript.Tools.SendData(35, string.format("%.4f", lIAS)) + ExportScript.Tools.SendData(36, string.format("%.4f", lThousand)) +end + +-- Machmeter for MiG-29A, MiG-29S +function ExportScript.AF.FC_Russian_Mach_MiG29() + -- Mach {max, Mach} + local lMACH = LoGetMachNumber() -- MACH + --[[ + y_min = 0.0 -- minimaler Ausgabewert + y_max = 1.0 -- maximaler Ausgabewert + x_min = 0.0 -- minimaler Eingangswert + x_max = 3.0 -- maximaler Eingangswert + x = 1.65 -- aktueller Eingangswert + + d_y = 1.0 -- Delta Ausgabewerte (y_max - y_min) + d_x = 3.0 -- Delta Eingangswerte (x_max - x_min) + m = 0.33333333333333333333333333333333 -- Steigung der linearen Funktion (d_y / d_x) + n = 0.00000000000000000000000000000001 -- Schnittpunkt der Funktion mit y-Achse (y_max - m * x_max) + + y = 0.55 -- Ergebnis (m * x + n) + ]] + lMACH = 0.33333333333333333333333333333333 * lMACH + 0.00000000000000000000000000000001 + + ExportScript.Tools.SendData(37, string.format("%0.4f", lMACH)) -- Mach + ExportScript.Tools.SendData(38, 0) -- Mach max +end + +-- Vertical Velocity Indicator (Old Style) for SU-25, SU25T, SU-27, MIG-29A and MIG-29S +function ExportScript.AF.FC_Russian_VVI_Old() + + local lVVI = LoGetVerticalVelocity() -- VERTICAL SPEED (Meter/Second) + local lPitch, lBank, lYaw = LoGetADIPitchBankYaw() -- PITCH, BANK, YAW (Radian) + lBank = math.deg(lBank) + local lSlipBallPosition = LoGetSlipBallPosition() -- SLIP BALL (-1 +1) + --local lTAS = LoGetTrueAirSpeed() -- TRUE AIRSPEED (Meter/Second) + --local lTurn = 0 + + if lVVI >= 0.0 then + lVVI = lVVI / 200 + lVVI = (lVVI > 1.0 and 1.0 or lVVI) -- the result is limited to 1.0 + else + lVVI = lVVI / 200 + lVVI = (lVVI < -1.0 and -1.0 or lVVI) -- the result is limited to -1.0 + end + + if lBank >= 0.0 then + lBank = lBank / 45 + lBank = (lBank > 1.0 and 1.0 or lBank) -- the result is limited to 1.0 + else + lBank = lBank / 45 + lBank = (lBank < -1.0 and -1.0 or lBank) -- the result is limited to -1.0 + end + --lTurn = lTAS / 187.628865979 -- TRUE AIRSPEED (Meter/Second) / 187.628865979 m/s = Turn-Winkel or True Airspeed in Knots/min / 364 Knots + --WriteToLog('lTurn: '..dump(lTurn)) + --WriteToLog('lVVI: '..dump(lVVI)..', lBank :'..dump(lBank)) + -- lVVI {-1.0, 0.0, 1.0} {0.0=0, 0.05=10, 0.10=20, 0.24=50, 0.49=100, 0.74=150, 1.0=200} + -- lBank {-1.0, 0.0,1.0} + -- lSlipBallPosition {0.0,1.0} + + ExportScript.Tools.SendData(40, string.format("%.4f", lVVI)) + ExportScript.Tools.SendData(41, string.format("%.4f", lBank)) + ExportScript.Tools.SendData(42, string.format("%.4f", lSlipBallPosition)) +end + +-- VVI for SU-33 +function ExportScript.AF.FC_Russian_VVI_New() + + local lVVI = LoGetVerticalVelocity() -- VERTICAL SPEED (Meter/Second) + + --[[ + y_min = 0.0 0.325 -- minimaler Ausgabewert + y_max = 0.325 1.0 -- maximaler Ausgabewert + x_min = 0.0 20.0 -- minimaler Eingangswert + x_max = 20.0 60.0 -- maximaler Eingangswert + x = 5.0 40.0 -- aktueller Eingangswert + + d_y = 0.325 0.675 -- Delta Ausgabewerte (y_max - y_min) + d_x = 20.0 40.0 -- Delta Eingangswerte (x_max - x_min) + m = 0.01625 0.016875 -- Steigung der linearen Funktion (d_y / d_x) + n = 0.0 -0.0125 -- Schnittpunkt der Funktion mit y-Achse (y_max - m * x_max) + + y = 0.08125 0,6625 -- Ergebnis (m * x + n) + ]] + + if lVVI >= 0.0 then + if lVVI >= 0.0 and lVVI < 20.0 then + lVVI = 0.01625 * lVVI + else + lVVI = 0.016875 * lVVI + -0.0125 + end + lVVI = (lVVI > 1.0 and 1.0 or lVVI) + else + if lVVI <= 0.0 and lVVI < -20.0 then + lVVI = 0.01625 * lVVI + else + lVVI = 0.016875 * lVVI + -0.0125 + end + lVVI = (lVVI < -1.0 and -1.0 or lVVI) + end + + ExportScript.Tools.SendData(40, string.format("%.4f", lVVI)) +end + +-- Airintake for SU-27 and SU-33 +function ExportScript.AF.FC_Russian_AirIntake() + + local lAirI = LoGetMechInfo().airintake.value + + ExportScript.Tools.SendData(45, string.format("%.4f", lAirI)) + ExportScript.Tools.SendData(46, string.format("%.4f", lAirI)) +end + +-- AOA Indicator and Accelerometer (AOA, GLoad) for SU-25, SU25T +function ExportScript.AF.FC_Russian_AOA_Su25() + + local lAoA = LoGetAngleOfAttack() -- ANGLE OF ATTACK AoA (Radian) + local lAccelerationUnits = LoGetAccelerationUnits().y -- G-LOAD + + -- AOA Indicator and Accelerometer (AOA, GLoad) + if lAoA > 0.0 then -- positive AOA + --[[ + y_min = 0.0 -- minimaler Ausgabewert + y_max = 1.0 -- maximaler Ausgabewert + x_min = 0.0 -- minimaler Eingangswert + x_max = 40.0 -- maximaler Eingangswert + x = 1.4 -- aktueller Eingangswert + + d_y = 1.0 -- Delta Ausgabewerte (y_max - y_min) + d_x = 40.0 -- Delta Eingangswerte (x_max - x_min) + m = 0.025 -- Steigung der linearen Funktion (d_y / d_x) + n = 0.0 -- Schnittpunkt der Funktion mit y-Achse (y_max - m * x_max) + + y = 0.035 -- Ergebnis (m * x + n) + ]] + lAoA = 0.025 * lAoA + else + --[[ + y_min = 0.0 -- minimaler Ausgabewert + y_max = -0.28 -- maximaler Ausgabewert + x_min = 0.0 -- minimaler Eingangswert + x_max = -10.0 -- maximaler Eingangswert + x = -3.2 -- aktueller Eingangswert + + d_y = -0.28 -- Delta Ausgabewerte (y_max - y_min) + d_x = -10.0 -- Delta Eingangswerte (x_max - x_min) + m = 0.028 -- Steigung der linearen Funktion (d_y / d_x) + n = 0.0 -- Schnittpunkt der Funktion mit y-Achse (y_max - m * x_max) + + y = -0.0896 -- Ergebnis (m * x + n) + ]] --0.14 + lAoA = 0.028 * lAoA + end + + if lAccelerationUnits > 0.0 then -- positive AOA + --[[ + y_min = 0.0 -- minimaler Ausgabewert + y_max = 1.0 -- maximaler Ausgabewert + x_min = 0.0 -- minimaler Eingangswert + x_max = 11.0 -- maximaler Eingangswert + x = 2.5 -- aktueller Eingangswert + + d_y = 1.0 -- Delta Ausgabewerte (y_max - y_min) + d_x = 11.0 -- Delta Eingangswerte (x_max - x_min) + m = 0.09090909090909090909090909090909 -- Steigung der linearen Funktion (d_y / d_x) + n = 0.0 -- Schnittpunkt der Funktion mit y-Achse (y_max - m * x_max) + + y = 0,22727272727272727272727272727273 -- Ergebnis (m * x + n) + ]] + lAccelerationUnits = 0.09090909090909090909090909090909 * lAccelerationUnits + else + --[[ + y_min = 0.0 -- minimaler Ausgabewert + y_max = -0.40625 -- maximaler Ausgabewert + x_min = 0.0 -- minimaler Eingangswert + x_max = -2.2125720977783 -- maximaler Eingangswert + x = -0.5 -- aktueller Eingangswert + + d_y = -0.40625 -- Delta Ausgabewerte (y_max - y_min) + d_x = -2.2125720977783 -- Delta Eingangswerte (x_max - x_min) + m = 0.18360983599491558834620754850374 -- Steigung der linearen Funktion (d_y / d_x) + n = 2.559143240842e-33 -- Schnittpunkt der Funktion mit y-Achse (y_max - m * x_max) + + y = -0.09180491799745779417310377425187 -- Ergebnis (m * x + n) + ]] + lAccelerationUnits = 0.18360983599491558834620754850374 * lAccelerationUnits + 2.559143240842e-33 + end + + ExportScript.Tools.SendData(50, string.format("%.4f", lAoA)) + ExportScript.Tools.SendData(51, string.format("%.4f", lAccelerationUnits)) +end + +-- AOA Indicator and Accelerometer (AOA, GLoad) for SU-27, SU33 +function ExportScript.AF.FC_Russian_AOA_Su2733() + + local lAoA = LoGetAngleOfAttack() -- ANGLE OF ATTACK AoA (Radian) + local lAccelerationUnits = LoGetAccelerationUnits().y -- G-LOAD + + if lAoA > 0.0 then -- positive AOA + --[[ + y_min = 0.0 -- minimaler Ausgabewert + y_max = 1.0 -- maximaler Ausgabewert + x_min = 0.0 -- minimaler Eingangswert + x_max = 40.0 -- maximaler Eingangswert + x = 1.4 -- aktueller Eingangswert + + d_y = 1.0 -- Delta Ausgabewerte (y_max - y_min) + d_x = 40.0 -- Delta Eingangswerte (x_max - x_min) + m = 0.025 -- Steigung der linearen Funktion (d_y / d_x) + n = 0.0 -- Schnittpunkt der Funktion mit y-Achse (y_max - m * x_max) + + y = 0.035 -- Ergebnis (m * x + n) + ]] + lAoA = 0.025 * lAoA + else + --[[ + y_min = 0.0 -- minimaler Ausgabewert + y_max = -0.28 -- maximaler Ausgabewert + x_min = 0.0 -- minimaler Eingangswert + x_max = -10.0 -- maximaler Eingangswert + x = -3.2 -- aktueller Eingangswert + + d_y = -0.28 -- Delta Ausgabewerte (y_max - y_min) + d_x = -10.0 -- Delta Eingangswerte (x_max - x_min) + m = 0.028 -- Steigung der linearen Funktion (d_y / d_x) + n = 0.0 -- Schnittpunkt der Funktion mit y-Achse (y_max - m * x_max) + + y = -0.0896 -- Ergebnis (m * x + n) + ]] --0.14 + lAoA = 0.028 * lAoA + end + + if lAccelerationUnits > 0.0 then -- positive AOA + --[[ + y_min = 0.0 -- minimaler Ausgabewert + y_max = 1.0 -- maximaler Ausgabewert + x_min = 0.0 -- minimaler Eingangswert + x_max = 11.0 -- maximaler Eingangswert + x = 2.5 -- aktueller Eingangswert + + d_y = 1.0 -- Delta Ausgabewerte (y_max - y_min) + d_x = 11.0 -- Delta Eingangswerte (x_max - x_min) + m = 0.09090909090909090909090909090909 -- Steigung der linearen Funktion (d_y / d_x) + n = 0.0 -- Schnittpunkt der Funktion mit y-Achse (y_max - m * x_max) + + y = 0.22727272727272727272727272727273 -- Ergebnis (m * x + n) + ]] + lAccelerationUnits = 0.09090909090909090909090909090909 * lAccelerationUnits + else + --[[ + y_min = 0.0 -- minimaler Ausgabewert + y_max = -0.40625 -- maximaler Ausgabewert + x_min = 0.0 -- minimaler Eingangswert + x_max = -4.2 -- maximaler Eingangswert + x = -0.5 -- aktueller Eingangswert + + d_y = -0.40625 -- Delta Ausgabewerte (y_max - y_min) + d_x = -4.2 -- Delta Eingangswerte (x_max - x_min) + m = 0.09672619047619047619047619047619 -- Steigung der linearen Funktion (d_y / d_x) + n = 0.0 -- Schnittpunkt der Funktion mit y-Achse (y_max - m * x_max) + + y = -0.09180491799745779417310377425187 -- Ergebnis (m * x + n) + ]] + lAccelerationUnits = 0.09672619047619047619047619047619 * lAccelerationUnits + end + + ExportScript.Tools.SendData(50, string.format("%.4f", lAoA)) + ExportScript.Tools.SendData(51, string.format("%.4f", lAccelerationUnits)) +end + +-- AOA Indicator and Accelerometer (AOA, GLoad) for MiG-29A, MiG-29S +function ExportScript.AF.FC_Russian_AOA_MiG29() + + local lAoA = LoGetAngleOfAttack() -- ANGLE OF ATTACK AoA (Radian) + local lAccelerationUnits = LoGetAccelerationUnits().y -- G-LOAD + + if lAoA > 0.0 then -- positive AOA + --[[ + y_min = 0.0 -- minimaler Ausgabewert + y_max = 0.7812 -- maximaler Ausgabewert + x_min = 0.0 -- minimaler Eingangswert + x_max = 30.0 -- maximaler Eingangswert + x = 5.4 -- aktueller Eingangswert + + d_y = 0.7812 -- Delta Ausgabewerte (y_max - y_min) + d_x = 30.0 -- Delta Eingangswerte (x_max - x_min) + m = 0.02604 -- Steigung der linearen Funktion (d_y / d_x) + n = 0.0 -- Schnittpunkt der Funktion mit y-Achse (y_max - m * x_max) + + y = 0.1406 -- Ergebnis (m * x + n) + ]] + lAoA = 0.03333333333333333333333333333333 * lAoA + else + --[[ + y_min = 0.0 -- minimaler Ausgabewert + y_max = -0.28 -- maximaler Ausgabewert + x_min = 0.0 -- minimaler Eingangswert + x_max = -5.5 -- maximaler Eingangswert + x = -2.1 -- aktueller Eingangswert + + d_y = -0.28 -- Delta Ausgabewerte (y_max - y_min) + d_x = -5.5 -- Delta Eingangswerte (x_max - x_min) + m = 0,05090909090909090909090909090909 -- Steigung der linearen Funktion (d_y / d_x) + n = 0 -- Schnittpunkt der Funktion mit y-Achse (y_max - m * x_max) + + y = -0.10691 -- Ergebnis (m * x + n) + ]] + lAoA = 0.05090909090909090909090909090909 * lAoA + end + + if lAccelerationUnits > 0.0 then -- positive AOA + --[[ + y_min = 0.0 -- minimaler Ausgabewert + y_max = 1.0 -- maximaler Ausgabewert + x_min = 0.0 -- minimaler Eingangswert + x_max = 11.0 -- maximaler Eingangswert + x = 2.5 -- aktueller Eingangswert + + d_y = 1.0 -- Delta Ausgabewerte (y_max - y_min) + d_x = 11.0 -- Delta Eingangswerte (x_max - x_min) + m = 0.09090909090909090909090909090909 -- Steigung der linearen Funktion (d_y / d_x) + n = 0.0 -- Schnittpunkt der Funktion mit y-Achse (y_max - m * x_max) + + y = 0.22727272727272727272727272727273 -- Ergebnis (m * x + n) + ]] + lAccelerationUnits = 0.09090909090909090909090909090909 * lAccelerationUnits + else + --[[ + y_min = 0.0 -- minimaler Ausgabewert + y_max = -0.40625 -- maximaler Ausgabewert + x_min = 0.0 -- minimaler Eingangswert + x_max = -4.2 -- maximaler Eingangswert + x = -0.5 -- aktueller Eingangswert + + d_y = -0.40625 -- Delta Ausgabewerte (y_max - y_min) + d_x = -4.2 -- Delta Eingangswerte (x_max - x_min) + m = 0.09672619047619047619047619047619 -- Steigung der linearen Funktion (d_y / d_x) + n = 0.0 -- Schnittpunkt der Funktion mit y-Achse (y_max - m * x_max) + + y = -0.09180491799745779417310377425187 -- Ergebnis (m * x + n) + ]] + lAccelerationUnits = 0.09672619047619047619047619047619 * lAccelerationUnits + end + + ExportScript.Tools.SendData(50, string.format("%.4f", lAoA)) + ExportScript.Tools.SendData(51, string.format("%.4f", lAccelerationUnits)) +end + +-- Russian Clock ACS-1 for KA-50, SU-25A, MIG-29A , MIG-29S +function ExportScript.AF.FC_Russian_Clock_ACS1() + + local lDefaultOne = 1.0 + local lDefaultNull = 0.0 + + local lCurrentClock = LoGetMissionStartTime() + LoGetModelTime() -- in seconds + local lCurrentHours = lCurrentClock / 43200 -- (3600 * 12) + lCurrentHours = lCurrentHours - ExportScript.Tools.round(lCurrentHours, 0, "floor") + local lCurrentMinutes = lCurrentClock / 3600 -- (60 * 60) + lCurrentMinutes = lCurrentMinutes - ExportScript.Tools.round(lCurrentMinutes, 0, "floor") + local lCurrentSeconds = lCurrentClock / 60 + lCurrentSeconds = lCurrentSeconds - ExportScript.Tools.round(lCurrentSeconds, 0, "floor") + local lFlightTimeHours = LoGetModelTime() / 43200 + lFlightTimeHours = lFlightTimeHours - ExportScript.Tools.round(lFlightTimeHours, 0, "floor") + local lFlightTimeMinutes = LoGetModelTime() / 3600 + lFlightTimeMinutes = lFlightTimeMinutes - ExportScript.Tools.round(lFlightTimeMinutes, 0, "floor") + -- currtime_hours {0.0,1.0} + -- currtime_minutes {0.0,1.0} + -- currtime_seconds {0.0,1.0} + -- flight_time_meter_status{0.0,0.2} + -- flight_hours {0.0,1.0} + -- flight_minutes {0.0,1.0} + -- seconds_meter_time_minutes {0.0,1.0} + -- seconds_meter_time_seconds {0.0,1.0} + + ExportScript.Tools.SendData(55, string.format("%.4f", lCurrentHours)) + ExportScript.Tools.SendData(56, string.format("%.4f", lCurrentMinutes)) + ExportScript.Tools.SendData(57, string.format("%.4f", lCurrentSeconds)) + ExportScript.Tools.SendData(58, lDefaultNull) -- red/white flag + ExportScript.Tools.SendData(59, string.format("%.4f", lFlightTimeHours)) + ExportScript.Tools.SendData(60, string.format("%.4f", lFlightTimeMinutes)) + ExportScript.Tools.SendData(61, lDefaultNull) + ExportScript.Tools.SendData(62, lDefaultNull) +end + +-- Russian Clock (latest Model) for SU-25T, SU-27, SU-33 +function ExportScript.AF.FC_Russian_Clock_late() + + local lDefaultOne = 1.0 + local lDefaultNull = 0.0 + + local lCurrentClock = LoGetMissionStartTime() + LoGetModelTime() -- in seconds + local lCurrentHours = lCurrentClock / 43200 -- (3600 * 12) + lCurrentHours = lCurrentHours - ExportScript.Tools.round(lCurrentHours, 0, "floor") + local lCurrentMinutes = lCurrentClock / 3600 -- (60 * 60) + lCurrentMinutes = lCurrentMinutes - ExportScript.Tools.round(lCurrentMinutes, 0, "floor") + local lCurrentSeconds = lCurrentClock / 60 + lCurrentSeconds = lCurrentSeconds - ExportScript.Tools.round(lCurrentSeconds, 0, "floor") + local lFlightTimeHours = LoGetModelTime() / 43200 + lFlightTimeHours = lFlightTimeHours - ExportScript.Tools.round(lFlightTimeHours, 0, "floor") + local lFlightTimeMinutes = LoGetModelTime() / 3600 + lFlightTimeMinutes = lFlightTimeMinutes - ExportScript.Tools.round(lFlightTimeMinutes, 0, "floor") + -- currtime_hours {0.0,1.0} + -- currtime_minutes {0.0,1.0} + -- currtime_seconds {0.0,1.0} + -- flight_time_meter_status{0.0,0.2} + -- flight_hours {0.0,1.0} + -- flight_minutes {0.0,1.0} + -- seconds_meter_time_seconds {0.0,1.0} + + ExportScript.Tools.SendData(55, string.format("%.4f", lCurrentHours)) + ExportScript.Tools.SendData(56, string.format("%.4f", lCurrentMinutes)) + ExportScript.Tools.SendData(57, string.format("%.4f", lCurrentSeconds)) + ExportScript.Tools.SendData(58, lDefaultNull) -- red/white flag + ExportScript.Tools.SendData(59, string.format("%.4f", lFlightTimeHours)) + ExportScript.Tools.SendData(60, string.format("%.4f", lFlightTimeMinutes)) + ExportScript.Tools.SendData(61, string.format("%.4f", lCurrentSeconds)) +end + +-- Russian Enging RPM (Tachometer) for SU-25A+T, SU-27, SU-33, MIG-29 +function ExportScript.AF.FC_Russian_EngineRPM() + + local lScaleValue = 110 + local lEngineRPMleft = LoGetEngineInfo().RPM.left -- ENG1 RPM % + local lEngineRPMright = LoGetEngineInfo().RPM.right -- ENG2 RPM % + + lEngineRPMleft = lEngineRPMleft / lScaleValue + lEngineRPMleft = (lEngineRPMleft > 1.0 and 1.0 or lEngineRPMleft) -- the result is limited to 1.0 + lEngineRPMright = lEngineRPMright / lScaleValue + lEngineRPMright = (lEngineRPMright > 1.0 and 1.0 or lEngineRPMright) -- the result is limited to 1.0 + -- EngineRPMleft {0.0,1.0} + -- EngineRPMright {0.0,1.0} + + ExportScript.Tools.SendData(65, string.format("%.4f", lEngineRPMleft)) + ExportScript.Tools.SendData(66, string.format("%.4f", lEngineRPMright)) +end + +-- Russian Exthaus Gas Temperature 1.000GradC for SU-25A, SU25T, MIG-29 +function ExportScript.AF.FC_Russian_EGT_1000gc(egttemp, exportid) + local lEGTtemp = egttemp or 1 + local lExportID = exportid or 70 + + --[[ + y_min = 0.0 0.068 -- minimaler Ausgabewert + y_max = 0.068 1.0 -- maximaler Ausgabewert + x_min = 0 200 -- minimaler Eingangswert + x_max = 200 1080 -- maximaler Eingangswert + x = 100 650 -- aktueller Eingangswert + + d_y = 0.068 0.932 -- Delta Ausgabewerte (y_max - y_min) + d_x = 200 880 -- Delta Eingangswerte (x_max - x_min) + m = 0.00034 0.00105909090909090909090909090909 -- Steigung der linearen Funktion (d_y / d_x) + n = 0 -0.1438181818181818181818181818172 -- Schnittpunkt der Funktion mit y-Achse (y_max - m * x_max) + + y = 0.034 0.5445909090909090909090909090913 -- Ergebnis (m * x + n) + ]] + + if lEGTtemp < 200 then + lEGTtemp = 0.00034 * lEGTtemp + else + lEGTtemp = 0.00105909090909090909090909090909 * lEGTtemp + -0.1438181818181818181818181818172 + end + + -- ExthausGasTemperature {0.0,1.0} + ExportScript.Tools.SendData(lExportID, string.format("%.4f", lEGTtemp)) +end + +-- Russian Mechanical Device Indicator for SU-25A+T +function ExportScript.AF.FC_Russian_MDI_SU25(FunctionTyp) + local lFunctionTyp = FunctionTyp or "Ikarus" + + local lMechInfo = LoGetMechInfo() -- mechanical components, e.g. Flaps, Wheelbrakes,... + if lMechInfo == nil then + return + end + local lTrueAirSpeed = LoGetTrueAirSpeed() + if lTrueAirSpeed == nil then + return + end + + local lWarningLight = 0.0 + lWarningLight = ((lMechInfo.flaps.value > 0.93 and lTrueAirSpeed > 340) and 1.0 or 0.0) -- Speed Warning for Flaps, same light as gear warning light, but blinking light + lWarningLight = (((lMechInfo.gear.status == 1 and lMechInfo.gear.value < 1) or (lMechInfo.gear.status == 0 and lMechInfo.gear.value > 0)) and 1.0 or lWarningLight ) -- gear warning light + -- WarningLight {0.0 = Off, 0.1 = blinking light, 0.2 = on} + -- WarningLight {0.0 = Off, no blinking light, 1.0 = on} + -- nose gear {0, 1} + -- left gear {0, 1} + -- right gear {0, 1} + -- speedbreakes on {0, 1} + -- flap 1. position {0, 1} + -- flap 2. position {0, 1} + + if ExportScript.Config.IkarusExport and lFunctionTyp == "Ikarus" then + ExportScript.Tools.SendData(500, string.format("%.1f", lWarningLight)) + ExportScript.Tools.SendData(501, (lMechInfo.gear.value > 0.85 and 1 or 0)) -- nose gear + ExportScript.Tools.SendData(502, (lMechInfo.gear.value > 0.95 and 1 or 0)) -- left gear + ExportScript.Tools.SendData(503, (lMechInfo.gear.value == 1 and 1 or 0)) -- right gear + ExportScript.Tools.SendData(510, (lMechInfo.speedbrakes.value > 0.1 and 1 or 0)) -- speedbreakes on > 0.1 (0 - 1) + ExportScript.Tools.SendData(531, (lMechInfo.flaps.value > 0.25 and 1 or 0)) -- flap 1. position + ExportScript.Tools.SendData(532, (lMechInfo.flaps.value > 0.93 and 1 or 0)) -- flap 2. position + end + + if ExportScript.Config.DACExport and lFunctionTyp == "DAC" then + ExportScript.Tools.SendDataDAC(500, (((lMechInfo.gear.status == 1 and lMechInfo.gear.value < 1) or (lMechInfo.gear.status == 0 and lMechInfo.gear.value > 0)) and 1 or 0 )) + ExportScript.Tools.SendDataDAC(501, (lMechInfo.gear.value > 0.85 and 1 or 0)) -- nose gear + ExportScript.Tools.SendDataDAC(502, (lMechInfo.gear.value > 0.95 and 1 or 0)) -- left gear + ExportScript.Tools.SendDataDAC(503, (lMechInfo.gear.value == 1 and 1 or 0)) -- right gear + ExportScript.Tools.SendDataDAC(510, (lMechInfo.speedbrakes.value > 0.1 and 1 or 0)) -- speedbreakes on > 0.1 (0 - 1) + ExportScript.Tools.SendDataDAC(531, (lMechInfo.flaps.value > 0.25 and 1 or 0)) -- flap 1. position + ExportScript.Tools.SendDataDAC(532, (lMechInfo.flaps.value > 0.93 and 1 or 0)) -- flap 2. position + ExportScript.Tools.SendDataDAC(533, ((lMechInfo.flaps.value > 0.93 and lTrueAirSpeed > 340) and 1 or 0)) -- Speed Warning for Flaps, same light as gear warning light, but blinking light + end +end + +-- Russian Mechanical Device Indicator for MiG-29A+S +function ExportScript.AF.FC_Russian_MDI_MiG29(FunctionTyp) + local lFunctionTyp = FunctionTyp or "Ikarus" +-- The mechanical devices indicator shows the position of the landing gear, flaps, leading edge flaps and airbrake + local lMechInfo = LoGetMechInfo() -- mechanical components, e.g. Flaps, Wheelbrakes,... + if lMechInfo == nil then + return + end + + local lTrueAirSpeed = LoGetTrueAirSpeed() + + if ExportScript.Config.DACExport and lFunctionTyp == "DAC" then + ExportScript.Tools.SendDataDAC(500, (((lMechInfo.gear.status == 1 and lMechInfo.gear.value < 1) or (lMechInfo.gear.status == 0 and lMechInfo.gear.value > 0)) and 1 or 0 ) ) -- gear warning light + ExportScript.Tools.SendDataDAC(501, (lMechInfo.gear.value > 0.85 and 1 or 0) ) -- nose gear + ExportScript.Tools.SendDataDAC(502, (lMechInfo.gear.value > 0.95 and 1 or 0) ) -- left gear + ExportScript.Tools.SendDataDAC(503, (lMechInfo.gear.value > 0.97 and 1 or 0) ) -- right gear + + ExportScript.Tools.SendDataDAC(510, (lMechInfo.speedbrakes.value > 0.1 and 1 or 0) ) -- speedbreakes on > 0.1 (0 - 1) + + ExportScript.Tools.SendDataDAC(531, (lMechInfo.flaps.value > 0.25 and 1 or 0) ) -- flap 1. position + ExportScript.Tools.SendDataDAC(532, (lMechInfo.flaps.value > 0.93 and 1 or 0) ) -- flap 2. position + ExportScript.Tools.SendDataDAC(533, ((lMechInfo.flaps.value > 0.93 and lTrueAirSpeed > 340) and 1 or 0) ) -- Speed Warning for Flaps, same light as gear warning light, but blinking light + ExportScript.Tools.SendDataDAC(534, (lMechInfo.gear.value > 0.5 and 1 or 0) ) -- Intake FOD shields + + ExportScript.Tools.SendDataDAC(541, (lMechInfo.parachute.value < 0.5 and 1 or 0) ) + + ExportScript.Tools.SendDataDAC(551, (lMechInfo.noseflap.value > 20.0 and 1 or 0) ) + + ExportScript.Tools.SendDataDAC(560, lMechInfo.airintake.status ) + end + + if ExportScript.Config.IkarusExport and lFunctionTyp == "Ikarus" then + local lWarningLight = 0.0 + + if lTrueAirSpeed ~= nil then + lWarningLight = ((lMechInfo.flaps.value > 0.93 and lTrueAirSpeed > 340) and 1.0 or 0.0) -- Speed Warning for Flaps, same light as gear warning light, but blinking light + lWarningLight = (((lMechInfo.gear.status == 1 and lMechInfo.gear.value < 1) or (lMechInfo.gear.status == 0 and lMechInfo.gear.value > 0)) and 1.0 or lWarningLight ) -- gear warning light + end + + ExportScript.Tools.SendData(500, string.format("%.1f", lWarningLight)) + ExportScript.Tools.SendData(501, (lMechInfo.gear.value > 0.85 and 1 or 0)) -- nose gear + ExportScript.Tools.SendData(502, (lMechInfo.gear.value > 0.95 and 1 or 0)) -- left gear + ExportScript.Tools.SendData(503, (lMechInfo.gear.value == 1 and 1 or 0)) -- right gear + ExportScript.Tools.SendData(510, (lMechInfo.speedbrakes.value > 0.1 and 1 or 0)) -- speedbreakes on > 0.1 (0 - 1) + ExportScript.Tools.SendData(531, (lMechInfo.gear.value > 0.5 and 1 or 0)) -- flap + ExportScript.Tools.SendData(532, (lMechInfo.flaps.value > 0.93 and 1 or 0)) -- Intake FOD shild + end +end + +-- Russian Mechanical Device Indicator for MiG-29A+S +function ExportScript.AF.FC_Russian_FlareChaff_MiG29(FunctionTyp) + local lFunctionTyp = FunctionTyp or "Ikarus" + local lSnares = LoGetSnares() -- Flare and Chaff + --ExportScript.Tools.WriteToLog('lSnares: '..ExportScript.Tools.dump(lSnares)) + + --[chaff] = number: "30" + --[flare] = number: "30" + + if ExportScript.Config.DACExport and lFunctionTyp == "DAC" then + ExportScript.Tools.SendDataDAC(800, lSnares.chaff + lSnares.flare ) + end + + if ExportScript.Config.IkarusExport and lFunctionTyp == "Ikarus" then + ExportScript.Tools.SendDataDAC(800, lSnares.chaff + lSnares.flare ) + end +end + +-- Russian System Test EKRAN +function ExportScript.AF.FC_EKRAN() + + local lMCPState = LoGetMCPState() -- Warning Lights + if lMCPState == nil then + return + end + local lDisplayWindow = "" -- Message + local lFAILlight = "" -- FAILURE + local lMEMORYlight = "" -- MEMORY + local lTURNlight = "" -- TURN + if gDisplayWindow == nil then + gFC_EKRAN_active = {false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false} + gDisplayWindow = "" + end + + if lMCPState.LeftTailPlaneFailure and not gFC_EKRAN_active[1] then + lDisplayWindow = "LEFT\nTAIL\nPLANE\nFAILURE" + gFC_EKRAN_active[1] = true + elseif lMCPState.RightTailPlaneFailure and not gFC_EKRAN_active[2] then + lDisplayWindow = "RIGHT\nTAIL\nPLANE\nFAILURE" + gFC_EKRAN_active[2] = true + elseif lMCPState.MasterWarning and not gFC_EKRAN_active[3] then + ---lDisplayWindow = "MASTER\nWARNING" -- don't display + gFC_EKRAN_active[3] = true + elseif lMCPState.LeftEngineFailure and not gFC_EKRAN_active[4] then + lDisplayWindow = "LEFT\nENGINE\nFAILURE" + gFC_EKRAN_active[4] = true + elseif lMCPState.RightEngineFailure and not gFC_EKRAN_active[5] then + lDisplayWindow = "RIGHT\nENGINE\nFAILURE" + gFC_EKRAN_active[5] = true + elseif lMCPState.RightAileronFailure and not gFC_EKRAN_active[6] then + lDisplayWindow = "RIGHT\nAILERON\nFAILURE" + gFC_EKRAN_active[6] = true + elseif lMCPState.LeftMainPumpFailure and not gFC_EKRAN_active[7] then + lDisplayWindow = "LEFT\nMAIN\nPUMP\nFAILURE" + gFC_EKRAN_active[7] = true + elseif lMCPState.RightMainPumpFailure and not gFC_EKRAN_active[8] then + lDisplayWindow = "RIGHT\nMAIN\nPUMP\nFAILURE" + gFC_EKRAN_active[8] = true + elseif lMCPState.LeftWingPumpFailure and not gFC_EKRAN_active[9] then + lDisplayWindow = "LEFT\nWING\nPUMP\nFAILURE" + gFC_EKRAN_active[10] = true + elseif lMCPState.RightWingPumpFailure and not gFC_EKRAN_active[10] then + lDisplayWindow = "RIGHT\nWING\nPUMP\nFAILURE" + gFC_EKRAN_active[10] = true + elseif lMCPState.EOSFailure and not gFC_EKRAN_active[11] then + lDisplayWindow = "EOS\nFAILURE" + gFC_EKRAN_active[11] = true + elseif lMCPState.ECMFailure and not gFC_EKRAN_active[12] then + lDisplayWindow = "ECM\nFAILURE" + gFC_EKRAN_active[12] = true + elseif lMCPState.CannonFailure and not gFC_EKRAN_active[13] then + lDisplayWindow = "CANNON\nFAILURE" + gFC_EKRAN_active[13] = true + elseif lMCPState.MLWSFailure and not gFC_EKRAN_active[14] then + lDisplayWindow = "MLWS\nFAILURE" + gFC_EKRAN_active[14] = true + elseif lMCPState.ACSFailure and not gFC_EKRAN_active[15] then + lDisplayWindow = "ACS\nFAILURE" + gFC_EKRAN_active[15] = true + elseif lMCPState.RadarFailure and not gFC_EKRAN_active[16] then + lDisplayWindow = "RADAR\nFAILURE" + gFC_EKRAN_active[16] = true + elseif lMCPState.HelmetFailure and not gFC_EKRAN_active[17] then + lDisplayWindow = "HELMET\nFAILURE" + gFC_EKRAN_active[17] = true + elseif lMCPState.HUDFailure and not gFC_EKRAN_active[18] then + lDisplayWindow = "HUD\nFAILURE" + gFC_EKRAN_active[18] = true + elseif lMCPState.MFDFailure and not gFC_EKRAN_active[19] then + lDisplayWindow = "MFD\nFAILURE" + gFC_EKRAN_active[19] = true + elseif lMCPState.RWSFailure and not gFC_EKRAN_active[20] then + lDisplayWindow = "RWS\nFAILURE" + gFC_EKRAN_active[20] = true + elseif lMCPState.GearFailure and not gFC_EKRAN_active[21] then + lDisplayWindow = "GEAR\nFAILURE" + gFC_EKRAN_active[21] = true + elseif lMCPState.HydraulicsFailure and not gFC_EKRAN_active[22] then + lDisplayWindow = "HYDRAULICS\nFAILURE" + gFC_EKRAN_active[22] = true + elseif lMCPState.AutopilotFailure and not gFC_EKRAN_active[23] then + --lDisplayWindow = "AUTOPILOT\nFAILURE" -- bug in DCS, error is always active + gFC_EKRAN_active[23] = true + elseif lMCPState.FuelTankDamage and not gFC_EKRAN_active[24] then + lDisplayWindow = "FUEL\nTANK\nDAMAGE" + gFC_EKRAN_active[24] = true + end + + if lDisplayWindow ~= "" then + gDisplayWindow = lDisplayWindow + end + if gDisplayWindow ~= "" then + lFAILlight = " FAILURE" + end + -- DisplayWindow (main message) + -- FAILlight (failure text) + -- MEMORYlight (memmory text) + -- TURNlight (turn text) + + ExportScript.Tools.SendData(80, string.format("%s;", gDisplayWindow)) + ExportScript.Tools.SendData(81, string.format("%s;", lFAILlight)) + ExportScript.Tools.SendData(82, string.format("%s;", lMEMORYlight)) + ExportScript.Tools.SendData(83, string.format("%s;", lTURNlight)) +end + +-- ADI for A-10A, F-15C +function ExportScript.AF.FC_US_ADI() + local lDefaultNull = 0.0 + local lRadToDCSsignd = math.pi + local lNavInfoPitch = LoGetNavigationInfo().Requirements.pitch -- AP REQUIRED PITCH (Radian) + local lNavInfoRoll = LoGetNavigationInfo().Requirements.roll -- AP REQUIRED BANK (Radian) + local lPitch, lBank, lYaw = LoGetADIPitchBankYaw() -- PITCH, BANK, YAW (Radian) + local lSlipBallPosition = LoGetSlipBallPosition() -- SLIP BALL (-1 +1) + local lGlide = LoGetGlideDeviation() -- VOR1 HORIZONTAL DEFLECTION (-1 +1) + --local lSide = LoGetSideDeviation() -- VOR1 VERTICAL DEFLECTION (-1 +1) + --[[ ADI from A-10C + [17] = "%.4f", -- ADI Pitch + [18] = "%.4f", -- ADI Bank + [24] = "%.4f", -- ADI Slip Ball + [20] = "%.4f", -- ADI Bank Steering Bar + [21] = "%.4f", -- ADI Pitch Steering Bar + [23] = "%.4f", -- ADI Turn Needle + [27] = "%.4f", -- ADI Glide-Slope Indicator + [26] = "%0.1f", -- ADI Glide-Slope Warning Flag + [25] = "%0.1f", -- ADI Attitude Warning Flag + [19] = "%0.1f", -- ADI Course Warning Flag + ]] + lNavInfoPitch = lNavInfoPitch / lRadToDCSsignd + lNavInfoRoll = lNavInfoRoll / lRadToDCSsignd + lNavInfoPitch = (lNavInfoPitch > 0.0 and (0 - lNavInfoPitch) or (lNavInfoPitch - lNavInfoPitch - lNavInfoPitch)) + lPitch = lPitch / (lRadToDCSsignd / 1.5) + lPitch = (lPitch > 0.0 and (0 - lPitch) or (lPitch - lPitch - lPitch)) -- pitch muss negiert werden + lBank = lBank / lRadToDCSsignd + --lBank = (lBank > 0.0 and (0 - lBank) or (lBank - lBank - lBank)) -- Bank muss negiert werden + + ExportScript.Tools.SendData(2, string.format("%.4f", lPitch)) + ExportScript.Tools.SendData(1, string.format("%.4f", lBank)) + ExportScript.Tools.SendData(10, string.format("%.4f", lSlipBallPosition)) + ExportScript.Tools.SendData(5, string.format("%.4f", lNavInfoRoll)) + ExportScript.Tools.SendData(6, string.format("%.4f", lNavInfoPitch)) + ExportScript.Tools.SendData(3, string.format("%.4f", lBank)) -- as Turn Needle + ExportScript.Tools.SendData(4, string.format("%.4f", lGlide)) + ExportScript.Tools.SendData(7, 0) + ExportScript.Tools.SendData(8, 0) + ExportScript.Tools.SendData(9, 0) +end + +-- Standby ADI for A-10A, F-15C +function ExportScript.AF.FC_US_stbyADI() + local lDefaultNull = 0.0 + local lRadToDCSsignd = math.pi + local lPitch, lBank, lYaw = LoGetADIPitchBankYaw() -- PITCH, BANK, YAW (Radian) + --local lSide = LoGetSideDeviation() -- VOR1 VERTICAL DEFLECTION (-1 +1) + -- [63] = "%.4f", -- Standby Attitude Indicator pitch {-1.0, 1.0} + -- [64] = "%.4f", -- Standby Attitude Indicator bank {-1.0, 1.0} + -- [65] = "%0.1f", -- Standby Attitude Indicator warning flag {0.0, 1.0} + lPitch = lPitch / (lRadToDCSsignd / 1.5) + --lPitch = (lPitch > 0.0 and (0 - lPitch) or (lPitch + lPitch + lPitch)) -- pitch muss negiert werden + lBank = lBank / lRadToDCSsignd + lBank = (lBank > 0.0 and (0 - lBank) or (lBank - lBank - lBank)) -- Bank muss negiert werden + + ExportScript.Tools.SendData(34, string.format("%.4f;", lPitch)) + ExportScript.Tools.SendData(35, string.format("%.4f;", lBank)) + ExportScript.Tools.SendData(0, 0) +end + +-- HSI for A-10A, F-15C +function ExportScript.AF.FC_US_HSI(distancetoway) + local lDistanceToWay = distancetoway or 999 + + local lDefaultOne = 1.0 + local lDefaultNull = 0.0 + local lRadToDCSunsignd = math.pi * 2 + local lPitch,lBank,lYaw = LoGetADIPitchBankYaw() -- PITCH, BANK, YAW (Radian) + local lHSI_RMI = LoGetControlPanel_HSI().RMI_raw -- VOR1 OBS (Radian) + local lHSI_ADF = LoGetControlPanel_HSI().ADF_raw -- ADF OBS (Radian) + local lHSI_Curse = LoGetControlPanel_HSI().Course -- HSI Course (Radian) + local lHeading = LoGetSelfData().Heading -- HEADING (Radian) + lPitch, lBank = nil +--[[ + [Course] = number: "0.76548692098835" + [CourseDeviation] = number: "0" + [ADF_raw] = number: "5.5811524391174" + [BearingPointer] = number: "0.80134677481978" + [RMI_raw] = number: "5.4092655181885" + [HeadingPointer] = number: "0.098191173578347" + [Heading_raw] = number: "6.2831854820251" + ]] + --[[ HSI A-10C + [34] = "%.4f", -- HSI Heading + [33] = "%.4f", -- HSI Bearing #1 + [35] = "%.4f", -- HSI Bearing #2 + [36] = "%.4f", -- HSI Heading Marker + [47] = "%.4f", -- HSI Course Arrow + [41] = "%.4f", -- HSI Deviation + [29] = "%.2f", -- HSI range_counter_100 + [30] = "%.2f", -- HSI range_counter_10 + [31] = "%.2f", -- HSI range_counter_1 + [42] = "%0.1f", -- HSI Bearing to_from_1 + [43] = "%0.1f", -- HSI Bearing to_from_2 + [46] = "%0.1f", -- HSI Bearing Flag + [40] = "%0.1f", -- HSI Power Flag + [32] = "%0.1f", -- HSI Range Flag + ]] + lDistanceToWay = lDistanceToWay * 0.00062136994937697 -- meter to miles + --lDistanceToWay = ExportScript.Tools.round(lDistanceToWay / 1000, 1) + local lRangeCounter1 = 0 + local lRangeCounter2 = 0 + local lRangeCounter3 = 0 + if lDistanceToWay > 100 then + lRangeCounter1 = ExportScript.Tools.round((lDistanceToWay / 100), 0, "floor") * 0.11 + lRangeCounter1 = lRangeCounter1 - ExportScript.Tools.round(lRangeCounter1, 0, "floor") + end + if lDistanceToWay > 10 then + if lDistanceToWay > 100 then + lRangeCounter2 = (ExportScript.Tools.round((lDistanceToWay - (ExportScript.Tools.round(lDistanceToWay / 100, 0, "floor") * 100)), 0, "floor") / 10) * 0.11 + else + lRangeCounter2 = (lDistanceToWay / 10) * 0.11 + lRangeCounter2 = lRangeCounter2 - ExportScript.Tools.round(lRangeCounter2, 0, "floor") + end + end + if lDistanceToWay > 10 then + lRangeCounter3 = (lDistanceToWay - (ExportScript.Tools.round(lDistanceToWay / 10, 0, "floor") * 10)) * 0.11 + else + lRangeCounter3 = lDistanceToWay * 0.11 + end + + lHeading = 1.0 - (lHeading / lRadToDCSunsignd) + lHSI_Curse = (lHSI_Curse / lRadToDCSunsignd) + lHSI_ADF = (lHSI_ADF / lRadToDCSunsignd) + -- HSI Heading {0.0, 1.0} + -- HSI Bearing #1 {0.0, 1.0} + -- HSI Bearing #2 {0.0, 1.0} + -- HSI Heading Marker {0.0, 1.0} + -- HSI Course Arrow {0.0, 1.0} + -- HSI Deviation {0.0, 1.0} + -- HSI range_counter_100 + -- HSI range_counter_10 + -- HSI range_counter_1 + -- HSI Bearing to_from_1 + -- HSI Bearing to_from_2 + -- HSI Bearing Flag + -- HSI Power Flag + -- HSI Range Flag + + ExportScript.Tools.SendData(11, string.format("%.4f", lHeading)) -- compass card + ExportScript.Tools.SendData(12, string.format("%.4f", lHSI_Curse)) -- Bearing #1 + ExportScript.Tools.SendData(13, string.format("%.4f", lHSI_Curse)) -- Bearing #2 + ExportScript.Tools.SendData(14, lDefaultNull) + ExportScript.Tools.SendData(15, string.format("%.4f", lHSI_Curse)) + ExportScript.Tools.SendData(16, string.format("%.4f", lHSI_ADF)) + ExportScript.Tools.SendData(17, string.format("%.4f", lRangeCounter1)) + ExportScript.Tools.SendData(18, string.format("%.4f", lRangeCounter2)) + ExportScript.Tools.SendData(19, string.format("%.4f", lRangeCounter3)) + ExportScript.Tools.SendData(20, lDefaultNull) + ExportScript.Tools.SendData(21, lDefaultNull) + ExportScript.Tools.SendData(22, lDefaultNull) + ExportScript.Tools.SendData(23, lDefaultNull) -- deaktiviert die Course Anzeige +end + +-- VVI for A-10A, F-15C +function ExportScript.AF.FC_US_VVI() + local lVVITmp = LoGetVerticalVelocity() * 196.8504 -- VERTICAL SPEED (Meter/Second to Foots/Minute) + -- {-1.0, -0.5, -0.29, 0.29, 0.5, 1.0} + --{-6000, -2000, -1000, 1000, 2000, 6000} + --ExportScript.Tools.WriteToLog('lVVITmp 1: '..ExportScript.Tools.dump(lVVITmp)) + if lVVITmp >= 0.0 then + --[[ + y_min = 0.0 0.29 0.503 0.765 -- minimaler Ausgabewert + y_max = 0.29 0.503 0.765 1.0 -- maximaler Ausgabewert + x_min = 0.0 1000.0 2000.0 4000.0 -- minimaler Eingangswert + x_max = 1000.0 2000.0 4000.0 6000.0 -- maximaler Eingangswert + x = 500.0 1600.0 2250.0 5500.0 -- aktueller Eingangswert + + d_y = 0.29 0.213 0.262 0.235 -- Delta Ausgabewerte (y_max - y_min) + d_x = 1000.0 1000.0 2000.0 2000.0 -- Delta Eingangswerte (x_max - x_min) + m = 0.00029 0.000213 0.000131 0.0001175 -- Steigung der linearen Funktion (d_y / d_x) + n = 0.0 0.077 0.241 0.295 -- Schnittpunkt der Funktion mit y-Achse (y_max - m * x_max) + + y = 0.145 0.4178 0.53575 0.94125 -- Ergebnis (m * x + n) + ]] + if lVVITmp >= 4000 then + lVVITmp = 0.0001175 * lVVITmp + 0.295 + elseif lVVITmp >= 2000 then + lVVITmp = 0.000131 * lVVITmp + 0.241 + elseif lVVITmp >= 1000 then + lVVITmp = 0.000213 * lVVITmp + 0.077 + else + lVVITmp = 0.00029 * lVVITmp + end + lVVITmp = (lVVITmp > 1.0 and 1.0 or lVVITmp) -- the result is limited to 1.0 + else + --[[ + y_min = -0.0 -0.29 -0.503 -0.765 -- minimaler Ausgabewert + y_max = -0.29 -0.503 -0.765 -1.0 -- maximaler Ausgabewert + x_min = -0.0 -1000.0 -2000.0 -4000.0 -- minimaler Eingangswert + x_max = -1000.0 -2000.0 -4000.0 -6000.0 -- maximaler Eingangswert + x = -500.0 -1600.0 -2250.0 -5500.0 -- aktueller Eingangswert + + d_y = -0.29 -0.213 -0.262 -0.235 -- Delta Ausgabewerte (y_max - y_min) + d_x = -1000.0 -1000.0 -2000.0 -2000.0 -- Delta Eingangswerte (x_max - x_min) + m = 0.00029 0.000213 0.000131 0.0001175 -- Steigung der linearen Funktion (d_y / d_x) + n = 0.0 -0.077 -0.241 -0.295 -- Schnittpunkt der Funktion mit y-Achse (y_max - m * x_max) + + y = -0.145 -0.4178 -0.53575 -0.94125 -- Ergebnis (m * x + n) + ]] + if lVVITmp <= 0 and lVVITmp > -1000 then + lVVITmp = 0.00029 * lVVITmp + elseif lVVITmp <= -1000 and lVVITmp > -2000 then + lVVITmp = 0.000213 * lVVITmp + -0.077 + elseif lVVITmp <= -2000 and lVVITmp > -4000 then + lVVITmp = 0.000131 * lVVITmp + -0.241 + else + lVVITmp = 0.0001175 * lVVITmp + -0.295 + end + + lVVITmp = (lVVITmp < -1.0 and -1.0 or lVVITmp) -- the result is limited to -1.0 + end + + ExportScript.Tools.SendData(24, string.format("%.4f", lVVITmp)) +end + +-- AOA Indicator (AOA) for A-10A, F-15C +function ExportScript.AF.FC_US_AOA() + local lRadToDCSsignd = math.pi + local lAoA = LoGetAngleOfAttack() -- ANGLE OF ATTACK AoA (Radian) +--ExportScript.Tools.WriteToLog('lAoA 1: '..ExportScript.Tools.dump(lAoA)) + lAoA = (lAoA / 0.3) + 0.38 + --lAoA = ((lAoA / lRadToDCSsignd) * 10) + 0.38 + --[[ + lAoA = lAoA / (lRadToDCSsignd / 10) + if lAoA >= 0.0 then + lAoA = lAoA + 0.4 + lAoA = lAoA / 18 + else + lAoA = lAoA + 0.4 + lAoA = lAoA / 12 + end + ]] +--ExportScript.Tools.WriteToLog('lAoA 2: '..ExportScript.Tools.dump(lAoA)) + ExportScript.Tools.SendData(50, string.format("%.4f", lAoA) ) +end + +-- Accelerometer (GLoad) for A-10A, F-15C +function ExportScript.AF.FC_US_GLOAD() + local lAccelerationUnits = LoGetAccelerationUnits().y -- G-LOAD + + lAccelerationUnits = (lAccelerationUnits / 15) + 0.33 + + ExportScript.Tools.SendData(25, string.format("%.4f", lAccelerationUnits)) + ExportScript.Tools.SendData(26, 0) + ExportScript.Tools.SendData(27, 0) +end + +-- US Clock for A-10A, F-15C +function ExportScript.AF.FC_US_Clock() + local lCurrentClock = LoGetMissionStartTime() + LoGetModelTime() -- in seconds + local lCurrentHours = lCurrentClock / 43200 -- (3600 * 12) + lCurrentHours = lCurrentHours - ExportScript.Tools.round(lCurrentHours, 0, "floor") + local lCurrentMinutes = lCurrentClock / 3600 -- (60 * 60) + lCurrentMinutes = lCurrentMinutes - ExportScript.Tools.round(lCurrentMinutes, 0, "floor") + local lCurrentSeconds = lCurrentClock / 60 + lCurrentSeconds = lCurrentSeconds - ExportScript.Tools.round(lCurrentSeconds, 0, "floor") + -- currtime_hours {0.0,1.0} + -- currtime_minutes {0.0,1.0} + -- currtime_seconds {0.0,1.0} + + ExportScript.Tools.SendData(28, string.format("%.4f", lCurrentHours)) + ExportScript.Tools.SendData(29, string.format("%.4f", lCurrentMinutes)) + ExportScript.Tools.SendData(30, string.format("%.4f", lCurrentSeconds)) +end + +-- US Standby Compass for A-10A, F-15C +function ExportScript.AF.FC_US_Compass() + local lDefaultNull = 0.0 + local lHeading = math.deg(LoGetSelfData().Heading) -- HEADING (Radian to Grad) + --local lHeading = math.deg(LoGetMagneticYaw()) -- HEADING (Radian to Grad) + --lHeading = 360 - lHeading -- muss umgerechnet werden?? + + --[[ + y_min = 1.0 -- minimaler Ausgabewert + y_max = -1.0 -- maximaler Ausgabewert + x_min = 0.0 -- minimaler Eingangswert + x_max = 360.00 -- maximaler Eingangswert + x = 185.5 -- aktueller Eingangswert + + d_y = -2.0 -- Delta Ausgabewerte (y_max - y_min) + d_x = 360.0 -- Delta Eingangswerte (x_max - x_min) + m = -0,00555555555555555555555555555556 -- Steigung der linearen Funktion (d_y / d_x) + n = 1.0 -- Schnittpunkt der Funktion mit y-Achse (y_max - m * x_max) + + y = 0.4995680345615518 -- Ergebnis (m * x + n) + ]] + lHeading = -0.00555555555555555555555555555556 * lHeading + 1.0 + + ExportScript.Tools.SendData(31, string.format("%.4f", lHeading)) -- heading + ExportScript.Tools.SendData(32, string.format("%.4f", lDefaultNull)) -- pitch + ExportScript.Tools.SendData(33, string.format("%.4f", lDefaultNull)) -- bank +end + +-- US F-15C Exaust Gas Temperature +function ExportScript.AF.FC_F15C_ExaustGasTemp(value, exportidNeedle, exportid100, exportid10, exportid1) + local lValue = value or 1 + local lExportIDNeedle = exportidNeedle or 0 + local lExportID100 = exportid100 or 0 + local lExportID10 = exportid10 or 0 + local lExportID1 = exportid1 or 0 + local lValueTmp = lValue + + local lCounter = {[0] = 0.0, [1] = 0.1, [2] = 0.2, [3] = 0.3, [4] = 0.4, [5] = 0.5, [6] = 0.6, [7] = 0.7, [8] = 0.8, [9] = 0.9} + local lCounter3 = 0 + local lValueTmp2 = lValueTmp + + lValueTmp2 = lValueTmp2 / 100 + lValueTmp2 = string.format("%02d", lValueTmp2) + + if lValueTmp > 100 then + lCounter3 = (lValueTmp - (ExportScript.Tools.round(lValueTmp / 100, 0, "floor") * 100)) * 0.01 + else + lCounter3 = lValueTmp * 0.01 + end + + --[[ + y_min = 0.0 0.08 -- minimaler Ausgabewert + y_max = 0.08 1.0 -- maximaler Ausgabewert + x_min = 0 200 -- minimaler Eingangswert + x_max = 200 1400 -- maximaler Eingangswert + x = 100 650 -- aktueller Eingangswert + + d_y = 0.08 0.92 -- Delta Ausgabewerte (y_max - y_min) + d_x = 200 1200 -- Delta Eingangswerte (x_max - x_min) + m = 0.0004 7.6666666666666666666666666666667e-4 -- Steigung der linearen Funktion (d_y / d_x) + n = 0 -0.07333333333333333333333333333333 -- Schnittpunkt der Funktion mit y-Achse (y_max - m * x_max) + + y = 0.04 0,425 -- Ergebnis (m * x + n) + ]] + + if lValueTmp > 200 then + lValue = 7.6666666666666666666666666666667e-4 * lValueTmp + -0.07333333333333333333333333333333 + else + lValue = 0.0004 * lValueTmp + end + + ExportScript.Tools.SendData(lExportIDNeedle, string.format("%.4f", lValue)) + ExportScript.Tools.SendData(lExportID100, string.format("%.2f", lCounter[tonumber(string.sub(lValueTmp2, 1, 1))])) + ExportScript.Tools.SendData(lExportID10, string.format("%.2f", lCounter[tonumber(string.sub(lValueTmp2, 2, 2))])) + ExportScript.Tools.SendData(lExportID1, string.format("%.2f", lCounter3)) +end + +-- A-10A Exaust Gas Temperature +function ExportScript.AF.FC_A10A_ExaustGasTemp(value, exportidMain, exportidSecond) + local lValue = value or 1 + local lExportIDMain = exportidMain or 0 + local lExportIDSecond = exportidSecond or 0 + local lValueTmp = lValue + + --[[ + y_min = 0.0 -- minimaler Ausgabewert + y_max = 1.0 -- maximaler Ausgabewert + x_min = 100.0 -- minimaler Eingangswert + x_max = 1100.00 -- maximaler Eingangswert + x = 605.5 -- aktueller Eingangswert + + d_y = 1.0 -- Delta Ausgabewerte (y_max - y_min) + d_x = 1000.0 -- Delta Eingangswerte (x_max - x_min) + m = 0.001 -- Steigung der linearen Funktion (d_y / d_x) + n = -0.1 -- Schnittpunkt der Funktion mit y-Achse (y_max - m * x_max) + + y = 0.5055 -- Ergebnis (m * x + n) + ]] + lValue = 0.001 * lValue + -0.1 + + local lv1, lValueTmp = math.modf(lValueTmp / 100) -- 100 = Secound Scala + + ExportScript.Tools.SendData(lExportIDMain, string.format("%.4f", lValue)) + ExportScript.Tools.SendData(lExportIDSecond, string.format("%.4f", lValueTmp)) +end + +-- Gauges with 2 needles (small and large), +-- for example: +-- A-10A RPM Engine +-- Su-27/33 Exthaus Gas Temperature 1.200GradC +function ExportScript.AF.FC_TwoNeedlesGauge(value, mainscala, secondscale, exportidMain, exportidSecond) + local lValue = value or 1 + local lMainScala = mainscala or 100 + local lSecondScale = secondscale or 10 + local lExportIDMain = exportidMain or 0 + local lExportIDSecond = exportidSecond or 0 + local lValueTmp = lValue + + lValue = lValue / lMainScala + lValue = (lValue > 1.0 and 1.0 or lValue) -- the result is limited to 1.0 + + --lValueTmp = lValueTmp - (ExportScript.Tools.round((lValueTmp / lSecondScale), 0, "floor") * lSecondScale) + --lValueTmp = lValueTmp / lSecondScale + --lValueTmp = (lValueTmp > 1.0 and 1.0 or lValueTmp) -- the result is limited to 1.0 + local lv1, lValueTmp = math.modf(lValueTmp / lSecondScale) + + ExportScript.Tools.SendData(lExportIDMain, string.format("%.4f", lValue)) + ExportScript.Tools.SendData(lExportIDSecond, string.format("%.4f", lValueTmp)) +end + +-- Gauges with 1 needle, +-- for example: +-- A-10A RPM FAN, RPM APU, Exaust Gas Temperature APU, Fuel Flow, Oil Pressure, Hydraulic Pressure +-- F-15C Oil Pressure, Hydraulic Pressure, Engine Exhaust Nozzle Position Indicator +-- Su-25A/T, Russian Hydraulic Pressure Gauges +function ExportScript.AF.FC_OneNeedleGauge(value, scala, exportid) + local lValue = value or 1 + local lScala = scala or 100 + local lExportID = exportid or 0 + + lValue = lValue / lScala + lValue = (lValue > 1.0 and 1.0 or lValue) -- the result is limited to 1.0 + + ExportScript.Tools.SendData(lExportID, string.format("%.4f", lValue)) +end + +-- Gauges with 1 needle and 2 digits display +-- for example: +-- +function ExportScript.AF.FC_OneNeedleGauge2Digits(value, scala, fixdigits, exportid) + local lValue = value or 1 + local lScala = scala or 100 + local lExportID = exportid or 1 + local lFixDigits = fixdigits or 0 + local lValueTmp = lValue + + --local lCounter = {[0] = 0.0, [1] = 0.11, [2] = 0.22, [3] = 0.33, [4] = 0.44, [5] = 0.55, [6] = 0.66, [7] = 0.77, [8] = 0.88, [9] = 0.99} + local lCounter = {[0] = 0.0, [1] = 0.1, [2] = 0.2, [3] = 0.3, [4] = 0.4, [5] = 0.5, [6] = 0.6, [7] = 0.7, [8] = 0.8, [9] = 0.9} + + local lCounter1 = 0 + local lCounter2 = 0 + local lFormat = 2 - lFixDigits + lFormat = "%0"..lFormat.."d" + + local lValueTmp2 = string.format(lFormat, lValueTmp) + --[[ + if lValueTmp > 10 then + if lValueTmp > 100 then + lCounter1 = (ExportScript.Tools.round((lValueTmp - (ExportScript.Tools.round(lValueTmp / 100, 0, "floor") * 100)), 0, "floor") / 10) * 0.1 + else + lCounter1 = (lValueTmp / 10) * 0.1 + lCounter1 = lCounter2 - ExportScript.Tools.round(lCounter2, 0, "floor") + end + end]] + if lValueTmp > 10 then + lCounter2 = (lValueTmp - (ExportScript.Tools.round(lValueTmp / 10, 0, "floor") * 10)) * 0.1 + else + lCounter2 = lValueTmp * 0.1 + end + + + lValue = lValue / lScala + lValue = (lValue > 1.0 and 1.0 or lValue) -- the result is limited to 1.0 + + SendData(lExportID, string.format("%.4f;%.2f;%.2f", + lValue, + lCounter[tonumber(string.sub(lValueTmp2, 1, 1))], + lCounter2)) +end + +-- Gauges with 1 needle and 3 digits display +-- for example: +-- F-15C RPM, Fuel Flow +function ExportScript.AF.FC_OneNeedleGauge3Digits_alt(value, scala, fixdigits, exportidNeedle, exportid100, exportid10, exportid1) + local lValue = value or 1 + local lScala = scala or 100 + local lExportidNeedle = exportidNeedle or 0 + local lExportid100 = exportid100 or 0 + local lExportid10 = exportid10 or 0 + local lExportid1 = exportid1 or 0 + local lFixDigits = fixdigits or 0 + local lValueTmp = lValue + + local lCounter = {[0] = 0.0, [1] = 0.11, [2] = 0.22, [3] = 0.33, [4] = 0.44, [5] = 0.55, [6] = 0.66, [7] = 0.77, [8] = 0.88, [9] = 0.99} + --local lCounter = {[0] = 0.0, [1] = 0.1, [2] = 0.2, [3] = 0.3, [4] = 0.4, [5] = 0.5, [6] = 0.6, [7] = 0.7, [8] = 0.8, [9] = 0.9} + + local lCounter3 = 0 + local lValueTmp2 = lValueTmp + + if lFixDigits > 0 then + lValueTmp2 = lValueTmp2 / math.pow(10, lFixDigits) + end + + lValueTmp2 = string.format("%03d", lValueTmp2) + + if lValueTmp > 1000 then + lCounter3 = (lValueTmp - (ExportScript.Tools.round(lValueTmp / 1000, 0, "floor") * 1000)) * math.pow(0.1, lFixDigits + 1) --0.1 + else + lCounter3 = lValueTmp * math.pow(0.1, lFixDigits + 1) --0.1 + end + + lValue = lValue / lScala + lValue = (lValue > 1.0 and 1.0 or lValue) -- the result is limited to 1.0 + + ExportScript.Tools.SendData(lExportIDNeedle, string.format("%.4f", lValue)) + ExportScript.Tools.SendData(lExportID100, string.format("%.2f", lCounter[tonumber(string.sub(lValueTmp2, 1, 1))])) + ExportScript.Tools.SendData(lExportID10, string.format("%.2f", lCounter[tonumber(string.sub(lValueTmp2, 2, 2))])) + ExportScript.Tools.SendData(lExportID1, string.format("%.2f", lCounter3)) +end + +-- Gauges with 1 needle and 3 digits display +-- for example: +-- F-15C RPM, Fuel Flow +function ExportScript.AF.FC_OneNeedleGauge3Digits(value, scala, fixdigits, exportidNeedle, exportid100, exportid10, exportid1) + local lValue = value or 1 + local lScala = scala or 100 + local lExportidNeedle = exportidNeedle or 0 + local lExportid100 = exportid100 or 0 + local lExportid10 = exportid10 or 0 + local lExportid1 = exportid1 or 0 + local lFixDigits = fixdigits or 0 + local lValueTmp = lValue + local lFactor = string.len(tostring(lScala)) - 2 + lFactor = math.pow(10, lFactor) + + local lCounter = {[0] = 0.0, [1] = 0.1, [2] = 0.2, [3] = 0.3, [4] = 0.4, [5] = 0.5, [6] = 0.6, [7] = 0.7, [8] = 0.8, [9] = 0.9} + + local lValueTmp2 = lValueTmp + + if lFixDigits > 0 then + lValueTmp2 = lValueTmp2 / math.pow(10, lFixDigits) + end + + lValueTmp2 = string.format("%03d", lValueTmp2) + + local lv1, lCounter3 = math.modf(lValueTmp / lFactor) + + lValue = lValue / lScala + lValue = (lValue > 1.0 and 1.0 or lValue) -- the result is limited to 1.0 + +ExportScript.Tools.WriteToLog("lExportIDNeedle: "..ExportScript.Tools.dump(lExportIDNeedle)) +ExportScript.Tools.WriteToLog("lExportID100: "..ExportScript.Tools.dump(lExportID100)) +ExportScript.Tools.WriteToLog("lExportID10: "..ExportScript.Tools.dump(lExportID10)) +ExportScript.Tools.WriteToLog("lExportID1: "..ExportScript.Tools.dump(lExportID1)) +ExportScript.Tools.WriteToLog("lExportIDNeedle: "..ExportScript.Tools.dump(lValue)) +ExportScript.Tools.WriteToLog("lExportID100: "..ExportScript.Tools.dump(lCounter[tonumber(string.sub(lValueTmp2, 1, 1))])) +ExportScript.Tools.WriteToLog("lExportID10: "..ExportScript.Tools.dump(lCounter[tonumber(string.sub(lValueTmp2, 2, 2))])) +ExportScript.Tools.WriteToLog("lExportID1: "..ExportScript.Tools.dump(lCounter3)) + ExportScript.Tools.SendData(lExportIDNeedle, string.format("%.4f", lValue)) + ExportScript.Tools.SendData(lExportID100, string.format("%.2f", lCounter[tonumber(string.sub(lValueTmp2, 1, 1))])) + ExportScript.Tools.SendData(lExportID10, string.format("%.2f", lCounter[tonumber(string.sub(lValueTmp2, 2, 2))])) + ExportScript.Tools.SendData(lExportID1, string.format("%.2f", lCounter3)) +end + +-- Gauges with 1 needle and 4 digits display +-- for example: +-- +function ExportScript.AF.FC_OneNeedleGauge4Digits(value, scala, fixdigits, exportid) + local lValue = value or 1 + local lScala = scala or 100 + local lExportID = exportid or 1 + local lFixDigits = fixdigits or 0 + local lValueTmp = lValue + + --local lCounter = {[0] = 0.0, [1] = 0.11, [2] = 0.22, [3] = 0.33, [4] = 0.44, [5] = 0.55, [6] = 0.66, [7] = 0.77, [8] = 0.88, [9] = 0.99} + local lCounter = {[0] = 0.0, [1] = 0.1, [2] = 0.2, [3] = 0.3, [4] = 0.4, [5] = 0.5, [6] = 0.6, [7] = 0.7, [8] = 0.8, [9] = 0.9} + + local lCounter1 = 0 + local lCounter2 = 0 + local lCounter3 = 0 + local lCounter4 = 0 + local lValueTmp2 = lValueTmp + if lFixDigits > 0 then + lValueTmp2 = lValueTmp2 / math.pow(10, lFixDigits) + end + lValueTmp2 = string.format("%04d", lValueTmp2) + --[[ + if lValueTmp > 10000 then + lCounter1 = ExportScript.Tools.round((lValueTmp / 1000), 0, "floor") * 0.1 + lCounter1 = lCounter1 - ExportScript.Tools.round(lCounter1, 0, "floor") + end + if lValueTmp > 1000 then + if lValueTmp > 100 then + lCounter2 = (ExportScript.Tools.round((lValueTmp - (ExportScript.Tools.round(lValueTmp / 100, 0, "floor") * 100)), 0, "floor") / 10) * 0.1 + else + lCounter2 = (lValueTmp / 10) * 0.1 + lCounter2 = lCounter2 - ExportScript.Tools.round(lCounter2, 0, "floor") + end + end + if lValueTmp > 100 then + if lValueTmp > 10 then + lCounter3 = (ExportScript.Tools.round((lValueTmp - (ExportScript.Tools.round(lValueTmp / 100, 0, "floor") * 100)), 0, "floor") / 10) * 0.1 + else + lCounter3 = (lValueTmp / 10) * 0.1 + lCounter3 = lCounter3 - ExportScript.Tools.round(lCounter3, 0, "floor") + end + end]] + if lValueTmp > 10 then + lCounter4 = (lValueTmp - (ExportScript.Tools.round(lValueTmp / 10, 0, "floor") * 10)) * 0.1 + else + lCounter4 = lValueTmp * 0.1 + end + + + lValue = lValue / lScala + lValue = (lValue > 1.0 and 1.0 or lValue) -- the result is limited to 1.0 + + SendData(lExportID, string.format("%.4f;%.2f;%.2f;%.2f;%.2f", + lValue, + lCounter[tonumber(string.sub(lValueTmp2, 1, 1))], + lCounter[tonumber(string.sub(lValueTmp2, 2, 2))], + lCounter[tonumber(string.sub(lValueTmp2, 3, 3))], + lCounter4)) +end + + +-- Auxiliary Functions for Hardware export + +function ExportScript.AF.FC_SPO15RWR(FunctionTyp) +-- The RWR display indicates any threat radars illuminating ("painting") the aircraft. +-- Information is presented as symbols representing the type and direction to the threat. +-- Six illuminated symbols at the bottom of the display notify the pilot of the threat radar type. +-- The system indicates both enemy and friendly radars +-- +--[[ +LoGetTWSInfo() -- return Threat Warning System status (result the table ) +result_of_LoGetTWSInfo = +{ + Mode = , -- current mode (0 - all ,1 - lock only,2 - launch only + Emitters = {table of emitters} +} +emitter_table = +{ + ID =, -- world ID + Type = {level1,level2,level3,level4}, -- world database classification of emitter + Power =, -- power of signal + Azimuth =, + Priority =,-- priority of emitter (int) + SignalType =, -- string with vlues: "scan" ,"lock", "missile_radio_guided","track_while_scan"; +}]] + + local lFunctionTyp = FunctionTyp or "Ikarus" + local lTWSInfo = LoGetTWSInfo() -- SPO15 Information + if lTWSInfo == nil then + return + end + --ExportScript.Tools.WriteToLog('lTWSInfo: '..ExportScript.Tools.dump(lTWSInfo)) + --[[ + [Emitters] = { + [1] = { + [Type] = { + [level3] = number: "105" + [level1] = number: "2" + [level4] = number: "46" + [level2] = number: "16" + } + [Azimuth] = number: "1.8300691843033" + [Power] = number: "0.92326503992081" + [ID] = number: "16777472" + [Priority] = number: "230.92445373535" + [SignalType] = string: "lock" + } + [2] = { + [Type] = { + [level3] = number: "101" + [level1] = number: "2" + [level4] = number: "39" + [level2] = number: "16" + } + [Azimuth] = number: "2.6759564876556" + [Power] = number: "0.90609884262085" + [ID] = number: "16777728" + [Priority] = number: "140.90609741211" + [SignalType] = string: "scan" + } + } + [Mode] = number: "0" + ]] + + if ExportScript.AF.EventNumberFC_SPO15RWR == nil then + ExportScript.AF.EventNumberFC_SPO15RWR = 0 + end + + if(ExportScript.AF.EventNumberFC_SPO15RWR < ExportScript.AF.EventNumber) then + ExportScript.AF.EventNumberFC_SPO15RWR = ExportScript.AF.EventNumber + + local lPriorityTmp = 0 + local lPrimaryThreatTmp = 0 + + if ExportScript.AF.SPO15RWRData == nil then + ExportScript.AF.SPO15RWRData = {} + + ExportScript.AF.SPO15RWRData[400] = 1 -- Power light + end + + -- 10 x for Secondary Thread direction + ExportScript.AF.SPO15RWRData[451]=0 + ExportScript.AF.SPO15RWRData[452]=0 + ExportScript.AF.SPO15RWRData[453]=0 + ExportScript.AF.SPO15RWRData[454]=0 + ExportScript.AF.SPO15RWRData[455]=0 + ExportScript.AF.SPO15RWRData[456]=0 + ExportScript.AF.SPO15RWRData[457]=0 + ExportScript.AF.SPO15RWRData[458]=0 + ExportScript.AF.SPO15RWRData[459]=0 + ExportScript.AF.SPO15RWRData[460]=0 + + if(#lTWSInfo.Emitters > 0) then + + ExportScript.AF.SPO15_FoundErmitter = true + + for EmitterIndex = 1, #lTWSInfo.Emitters, 1 do + if(lTWSInfo.Emitters[EmitterIndex].Priority > lPriorityTmp) then + lPriorityTmp = lTWSInfo.Emitters[EmitterIndex].Priority + lPrimaryThreatTmp = EmitterIndex + end + end + + for EmitterIndex = 1, #lTWSInfo.Emitters, 1 do + + local lAzimut = ExportScript.Tools.round(lTWSInfo.Emitters[EmitterIndex].Azimuth * 90, 1) + + if EmitterIndex == lPrimaryThreatTmp then + -- primary threat + -- direction to the threat + ExportScript.AF.SPO15RWRData[401] = (lAzimut <= -170.0 and 1 or 0) -- left back side + ExportScript.AF.SPO15RWRData[402] = ((lAzimut <= -90.0 and lAzimut >= -170.0 ) and 1 or 0) -- left 90 degree + ExportScript.AF.SPO15RWRData[403] = ((lAzimut <= -55.0 and lAzimut >= -125.0 ) and 1 or 0) -- left 50 degree + ExportScript.AF.SPO15RWRData[404] = ((lAzimut <= -30.0 and lAzimut >= -70.0 ) and 1 or 0) -- left 30 degree + ExportScript.AF.SPO15RWRData[405] = ((lAzimut <= 5.0 and lAzimut >= -40.0 ) and 1 or 0) -- left 10 degree + ExportScript.AF.SPO15RWRData[406] = ((lAzimut >= -5.0 and lAzimut <= 40.0 ) and 1 or 0) -- right 10 degree + ExportScript.AF.SPO15RWRData[407] = ((lAzimut >= 30.0 and lAzimut <= 70.0 ) and 1 or 0) -- right 30 degree + ExportScript.AF.SPO15RWRData[408] = ((lAzimut >= 55.0 and lAzimut <= 125.0 ) and 1 or 0) -- right 50 degree + ExportScript.AF.SPO15RWRData[409] = ((lAzimut >= 90.0 and lAzimut <= 170.0 ) and 1 or 0) -- right 90 degree + ExportScript.AF.SPO15RWRData[410] = (lAzimut >= 170.0 and 1 or 0) -- right back side + + -- power of the threat + local lPower = ExportScript.Tools.round(lTWSInfo.Emitters[EmitterIndex].Power * 15, 0, "ceil") + 1 + --WriteToLog("lPower: "..lPower) + ExportScript.AF.SPO15RWRData[411] = (lPower <= 1 and 0 or 1) -- 1. power lamp + ExportScript.AF.SPO15RWRData[412] = (lPower <= 2 and 0 or 1) -- 2. power lamp + ExportScript.AF.SPO15RWRData[413] = (lPower <= 3 and 0 or 1) -- 3. power lamp + ExportScript.AF.SPO15RWRData[414] = (lPower <= 4 and 0 or 1) -- 4. power lamp + ExportScript.AF.SPO15RWRData[415] = (lPower <= 5 and 0 or 1) -- 5. power lamp + ExportScript.AF.SPO15RWRData[416] = (lPower <= 6 and 0 or 1) -- 6. power lamp + ExportScript.AF.SPO15RWRData[417] = (lPower <= 7 and 0 or 1) -- 7. power lamp + ExportScript.AF.SPO15RWRData[418] = (lPower <= 8 and 0 or 1) -- 8. power lamp + ExportScript.AF.SPO15RWRData[419] = (lPower <= 9 and 0 or 1) -- 9. power lamp + ExportScript.AF.SPO15RWRData[420] = (lPower <= 10 and 0 or 1) -- 10. power lamp + ExportScript.AF.SPO15RWRData[421] = (lPower <= 11 and 0 or 1) -- 11. power lamp + ExportScript.AF.SPO15RWRData[422] = (lPower <= 12 and 0 or 1) -- 12. power lamp + ExportScript.AF.SPO15RWRData[423] = (lPower <= 13 and 0 or 1) -- 13. power lamp + ExportScript.AF.SPO15RWRData[424] = (lPower <= 14 and 0 or 1) -- 14. power lamp + ExportScript.AF.SPO15RWRData[425] = (lPower <= 15 and 0 or 1) -- 15. power lamp + + -- type of the threat + local lPrimaryTypeTmp = ExportScript.AF.FindRadarTypeForSPO15(lTWSInfo, lPrimaryThreatTmp) + ExportScript.AF.SPO15RWRData[430] = (lPrimaryTypeTmp.AIR == 1 and 1 or 0) -- primary Air or Weapon + ExportScript.AF.SPO15RWRData[431] = (lPrimaryTypeTmp.LRR == 1 and 1 or 0) -- long range radar + ExportScript.AF.SPO15RWRData[432] = (lPrimaryTypeTmp.MRR == 1 and 1 or 0) -- mid range radar + ExportScript.AF.SPO15RWRData[433] = (lPrimaryTypeTmp.SRR == 1 and 1 or 0) -- short range radar + ExportScript.AF.SPO15RWRData[434] = (lPrimaryTypeTmp.EWR == 1 and 1 or 0) -- EWR + ExportScript.AF.SPO15RWRData[435] = (lPrimaryTypeTmp.AWACS == 1 and 1 or 0) -- AWACS + + -- look or missil on air + if lPrimaryTypeTmp.Lock == 0.1 then + ExportScript.AF.SPO15RWRData[440] = 0 + ExportScript.AF.SPO15RWRData[441] = 1 -- blinking lights on + elseif lPrimaryTypeTmp.Lock == 0.2 then + ExportScript.AF.SPO15RWRData[440] = 1 + ExportScript.AF.SPO15RWRData[441] = 0 -- blinking lights off + end + -- hemisphere + ExportScript.AF.SPO15RWRData[442] = lPrimaryTypeTmp.TopHemisphere -- top hemisphere + ExportScript.AF.SPO15RWRData[443] = lPrimaryTypeTmp.BottomHemisphere -- bottom hemisphere + + lPrimaryTypeTmp = nil + + end + + ExportScript.AF.SPO15RWR_SendData(451, lAzimut <= -170.0) -- left back side + ExportScript.AF.SPO15RWR_SendData(452, (lAzimut <= -90.0 and lAzimut >= -170.0 )) -- left 90 degree + ExportScript.AF.SPO15RWR_SendData(453, (lAzimut <= -55.0 and lAzimut >= -125.0 )) -- left 50 degree + ExportScript.AF.SPO15RWR_SendData(454, (lAzimut <= -30.0 and lAzimut >= -70.0 )) -- left 30 degree + ExportScript.AF.SPO15RWR_SendData(455, (lAzimut <= 5.0 and lAzimut >= -40.0 )) -- left 10 degree + ExportScript.AF.SPO15RWR_SendData(456, (lAzimut >= -5.0 and lAzimut <= 40.0 )) -- right 10 degree + ExportScript.AF.SPO15RWR_SendData(457, (lAzimut >= 30.0 and lAzimut <= 70.0 )) -- right 30 degree + ExportScript.AF.SPO15RWR_SendData(458, (lAzimut >= 55.0 and lAzimut <= 125.0 )) -- right 50 degree + ExportScript.AF.SPO15RWR_SendData(459, (lAzimut >= 90.0 and lAzimut <= 170.0 )) -- right 90 degree + ExportScript.AF.SPO15RWR_SendData(460, lAzimut >= 170.0) -- right back side + end + + -- type of the secondary threat + local lSecondaryTypeTmp = ExportScript.AF.FindRadarTypeForSPO15(lTWSInfo) + ExportScript.AF.SPO15RWRData[470] = (lSecondaryTypeTmp.AIR == 1 and 1 or 0) -- secondary Air or Weapon + ExportScript.AF.SPO15RWRData[471] = (lSecondaryTypeTmp.LRR == 1 and 1 or 0) -- long range radar + ExportScript.AF.SPO15RWRData[472] = (lSecondaryTypeTmp.MRR == 1 and 1 or 0) -- mid range radar + ExportScript.AF.SPO15RWRData[473] = (lSecondaryTypeTmp.SRR == 1 and 1 or 0) -- short range radar + ExportScript.AF.SPO15RWRData[474] = (lSecondaryTypeTmp.EWR == 1 and 1 or 0) -- EWR + ExportScript.AF.SPO15RWRData[475] = (lSecondaryTypeTmp.AWACS == 1 and 1 or 0) -- AWACS + lSecondaryTypeTmp = nil + + + if ExportScript.Config.IkarusExport then + -- Lock + ExportScript.AF.SPO15RWRData[444] = 0 -- off + if ExportScript.AF.SPO15RWRData[440] == 1 then + ExportScript.AF.SPO15RWRData[444] = 1 -- Lock + elseif ExportScript.AF.SPO15RWRData[441] == 1 then + ExportScript.AF.SPO15RWRData[444] = 0.5 -- Missle on air + end + + -- Ermitter Power Triangle + if ExportScript.AF.SPO15RWRData[411] == 1 then + ExportScript.AF.SPO15RWRData[426] = 1 + else + ExportScript.AF.SPO15RWRData[426] = 0 + end + end + + else + lPriorityTmp = 0 + lPrimaryThreatTmp = 0 + + if ExportScript.AF.SPO15_FoundErmitter == nil or ExportScript.AF.SPO15_FoundErmitter then + ExportScript.AF.SPO15RWR_Reset(401, 480) + end + end + end + + if ExportScript.Config.IkarusExport and lFunctionTyp == "Ikarus" then + if ExportScript.AF.SPO15RWRData ~= nil then + for key, value in pairs(ExportScript.AF.SPO15RWRData) do + ExportScript.Tools.SendData(key, value) + end + end + end + + if ExportScript.Config.DACExport and lFunctionTyp == "DAC" then + if ExportScript.AF.SPO15RWRData ~= nil then + for key, value in pairs(ExportScript.AF.SPO15RWRData) do + ExportScript.Tools.SendDataDAC(key, value) + end + end + end + + --[[ +level: 2, 16, 101, 39 +lNameByType: string: "hawk sr" + +alle Level -> wsTypes.lua +oder +Nummer 101 -> AN-MPQ-51 HAWK SR.lua +Nummer 39 -> TechnicsTable.sht + +lNameByType: string: "hawk sr" -> db_sensors.lua + + ]] +end + + +-- Auxiliary Functions + +function ExportScript.AF.FindRadarTypeForSPO15(lTWSInfo, PrimaryThreat) + local lPrimaryThreat = PrimaryThreat or 0 + local lReturn = {AIR = 0, LRR = 0, MRR = 0, SRR = 0, EWR = 0, AWACS = 0, Lock = 0, TopHemisphere = 0, BottomHemisphere = 0} + + for EmitterIndex = 1, #lTWSInfo.Emitters, 1 do + if lPrimaryThreat ~= 0 then + EmitterIndex = lPrimaryThreat + end + local lType = lTWSInfo.Emitters[EmitterIndex].Type + --ExportScript.Tools.WriteToLog('level: '..lType.level1..', '..lType.level2..', '..lType.level3..', '..lType.level4) + local lNameByType = LoGetNameByType(lType.level1, lType.level2, lType.level3, lType.level4) -- world database classification of emitter, args 4 (number : level1,level2,level3,level4), result string + --ExportScript.Tools.WriteToLog('lNameByType: '..ExportScript.Tools.dump(lNameByType)) + + -- threat type + if (lType.level1 == 1 or lType.level1 == 4) and + not(lType.level4 == 26 or -- level4 26: A-50 + lType.level4 == 27 or -- level4 27: E-3 + lType.level4 == 41) then -- level4 41: E-2C + lReturn.AIR = 1 -- primary Air or Weapon + end + + if lType.level1 == 2 or lType.level1 == 3 then + -- ground or navy + if lType.level2 == 16 then + local lAn, lEn + -- Ground SAM + lAn, lEn = string.find("s300 sr,s300 tr,an/mpq-53", lNameByType, 0, true) + -- long range radar + if lAn ~= nil then + lReturn.LRR = 1 + end + + lAn, lEn = string.find("p19,snr-125,kub,hawk sr,hawk tr,buk sr,buk tr,5n66m sr", lNameByType, 0, true) + -- mid range radar + if lAn ~= nil then + lReturn.MRR = 1 + end + + lAn, lEn = string.find("M163 Vulcan,shilka zsu-23-4,gepard,roland ads,roland radar,osa 9a33 ln,2c6m,9a331,Dog Ear Radar", lNameByType, 0, true) + -- short range radar + if lAn ~= nil then + lReturn.SRR = 1 + end +--[[ if lType.level4 == 27 or -- Dog Ear Radar + lType.level4 == 31 or -- roland ads + lType.level4 == 32 or -- roland radar + lType.level4 == 38 then -- gepard + lReturn.SRR = 1 + end +]] + lAn, lEn = string.find("1l13 ewr station,55G6", lNameByType, 0, true) + -- EWR + if lAn ~= nil then + lReturn.EWR = 1 + end + + elseif lType.level2 == 12 then + local lAn, lEn + -- Ship + lAn, lEn = string.find("FFG-7 Oliver H. Perry class,SG-47 Ticonderoga class", lNameByType, 0, true) + -- long range radar + if lAn ~= nil then + lReturn.LRR = 1 + end + + lAn, lEn = string.find("CVN-70 Vinson", lNameByType, 0, true) + -- short range radar + if lAn ~= nil then + lReturn.SRR = 1 + end + end + elseif lType.level1 == 1 and lType.level2 == 1 and lType.level3 == 5 then + if lType.level4 == 26 or lType.level4 == 27 or lType.level4 == 41 then + -- AWACS + -- level4 26: A-50 + -- level4 27: E-3 + -- level4 41: E-2C + lReturn.AWACS = 1 + end + end + -- primary threat handling only + if lPrimaryThreat ~= 0 then + if lTWSInfo.Emitters[lPrimaryThreat].SignalType == "lock" then + -- look + lReturn.Lock = 0.2 + + lReturn.TopHemisphere = 1 -- top hemisphere + lReturn.BottomHemisphere = 1 -- bottom hemisphere + elseif lTWSInfo.Emitters[lPrimaryThreat].SignalType == "missile_radio_guided" then + -- Rocket on air + lReturn.Lock = 0.1 + elseif lTWSInfo.Emitters[lPrimaryThreat].SignalType == "scan" then + -- beep + elseif lTWSInfo.Emitters[lPrimaryThreat].SignalType == "track_while_scan" then + -- ??? + else + lReturn.Lock = 0 + end + + local lErmitterObject = LoGetObjectById(lTWSInfo.Emitters[lPrimaryThreat].ID) + local lErmitterObjectAlt = 0 + + if lErmitterObject then + lErmitterObjectAlt = lErmitterObject.LatLongAlt.Alt + end + + local lSelfData = LoGetSelfData() + local lSelfDataAlt = ExportScript.Tools.round(lSelfData.LatLongAlt.Alt, 0) + + if lErmitterObjectAlt and lSelfDataAlt then + --ExportScript.Tools.WriteToLog('lErmitterObjectAlt: '..lErmitterObjectAlt..', lSelfDataAlt: '..lSelfDataAlt) + if lErmitterObjectAlt > (lSelfDataAlt + 400) then + lReturn.TopHemisphere = 1 -- top hemisphere + elseif lErmitterObjectAlt < (lSelfDataAlt - 400) then + lReturn.BottomHemisphere = 1 -- bottom hemisphere + else + lReturn.TopHemisphere = 1 -- top hemisphere + lReturn.BottomHemisphere = 1 -- bottom hemisphere + end + end + + lErmitterObject, lErmitterObjectAlt, lSelfData, lSelfDataAlt = nil + + break + end + end + + return lReturn +end + +function ExportScript.AF.SPO15RWR_Reset(lMinId, lMaxID) +--ExportScript.Tools.WriteToLog('SPO15RWR_Reset') + for lCounter = lMinId, lMaxID, 1 do + ExportScript.AF.SPO15RWRData[lCounter] = 0 + end + + ExportScript.AF.SPO15_FoundErmitter = false +end + +function ExportScript.AF.SPO15RWR_SendData(lKey, lValue) +--ExportScript.Tools.WriteToLog('SPO15RWR_SendData: '..ExportScript.Tools.dump(lKey)..', '..ExportScript.Tools.dump(lValue)) + if ExportScript.AF.SPO15RWRData[lKey] == 0 then + if lValue then + ExportScript.AF.SPO15RWRData[lKey] = 1 + end + end +end + +-- WeaponStatusPanel Reset for A-10A, F-15C +function ExportScript.AF.WeaponStatusPanel_Reset(lMinId, lMaxID) +--ExportScript.Tools.WriteToLog('WeaponStatusPanel_Reset') + for lCounter = lMinId, lMaxID, 1 do + ExportScript.Tools.SendDataDAC(lCounter, 0) + end +end + +function ExportScript.AF.WeaponStatusPanel_selectCurrentPayloadStation(_index) + if ExportScript.AF.PayloadInfo.Stations[ExportScript.AF.PayloadInfo.CurrentStation].CLSID == ExportScript.AF.PayloadInfo.Stations[_index].CLSID and ExportScript.AF.PayloadInfo.CurrentStation ~= _index then + ExportScript.AF.TmpWeaponPanelActive[ExportScript.AF.TmpStationToPanel[_index].CurrentID] = 1 + end +end + +function ExportScript.AF.WeaponStatusPanel_FindCannonContainer(_index) + if ExportScript.AF.PayloadInfo.Stations[_index].weapon.level1 == 4 and -- weapon + ExportScript.AF.PayloadInfo.Stations[_index].weapon.level2 == 6 then -- Shell + ExportScript.AF.CannonContainer[_index] = ExportScript.AF.PayloadInfo.Stations[_index].CLSID + ExportScript.AF.CannonContainer.counter = ExportScript.AF.CannonContainer.counter + 1 + end +end diff --git a/Scripts/DCS-ExportScript/ExportsModules/MiG-29A.lua b/Scripts/DCS-ExportScript/ExportsModules/MiG-29A.lua index 2941857..b1d51a9 100644 --- a/Scripts/DCS-ExportScript/ExportsModules/MiG-29A.lua +++ b/Scripts/DCS-ExportScript/ExportsModules/MiG-29A.lua @@ -1,841 +1,456 @@ --- MiG-29A Export --- Version 0.9.9 BETA - -gES_FoundFCModule = true - --- auxiliary function -dofile(gES_ExportModulePath.."FC_AuxiliaryFuntions.lua") - ------------------------------------------ --- FLAMING CLIFFS AIRCRAFT / MiG-29A -- --- FC aircraft don't support GetDevice -- ------------------------------------------ - -function ProcessGlassCockpitFCHighImportanceConfig() - - local myData = LoGetSelfData() - - if (myData) then - local lLatitude = myData.LatLongAlt.Lat -- LATITUDE - local lLongitude = myData.LatLongAlt.Long -- LONGITUDE - local lBasicAtmospherePressure = LoGetBasicAtmospherePressure() -- BAROMETRIC PRESSURE - local lAltBar = LoGetAltitudeAboveSeaLevel() -- ALTITUDE SEA LEVEL (Meter) - local lAltRad = LoGetAltitudeAboveGroundLevel() -- ALTITUDE GROUND LEVEL (Meter) - --local lTrueAirSpeed = LoGetTrueAirSpeed() -- TRUE AIRSPEED (Meter/Second) - local lPitch, lBank, lYaw = LoGetADIPitchBankYaw() -- PITCH, BANK, YAW (Radian) - - local lHeading = myData.Heading -- HEADING (Radian) - local lVVI = LoGetVerticalVelocity() -- VERTICAL SPEED (Meter/Second) - local lIAS = LoGetIndicatedAirSpeed() -- INDICATED AIRSPEED (Meter/Second) - local lMachNumber = LoGetMachNumber() -- MACH - local lAoA = LoGetAngleOfAttack() -- ANGLE OF ATTACK AoA (Radian) - - local lGlide = LoGetGlideDeviation() -- VOR1 HORIZONTAL DEFLECTION (-1 +1) - local lSide = LoGetSideDeviation() -- VOR1 VERTICAL DEFLECTION (-1 +1) - --local lSlipBallPosition = LoGetSlipBallPosition() -- SLIP BALL (-1 +1) - --local lAccelerationUnits = LoGetAccelerationUnits().y -- G-LOAD - - --local lNavInfoPitch = LoGetNavigationInfo().Requirements.pitch -- AP REQUIRED PITCH (Radian) - --local lNavInfoRoll = LoGetNavigationInfo().Requirements.roll -- AP REQUIRED BANK (Radian) - --local lNavInfoSpeed = LoGetNavigationInfo().Requirements.speed -- AP SPEED (Meter/Second) - --local lNavInfoAltitude = LoGetNavigationInfo().Requirements.altitude -- AP ALTITUDE (Meter) - --local lNavInfoVerticalSpeed = LoGetNavigationInfo().Requirements.vertical_speed -- AP VERTICAL SPEED (Meter/Second) - - --local lControlPanel_HSI = LoGetControlPanel_HSI() -- HSI Data - local lHSI_RMI = LoGetControlPanel_HSI().RMI_raw -- VOR1 OBS (Radian) - local lHSI_ADF = LoGetControlPanel_HSI().ADF_raw -- ADF OBS (Radian) - --local lHSI_Heading = LoGetControlPanel_HSI().Heading_raw -- Heading (Radian) - - local lEngineRPMleft = LoGetEngineInfo().RPM.left -- ENG1 RPM % - local lEngineRPMright = LoGetEngineInfo().RPM.right -- ENG2 RPM % - local lEngineTempLeft = LoGetEngineInfo().Temperature.left -- ENG1 EGT ºC - local lEngineTempRight = LoGetEngineInfo().Temperature.right -- ENG2 EGT ºC - --local lEngineFuelInternal = LoGetEngineInfo().fuel_internal -- TANK1 (INT) (KG) - --local lEngineFuelExternal = LoGetEngineInfo().fuel_external -- TANK2 (EXT) (KG) - - --local lMechInfo = LoGetMechInfo() -- mechanical components, e.g. Flaps, Wheelbrakes,... - --local lPayloadInfo = LoGetPayloadInfo() -- Paylod, e.g. bombs, guns, rockets, fuel tanks,... - - local lDistanceToWay = 999 - local lRoute = LoGetRoute() - - if (myData and lRoute) then -- if neither are nil - local myLoc = LoGeoCoordinatesToLoCoordinates(lLongitude, lLatitude) - --lDistanceToWay = math.sqrt((myLoc.x - lRoute.goto_point.world_point.x)^2 + (myLoc.y - lRoute.goto_point.world_point.y)^2) - lDistanceToWay = math.sqrt((myLoc.x - lRoute.goto_point.world_point.x)^2 + (myLoc.z - lRoute.goto_point.world_point.z)^2) - end - - if gES_GlassCockpitType == 1 then - -- HELIOS Version 1.3 - -- customizing for HELOS - lPitch = math.deg(lPitch) -- PITCH, (Radian to Grad) - lBank = math.deg(lBank) -- BANK (Radian to Grad) - lYaw = math.deg(lYaw) -- YAW (Radian to Grad) - lHSI_RMI = math.deg(lHSI_RMI) -- VOR1 OBS (Radian to Grad) - lHSI_ADF = math.deg(lHSI_ADF) -- ADF OBS (Radian to Grad) - lAoA = math.deg(lAoA) -- ANGLE OF ATTACK AoA (Radian to Grad) - lHeading = math.deg(lHeading) -- Heading (Radian to Grad) - lHSI_ADF = (360 - lHSI_ADF) + (360 - lHeading) - lHSI_RMI = 360 - lHSI_RMI - lIAS = lIAS * 3.6 -- change from m/s to km/h - - SendData("1", string.format("%.2f", lPitch) ) - SendData("2", string.format("%.2f", lBank) ) - SendData("3", string.format("%.2f", lYaw) ) - SendData("4", string.format("%.2f", lAltBar) ) - SendData("5", string.format("%.2f", lAltRad) ) - SendData("6", string.format("%.2f", lHSI_ADF) ) - SendData("7", string.format("%.2f", lHSI_RMI) ) - SendData("8", string.format("%.2f", lHeading) ) - SendData("9", string.format("%.2f", lEngineRPMleft) ) - SendData("10", string.format("%.2f", lEngineRPMright) ) - SendData("11", string.format("%.2f", lEngineTempLeft) ) - SendData("12", string.format("%.2f", lEngineTempRight) ) - SendData("13", string.format("%.2f", lVVI) ) - SendData("14", string.format("%.2f", lIAS) ) - SendData("15", string.format("%.2f", lDistanceToWay) ) - SendData("16", string.format("%.2f", lAoA) ) - SendData("17", string.format("%.2f", lGlide) ) - SendData("18", string.format("%.2f", lSide) ) - - elseif gES_GlassCockpitType == 2 then - -- HawgTouch version 1.6 - - local lRadToDCSsignd = math.pi - local lRadToDCSunsignd = math.pi * 2 - local lDefaultNull = 0.0 - local lDefaultOne = 1.0 - - -- IAS Indicator (IAS, Thousend) {"%.4f;%.4f"} - FC_Russian_AirSpeed_1000hkm(1) - - -- AOA Indicator and Accelerometer (AOA, GLoad) - FC_Russian_AOA_MiG29(3) - - -- ADI - FC_Russian_ADI_Old(4) - - -- HSI - FC_Russian_HSI(lDistanceToWay, 5) - - -- Vertical Velocity Indicator (VVI) (VVI, TurnIndicator, SlipBallPosition) - FC_Russian_VVI_Old(6) - - -- Radar Altimeter (AltRad, MinAltitude, WarningFlag, MinAltitudeLamp) {"%.4f;%.4f;%.1f;%.1f"} (below 100m is warning light on) - FC_Russian_RadarAltimeter_1000m(100, 7) - - -- Barometric Altimeter (AltBar, BasicAtmospherePressure) - FC_Russian_BarometricAltimeter_30000(8) - - -- Tachometer (RPM) (EngineRPMleft, EngineRPMright) {"%.4f;%.4f"} - FC_Russian_EngineRPM(9) - - -- Left Jet Engine Turbine Temperature Indicator (EngineTemp) {"%.4f"} - FC_Russian_EGT_1000gc(lEngineTempLeft + 80, 10) -- differenc fromtechnical temperature to showing temperature - - -- Right Jet Engine Turbine Temperature Indicator (EngineTemp) {"%.4f"} - FC_Russian_EGT_1000gc(lEngineTempRight + 80, 11) - - -- Clock from Ka-50 {CurrentHours, CurrentMinutes, CurrentSeconds, 0, FlightTimeHours, FlightTimeMinutes, 0, 0) {"%.4f;%.4f;%.4f;%.1f;%.4f;%.4f;%.4f;%.4f"} - FC_Russian_Clock_ACS1(12) - - -- Mach {max, Mach} - local lMachTmp = 0 - --[[ - y_min = 0.0 -- minimaler Ausgabewert - y_max = 1.0 -- maximaler Ausgabewert - x_min = 0.0 -- minimaler Eingangswert - x_max = 3.0 -- maximaler Eingangswert - x = 1.65 -- aktueller Eingangswert - - d_y = 1.0 -- Delta Ausgabewerte (y_max - y_min) - d_x = 3.0 -- Delta Eingangswerte (x_max - x_min) - m = 0.33333333333333333333333333333333 -- Steigung der linearen Funktion (d_y / d_x) - n = 0.00000000000000000000000000000001 -- Schnittpunkt der Funktion mit y-Achse (y_max - m * x_max) - - y = 0.55 -- Ergebnis (m * x + n) - ]] - lMachTmp = 0.33333333333333333333333333333333 * lMachNumber + 0.00000000000000000000000000000001 - - SendData("13", string.format("%0.4f;%0.4f", lMachTmp, 0.0)) - end - else - WriteToLog("Unknown FC Error, no LoGetSelfData.") - end - -end - -function ProcessHARDWAREConfigHighImportance(mainPanelDevice) -end - -function ProcessGlassCockpitFCLowImportanceConfig() - - if gES_GlassCockpitType == 1 then - -- HELIOS Version 1.3 - - elseif gES_GlassCockpitType == 2 then - -- HawgTouch version 1.6 - - FC_RadarWarning_SPO15(14) - - -- Fuel Quantity Indicator - local lEngineInfo = LoGetEngineInfo() - if lEngineInfo ~= nil then - --WriteToLog('lEngineInfo: '..dump(lEngineInfo)) - --[[ - [fuel_external] = number: "0" - [Temperature] = { - [left] = number: "626.99444580078" - [right] = number: "626.99444580078" - } - [RPM] = { - [left] = number: "87.453765869141" - [right] = number: "87.453758239746" - } - [FuelConsumption] = { - [left] = number: "0.1500396137767" - [right] = number: "0.1500396137767" - } - [fuel_internal] = number: "3773.2749023438" - [EngineStart] = { - [left] = number: "0" - [right] = number: "0" - } - [HydraulicPressure] = { - [left] = number: "210" - [right] = number: "210" - } - lPayloadInfo.Stations[8].CLSID == E8D4652F-FD48-45B7-BA5B-2AE05BB5A9CF -- ext 800l Fuel Tank - ]] - - local lTotalFuel = lEngineInfo.fuel_internal + lEngineInfo.fuel_external - --local lTotalFuel = string.format("%3d", math.round((lEngineInfo.fuel_internal / 10), 0, "ceil") * 10) - --local lTotalFuel = string.format("%4d", lEngineInfo.fuel_internal) -- total fuel in kg - --local lTotalFuel = string.format("%4d", lEngineInfo.fuel_external) -- external fuel in kg - local lTotalFuel_7_5 = 0 - local lTotalFuel_5_0 = 0 - - if lTotalFuel < 7500 then - if lTotalFuel > 5000 then - --[[ - y_min = 0.0 -- minimaler Ausgabewert - y_max = 1.0 -- maximaler Ausgabewert - x_min = 5000 -- minimaler Eingangswert - x_max = 7500 -- maximaler Eingangswert - x = 6000 -- aktueller Eingangswert - - d_y = 1 -- Delta Ausgabewerte (y_max - y_min) - d_x = 2500 -- Delta Eingangswerte (x_max - x_min) - m = 0.0004 -- Steigung der linearen Funktion (d_y / d_x) - n = -2.0 -- Schnittpunkt der Funktion mit y-Achse (y_max - m * x_max) - - y = 0.4 -- Ergebnis (m * x + n) - ]] - lTotalFuel_7_5 = 0.0004 * lTotalFuel + -2.0 - else - lTotalFuel_7_5 = 0.0 - end - else - lTotalFuel_7_5 = 1.0 - end - if lTotalFuel < 5000 then - --[[ - y_min = 0.04 -- minimaler Ausgabewert - y_max = 1.0 -- maximaler Ausgabewert - x_min = 0 -- minimaler Eingangswert - x_max = 5000 -- maximaler Eingangswert - x = 3000 -- aktueller Eingangswert - - d_y = 0.96 -- Delta Ausgabewerte (y_max - y_min) - d_x = 5000 -- Delta Eingangswerte (x_max - x_min) - m = 0.000192 -- Steigung der linearen Funktion (d_y / d_x) - n = 0.04 -- Schnittpunkt der Funktion mit y-Achse (y_max - m * x_max) - - y = 0.616 -- Ergebnis (m * x + n) - ]] - lTotalFuel_5_0 = 0.000192 * lTotalFuel + 0.04 - else - lTotalFuel_5_0 = 1.0 - end - - -- TotalFuel_5_0 - -- TotalFuel_7_5 - -- Light1 - -- Light2 - -- Light3 - -- Light4 - -- BingoLight - SendData("15", string.format("%0.4f;%0.4f;%d;%d;%d;%d;%d", - lTotalFuel_5_0, - lTotalFuel_7_5, - 0, - (lEngineInfo.fuel_internal < 3200.0 and 1 or 0), -- Tank warning 1 - (lEngineInfo.fuel_internal < 2800.0 and 1 or 0), -- Tank warning 2 - (lEngineInfo.fuel_internal < 1400.0 and 1 or 0), -- Tank warning 3 - (lEngineInfo.fuel_internal < 800.0 and 1 or 0))) -- Tank warning 4 - - -- Hydraulic Pressure Left - FC_OneNeedleGauge(lEngineInfo.HydraulicPressure.left, 240, 17) - - -- Hydraulic Pressure Right - FC_OneNeedleGauge(lEngineInfo.HydraulicPressure.right, 240, 18) - end - - -- EKRAN Message - FC_EKRAN(16) - - -- Mechanical Configuration Indicator (GearWarningLight, NoseGear, LeftGear, RightGear, Airbreaks, Flaps1, Flaps2) {"%.1f;%d;%d;%d;%d;%d;%d"} - local lMechInfo = LoGetMechInfo() -- mechanical components, e.g. Flaps, Wheelbrakes,... - if lMechInfo ~= nil then - --WriteToLog('lMechInfo: '..dump(lMechInfo)) - local lWarningLight = 0.0 - local lTrueAirSpeed = LoGetTrueAirSpeed() - if lTrueAirSpeed ~= nil then - --WriteToLog('lTrueAirSpeed: '..dump(lTrueAirSpeed)) - lWarningLight = ((lMechInfo.flaps.value > 0.93 and lTrueAirSpeed > 340) and 1.0 or 0.0) -- Speed Warning for Flaps, same light as gear warning light, but blinking light - lWarningLight = (((lMechInfo.gear.status == 1 and lMechInfo.gear.value < 1) or (lMechInfo.gear.status == 0 and lMechInfo.gear.value > 0)) and 1.0 or lWarningLight ) -- gear warning light - end - -- WarningLight {0.0 = Off, 0.1 = blinking light, 0.2 = on} - -- WarningLight {0.0 = Off, no blinking light, 1.0 = on} - - -- left gear {0, 1} - -- right gear {0, 1} - -- nose gear {0, 1} - -- WarningLight - -- Flap 1 - -- Flap 2 - -- Nose Flap - -- Speedbreakes on {0, 1} - SendData("2", string.format("%.1f;%d;%d;%d;%d;%d;%d", - (lMechInfo.gear.value > 0.95 and 1 or 0), -- left gear - (lMechInfo.gear.value == 1 and 1 or 0), -- right gear - (lMechInfo.gear.value > 0.85 and 1 or 0), -- nose gear - lWarningLight, --- (lMechInfo.flaps.value > 0.47 and 1 or 0), -- flap 1 --- (lMechInfo.flaps.value > 0.93 and 1 or 0), -- flap 2 - (lMechInfo.flaps.status == 1 and 1 or 0), -- flap 1 - (lMechInfo.flaps.status == 2 and 1 or 0), -- flap 2 - (lMechInfo.noseflap.value > 0.1 and 1 or 0), -- noseflap - (lMechInfo.speedbrakes.status == 1 and 1 or 0))) -- speedbreakes on > 0.1 (0 - 1) - - -- Wheelbrakes Hydraulic Pressure Left - FC_OneNeedleGauge(lMechInfo.wheelbrakes.value, 240, 19) - - -- Wheelbrakes Hydraulic Pressure Right - FC_OneNeedleGauge(lMechInfo.wheelbrakes.value, 240, 20) - end - - -- Airintake - FC_Russian_AirIntake(21) - end - - --(x < 0 and 'negative' or 'non-negative') - --[[ - local lPayloadInfo = LoGetPayloadInfo() - WriteToLog('lPayloadInfo: '..dump(lPayloadInfo)) - - local lSnares = LoGetSnares() -- Flare and Chaff - WriteToLog('lSnares: '..dump(lSnares)) - - local lSightingSystemInfo = LoGetSightingSystemInfo() - WriteToLog('lSightingSystemInfo: '..dump(lSightingSystemInfo)) - - local lTWSInfo = LoGetTWSInfo() -- SPO Informationen, z.B. Radarwarner F15C - WriteToLog('lTWSInfo: '..dump(lTWSInfo)) - - local lTargetInformation = LoGetTargetInformation() -- detalierte Radar Infos z.B. F15C - WriteToLog('lTargetInformation: '..dump(lTargetInformation)) - - local lLockedTargetInformation = LoGetLockedTargetInformation() - WriteToLog('lLockedTargetInformation: '..dump(lLockedTargetInformation)) - - local lF15_TWS_Contacs = LoGetF15_TWS_Contacts() -- the same information but only for F-15 in TWS mode - WriteToLog('lF15_TWS_Contacs: '..dump(lF15_TWS_Contacs)) - - local lMechInfo = LoGetMechInfo() -- mechanical components, e.g. Flaps, Wheelbrakes,... - WriteToLog('lMechInfo: '..dump(lMechInfo)) - - local lMCPState = LoGetMCPState() -- Warnlichter - WriteToLog('lMCPState: '..dump(lMCPState)) - - local lControlPanel_HSI = LoGetControlPanel_HSI() - WriteToLog('lControlPanel_HSI: '..dump(lControlPanel_HSI)) - - local lRadioBeaconsStatus = LoGetRadioBeaconsStatus() - WriteToLog('lRadioBeaconsStatus: '..dump(lRadioBeaconsStatus)) - - local lEngineInfo = LoGetEngineInfo() - WriteToLog('lEngineInfo: '..dump(lEngineInfo)) - ]] - -- Weapon Control System - --local lNameByType = LoGetNameByType () -- args 4 (number : level1,level2,level3,level4), result string - -- values from LoGetTargetInformation().type - --WriteToLog('lNameByType: '..dump(lNameByType)) -end - -function ProcessHARDWAREConfigLowImportance(mainPanelDevice) --- where necessary, specify HardwareID, example WeaponStatusPanel(2) - WeaponStatusPanel() - MechanicalDevicesIndicator() - StatusLamp() - FuelQuantityIndicator() - SightingSystem() - SPO15RWR() - FlareChaff() -end - ------------------------------ --- Custom functions -- ------------------------------ - -function SightingSystem(hardware) - local lHardware = hardware or 1 - local lSightingSystemInfo = LoGetSightingSystemInfo() - if lSightingSystemInfo == nil then - return - end - --WriteToLog('lSightingSystemInfo: '..dump(lSightingSystemInfo)9 - --[[ - [PRF] = { - [selection] = string: "ILV" - [current] = string: "MED" - } - [laser_on] = boolean: "false" - [scale] = { - [azimuth] = number: "0.52359873056412" - [distance] = number: "10000" - } - [radar_on] = boolean: "false" - [optical_system_on] = boolean: "false" - [LaunchAuthorized] = boolean: "false" - [ECM_on] = boolean: "false" - [Manufacturer] = string: "RUS" - [TDC] = { - [y] = number: "0" - [x] = number: "0" - } - [ScanZone] = { - [coverage_H] = { - [min] = number: "0" - [max] = number: "20000" - } - [size] = { - [azimuth] = number: "1.0471974611282" - [elevation] = number: "0.17453290522099" - } - [position] = { - [exceeding_manual] = number: "0" - [distance_manual] = number: "0" - [azimuth] = number: "0" - [elevation] = number: "0" - } - } - ]] - SendDataHW("600", lSightingSystemInfo.ECM_on == true and 1 or 0, lHardware ) - SendDataHW("601", lSightingSystemInfo.laser_on == true and 1 or 0, lHardware ) - SendDataHW("602", lSightingSystemInfo.optical_system_on == true and 1 or 0, lHardware ) - SendDataHW("603", lSightingSystemInfo.LaunchAuthorized == true and 1 or 0, lHardware ) - SendDataHW("604", lSightingSystemInfo.radar_on == true and 1 or 0, lHardware ) -end - -function FlareChaff(hardware) - local lHardware = hardware or 1 - local lSnares = LoGetSnares() -- Flare and Chaff - --WriteToLog('lSnares: '..dump(lSnares)) - - --[chaff] = number: "30" - --[flare] = number: "30" - - SendDataHW("800", lSnares.chaff + lSnares.flare, lHardware ) -end - -function StatusLamp(hardware) - local lHardware = hardware or 1 - local lMCPState = LoGetMCPState() -- Warnlichter - if lMCPState == nil then - return - end - --WriteToLog('lMCPState: '..dump(lMCPState)) - --[[ - [RightTailPlaneFailure] = boolean: "false" - [EOSFailure] = boolean: "false" - [ECMFailure] = boolean: "false" - [RightAileronFailure] = boolean: "false" - [MasterWarning] = boolean: "false" - [RightEngineFailure] = boolean: "false" - [CannonFailure] = boolean: "false" - [MLWSFailure] = boolean: "false" - [ACSFailure] = boolean: "false" - [RadarFailure] = boolean: "false" - [HelmetFailure] = boolean: "false" - [HUDFailure] = boolean: "false" - [LeftMainPumpFailure] = boolean: "false" - [RightWingPumpFailure] = boolean: "false" - [LeftWingPumpFailure] = boolean: "false" - [MFDFailure] = boolean: "false" - [RWSFailure] = boolean: "false" - [GearFailure] = boolean: "false" - [HydraulicsFailure] = boolean: "false" - [AutopilotFailure] = boolean: "true" - [FuelTankDamage] = boolean: "false" - [LeftAileronFailure] = boolean: "false" - [CanopyOpen] = boolean: "false" - [RightMainPumpFailure] = boolean: "false" - [StallSignalization] = boolean: "false" - [LeftEngineFailure] = boolean: "false" - [AutopilotOn] = boolean: "false" - [LeftTailPlaneFailure] = boolean: "false" - ]] - - SendDataHW("700", lMCPState.LeftTailPlaneFailure == true and 1 or 0, lHardware ) - SendDataHW("701", lMCPState.RightTailPlaneFailure == true and 1 or 0, lHardware ) - SendDataHW("702", lMCPState.MasterWarning == true and 1 or 0, lHardware ) - SendDataHW("703", lMCPState.LeftEngineFailure == true and 1 or 0, lHardware ) - SendDataHW("704", lMCPState.RightEngineFailure == true and 1 or 0, lHardware ) - SendDataHW("705", lMCPState.LeftAileronFailure == true and 1 or 0, lHardware ) - SendDataHW("706", lMCPState.RightAileronFailure == true and 1 or 0, lHardware ) - SendDataHW("707", lMCPState.LeftMainPumpFailure == true and 1 or 0, lHardware ) - SendDataHW("708", lMCPState.RightMainPumpFailure == true and 1 or 0, lHardware ) - SendDataHW("709", lMCPState.LeftWingPumpFailure == true and 1 or 0, lHardware ) - SendDataHW("710", lMCPState.RightWingPumpFailure == true and 1 or 0, lHardware ) - SendDataHW("711", lMCPState.EOSFailure == true and 1 or 0, lHardware ) - SendDataHW("712", lMCPState.ECMFailure == true and 1 or 0, lHardware ) - SendDataHW("713", lMCPState.CannonFailure == true and 1 or 0, lHardware ) - SendDataHW("714", lMCPState.MLWSFailure == true and 1 or 0, lHardware ) - SendDataHW("715", lMCPState.ACSFailure == true and 1 or 0, lHardware ) - SendDataHW("716", lMCPState.RadarFailure == true and 1 or 0, lHardware ) - SendDataHW("717", lMCPState.HelmetFailure == true and 1 or 0, lHardware ) - SendDataHW("718", lMCPState.HUDFailure == true and 1 or 0, lHardware ) - SendDataHW("719", lMCPState.MFDFailure == true and 1 or 0, lHardware ) - SendDataHW("720", lMCPState.RWSFailure == true and 1 or 0, lHardware ) - SendDataHW("721", lMCPState.GearFailure == true and 1 or 0, lHardware ) - SendDataHW("722", lMCPState.HydraulicsFailure == true and 1 or 0, lHardware ) - SendDataHW("723", lMCPState.AutopilotFailure == true and 1 or 0, lHardware ) - SendDataHW("724", lMCPState.FuelTankDamage == true and 1 or 0, lHardware ) - SendDataHW("725", lMCPState.CanopyOpen == true and 1 or 0, lHardware ) - SendDataHW("726", lMCPState.StallSignalization == true and 1 or 0, lHardware ) - SendDataHW("727", lMCPState.AutopilotOn == true and 1 or 0, lHardware ) - - local lEngineInfo = LoGetEngineInfo() - if lEngineInfo ~= nil then - --WriteToLog('lEngineInfo: '..dump(lEngineInfo)) - - SendDataHW("728", lEngineInfo.EngineStart.left, lHardware ) -- lamp start left engine 1 (0|1) - SendDataHW("729", lEngineInfo.EngineStart.right, lHardware ) -- lamp start right engine 1 (0|1) - - SendDataHW("730", (lEngineInfo.RPM.left > 100.0 and 1 or 0), lHardware ) -- lamp after burner left engine - SendDataHW("731", (lEngineInfo.RPM.right > 100.0 and 1 or 0), lHardware ) -- lam after burner right engine - end - - local lAccelerationUnits = LoGetAccelerationUnits() - if lAccelerationUnits ~= nil then - --WriteToLog('lAccelerationUnits: '..dump(lAccelerationUnits)) - SendDataHW("732", (lAccelerationUnits.y > 8.0 and 1 or 0), lHardware ) -- lamp Over-G warning - end -end - -function WeaponStatusPanel(hardware) - local lHardware = hardware or 1 --- The weapon status panel, quantity and readiness of the currently selected weapon and the remaining gun ammunition are indicated. - gES_PayloadInfo = LoGetPayloadInfo() - if gES_PayloadInfo == nil then - return - end - --WriteToLog('gES_PayloadInfo: '..dump(gES_PayloadInfo)) - --[[ exsample - [Stations] = { - [1] = { - [CLSID] = string: "{FBC29BFE-3D24-4C64-B81D-941239D12249}" - [container] = boolean: "false" - [count] = number: "1" - [weapon] = { - [level3] = number: "7" - [level1] = number: "4" - [level4] = number: "18" - [level2] = number: "4" - } - } - [2] = { - [CLSID] = string: "{FBC29BFE-3D24-4C64-B81D-941239D12249}" - [container] = boolean: "false" - [count] = number: "1" - [weapon] = { - [level3] = number: "7" - [level1] = number: "4" - [level4] = number: "18" - [level2] = number: "4" - } - } - [3] = { - [CLSID] = string: "{B4C01D60-A8A3-4237-BD72-CA7655BC0FE9}" - [container] = boolean: "false" - [count] = number: "1" - [weapon] = { - [level3] = number: "7" - [level1] = number: "4" - [level4] = number: "19" - [level2] = number: "4" - } - } - [4] = { - [CLSID] = string: "{B4C01D60-A8A3-4237-BD72-CA7655BC0FE9}" - [container] = boolean: "false" - [count] = number: "1" - [weapon] = { - [level3] = number: "7" - [level1] = number: "4" - [level4] = number: "19" - [level2] = number: "4" - } - } - [5] = { - [CLSID] = string: "{B4C01D60-A8A3-4237-BD72-CA7655BC0FE9}" - [container] = boolean: "false" - [count] = number: "1" - [weapon] = { - [level3] = number: "7" - [level1] = number: "4" - [level4] = number: "19" - [level2] = number: "4" - } - } - [6] = { - [CLSID] = string: "{B4C01D60-A8A3-4237-BD72-CA7655BC0FE9}" - [container] = boolean: "false" - [count] = number: "1" - [weapon] = { - [level3] = number: "7" - [level1] = number: "4" - [level4] = number: "19" - [level2] = number: "4" - } - } - [7] = { - [CLSID] = string: "{2BEC576B-CDF5-4B7F-961F-B0FA4312B841}" - [container] = boolean: "false" - [count] = number: "1" - [weapon] = { - [level3] = number: "43" - [level1] = number: "1" - [level4] = number: "17" - [level2] = number: "3" - } - } - } - [CurrentStation] = number: "3" - [Cannon] = { - [shells] = number: "150" - } - ]] - --[[ - Weapon Panel - | - ------------------------------- - | | | | | | | - 1 2 3 C 4 5 6 - ]] - -- Payload Info - -- weapon stations (panel) 1 (left) - 10 (right), no lamp for center station - SendDataHW("100", gES_PayloadInfo.Cannon.shells ) -- count cannon shells - SendDataHW("101", (gES_PayloadInfo.Stations[1].count > 0 and 1 or 0), lHardware ) -- weapon presend > 0 (panel 1) - SendDataHW("111", (gES_PayloadInfo.Stations[2].count > 0 and 1 or 0), lHardware ) -- weapon presend > 0 (panel 6) - SendDataHW("102", (gES_PayloadInfo.Stations[3].count > 0 and 1 or 0), lHardware ) -- weapon presend > 0 (panel 2) - SendDataHW("103", (gES_PayloadInfo.Stations[4].count > 0 and 1 or 0), lHardware ) -- weapon presend > 0 (panel 5) - SendDataHW("104", (gES_PayloadInfo.Stations[5].count > 0 and 1 or 0), lHardware ) -- weapon presend > 0 (panel 3) - SendDataHW("105", (gES_PayloadInfo.Stations[6].count > 0 and 1 or 0), lHardware ) -- weapon presend > 0 (panel 4) - --SendDataHW("106", (gES_PayloadInfo.Stations[7].count > 0 and 1 or 0) ) -- weapon presend > 0 center station, not visible - --SendDataHW("CurrentStation", gES_PayloadInfo.CurrentStation ) - - -- defination - gES_TmpStationToPanel = {} - gES_TmpStationToPanel[1] = {Panel = 1, StationID = 101, CurrentID = 201, HardwareID = lHardware } -- left - gES_TmpStationToPanel[2] = {Panel = 6, StationID = 106, CurrentID = 206, HardwareID = lHardware } -- right - gES_TmpStationToPanel[3] = {Panel = 2, StationID = 102, CurrentID = 202, HardwareID = lHardware } - gES_TmpStationToPanel[4] = {Panel = 5, StationID = 103, CurrentID = 203, HardwareID = lHardware } - gES_TmpStationToPanel[5] = {Panel = 3, StationID = 104, CurrentID = 204, HardwareID = lHardware } - gES_TmpStationToPanel[6] = {Panel = 4, StationID = 105, CurrentID = 205, HardwareID = lHardware } - - if gES_PayloadInfo.CurrentStation ~= 0 then -- gegebenenfalls prüfen ob sich CurrentStation geändert hat - SendDataHW(gES_TmpStationToPanel[gES_PayloadInfo.CurrentStation].CurrentID, 1, lHardware) -- eigentliche Auswahl - table.foreach(gES_PayloadInfo.Stations, WeaponStatusPanel_selectCurrentPayloadStation) -- zugehörige Stationen - end -end - -function FuelQuantityIndicator(hardware) - local lHardware = hardware or 1 --- Fuel quantity shows the fuel remaining in all tanks - local lEngineInfo = LoGetEngineInfo() - if lEngineInfo == nil then - return - end - --WriteToLog('lEngineInfo: '..dump(lEngineInfo)) - --[[ - [fuel_external] = number: "0" - [Temperature] = { - [left] = number: "626.99444580078" - [right] = number: "626.99444580078" - } - [RPM] = { - [left] = number: "87.453765869141" - [right] = number: "87.453758239746" - } - [FuelConsumption] = { - [left] = number: "0.1500396137767" - [right] = number: "0.1500396137767" - } - [fuel_internal] = number: "3773.2749023438" - [EngineStart] = { - [left] = number: "0" - [right] = number: "0" - } - [HydraulicPressure] = { - [left] = number: "210" - [right] = number: "210" - } - lPayloadInfo.Stations[7].CLSID == 2BEC576B-CDF5-4B7F-961F-B0FA4312B841 -- ext 1500l Fuel Tank - ]] - - SendDataHW("300", string.format("%d", math.round(((lEngineInfo.fuel_internal + lEngineInfo.fuel_external) / 10), 0, "ceil") * 10), lHardware ) -- total fuel in kg - --SendDataHW("301", string.format("%d", lEngineInfo.fuel_internal)) -- internal fuel in kg - --SendDataHW("302", string.format("%d", lEngineInfo.fuel_external)) -- external fuel in kg - - --[[ - local lPayloadInfo = LoGetPayloadInfo() - if lPayloadInfo ~= nil then - --WriteToLog('lPayloadInfo: '..dump(lPayloadInfo)) - if lPayloadInfo.Stations[7].CLSID == "{2BEC576B-CDF5-4B7F-961F-B0FA4312B841}" then -- center tanks presend and full - SendDataHW("303", ((lEngineInfo.fuel_external < 1200.0 ) and 1 or 0), lHardware ) - else - SendDataHW("303", 1, lHardware ) - end - if lPayloadInfo.Stations[3].CLSID == "{C0FF4842-FBAC-11d5-9190-00A0249B6F00}" or - lPayloadInfo.Stations[4].CLSID == "{C0FF4842-FBAC-11d5-9190-00A0249B6F00}" then -- external tank presend and full (panel 2 and 5) - SendDataHW("304", ((lEngineInfo.fuel_internal < 2830.0 ) and 1 or 0), lHardware ) - else - SendDataHW("304", 1, lHardware ) - end - else - SendDataHW("303", 1, lHardware ) - SendDataHW("304", 1, lHardware ) - end]] - - SendDataHW("304", (lEngineInfo.fuel_internal < 3200.0 and 1 or 0), lHardware ) -- Tank warning 1 - SendDataHW("305", (lEngineInfo.fuel_internal < 2800.0 and 1 or 0), lHardware ) -- Tank warning 2 - SendDataHW("306", (lEngineInfo.fuel_internal < 1390.0 and 1 or 0), lHardware ) -- Tank warning 3 - SendDataHW("307", (lEngineInfo.fuel_internal < 760.0 and 1 or 0), lHardware ) -- Tank warning 4 - --SendDataHW("308", (lEngineInfo.fuel_internal < 600.0 and 1 or 0), lHardware ) -- Bingo Fuel - -end - -function MechanicalDevicesIndicator(hardware) - local lHardware = hardware or 1 --- The mechanical devices indicator shows the position of the landing gear, flaps, leading edge flaps and airbrake - local lMechInfo = LoGetMechInfo() -- mechanical components, e.g. Flaps, Wheelbrakes,... - if lMechInfo == nil then - return - end - --[[ - [hook] = { - [status] = number: "0" - [value] = number: "0" - } - [parachute] = { - [status] = number: "0" - [value] = number: "0" - } - [controlsurfaces] = { - [eleron] = { - [left] = number: "0" - [right] = number: "-0.21084336936474" - } - [elevator] = { - [left] = number: "-0" - [right] = number: "-0" - } - [rudder] = { - [left] = number: "0" - [right] = number: "0" - } - } - [airintake] = { - [status] = number: "0" - [value] = number: "0" - } - [canopy] = { - [status] = number: "0" - [value] = number: "0" - } - [refuelingboom] = { - [status] = number: "0" - [value] = number: "0" - } - [wing] = { - [status] = number: "0" - [value] = number: "0" - } - [noseflap] = { - [status] = number: "0" - [value] = number: "0" - } - [gear] = { - [value] = number: "0" - [nose] = { - [rod] = number: "0" - } - [main] = { - [left] = { - [rod] = number: "0" - } - [right] = { - [rod] = number: "0" - } - } - [status] = number: "0" - } - [speedbrakes] = { - [status] = number: "0" - [value] = number: "0" - } - [wheelbrakes] = { - [status] = number: "0" - [value] = number: "0" - } - [flaps] = { - [status] = number: "0" - [value] = number: "0" - }]] - --SendDataHW("500", lMechInfo.gear.status ) - --SendDataHW("501", lMechInfo.gear.value ) - --SendDataHW("502", lMechInfo.gear.nose.rod ) -- zeigt an wie weit das Fahrwerk einsackt wenn das Flugzeug auf dem Boden ist - --SendDataHW("503", lMechInfo.gear.main.left.rod ) -- zeigt an wie weit das Fahrwerk einsackt wenn das Flugzeug auf dem Boden ist - --SendDataHW("504", lMechInfo.gear.main.right.rod ) -- zeigt an wie weit das Fahrwerk einsackt wenn das Flugzeug auf dem Boden ist - --SendDataHW("500", ((lMechInfo.gear.status == 1 and lMechInfo.gear.value < 1) and 1 or 0 ) ) -- gear warning light, go up - --SendDataHW("500", ((lMechInfo.gear.status == 0 and lMechInfo.gear.value > 0) and 1 or 0 ) ) -- gear warning light, go down - SendDataHW("500", (((lMechInfo.gear.status == 1 and lMechInfo.gear.value < 1) or (lMechInfo.gear.status == 0 and lMechInfo.gear.value > 0)) and 1 or 0 ), lHardware ) -- gear warning light - SendDataHW("501", (lMechInfo.gear.value > 0.85 and 1 or 0), lHardware ) -- nose gear - SendDataHW("502", (lMechInfo.gear.value > 0.95 and 1 or 0), lHardware ) -- left gear - SendDataHW("503", (lMechInfo.gear.value == 1 and 1 or 0), lHardware ) -- right gear - - --SendDataHW("510", lMechInfo.speedbrakes.status ) -- speedbreakes on 1 (0|1) - SendDataHW("510", (lMechInfo.speedbrakes.value > 0.1 and 1 or 0), lHardware ) -- speedbreakes on > 0.1 (0 - 1) - - --SendDataHW("520", lMechInfo.wheelbrakes.status ) -- not in use - --SendDataHW("521", lMechInfo.wheelbrakes.value ) -- not in use - - local lGetTrueAirSpeed = LoGetTrueAirSpeed() - --SendDataHW("530", lMechInfo.flaps.status ) -- flap switch off 0, 1. position 1, 2. position 2 (0|1|2) - --SendDataHW("531", lMechInfo.flaps.value ) -- flap 1. position > 0.25, 2. position > 0.93 (0 - 1) - SendDataHW("531", (lMechInfo.flaps.value > 0.25 and 1 or 0), lHardware ) -- flap 1. position - SendDataHW("532", (lMechInfo.flaps.value > 0.93 and 1 or 0), lHardware ) -- flap 2. position - SendDataHW("533", ((lMechInfo.flaps.value > 0.93 and lGetTrueAirSpeed > 340) and 1 or 0), lHardware ) -- Speed Warning for Flaps, same light as gear warning light, but blinking light - SendDataHW("534", (lMechInfo.gear.status > 1.0 and 1 or 0), lHardware ) -- Intake FOD shields - - --SendDataHW("540", lMechInfo.parachute.status ) - SendDataHW("541", (lMechInfo.parachute.value < 0.5 and 1 or 0), lHardware ) - - --SendDataHW("550", lMechInfo.noseflap.status ) - SendDataHW("551", (lMechInfo.noseflap.value > 20.0 and 1 or 0), lHardware ) - - SendDataHW("560", lMechInfo.airintake.status, lHardware ) - --SendDataHW("561", lMechInfo.airintake.value ) +-- MiG-29A Export +-- Version 1.0.0 BETA + +ExportScript.FoundFCModule = true + +-- auxiliary function +dofile(ExportScript.Config.ExportModulePath.."FC_AuxiliaryFuntions.lua") + +----------------------------------------- +-- FLAMING CLIFFS AIRCRAFT / MiG-29A -- +-- FC aircraft don't support GetDevice -- +----------------------------------------- + +function ExportScript.ProcessIkarusFCHighImportanceConfig() + local lFunctionTyp = "Ikarus" -- function type for shared function + local myData = LoGetSelfData() + + if (myData) then + local lLatitude = myData.LatLongAlt.Lat -- LATITUDE + local lLongitude = myData.LatLongAlt.Long -- LONGITUDE + + local lEngineTempLeft = LoGetEngineInfo().Temperature.left -- ENG1 EGT ºC + local lEngineTempRight = LoGetEngineInfo().Temperature.right -- ENG2 EGT ºC + + local lMachNumber = LoGetMachNumber() -- MACH + --[[ + local lBasicAtmospherePressure = LoGetBasicAtmospherePressure() -- BAROMETRIC PRESSURE + local lAltBar = LoGetAltitudeAboveSeaLevel() -- ALTITUDE SEA LEVEL (Meter) + local lAltRad = LoGetAltitudeAboveGroundLevel() -- ALTITUDE GROUND LEVEL (Meter) + local lTrueAirSpeed = LoGetTrueAirSpeed() -- TRUE AIRSPEED (Meter/Second) + local lPitch, lBank, lYaw = LoGetADIPitchBankYaw() -- PITCH, BANK, YAW (Radian) + + local lHeading = myData.Heading -- HEADING (Radian) + local lVVI = LoGetVerticalVelocity() -- VERTICAL SPEED (Meter/Second) + local lIAS = LoGetIndicatedAirSpeed() -- INDICATED AIRSPEED (Meter/Second) + local lAoA = LoGetAngleOfAttack() -- ANGLE OF ATTACK AoA (Radian) + + local lGlide = LoGetGlideDeviation() -- VOR1 HORIZONTAL DEFLECTION (-1 +1) + local lSide = LoGetSideDeviation() -- VOR1 VERTICAL DEFLECTION (-1 +1) + local lSlipBallPosition = LoGetSlipBallPosition() -- SLIP BALL (-1 +1) + local lAccelerationUnits = LoGetAccelerationUnits().y -- G-LOAD + + local lNavInfoPitch = LoGetNavigationInfo().Requirements.pitch -- AP REQUIRED PITCH (Radian) + local lNavInfoRoll = LoGetNavigationInfo().Requirements.roll -- AP REQUIRED BANK (Radian) + local lNavInfoSpeed = LoGetNavigationInfo().Requirements.speed -- AP SPEED (Meter/Second) + local lNavInfoAltitude = LoGetNavigationInfo().Requirements.altitude -- AP ALTITUDE (Meter) + local lNavInfoVerticalSpeed = LoGetNavigationInfo().Requirements.vertical_speed -- AP VERTICAL SPEED (Meter/Second) + + local lControlPanel_HSI = LoGetControlPanel_HSI() -- HSI Data + local lHSI_RMI = LoGetControlPanel_HSI().RMI_raw -- VOR1 OBS (Radian) + local lHSI_ADF = LoGetControlPanel_HSI().ADF_raw -- ADF OBS (Radian) + local lHSI_Heading = LoGetControlPanel_HSI().Heading_raw -- Heading (Radian) + + local lEngineRPMleft = LoGetEngineInfo().RPM.left -- ENG1 RPM % + local lEngineRPMright = LoGetEngineInfo().RPM.right -- ENG2 RPM % + + local lEngineFuelInternal = LoGetEngineInfo().fuel_internal -- TANK1 (INT) (KG) + local lEngineFuelExternal = LoGetEngineInfo().fuel_external -- TANK2 (EXT) (KG) + + local lMechInfo = LoGetMechInfo() -- mechanical components, e.g. Flaps, Wheelbrakes,... + local lPayloadInfo = LoGetPayloadInfo() -- Paylod, e.g. bombs, guns, rockets, fuel tanks,... + ]] + + local lDistanceToWay = 999 + local lRoute = LoGetRoute() + + if (myData and lRoute) then -- if neither are nil + local myLoc = LoGeoCoordinatesToLoCoordinates(lLongitude, lLatitude) + --lDistanceToWay = math.sqrt((myLoc.x - lRoute.goto_point.world_point.x)^2 + (myLoc.y - lRoute.goto_point.world_point.y)^2) + lDistanceToWay = math.sqrt((myLoc.x - lRoute.goto_point.world_point.x)^2 + (myLoc.z - lRoute.goto_point.world_point.z)^2) + end + + -- IAS-TAS Indicator + ExportScript.AF.FC_Russian_AirSpeed_1000hkm() + + -- AOA Indicator and Accelerometer + ExportScript.AF.FC_Russian_AOA_MiG29() + + -- ADI + ExportScript.AF.FC_Russian_ADI_Old() + + -- HSI + ExportScript.AF.FC_Russian_HSI(lDistanceToWay) + + -- Vertical Velocity Indicator (VVI, TurnIndicator, SlipBallPosition) + ExportScript.AF.FC_Russian_VVI_Old() + + -- Radar Altimeter (below 100m is warning light on) + ExportScript.AF.FC_Russian_RadarAltimeter_1000m(100) + + -- Barometric Altimeter + ExportScript.AF.FC_Russian_BarometricAltimeter_30000() + + -- Tachometer (RPM) + ExportScript.AF.FC_Russian_EngineRPM() + + -- Left Jet Engine Turbine Temperature Indicator (EngineTemp, ExportID) + ExportScript.AF.FC_Russian_EGT_1000gc(lEngineTempLeft + 80, 70) + + -- Right Jet Engine Turbine Temperature Indicator (EngineTemp, ExportID) + ExportScript.AF.FC_Russian_EGT_1000gc(lEngineTempRight + 80, 71) + + -- Clock from Ka-50 + ExportScript.AF.FC_Russian_Clock_late() + + -- Machmeter + ExportScript.AF.FC_Russian_Mach_MiG29() + else + ExportScript.Tools.WriteToLog("Unknown FC Error, no LoGetSelfData.") + end +end + +function ExportScript.ProcessDACConfigHighImportance() + local lFunctionTyp = "DAC" -- function type for shared function + + -- your script + +end + +function ExportScript.ProcessIkarusFCLowImportanceConfig() + local lFunctionTyp = "Ikarus" -- function type for shared function + -- Weapon Panel + --ExportScript.AF.FC_WeaponPanel_MiG29(lFunctionTyp) + + -- SPO15 Radar Warning Reciver + ExportScript.AF.FC_SPO15RWR(lFunctionTyp) + + -- EKRAN Message + ExportScript.AF.FC_EKRAN() + + -- Mechanical Configuration Indicator + ExportScript.AF.FC_Russian_MDI_MiG29(lFunctionTyp) + + -- Fuel Quantity Indicator + ExportScript.AF.FuelQuantityIndicator(lFunctionTyp) + + -- Airintake + ExportScript.AF.FC_Russian_AirIntake() + + -- Fuel Quantity Indicator + local lEngineInfo = LoGetEngineInfo() + if lEngineInfo ~= nil then + -- Hydraulic Pressure Left + ExportScript.AF.FC_OneNeedleGauge(lEngineInfo.HydraulicPressure.left, 240, 85) + + -- Hydraulic Pressure Right + ExportScript.AF.FC_OneNeedleGauge(lEngineInfo.HydraulicPressure.right, 240, 86) + end + + local lMechInfo = LoGetMechInfo() -- mechanical components, e.g. Flaps, Wheelbrakes,... + if lMechInfo ~= nil then + -- Wheelbrakes Hydraulic Pressure Left + ExportScript.AF.FC_OneNeedleGauge(lMechInfo.wheelbrakes.value, 240, 87) + + -- Wheelbrakes Hydraulic Pressure Right + ExportScript.AF.FC_OneNeedleGauge(lMechInfo.wheelbrakes.value, 240, 88) + end + + --[[ + local lPayloadInfo = LoGetPayloadInfo() + ExportScript.Tools.WriteToLog('lPayloadInfo: '..ExportScript.Tools.dump(lPayloadInfo)) + + local lSnares = LoGetSnares() -- Flare and Chaff + ExportScript.Tools.WriteToLog('lSnares: '..ExportScript.Tools.dump(lSnares)) + + local lSightingSystemInfo = LoGetSightingSystemInfo() + ExportScript.Tools.WriteToLog('lSightingSystemInfo: '..ExportScript.Tools.dump(lSightingSystemInfo)) + + local lTWSInfo = LoGetTWSInfo() -- SPO Informationen, z.B. Radarwarner F15C + ExportScript.Tools.WriteToLog('lTWSInfo: '..ExportScript.Tools.dump(lTWSInfo)) + + local lTargetInformation = LoGetTargetInformation() -- detalierte Radar Infos z.B. F15C + ExportScript.Tools.WriteToLog('lTargetInformation: '..ExportScript.Tools.dump(lTargetInformation)) + + local lLockedTargetInformation = LoGetLockedTargetInformation() + ExportScript.Tools.WriteToLog('lLockedTargetInformation: '..ExportScript.Tools.dump(lLockedTargetInformation)) + + local lF15_TWS_Contacs = LoGetF15_TWS_Contacts() -- the same information but only for F-15 in TWS mode + ExportScript.Tools.WriteToLog('lF15_TWS_Contacs: '..ExportScript.Tools.dump(lF15_TWS_Contacs)) + + local lMechInfo = LoGetMechInfo() -- mechanical components, e.g. Flaps, Wheelbrakes,... + ExportScript.Tools.WriteToLog('lMechInfo: '..ExportScript.Tools.dump(lMechInfo)) + + local lMCPState = LoGetMCPState() -- Warnlichter + ExportScript.Tools.WriteToLog('lMCPState: '..ExportScript.Tools.dump(lMCPState)) + + local lControlPanel_HSI = LoGetControlPanel_HSI() + ExportScript.Tools.WriteToLog('lControlPanel_HSI: '..ExportScript.Tools.dump(lControlPanel_HSI)) + + local lRadioBeaconsStatus = LoGetRadioBeaconsStatus() + ExportScript.Tools.WriteToLog('lRadioBeaconsStatus: '..ExportScript.Tools.dump(lRadioBeaconsStatus)) + + local lEngineInfo = LoGetEngineInfo() + ExportScript.Tools.WriteToLog('lEngineInfo: '..ExportScript.Tools.dump(lEngineInfo)) + ]] + -- Weapon Control System + --local lNameByType = LoGetNameByType () -- args 4 (number : level1,level2,level3,level4), result string + -- values from LoGetTargetInformation().type + --ExportScript.Tools.WriteToLog('lNameByType: '..ExportScript.Tools.dump(lNameByType)) +end + +function ExportScript.ProcessDACConfigLowImportance() + local lFunctionTyp = "DAC" -- function type for shared function + + ExportScript.AF.FC_WeaponPanel_MiG29(lFunctionTyp) + ExportScript.AF.FC_SPO15RWR(lFunctionTyp) + ExportScript.AF.FC_Russian_MDI_MiG29(lFunctionTyp) + ExportScript.AF.FuelQuantityIndicator(lFunctionTyp) + ExportScript.AF.FC_Russian_FlareChaff_MiG29(lFunctionTyp) + + ExportScript.AF.StatusLamp() + ExportScript.AF.SightingSystem() +end + +----------------------------- +-- Custom functions -- +----------------------------- + +function ExportScript.AF.SightingSystem() + local lSightingSystemInfo = LoGetSightingSystemInfo() + if lSightingSystemInfo == nil then + return + end + --ExportScript.Tools.WriteToLog('lSightingSystemInfo: '..ExportScript.Tools.dump(lSightingSystemInfo)9 + --[[ + [PRF] = { + [selection] = string: "ILV" + [current] = string: "MED" + } + [laser_on] = boolean: "false" + [scale] = { + [azimuth] = number: "0.52359873056412" + [distance] = number: "10000" + } + [radar_on] = boolean: "false" + [optical_system_on] = boolean: "false" + [LaunchAuthorized] = boolean: "false" + [ECM_on] = boolean: "false" + [Manufacturer] = string: "RUS" + [TDC] = { + [y] = number: "0" + [x] = number: "0" + } + [ScanZone] = { + [coverage_H] = { + [min] = number: "0" + [max] = number: "20000" + } + [size] = { + [azimuth] = number: "1.0471974611282" + [elevation] = number: "0.17453290522099" + } + [position] = { + [exceeding_manual] = number: "0" + [distance_manual] = number: "0" + [azimuth] = number: "0" + [elevation] = number: "0" + } + } + ]] + ExportScript.Tools.SendDataDAC("600", lSightingSystemInfo.ECM_on == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("601", lSightingSystemInfo.laser_on == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("602", lSightingSystemInfo.optical_system_on == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("603", lSightingSystemInfo.LaunchAuthorized == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("604", lSightingSystemInfo.radar_on == true and 1 or 0 ) +end + +function ExportScript.AF.StatusLamp() + local lMCPState = LoGetMCPState() -- Warning Lights + if lMCPState == nil then + return + end + --ExportScript.Tools.WriteToLog('lMCPState: '..ExportScript.Tools.dump(lMCPState)) + --[[ + [RightTailPlaneFailure] = boolean: "false" + [EOSFailure] = boolean: "false" + [ECMFailure] = boolean: "false" + [RightAileronFailure] = boolean: "false" + [MasterWarning] = boolean: "false" + [RightEngineFailure] = boolean: "false" + [CannonFailure] = boolean: "false" + [MLWSFailure] = boolean: "false" + [ACSFailure] = boolean: "false" + [RadarFailure] = boolean: "false" + [HelmetFailure] = boolean: "false" + [HUDFailure] = boolean: "false" + [LeftMainPumpFailure] = boolean: "false" + [RightWingPumpFailure] = boolean: "false" + [LeftWingPumpFailure] = boolean: "false" + [MFDFailure] = boolean: "false" + [RWSFailure] = boolean: "false" + [GearFailure] = boolean: "false" + [HydraulicsFailure] = boolean: "false" + [AutopilotFailure] = boolean: "true" + [FuelTankDamage] = boolean: "false" + [LeftAileronFailure] = boolean: "false" + [CanopyOpen] = boolean: "false" + [RightMainPumpFailure] = boolean: "false" + [StallSignalization] = boolean: "false" + [LeftEngineFailure] = boolean: "false" + [AutopilotOn] = boolean: "false" + [LeftTailPlaneFailure] = boolean: "false" + ]] + + ExportScript.Tools.SendDataDAC("700", lMCPState.LeftTailPlaneFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("701", lMCPState.RightTailPlaneFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("702", lMCPState.MasterWarning == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("703", lMCPState.LeftEngineFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("704", lMCPState.RightEngineFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("705", lMCPState.LeftAileronFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("706", lMCPState.RightAileronFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("707", lMCPState.LeftMainPumpFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("708", lMCPState.RightMainPumpFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("709", lMCPState.LeftWingPumpFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("710", lMCPState.RightWingPumpFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("711", lMCPState.EOSFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("712", lMCPState.ECMFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("713", lMCPState.CannonFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("714", lMCPState.MLWSFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("715", lMCPState.ACSFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("716", lMCPState.RadarFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("717", lMCPState.HelmetFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("718", lMCPState.HUDFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("719", lMCPState.MFDFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("720", lMCPState.RWSFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("721", lMCPState.GearFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("722", lMCPState.HydraulicsFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("723", lMCPState.AutopilotFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("724", lMCPState.FuelTankDamage == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("725", lMCPState.CanopyOpen == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("726", lMCPState.StallSignalization == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("727", lMCPState.AutopilotOn == true and 1 or 0 ) + + local lEngineInfo = LoGetEngineInfo() + if lEngineInfo ~= nil then + --ExportScript.Tools.WriteToLog('lEngineInfo: '..ExportScript.Tools.dump(lEngineInfo)) + + ExportScript.Tools.SendDataDAC("728", lEngineInfo.EngineStart.left ) -- lamp start left engine 1 (0|1) + ExportScript.Tools.SendDataDAC("729", lEngineInfo.EngineStart.right ) -- lamp start right engine 1 (0|1) + + ExportScript.Tools.SendDataDAC("730", (lEngineInfo.RPM.left > 100.0 and 1 or 0) ) -- lamp after burner left engine + ExportScript.Tools.SendDataDAC("731", (lEngineInfo.RPM.right > 100.0 and 1 or 0) ) -- lam after burner right engine + end + + local lAccelerationUnits = LoGetAccelerationUnits() + if lAccelerationUnits ~= nil then + --ExportScript.Tools.WriteToLog('lAccelerationUnits: '..ExportScript.Tools.dump(lAccelerationUnits)) + ExportScript.Tools.SendDataDAC("732", (lAccelerationUnits.y > 8.0 and 1 or 0) ) -- lamp Over-G warning + end +end + +function ExportScript.AF.FuelQuantityIndicator(FunctionTyp) + local lFunctionTyp = FunctionTyp or "Ikarus" +-- Fuel quantity shows the fuel remaining in all tanks + local lEngineInfo = LoGetEngineInfo() + if lEngineInfo == nil then + return + end + --ExportScript.Tools.WriteToLog('lEngineInfo: '..ExportScript.Tools.dump(lEngineInfo)) + --[[ + [fuel_external] = number: "0" + [Temperature] = { + [left] = number: "626.99444580078" + [right] = number: "626.99444580078" + } + [RPM] = { + [left] = number: "87.453765869141" + [right] = number: "87.453758239746" + } + [FuelConsumption] = { + [left] = number: "0.1500396137767" + [right] = number: "0.1500396137767" + } + [fuel_internal] = number: "3773.2749023438" + [EngineStart] = { + [left] = number: "0" + [right] = number: "0" + } + [HydraulicPressure] = { + [left] = number: "210" + [right] = number: "210" + } + lPayloadInfo.Stations[7].CLSID == 2BEC576B-CDF5-4B7F-961F-B0FA4312B841 -- ext 1500l Fuel Tank + ]] + + local lTotalFuel = lEngineInfo.fuel_internal + lEngineInfo.fuel_external + + if ExportScript.Config.DACExport and lFunctionTyp == "DAC" then + ExportScript.Tools.SendDataDAC("300", string.format("%d", ExportScript.Tools.round(((lEngineInfo.fuel_internal + lEngineInfo.fuel_external) / 10), 0, "ceil") * 10) ) -- total fuel in kg + + ExportScript.Tools.SendDataDAC("304", (lEngineInfo.fuel_internal < 3200.0 and 1 or 0) ) -- Tank warning 1 + ExportScript.Tools.SendDataDAC("305", (lEngineInfo.fuel_internal < 2800.0 and 1 or 0) ) -- Tank warning 2 + ExportScript.Tools.SendDataDAC("306", (lEngineInfo.fuel_internal < 1390.0 and 1 or 0) ) -- Tank warning 3 + ExportScript.Tools.SendDataDAC("307", (lEngineInfo.fuel_internal < 760.0 and 1 or 0) ) -- Tank warning 4 + --ExportScript.Tools.SendDataDAC("308", (lEngineInfo.fuel_internal < 600.0 and 1 or 0) ) -- Bingo Fuel + end + + if ExportScript.Config.IkarusExport and lFunctionTyp == "Ikarus" then + local lTotalFuel_7_5 = 0 + local lTotalFuel_5_0 = 0 + + if lTotalFuel < 7500 then + if lTotalFuel > 5000 then + --[[ + y_min = 0.0 -- minimaler Ausgabewert + y_max = 1.0 -- maximaler Ausgabewert + x_min = 5000 -- minimaler Eingangswert + x_max = 7500 -- maximaler Eingangswert + + x = 6000 -- aktueller Eingangswert + + d_y = 1 -- Delta Ausgabewerte (y_max - y_min) + d_x = 2500 -- Delta Eingangswerte (x_max - x_min) + m = 0.0004 -- Steigung der linearen Funktion (d_y / d_x) + n = -2.0 -- Schnittpunkt der Funktion mit y-Achse (y_max - m * x_max) + + y = 0.4 -- Ergebnis (m * x + n) + ]] + lTotalFuel_7_5 = 0.0004 * lTotalFuel + -2.0 + else + lTotalFuel_7_5 = 0.0 + end + else + lTotalFuel_7_5 = 1.0 + end + if lTotalFuel < 5000 then + --[[ + y_min = 0.04 -- minimaler Ausgabewert + y_max = 1.0 -- maximaler Ausgabewert + x_min = 0 -- minimaler Eingangswert + x_max = 5000 -- maximaler Eingangswert + + x = 3000 -- aktueller Eingangswert + + d_y = 0.96 -- Delta Ausgabewerte (y_max - y_min) + d_x = 5000 -- Delta Eingangswerte (x_max - x_min) + m = 0.000192 -- Steigung der linearen Funktion (d_y / d_x) + n = 0.04 -- Schnittpunkt der Funktion mit y-Achse (y_max - m * x_max) + + y = 0.616 -- Ergebnis (m * x + n) + ]] + lTotalFuel_5_0 = 0.000192 * lTotalFuel + 0.04 + else + lTotalFuel_5_0 = 1.0 + end + + ExportScript.Tools.SendData(301, string.format("%0.4f", lTotalFuel_7_5) ) + ExportScript.Tools.SendData(302, string.format("%0.4f", lTotalFuel_5_0) ) + + ExportScript.Tools.SendData(304, (lEngineInfo.fuel_internal < 3200.0 and 1 or 0) ) -- Tank warning 1 + ExportScript.Tools.SendData(305, (lEngineInfo.fuel_internal < 2800.0 and 1 or 0) ) -- Tank warning 2 + ExportScript.Tools.SendData(306, (lEngineInfo.fuel_internal < 1390.0 and 1 or 0) ) -- Tank warning 3 + ExportScript.Tools.SendData(307, (lEngineInfo.fuel_internal < 760.0 and 1 or 0) ) -- Tank warning 4 + --ExportScript.Tools.SendData(308, (lEngineInfo.fuel_internal < 600.0 and 1 or 0) ) -- Bingo Fuel + end end \ No newline at end of file diff --git a/Scripts/DCS-ExportScript/ExportsModules/MiG-29S.lua b/Scripts/DCS-ExportScript/ExportsModules/MiG-29S.lua index 8761e3f..ddc907f 100644 --- a/Scripts/DCS-ExportScript/ExportsModules/MiG-29S.lua +++ b/Scripts/DCS-ExportScript/ExportsModules/MiG-29S.lua @@ -1,840 +1,456 @@ --- MiG-29S Export --- Version 0.9.9 BETA - -gES_FoundFCModule = true - --- auxiliary function -dofile(gES_ExportModulePath.."FC_AuxiliaryFuntions.lua") - ------------------------------------------ --- FLAMING CLIFFS AIRCRAFT / MiG-29S -- --- FC aircraft don't support GetDevice -- ------------------------------------------ - -function ProcessGlassCockpitFCHighImportanceConfig() - - local myData = LoGetSelfData() - - if (myData) then - local lLatitude = myData.LatLongAlt.Lat -- LATITUDE - local lLongitude = myData.LatLongAlt.Long -- LONGITUDE - local lBasicAtmospherePressure = LoGetBasicAtmospherePressure() -- BAROMETRIC PRESSURE - local lAltBar = LoGetAltitudeAboveSeaLevel() -- ALTITUDE SEA LEVEL (Meter) - local lAltRad = LoGetAltitudeAboveGroundLevel() -- ALTITUDE GROUND LEVEL (Meter) - --local lTrueAirSpeed = LoGetTrueAirSpeed() -- TRUE AIRSPEED (Meter/Second) - local lPitch, lBank, lYaw = LoGetADIPitchBankYaw() -- PITCH, BANK, YAW (Radian) - - local lHeading = myData.Heading -- HEADING (Radian) - local lVVI = LoGetVerticalVelocity() -- VERTICAL SPEED (Meter/Second) - local lIAS = LoGetIndicatedAirSpeed() -- INDICATED AIRSPEED (Meter/Second) - local lMachNumber = LoGetMachNumber() -- MACH - local lAoA = LoGetAngleOfAttack() -- ANGLE OF ATTACK AoA (Radian) - - local lGlide = LoGetGlideDeviation() -- VOR1 HORIZONTAL DEFLECTION (-1 +1) - local lSide = LoGetSideDeviation() -- VOR1 VERTICAL DEFLECTION (-1 +1) - --local lSlipBallPosition = LoGetSlipBallPosition() -- SLIP BALL (-1 +1) - --local lAccelerationUnits = LoGetAccelerationUnits().y -- G-LOAD - - --local lNavInfoPitch = LoGetNavigationInfo().Requirements.pitch -- AP REQUIRED PITCH (Radian) - --local lNavInfoRoll = LoGetNavigationInfo().Requirements.roll -- AP REQUIRED BANK (Radian) - --local lNavInfoSpeed = LoGetNavigationInfo().Requirements.speed -- AP SPEED (Meter/Second) - --local lNavInfoAltitude = LoGetNavigationInfo().Requirements.altitude -- AP ALTITUDE (Meter) - --local lNavInfoVerticalSpeed = LoGetNavigationInfo().Requirements.vertical_speed -- AP VERTICAL SPEED (Meter/Second) - - --local lControlPanel_HSI = LoGetControlPanel_HSI() -- HSI Data - local lHSI_RMI = LoGetControlPanel_HSI().RMI_raw -- VOR1 OBS (Radian) - local lHSI_ADF = LoGetControlPanel_HSI().ADF_raw -- ADF OBS (Radian) - --local lHSI_Heading = LoGetControlPanel_HSI().Heading_raw -- Heading (Radian) - - local lEngineRPMleft = LoGetEngineInfo().RPM.left -- ENG1 RPM % - local lEngineRPMright = LoGetEngineInfo().RPM.right -- ENG2 RPM % - local lEngineTempLeft = LoGetEngineInfo().Temperature.left -- ENG1 EGT ºC - local lEngineTempRight = LoGetEngineInfo().Temperature.right -- ENG2 EGT ºC - --local lEngineFuelInternal = LoGetEngineInfo().fuel_internal -- TANK1 (INT) (KG) - --local lEngineFuelExternal = LoGetEngineInfo().fuel_external -- TANK2 (EXT) (KG) - - --local lMechInfo = LoGetMechInfo() -- mechanical components, e.g. Flaps, Wheelbrakes,... - --local lPayloadInfo = LoGetPayloadInfo() -- Paylod, e.g. bombs, guns, rockets, fuel tanks,... - - local lDistanceToWay = 999 - local lRoute = LoGetRoute() - - if (myData and lRoute) then -- if neither are nil - local myLoc = LoGeoCoordinatesToLoCoordinates(lLongitude, lLatitude) - --lDistanceToWay = math.sqrt((myLoc.x - lRoute.goto_point.world_point.x)^2 + (myLoc.y - lRoute.goto_point.world_point.y)^2) - lDistanceToWay = math.sqrt((myLoc.x - lRoute.goto_point.world_point.x)^2 + (myLoc.z - lRoute.goto_point.world_point.z)^2) - end - - if gES_GlassCockpitType == 1 then - -- HELIOS Version 1.3 - -- customizing for HELOS - lPitch = math.deg(lPitch) -- PITCH, (Radian to Grad) - lBank = math.deg(lBank) -- BANK (Radian to Grad) - lYaw = math.deg(lYaw) -- YAW (Radian to Grad) - lHSI_RMI = math.deg(lHSI_RMI) -- VOR1 OBS (Radian to Grad) - lHSI_ADF = math.deg(lHSI_ADF) -- ADF OBS (Radian to Grad) - lAoA = math.deg(lAoA) -- ANGLE OF ATTACK AoA (Radian to Grad) - lHeading = math.deg(lHeading) -- Heading (Radian to Grad) - lHSI_ADF = (360 - lHSI_ADF) + (360 - lHeading) - lHSI_RMI = 360 - lHSI_RMI - lIAS = lIAS * 3.6 -- change from m/s to km/h - - SendData("1", string.format("%.2f", lPitch) ) - SendData("2", string.format("%.2f", lBank) ) - SendData("3", string.format("%.2f", lYaw) ) - SendData("4", string.format("%.2f", lAltBar) ) - SendData("5", string.format("%.2f", lAltRad) ) - SendData("6", string.format("%.2f", lHSI_ADF) ) - SendData("7", string.format("%.2f", lHSI_RMI) ) - SendData("8", string.format("%.2f", lHeading) ) - SendData("9", string.format("%.2f", lEngineRPMleft) ) - SendData("10", string.format("%.2f", lEngineRPMright) ) - SendData("11", string.format("%.2f", lEngineTempLeft) ) - SendData("12", string.format("%.2f", lEngineTempRight) ) - SendData("13", string.format("%.2f", lVVI) ) - SendData("14", string.format("%.2f", lIAS) ) - SendData("15", string.format("%.2f", lDistanceToWay) ) - SendData("16", string.format("%.2f", lAoA) ) - SendData("17", string.format("%.2f", lGlide) ) - SendData("18", string.format("%.2f", lSide) ) - - elseif gES_GlassCockpitType == 2 then - -- HawgTouch version 1.6 - - local lRadToDCSsignd = math.pi - local lRadToDCSunsignd = math.pi * 2 - local lDefaultNull = 0.0 - local lDefaultOne = 1.0 - - -- IAS Indicator (IAS, Thousend) {"%.4f;%.4f"} - FC_Russian_AirSpeed_1000hkm(1) - - -- AOA Indicator and Accelerometer (AOA, GLoad) - FC_Russian_AOA_MiG29(3) - - -- ADI - FC_Russian_ADI_Old(4) - - -- HSI - FC_Russian_HSI(lDistanceToWay, 5) - - -- Vertical Velocity Indicator (VVI) (VVI, TurnIndicator, SlipBallPosition) - FC_Russian_VVI_Old(6) - - -- Radar Altimeter (AltRad, MinAltitude, WarningFlag, MinAltitudeLamp) {"%.4f;%.4f;%.1f;%.1f"} (below 100m is warning light on) - FC_Russian_RadarAltimeter_1000m(100, 7) - - -- Barometric Altimeter (AltBar, BasicAtmospherePressure) - FC_Russian_BarometricAltimeter_30000(8) - - -- Tachometer (RPM) (EngineRPMleft, EngineRPMright) {"%.4f;%.4f"} - FC_Russian_EngineRPM(9) - - -- Left Jet Engine Turbine Temperature Indicator (EngineTemp) {"%.4f"} - FC_Russian_EGT_1000gc(lEngineTempLeft + 80, 10) -- differenc fromtechnical temperature to showing temperature - - -- Right Jet Engine Turbine Temperature Indicator (EngineTemp) {"%.4f"} - FC_Russian_EGT_1000gc(lEngineTempRight + 80, 11) - - -- Clock from Ka-50 {CurrentHours, CurrentMinutes, CurrentSeconds, 0, FlightTimeHours, FlightTimeMinutes, 0, 0) {"%.4f;%.4f;%.4f;%.1f;%.4f;%.4f;%.4f;%.4f"} - FC_Russian_Clock_ACS1(12) - - -- Mach {max, Mach} - local lMachTmp = 0 - --[[ - y_min = 0.0 -- minimaler Ausgabewert - y_max = 1.0 -- maximaler Ausgabewert - x_min = 0.0 -- minimaler Eingangswert - x_max = 3.0 -- maximaler Eingangswert - x = 1.65 -- aktueller Eingangswert - - d_y = 1.0 -- Delta Ausgabewerte (y_max - y_min) - d_x = 3.0 -- Delta Eingangswerte (x_max - x_min) - m = 0.33333333333333333333333333333333 -- Steigung der linearen Funktion (d_y / d_x) - n = 0.00000000000000000000000000000001 -- Schnittpunkt der Funktion mit y-Achse (y_max - m * x_max) - - y = 0.55 -- Ergebnis (m * x + n) - ]] - lMachTmp = 0.33333333333333333333333333333333 * lMachNumber + 0.00000000000000000000000000000001 - - SendData("13", string.format("%0.4f;%0.4f", lMachTmp, 0.0)) - end - else - WriteToLog("Unknown FC Error, no LoGetSelfData.") - end - -end - -function ProcessHARDWAREConfigHighImportance(mainPanelDevice) -end - -function ProcessGlassCockpitFCLowImportanceConfig() - - if gES_GlassCockpitType == 1 then - -- HELIOS Version 1.3 - - elseif gES_GlassCockpitType == 2 then - -- HawgTouch version 1.6 - - FC_RadarWarning_SPO15(14) - - -- Fuel Quantity Indicator - local lEngineInfo = LoGetEngineInfo() - if lEngineInfo ~= nil then - --WriteToLog('lEngineInfo: '..dump(lEngineInfo)) - --[[ - [fuel_external] = number: "0" - [Temperature] = { - [left] = number: "626.99444580078" - [right] = number: "626.99444580078" - } - [RPM] = { - [left] = number: "87.453765869141" - [right] = number: "87.453758239746" - } - [FuelConsumption] = { - [left] = number: "0.1500396137767" - [right] = number: "0.1500396137767" - } - [fuel_internal] = number: "3773.2749023438" - [EngineStart] = { - [left] = number: "0" - [right] = number: "0" - } - [HydraulicPressure] = { - [left] = number: "210" - [right] = number: "210" - } - lPayloadInfo.Stations[8].CLSID == E8D4652F-FD48-45B7-BA5B-2AE05BB5A9CF -- ext 800l Fuel Tank - ]] - - local lTotalFuel = lEngineInfo.fuel_internal + lEngineInfo.fuel_external - --local lTotalFuel = string.format("%3d", math.round((lEngineInfo.fuel_internal / 10), 0, "ceil") * 10) - --local lTotalFuel = string.format("%4d", lEngineInfo.fuel_internal) -- total fuel in kg - --local lTotalFuel = string.format("%4d", lEngineInfo.fuel_external) -- external fuel in kg - local lTotalFuel_7_5 = 0 - local lTotalFuel_5_0 = 0 - - if lTotalFuel < 7500 then - if lTotalFuel > 5000 then - --[[ - y_min = 0.0 -- minimaler Ausgabewert - y_max = 1.0 -- maximaler Ausgabewert - x_min = 5000 -- minimaler Eingangswert - x_max = 7500 -- maximaler Eingangswert - x = 6000 -- aktueller Eingangswert - - d_y = 1 -- Delta Ausgabewerte (y_max - y_min) - d_x = 2500 -- Delta Eingangswerte (x_max - x_min) - m = 0.0004 -- Steigung der linearen Funktion (d_y / d_x) - n = -2.0 -- Schnittpunkt der Funktion mit y-Achse (y_max - m * x_max) - - y = 0.4 -- Ergebnis (m * x + n) - ]] - lTotalFuel_7_5 = 0.0004 * lTotalFuel + -2.0 - else - lTotalFuel_7_5 = 0.0 - end - else - lTotalFuel_7_5 = 1.0 - end - if lTotalFuel < 5000 then - --[[ - y_min = 0.04 -- minimaler Ausgabewert - y_max = 1.0 -- maximaler Ausgabewert - x_min = 0 -- minimaler Eingangswert - x_max = 5000 -- maximaler Eingangswert - x = 3000 -- aktueller Eingangswert - - d_y = 0.96 -- Delta Ausgabewerte (y_max - y_min) - d_x = 5000 -- Delta Eingangswerte (x_max - x_min) - m = 0.000192 -- Steigung der linearen Funktion (d_y / d_x) - n = 0.04 -- Schnittpunkt der Funktion mit y-Achse (y_max - m * x_max) - - y = 0.616 -- Ergebnis (m * x + n) - ]] - lTotalFuel_5_0 = 0.000192 * lTotalFuel + 0.04 - else - lTotalFuel_5_0 = 1.0 - end - - -- TotalFuel_5_0 - -- TotalFuel_7_5 - -- Light1 - -- Light2 - -- Light3 - -- Light4 - -- BingoLight - SendData("15", string.format("%0.4f;%0.4f;%d;%d;%d;%d;%d", - lTotalFuel_5_0, - lTotalFuel_7_5, - 0, - (lEngineInfo.fuel_internal < 3200.0 and 1 or 0), -- Tank warning 1 - (lEngineInfo.fuel_internal < 2800.0 and 1 or 0), -- Tank warning 2 - (lEngineInfo.fuel_internal < 1400.0 and 1 or 0), -- Tank warning 3 - (lEngineInfo.fuel_internal < 800.0 and 1 or 0))) -- Tank warning 4 - - -- Hydraulic Pressure Left - FC_OneNeedleGauge(lEngineInfo.HydraulicPressure.left, 240, 17) - - -- Hydraulic Pressure Right - FC_OneNeedleGauge(lEngineInfo.HydraulicPressure.right, 240, 18) - end - - -- EKRAN Message - FC_EKRAN(16) - - -- Mechanical Configuration Indicator (GearWarningLight, NoseGear, LeftGear, RightGear, Airbreaks, Flaps1, Flaps2) {"%.1f;%d;%d;%d;%d;%d;%d"} - local lMechInfo = LoGetMechInfo() -- mechanical components, e.g. Flaps, Wheelbrakes,... - if lMechInfo ~= nil then - --WriteToLog('lMechInfo: '..dump(lMechInfo)) - local lWarningLight = 0.0 - local lTrueAirSpeed = LoGetTrueAirSpeed() - if lTrueAirSpeed ~= nil then - --WriteToLog('lTrueAirSpeed: '..dump(lTrueAirSpeed)) - lWarningLight = ((lMechInfo.flaps.value > 0.93 and lTrueAirSpeed > 340) and 1.0 or 0.0) -- Speed Warning for Flaps, same light as gear warning light, but blinking light - lWarningLight = (((lMechInfo.gear.status == 1 and lMechInfo.gear.value < 1) or (lMechInfo.gear.status == 0 and lMechInfo.gear.value > 0)) and 1.0 or lWarningLight ) -- gear warning light - end - -- WarningLight {0.0 = Off, 0.1 = blinking light, 0.2 = on} - -- WarningLight {0.0 = Off, no blinking light, 1.0 = on} - - -- left gear {0, 1} - -- right gear {0, 1} - -- nose gear {0, 1} - -- WarningLight - -- Flap 1 - -- Flap 2 - -- Nose Flap - -- Speedbreakes on {0, 1} - SendData("2", string.format("%.1f;%d;%d;%d;%d;%d;%d", - (lMechInfo.gear.value > 0.95 and 1 or 0), -- left gear - (lMechInfo.gear.value == 1 and 1 or 0), -- right gear - (lMechInfo.gear.value > 0.85 and 1 or 0), -- nose gear - lWarningLight, --- (lMechInfo.flaps.value > 0.47 and 1 or 0), -- flap 1 --- (lMechInfo.flaps.value > 0.93 and 1 or 0), -- flap 2 - (lMechInfo.flaps.status == 1 and 1 or 0), -- flap 1 - (lMechInfo.flaps.status == 2 and 1 or 0), -- flap 2 - (lMechInfo.noseflap.value > 0.1 and 1 or 0), -- noseflap - (lMechInfo.speedbrakes.status == 1 and 1 or 0))) -- speedbreakes on > 0.1 (0 - 1) - - -- Wheelbrakes Hydraulic Pressure Left - FC_OneNeedleGauge(lMechInfo.wheelbrakes.value, 240, 19) - - -- Wheelbrakes Hydraulic Pressure Right - FC_OneNeedleGauge(lMechInfo.wheelbrakes.value, 240, 20) - end - - -- Airintake - FC_Russian_AirIntake(21) - end - - --(x < 0 and 'negative' or 'non-negative') - --[[ - local lPayloadInfo = LoGetPayloadInfo() - WriteToLog('lPayloadInfo: '..dump(lPayloadInfo)) - - local lSnares = LoGetSnares() -- Flare and Chaff - WriteToLog('lSnares: '..dump(lSnares)) - - local lSightingSystemInfo = LoGetSightingSystemInfo() - WriteToLog('lSightingSystemInfo: '..dump(lSightingSystemInfo)) - - local lTWSInfo = LoGetTWSInfo() -- SPO Informationen, z.B. Radarwarner F15C - WriteToLog('lTWSInfo: '..dump(lTWSInfo)) - - local lTargetInformation = LoGetTargetInformation() -- detalierte Radar Infos z.B. F15C - WriteToLog('lTargetInformation: '..dump(lTargetInformation)) - - local lLockedTargetInformation = LoGetLockedTargetInformation() - WriteToLog('lLockedTargetInformation: '..dump(lLockedTargetInformation)) - - local lF15_TWS_Contacs = LoGetF15_TWS_Contacts() -- the same information but only for F-15 in TWS mode - WriteToLog('lF15_TWS_Contacs: '..dump(lF15_TWS_Contacs)) - - local lMechInfo = LoGetMechInfo() -- mechanical components, e.g. Flaps, Wheelbrakes,... - WriteToLog('lMechInfo: '..dump(lMechInfo)) - - local lMCPState = LoGetMCPState() -- Warnlichter - WriteToLog('lMCPState: '..dump(lMCPState)) - - local lControlPanel_HSI = LoGetControlPanel_HSI() - WriteToLog('lControlPanel_HSI: '..dump(lControlPanel_HSI)) - - local lRadioBeaconsStatus = LoGetRadioBeaconsStatus() - WriteToLog('lRadioBeaconsStatus: '..dump(lRadioBeaconsStatus)) - - local lEngineInfo = LoGetEngineInfo() - WriteToLog('lEngineInfo: '..dump(lEngineInfo)) - ]] - -- Weapon Control System - --local lNameByType = LoGetNameByType () -- args 4 (number : level1,level2,level3,level4), result string - -- values from LoGetTargetInformation().type - --WriteToLog('lNameByType: '..dump(lNameByType)) -end - -function ProcessHARDWAREConfigLowImportance(mainPanelDevice) --- where necessary, specify HardwareID, example WeaponStatusPanel(2) - WeaponStatusPanel() - MechanicalDevicesIndicator() - StatusLamp() - FuelQuantityIndicator() - SightingSystem() - SPO15RWR() - FlareChaff() -end - ------------------------------ --- Custom functions -- ------------------------------ - -function SightingSystem(hardware) - local lHardware = hardware or 1 - local lSightingSystemInfo = LoGetSightingSystemInfo() - if lSightingSystemInfo == nil then - return - end - --WriteToLog('lSightingSystemInfo: '..dump(lSightingSystemInfo)9 - --[[ - [PRF] = { - [selection] = string: "ILV" - [current] = string: "MED" - } - [laser_on] = boolean: "false" - [scale] = { - [azimuth] = number: "0.52359873056412" - [distance] = number: "10000" - } - [radar_on] = boolean: "false" - [optical_system_on] = boolean: "false" - [LaunchAuthorized] = boolean: "false" - [ECM_on] = boolean: "false" - [Manufacturer] = string: "RUS" - [TDC] = { - [y] = number: "0" - [x] = number: "0" - } - [ScanZone] = { - [coverage_H] = { - [min] = number: "0" - [max] = number: "20000" - } - [size] = { - [azimuth] = number: "1.0471974611282" - [elevation] = number: "0.17453290522099" - } - [position] = { - [exceeding_manual] = number: "0" - [distance_manual] = number: "0" - [azimuth] = number: "0" - [elevation] = number: "0" - } - } - ]] - SendDataHW("600", lSightingSystemInfo.ECM_on == true and 1 or 0, lHardware ) - SendDataHW("601", lSightingSystemInfo.laser_on == true and 1 or 0, lHardware ) - SendDataHW("602", lSightingSystemInfo.optical_system_on == true and 1 or 0, lHardware ) - SendDataHW("603", lSightingSystemInfo.LaunchAuthorized == true and 1 or 0, lHardware ) - SendDataHW("604", lSightingSystemInfo.radar_on == true and 1 or 0, lHardware ) -end - -function FlareChaff(hardware) - local lHardware = hardware or 1 - local lSnares = LoGetSnares() -- Flare and Chaff - --WriteToLog('lSnares: '..dump(lSnares)) - - --[chaff] = number: "30" - --[flare] = number: "30" - - SendDataHW("800", lSnares.chaff + lSnares.flare, lHardware ) -end - -function StatusLamp(hardware) - local lHardware = hardware or 1 - local lMCPState = LoGetMCPState() -- Warnlichter - if lMCPState == nil then - return - end - --WriteToLog('lMCPState: '..dump(lMCPState)) - --[[ - [RightTailPlaneFailure] = boolean: "false" - [EOSFailure] = boolean: "false" - [ECMFailure] = boolean: "false" - [RightAileronFailure] = boolean: "false" - [MasterWarning] = boolean: "false" - [RightEngineFailure] = boolean: "false" - [CannonFailure] = boolean: "false" - [MLWSFailure] = boolean: "false" - [ACSFailure] = boolean: "false" - [RadarFailure] = boolean: "false" - [HelmetFailure] = boolean: "false" - [HUDFailure] = boolean: "false" - [LeftMainPumpFailure] = boolean: "false" - [RightWingPumpFailure] = boolean: "false" - [LeftWingPumpFailure] = boolean: "false" - [MFDFailure] = boolean: "false" - [RWSFailure] = boolean: "false" - [GearFailure] = boolean: "false" - [HydraulicsFailure] = boolean: "false" - [AutopilotFailure] = boolean: "true" - [FuelTankDamage] = boolean: "false" - [LeftAileronFailure] = boolean: "false" - [CanopyOpen] = boolean: "false" - [RightMainPumpFailure] = boolean: "false" - [StallSignalization] = boolean: "false" - [LeftEngineFailure] = boolean: "false" - [AutopilotOn] = boolean: "false" - [LeftTailPlaneFailure] = boolean: "false" - ]] - - SendDataHW("700", lMCPState.LeftTailPlaneFailure == true and 1 or 0, lHardware ) - SendDataHW("701", lMCPState.RightTailPlaneFailure == true and 1 or 0, lHardware ) - SendDataHW("702", lMCPState.MasterWarning == true and 1 or 0, lHardware ) - SendDataHW("703", lMCPState.LeftEngineFailure == true and 1 or 0, lHardware ) - SendDataHW("704", lMCPState.RightEngineFailure == true and 1 or 0, lHardware ) - SendDataHW("705", lMCPState.LeftAileronFailure == true and 1 or 0, lHardware ) - SendDataHW("706", lMCPState.RightAileronFailure == true and 1 or 0, lHardware ) - SendDataHW("707", lMCPState.LeftMainPumpFailure == true and 1 or 0, lHardware ) - SendDataHW("708", lMCPState.RightMainPumpFailure == true and 1 or 0, lHardware ) - SendDataHW("709", lMCPState.LeftWingPumpFailure == true and 1 or 0, lHardware ) - SendDataHW("710", lMCPState.RightWingPumpFailure == true and 1 or 0, lHardware ) - SendDataHW("711", lMCPState.EOSFailure == true and 1 or 0, lHardware ) - SendDataHW("712", lMCPState.ECMFailure == true and 1 or 0, lHardware ) - SendDataHW("713", lMCPState.CannonFailure == true and 1 or 0, lHardware ) - SendDataHW("714", lMCPState.MLWSFailure == true and 1 or 0, lHardware ) - SendDataHW("715", lMCPState.ACSFailure == true and 1 or 0, lHardware ) - SendDataHW("716", lMCPState.RadarFailure == true and 1 or 0, lHardware ) - SendDataHW("717", lMCPState.HelmetFailure == true and 1 or 0, lHardware ) - SendDataHW("718", lMCPState.HUDFailure == true and 1 or 0, lHardware ) - SendDataHW("719", lMCPState.MFDFailure == true and 1 or 0, lHardware ) - SendDataHW("720", lMCPState.RWSFailure == true and 1 or 0, lHardware ) - SendDataHW("721", lMCPState.GearFailure == true and 1 or 0, lHardware ) - SendDataHW("722", lMCPState.HydraulicsFailure == true and 1 or 0, lHardware ) - SendDataHW("723", lMCPState.AutopilotFailure == true and 1 or 0, lHardware ) - SendDataHW("724", lMCPState.FuelTankDamage == true and 1 or 0, lHardware ) - SendDataHW("725", lMCPState.CanopyOpen == true and 1 or 0, lHardware ) - SendDataHW("726", lMCPState.StallSignalization == true and 1 or 0, lHardware ) - SendDataHW("727", lMCPState.AutopilotOn == true and 1 or 0, lHardware ) - - local lEngineInfo = LoGetEngineInfo() - if lEngineInfo ~= nil then - --WriteToLog('lEngineInfo: '..dump(lEngineInfo)) - - SendDataHW("728", lEngineInfo.EngineStart.left, lHardware ) -- lamp start left engine 1 (0|1) - SendDataHW("729", lEngineInfo.EngineStart.right, lHardware ) -- lamp start right engine 1 (0|1) - - SendDataHW("730", (lEngineInfo.RPM.left > 100.0 and 1 or 0), lHardware ) -- lamp after burner left engine - SendDataHW("731", (lEngineInfo.RPM.right > 100.0 and 1 or 0), lHardware ) -- lam after burner right engine - end - - local lAccelerationUnits = LoGetAccelerationUnits() - if lAccelerationUnits ~= nil then - --WriteToLog('lAccelerationUnits: '..dump(lAccelerationUnits)) - SendDataHW("732", (lAccelerationUnits.y > 8.0 and 1 or 0), lHardware ) -- lamp Over-G warning - end -end - -function WeaponStatusPanel(hardware) - local lHardware = hardware or 1 --- The weapon status panel, quantity and readiness of the currently selected weapon and the remaining gun ammunition are indicated. - gES_PayloadInfo = LoGetPayloadInfo() - if gES_PayloadInfo == nil then - return - end - --WriteToLog('gES_PayloadInfo: '..dump(gES_PayloadInfo)) - --[[ exsample - [Stations] = { - [1] = { - [CLSID] = string: "{FBC29BFE-3D24-4C64-B81D-941239D12249}" - [container] = boolean: "false" - [count] = number: "1" - [weapon] = { - [level3] = number: "7" - [level1] = number: "4" - [level4] = number: "18" - [level2] = number: "4" - } - } - [2] = { - [CLSID] = string: "{FBC29BFE-3D24-4C64-B81D-941239D12249}" - [container] = boolean: "false" - [count] = number: "1" - [weapon] = { - [level3] = number: "7" - [level1] = number: "4" - [level4] = number: "18" - [level2] = number: "4" - } - } - [3] = { - [CLSID] = string: "{B4C01D60-A8A3-4237-BD72-CA7655BC0FE9}" - [container] = boolean: "false" - [count] = number: "1" - [weapon] = { - [level3] = number: "7" - [level1] = number: "4" - [level4] = number: "19" - [level2] = number: "4" - } - } - [4] = { - [CLSID] = string: "{B4C01D60-A8A3-4237-BD72-CA7655BC0FE9}" - [container] = boolean: "false" - [count] = number: "1" - [weapon] = { - [level3] = number: "7" - [level1] = number: "4" - [level4] = number: "19" - [level2] = number: "4" - } - } - [5] = { - [CLSID] = string: "{B4C01D60-A8A3-4237-BD72-CA7655BC0FE9}" - [container] = boolean: "false" - [count] = number: "1" - [weapon] = { - [level3] = number: "7" - [level1] = number: "4" - [level4] = number: "19" - [level2] = number: "4" - } - } - [6] = { - [CLSID] = string: "{B4C01D60-A8A3-4237-BD72-CA7655BC0FE9}" - [container] = boolean: "false" - [count] = number: "1" - [weapon] = { - [level3] = number: "7" - [level1] = number: "4" - [level4] = number: "19" - [level2] = number: "4" - } - } - [7] = { - [CLSID] = string: "{2BEC576B-CDF5-4B7F-961F-B0FA4312B841}" - [container] = boolean: "false" - [count] = number: "1" - [weapon] = { - [level3] = number: "43" - [level1] = number: "1" - [level4] = number: "17" - [level2] = number: "3" - } - } - } - [CurrentStation] = number: "3" - [Cannon] = { - [shells] = number: "150" - } - ]] - --[[ - Weapon Panel - | - ------------------------------- - | | | | | | | - 1 2 3 C 4 5 6 - ]] - -- Payload Info - -- weapon stations (panel) 1 (left) - 10 (right), no lamp for center station - SendDataHW("100", gES_PayloadInfo.Cannon.shells ) -- count cannon shells - SendDataHW("101", (gES_PayloadInfo.Stations[1].count > 0 and 1 or 0), lHardware ) -- weapon presend > 0 (panel 1) - SendDataHW("111", (gES_PayloadInfo.Stations[2].count > 0 and 1 or 0), lHardware ) -- weapon presend > 0 (panel 6) - SendDataHW("102", (gES_PayloadInfo.Stations[3].count > 0 and 1 or 0), lHardware ) -- weapon presend > 0 (panel 2) - SendDataHW("103", (gES_PayloadInfo.Stations[4].count > 0 and 1 or 0), lHardware ) -- weapon presend > 0 (panel 5) - SendDataHW("104", (gES_PayloadInfo.Stations[5].count > 0 and 1 or 0), lHardware ) -- weapon presend > 0 (panel 3) - SendDataHW("105", (gES_PayloadInfo.Stations[6].count > 0 and 1 or 0), lHardware ) -- weapon presend > 0 (panel 4) - --SendDataHW("106", (gES_PayloadInfo.Stations[7].count > 0 and 1 or 0) ) -- weapon presend > 0 center station, not visible - --SendDataHW("CurrentStation", gES_PayloadInfo.CurrentStation ) - - -- defination - gES_TmpStationToPanel = {} - gES_TmpStationToPanel[1] = {Panel = 1, StationID = 101, CurrentID = 201, HardwareID = lHardware } -- left - gES_TmpStationToPanel[2] = {Panel = 6, StationID = 106, CurrentID = 206, HardwareID = lHardware } -- right - gES_TmpStationToPanel[3] = {Panel = 2, StationID = 102, CurrentID = 202, HardwareID = lHardware } - gES_TmpStationToPanel[4] = {Panel = 5, StationID = 103, CurrentID = 203, HardwareID = lHardware } - gES_TmpStationToPanel[5] = {Panel = 3, StationID = 104, CurrentID = 204, HardwareID = lHardware } - gES_TmpStationToPanel[6] = {Panel = 4, StationID = 105, CurrentID = 205, HardwareID = lHardware } - - if gES_PayloadInfo.CurrentStation ~= 0 then -- gegebenenfalls prüfen ob sich CurrentStation geändert hat - SendDataHW(gES_TmpStationToPanel[gES_PayloadInfo.CurrentStation].CurrentID, 1, lHardware) -- eigentliche Auswahl - table.foreach(gES_PayloadInfo.Stations, WeaponStatusPanel_selectCurrentPayloadStation) -- zugehörige Stationen - end -end - -function FuelQuantityIndicator(hardware) - local lHardware = hardware or 1 --- Fuel quantity shows the fuel remaining in all tanks - local lEngineInfo = LoGetEngineInfo() - if lEngineInfo == nil then - return - end - --WriteToLog('lEngineInfo: '..dump(lEngineInfo)) - --[[ - [fuel_external] = number: "0" - [Temperature] = { - [left] = number: "626.99444580078" - [right] = number: "626.99444580078" - } - [RPM] = { - [left] = number: "87.453765869141" - [right] = number: "87.453758239746" - } - [FuelConsumption] = { - [left] = number: "0.1500396137767" - [right] = number: "0.1500396137767" - } - [fuel_internal] = number: "3773.2749023438" - [EngineStart] = { - [left] = number: "0" - [right] = number: "0" - } - [HydraulicPressure] = { - [left] = number: "210" - [right] = number: "210" - } - lPayloadInfo.Stations[7].CLSID == 2BEC576B-CDF5-4B7F-961F-B0FA4312B841 -- ext 1500l Fuel Tank - ]] - - SendDataHW("300", string.format("%d", math.round(((lEngineInfo.fuel_internal + lEngineInfo.fuel_external) / 10), 0, "ceil") * 10), lHardware ) -- total fuel in kg - --SendDataHW("301", string.format("%d", lEngineInfo.fuel_internal)) -- internal fuel in kg - --SendDataHW("302", string.format("%d", lEngineInfo.fuel_external)) -- external fuel in kg - - --[[ - local lPayloadInfo = LoGetPayloadInfo() - if lPayloadInfo ~= nil then - --WriteToLog('lPayloadInfo: '..dump(lPayloadInfo)) - if lPayloadInfo.Stations[7].CLSID == "{2BEC576B-CDF5-4B7F-961F-B0FA4312B841}" then -- center tanks presend and full - SendDataHW("303", ((lEngineInfo.fuel_external < 1200.0 ) and 1 or 0), lHardware ) - else - SendDataHW("303", 1, lHardware ) - end - if lPayloadInfo.Stations[3].CLSID == "{C0FF4842-FBAC-11d5-9190-00A0249B6F00}" or - lPayloadInfo.Stations[4].CLSID == "{C0FF4842-FBAC-11d5-9190-00A0249B6F00}" then -- external tank presend and full (panel 2 and 5) - SendDataHW("304", ((lEngineInfo.fuel_internal < 2830.0 ) and 1 or 0), lHardware ) - else - SendDataHW("304", 1, lHardware ) - end - else - SendDataHW("303", 1, lHardware ) - SendDataHW("304", 1, lHardware ) - end]] - - SendDataHW("304", (lEngineInfo.fuel_internal < 3200.0 and 1 or 0), lHardware ) -- Tank warning 1 - SendDataHW("305", (lEngineInfo.fuel_internal < 2800.0 and 1 or 0), lHardware ) -- Tank warning 2 - SendDataHW("306", (lEngineInfo.fuel_internal < 1390.0 and 1 or 0), lHardware ) -- Tank warning 3 - SendDataHW("307", (lEngineInfo.fuel_internal < 760.0 and 1 or 0), lHardware ) -- Tank warning 4 - --SendDataHW("308", (lEngineInfo.fuel_internal < 600.0 and 1 or 0), lHardware ) -- Bingo Fuel - -end - -function MechanicalDevicesIndicator(hardware) - local lHardware = hardware or 1 --- The mechanical devices indicator shows the position of the landing gear, flaps, leading edge flaps and airbrake - local lMechInfo = LoGetMechInfo() -- mechanical components, e.g. Flaps, Wheelbrakes,... - if lMechInfo == nil then - return - end - --[[ - [hook] = { - [status] = number: "0" - [value] = number: "0" - } - [parachute] = { - [status] = number: "0" - [value] = number: "0" - } - [controlsurfaces] = { - [eleron] = { - [left] = number: "0" - [right] = number: "-0.21084336936474" - } - [elevator] = { - [left] = number: "-0" - [right] = number: "-0" - } - [rudder] = { - [left] = number: "0" - [right] = number: "0" - } - } - [airintake] = { - [status] = number: "0" - [value] = number: "0" - } - [canopy] = { - [status] = number: "0" - [value] = number: "0" - } - [refuelingboom] = { - [status] = number: "0" - [value] = number: "0" - } - [wing] = { - [status] = number: "0" - [value] = number: "0" - } - [noseflap] = { - [status] = number: "0" - [value] = number: "0" - } - [gear] = { - [value] = number: "0" - [nose] = { - [rod] = number: "0" - } - [main] = { - [left] = { - [rod] = number: "0" - } - [right] = { - [rod] = number: "0" - } - } - [status] = number: "0" - } - [speedbrakes] = { - [status] = number: "0" - [value] = number: "0" - } - [wheelbrakes] = { - [status] = number: "0" - [value] = number: "0" - } - [flaps] = { - [status] = number: "0" - [value] = number: "0" - }]] - --SendDataHW("500", lMechInfo.gear.status ) - --SendDataHW("501", lMechInfo.gear.value ) - --SendDataHW("502", lMechInfo.gear.nose.rod ) -- zeigt an wie weit das Fahrwerk einsackt wenn das Flugzeug auf dem Boden ist - --SendDataHW("503", lMechInfo.gear.main.left.rod ) -- zeigt an wie weit das Fahrwerk einsackt wenn das Flugzeug auf dem Boden ist - --SendDataHW("504", lMechInfo.gear.main.right.rod ) -- zeigt an wie weit das Fahrwerk einsackt wenn das Flugzeug auf dem Boden ist - --SendDataHW("500", ((lMechInfo.gear.status == 1 and lMechInfo.gear.value < 1) and 1 or 0 ) ) -- gear warning light, go up - --SendDataHW("500", ((lMechInfo.gear.status == 0 and lMechInfo.gear.value > 0) and 1 or 0 ) ) -- gear warning light, go down - SendDataHW("500", (((lMechInfo.gear.status == 1 and lMechInfo.gear.value < 1) or (lMechInfo.gear.status == 0 and lMechInfo.gear.value > 0)) and 1 or 0 ), lHardware ) -- gear warning light - SendDataHW("501", (lMechInfo.gear.value > 0.85 and 1 or 0), lHardware ) -- nose gear - SendDataHW("502", (lMechInfo.gear.value > 0.95 and 1 or 0), lHardware ) -- left gear - SendDataHW("503", (lMechInfo.gear.value == 1 and 1 or 0), lHardware ) -- right gear - - --SendDataHW("510", lMechInfo.speedbrakes.status ) -- speedbreakes on 1 (0|1) - SendDataHW("510", (lMechInfo.speedbrakes.value > 0.1 and 1 or 0), lHardware ) -- speedbreakes on > 0.1 (0 - 1) - - --SendDataHW("520", lMechInfo.wheelbrakes.status ) -- not in use - --SendDataHW("521", lMechInfo.wheelbrakes.value ) -- not in use - - local lGetTrueAirSpeed = LoGetTrueAirSpeed() - --SendDataHW("530", lMechInfo.flaps.status ) -- flap switch off 0, 1. position 1, 2. position 2 (0|1|2) - --SendDataHW("531", lMechInfo.flaps.value ) -- flap 1. position > 0.25, 2. position > 0.93 (0 - 1) - SendDataHW("531", (lMechInfo.flaps.value > 0.25 and 1 or 0), lHardware ) -- flap 1. position - SendDataHW("532", (lMechInfo.flaps.value > 0.93 and 1 or 0), lHardware ) -- flap 2. position - SendDataHW("533", ((lMechInfo.flaps.value > 0.93 and lGetTrueAirSpeed > 340) and 1 or 0), lHardware ) -- Speed Warning for Flaps, same light as gear warning light, but blinking light - - --SendDataHW("540", lMechInfo.parachute.status ) - SendDataHW("541", (lMechInfo.parachute.value < 0.5 and 1 or 0), lHardware ) - - --SendDataHW("550", lMechInfo.noseflap.status ) - SendDataHW("551", (lMechInfo.noseflap.value > 20.0 and 1 or 0), lHardware ) - - SendDataHW("560", lMechInfo.airintake.status, lHardware ) - --SendDataHW("561", lMechInfo.airintake.value ) +-- MiG-29S Export +-- Version 1.0.0 BETA + +ExportScript.FoundFCModule = true + +-- auxiliary function +dofile(ExportScript.Config.ExportModulePath.."FC_AuxiliaryFuntions.lua") + +----------------------------------------- +-- FLAMING CLIFFS AIRCRAFT / MiG-29S -- +-- FC aircraft don't support GetDevice -- +----------------------------------------- + +function ExportScript.ProcessIkarusFCHighImportanceConfig() + local lFunctionTyp = "Ikarus" -- function type for shared function + local myData = LoGetSelfData() + + if (myData) then + local lLatitude = myData.LatLongAlt.Lat -- LATITUDE + local lLongitude = myData.LatLongAlt.Long -- LONGITUDE + + local lEngineTempLeft = LoGetEngineInfo().Temperature.left -- ENG1 EGT ºC + local lEngineTempRight = LoGetEngineInfo().Temperature.right -- ENG2 EGT ºC + + local lMachNumber = LoGetMachNumber() -- MACH + --[[ + local lBasicAtmospherePressure = LoGetBasicAtmospherePressure() -- BAROMETRIC PRESSURE + local lAltBar = LoGetAltitudeAboveSeaLevel() -- ALTITUDE SEA LEVEL (Meter) + local lAltRad = LoGetAltitudeAboveGroundLevel() -- ALTITUDE GROUND LEVEL (Meter) + local lTrueAirSpeed = LoGetTrueAirSpeed() -- TRUE AIRSPEED (Meter/Second) + local lPitch, lBank, lYaw = LoGetADIPitchBankYaw() -- PITCH, BANK, YAW (Radian) + + local lHeading = myData.Heading -- HEADING (Radian) + local lVVI = LoGetVerticalVelocity() -- VERTICAL SPEED (Meter/Second) + local lIAS = LoGetIndicatedAirSpeed() -- INDICATED AIRSPEED (Meter/Second) + local lAoA = LoGetAngleOfAttack() -- ANGLE OF ATTACK AoA (Radian) + + local lGlide = LoGetGlideDeviation() -- VOR1 HORIZONTAL DEFLECTION (-1 +1) + local lSide = LoGetSideDeviation() -- VOR1 VERTICAL DEFLECTION (-1 +1) + local lSlipBallPosition = LoGetSlipBallPosition() -- SLIP BALL (-1 +1) + local lAccelerationUnits = LoGetAccelerationUnits().y -- G-LOAD + + local lNavInfoPitch = LoGetNavigationInfo().Requirements.pitch -- AP REQUIRED PITCH (Radian) + local lNavInfoRoll = LoGetNavigationInfo().Requirements.roll -- AP REQUIRED BANK (Radian) + local lNavInfoSpeed = LoGetNavigationInfo().Requirements.speed -- AP SPEED (Meter/Second) + local lNavInfoAltitude = LoGetNavigationInfo().Requirements.altitude -- AP ALTITUDE (Meter) + local lNavInfoVerticalSpeed = LoGetNavigationInfo().Requirements.vertical_speed -- AP VERTICAL SPEED (Meter/Second) + + local lControlPanel_HSI = LoGetControlPanel_HSI() -- HSI Data + local lHSI_RMI = LoGetControlPanel_HSI().RMI_raw -- VOR1 OBS (Radian) + local lHSI_ADF = LoGetControlPanel_HSI().ADF_raw -- ADF OBS (Radian) + local lHSI_Heading = LoGetControlPanel_HSI().Heading_raw -- Heading (Radian) + + local lEngineRPMleft = LoGetEngineInfo().RPM.left -- ENG1 RPM % + local lEngineRPMright = LoGetEngineInfo().RPM.right -- ENG2 RPM % + + local lEngineFuelInternal = LoGetEngineInfo().fuel_internal -- TANK1 (INT) (KG) + local lEngineFuelExternal = LoGetEngineInfo().fuel_external -- TANK2 (EXT) (KG) + + local lMechInfo = LoGetMechInfo() -- mechanical components, e.g. Flaps, Wheelbrakes,... + local lPayloadInfo = LoGetPayloadInfo() -- Paylod, e.g. bombs, guns, rockets, fuel tanks,... + ]] + + local lDistanceToWay = 999 + local lRoute = LoGetRoute() + + if (myData and lRoute) then -- if neither are nil + local myLoc = LoGeoCoordinatesToLoCoordinates(lLongitude, lLatitude) + --lDistanceToWay = math.sqrt((myLoc.x - lRoute.goto_point.world_point.x)^2 + (myLoc.y - lRoute.goto_point.world_point.y)^2) + lDistanceToWay = math.sqrt((myLoc.x - lRoute.goto_point.world_point.x)^2 + (myLoc.z - lRoute.goto_point.world_point.z)^2) + end + + -- IAS-TAS Indicator + ExportScript.AF.FC_Russian_AirSpeed_1000hkm() + + -- AOA Indicator and Accelerometer + ExportScript.AF.FC_Russian_AOA_MiG29() + + -- ADI + ExportScript.AF.FC_Russian_ADI_Old() + + -- HSI + ExportScript.AF.FC_Russian_HSI(lDistanceToWay) + + -- Vertical Velocity Indicator (VVI, TurnIndicator, SlipBallPosition) + ExportScript.AF.FC_Russian_VVI_Old() + + -- Radar Altimeter (below 100m is warning light on) + ExportScript.AF.FC_Russian_RadarAltimeter_1000m(100) + + -- Barometric Altimeter + ExportScript.AF.FC_Russian_BarometricAltimeter_30000() + + -- Tachometer (RPM) + ExportScript.AF.FC_Russian_EngineRPM() + + -- Left Jet Engine Turbine Temperature Indicator (EngineTemp, ExportID) + ExportScript.AF.FC_Russian_EGT_1000gc(lEngineTempLeft + 80, 70) + + -- Right Jet Engine Turbine Temperature Indicator (EngineTemp, ExportID) + ExportScript.AF.FC_Russian_EGT_1000gc(lEngineTempRight + 80, 71) + + -- Clock from Ka-50 + ExportScript.AF.FC_Russian_Clock_late() + + -- Machmeter + ExportScript.AF.FC_Russian_Mach_MiG29() + else + ExportScript.Tools.WriteToLog("Unknown FC Error, no LoGetSelfData.") + end +end + +function ExportScript.ProcessDACConfigHighImportance() + local lFunctionTyp = "DAC" -- function type for shared function + + -- your script + +end + +function ExportScript.ProcessIkarusFCLowImportanceConfig() + local lFunctionTyp = "Ikarus" -- function type for shared function + -- Weapon Panel + --ExportScript.AF.FC_WeaponPanel_MiG29(lFunctionTyp) + + -- SPO15 Radar Warning Reciver + ExportScript.AF.FC_SPO15RWR(lFunctionTyp) + + -- EKRAN Message + ExportScript.AF.FC_EKRAN() + + -- Mechanical Configuration Indicator + ExportScript.AF.FC_Russian_MDI_MiG29(lFunctionTyp) + + -- Fuel Quantity Indicator + ExportScript.AF.FuelQuantityIndicator(lFunctionTyp) + + -- Airintake + ExportScript.AF.FC_Russian_AirIntake() + + -- Fuel Quantity Indicator + local lEngineInfo = LoGetEngineInfo() + if lEngineInfo ~= nil then + -- Hydraulic Pressure Left + ExportScript.AF.FC_OneNeedleGauge(lEngineInfo.HydraulicPressure.left, 240, 85) + + -- Hydraulic Pressure Right + ExportScript.AF.FC_OneNeedleGauge(lEngineInfo.HydraulicPressure.right, 240, 86) + end + + local lMechInfo = LoGetMechInfo() -- mechanical components, e.g. Flaps, Wheelbrakes,... + if lMechInfo ~= nil then + -- Wheelbrakes Hydraulic Pressure Left + ExportScript.AF.FC_OneNeedleGauge(lMechInfo.wheelbrakes.value, 240, 87) + + -- Wheelbrakes Hydraulic Pressure Right + ExportScript.AF.FC_OneNeedleGauge(lMechInfo.wheelbrakes.value, 240, 88) + end + + --[[ + local lPayloadInfo = LoGetPayloadInfo() + ExportScript.Tools.WriteToLog('lPayloadInfo: '..ExportScript.Tools.dump(lPayloadInfo)) + + local lSnares = LoGetSnares() -- Flare and Chaff + ExportScript.Tools.WriteToLog('lSnares: '..ExportScript.Tools.dump(lSnares)) + + local lSightingSystemInfo = LoGetSightingSystemInfo() + ExportScript.Tools.WriteToLog('lSightingSystemInfo: '..ExportScript.Tools.dump(lSightingSystemInfo)) + + local lTWSInfo = LoGetTWSInfo() -- SPO Informationen, z.B. Radarwarner F15C + ExportScript.Tools.WriteToLog('lTWSInfo: '..ExportScript.Tools.dump(lTWSInfo)) + + local lTargetInformation = LoGetTargetInformation() -- detalierte Radar Infos z.B. F15C + ExportScript.Tools.WriteToLog('lTargetInformation: '..ExportScript.Tools.dump(lTargetInformation)) + + local lLockedTargetInformation = LoGetLockedTargetInformation() + ExportScript.Tools.WriteToLog('lLockedTargetInformation: '..ExportScript.Tools.dump(lLockedTargetInformation)) + + local lF15_TWS_Contacs = LoGetF15_TWS_Contacts() -- the same information but only for F-15 in TWS mode + ExportScript.Tools.WriteToLog('lF15_TWS_Contacs: '..ExportScript.Tools.dump(lF15_TWS_Contacs)) + + local lMechInfo = LoGetMechInfo() -- mechanical components, e.g. Flaps, Wheelbrakes,... + ExportScript.Tools.WriteToLog('lMechInfo: '..ExportScript.Tools.dump(lMechInfo)) + + local lMCPState = LoGetMCPState() -- Warnlichter + ExportScript.Tools.WriteToLog('lMCPState: '..ExportScript.Tools.dump(lMCPState)) + + local lControlPanel_HSI = LoGetControlPanel_HSI() + ExportScript.Tools.WriteToLog('lControlPanel_HSI: '..ExportScript.Tools.dump(lControlPanel_HSI)) + + local lRadioBeaconsStatus = LoGetRadioBeaconsStatus() + ExportScript.Tools.WriteToLog('lRadioBeaconsStatus: '..ExportScript.Tools.dump(lRadioBeaconsStatus)) + + local lEngineInfo = LoGetEngineInfo() + ExportScript.Tools.WriteToLog('lEngineInfo: '..ExportScript.Tools.dump(lEngineInfo)) + ]] + -- Weapon Control System + --local lNameByType = LoGetNameByType () -- args 4 (number : level1,level2,level3,level4), result string + -- values from LoGetTargetInformation().type + --ExportScript.Tools.WriteToLog('lNameByType: '..ExportScript.Tools.dump(lNameByType)) +end + +function ExportScript.ProcessDACConfigLowImportance() + local lFunctionTyp = "DAC" -- function type for shared function + + ExportScript.AF.FC_WeaponPanel_MiG29(lFunctionTyp) + ExportScript.AF.FC_SPO15RWR(lFunctionTyp) + ExportScript.AF.FC_Russian_MDI_MiG29(lFunctionTyp) + ExportScript.AF.FuelQuantityIndicator(lFunctionTyp) + ExportScript.AF.FC_Russian_FlareChaff_MiG29(lFunctionTyp) + + ExportScript.AF.StatusLamp() + ExportScript.AF.SightingSystem() +end + +----------------------------- +-- Custom functions -- +----------------------------- + +function ExportScript.AF.SightingSystem() + local lSightingSystemInfo = LoGetSightingSystemInfo() + if lSightingSystemInfo == nil then + return + end + --ExportScript.Tools.WriteToLog('lSightingSystemInfo: '..ExportScript.Tools.dump(lSightingSystemInfo)9 + --[[ + [PRF] = { + [selection] = string: "ILV" + [current] = string: "MED" + } + [laser_on] = boolean: "false" + [scale] = { + [azimuth] = number: "0.52359873056412" + [distance] = number: "10000" + } + [radar_on] = boolean: "false" + [optical_system_on] = boolean: "false" + [LaunchAuthorized] = boolean: "false" + [ECM_on] = boolean: "false" + [Manufacturer] = string: "RUS" + [TDC] = { + [y] = number: "0" + [x] = number: "0" + } + [ScanZone] = { + [coverage_H] = { + [min] = number: "0" + [max] = number: "20000" + } + [size] = { + [azimuth] = number: "1.0471974611282" + [elevation] = number: "0.17453290522099" + } + [position] = { + [exceeding_manual] = number: "0" + [distance_manual] = number: "0" + [azimuth] = number: "0" + [elevation] = number: "0" + } + } + ]] + ExportScript.Tools.SendDataDAC("600", lSightingSystemInfo.ECM_on == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("601", lSightingSystemInfo.laser_on == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("602", lSightingSystemInfo.optical_system_on == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("603", lSightingSystemInfo.LaunchAuthorized == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("604", lSightingSystemInfo.radar_on == true and 1 or 0 ) +end + +function ExportScript.AF.StatusLamp() + local lMCPState = LoGetMCPState() -- Warning Lights + if lMCPState == nil then + return + end + --ExportScript.Tools.WriteToLog('lMCPState: '..ExportScript.Tools.dump(lMCPState)) + --[[ + [RightTailPlaneFailure] = boolean: "false" + [EOSFailure] = boolean: "false" + [ECMFailure] = boolean: "false" + [RightAileronFailure] = boolean: "false" + [MasterWarning] = boolean: "false" + [RightEngineFailure] = boolean: "false" + [CannonFailure] = boolean: "false" + [MLWSFailure] = boolean: "false" + [ACSFailure] = boolean: "false" + [RadarFailure] = boolean: "false" + [HelmetFailure] = boolean: "false" + [HUDFailure] = boolean: "false" + [LeftMainPumpFailure] = boolean: "false" + [RightWingPumpFailure] = boolean: "false" + [LeftWingPumpFailure] = boolean: "false" + [MFDFailure] = boolean: "false" + [RWSFailure] = boolean: "false" + [GearFailure] = boolean: "false" + [HydraulicsFailure] = boolean: "false" + [AutopilotFailure] = boolean: "true" + [FuelTankDamage] = boolean: "false" + [LeftAileronFailure] = boolean: "false" + [CanopyOpen] = boolean: "false" + [RightMainPumpFailure] = boolean: "false" + [StallSignalization] = boolean: "false" + [LeftEngineFailure] = boolean: "false" + [AutopilotOn] = boolean: "false" + [LeftTailPlaneFailure] = boolean: "false" + ]] + + ExportScript.Tools.SendDataDAC("700", lMCPState.LeftTailPlaneFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("701", lMCPState.RightTailPlaneFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("702", lMCPState.MasterWarning == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("703", lMCPState.LeftEngineFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("704", lMCPState.RightEngineFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("705", lMCPState.LeftAileronFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("706", lMCPState.RightAileronFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("707", lMCPState.LeftMainPumpFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("708", lMCPState.RightMainPumpFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("709", lMCPState.LeftWingPumpFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("710", lMCPState.RightWingPumpFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("711", lMCPState.EOSFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("712", lMCPState.ECMFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("713", lMCPState.CannonFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("714", lMCPState.MLWSFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("715", lMCPState.ACSFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("716", lMCPState.RadarFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("717", lMCPState.HelmetFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("718", lMCPState.HUDFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("719", lMCPState.MFDFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("720", lMCPState.RWSFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("721", lMCPState.GearFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("722", lMCPState.HydraulicsFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("723", lMCPState.AutopilotFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("724", lMCPState.FuelTankDamage == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("725", lMCPState.CanopyOpen == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("726", lMCPState.StallSignalization == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("727", lMCPState.AutopilotOn == true and 1 or 0 ) + + local lEngineInfo = LoGetEngineInfo() + if lEngineInfo ~= nil then + --ExportScript.Tools.WriteToLog('lEngineInfo: '..ExportScript.Tools.dump(lEngineInfo)) + + ExportScript.Tools.SendDataDAC("728", lEngineInfo.EngineStart.left ) -- lamp start left engine 1 (0|1) + ExportScript.Tools.SendDataDAC("729", lEngineInfo.EngineStart.right ) -- lamp start right engine 1 (0|1) + + ExportScript.Tools.SendDataDAC("730", (lEngineInfo.RPM.left > 100.0 and 1 or 0) ) -- lamp after burner left engine + ExportScript.Tools.SendDataDAC("731", (lEngineInfo.RPM.right > 100.0 and 1 or 0) ) -- lam after burner right engine + end + + local lAccelerationUnits = LoGetAccelerationUnits() + if lAccelerationUnits ~= nil then + --ExportScript.Tools.WriteToLog('lAccelerationUnits: '..ExportScript.Tools.dump(lAccelerationUnits)) + ExportScript.Tools.SendDataDAC("732", (lAccelerationUnits.y > 8.0 and 1 or 0) ) -- lamp Over-G warning + end +end + +function ExportScript.AF.FuelQuantityIndicator(FunctionTyp) + local lFunctionTyp = FunctionTyp or "Ikarus" +-- Fuel quantity shows the fuel remaining in all tanks + local lEngineInfo = LoGetEngineInfo() + if lEngineInfo == nil then + return + end + --ExportScript.Tools.WriteToLog('lEngineInfo: '..ExportScript.Tools.dump(lEngineInfo)) + --[[ + [fuel_external] = number: "0" + [Temperature] = { + [left] = number: "626.99444580078" + [right] = number: "626.99444580078" + } + [RPM] = { + [left] = number: "87.453765869141" + [right] = number: "87.453758239746" + } + [FuelConsumption] = { + [left] = number: "0.1500396137767" + [right] = number: "0.1500396137767" + } + [fuel_internal] = number: "3773.2749023438" + [EngineStart] = { + [left] = number: "0" + [right] = number: "0" + } + [HydraulicPressure] = { + [left] = number: "210" + [right] = number: "210" + } + lPayloadInfo.Stations[7].CLSID == 2BEC576B-CDF5-4B7F-961F-B0FA4312B841 -- ext 1500l Fuel Tank + ]] + + local lTotalFuel = lEngineInfo.fuel_internal + lEngineInfo.fuel_external + + if ExportScript.Config.DACExport and lFunctionTyp == "DAC" then + ExportScript.Tools.SendDataDAC("300", string.format("%d", ExportScript.Tools.round(((lEngineInfo.fuel_internal + lEngineInfo.fuel_external) / 10), 0, "ceil") * 10) ) -- total fuel in kg + + ExportScript.Tools.SendDataDAC("304", (lEngineInfo.fuel_internal < 3200.0 and 1 or 0) ) -- Tank warning 1 + ExportScript.Tools.SendDataDAC("305", (lEngineInfo.fuel_internal < 2800.0 and 1 or 0) ) -- Tank warning 2 + ExportScript.Tools.SendDataDAC("306", (lEngineInfo.fuel_internal < 1390.0 and 1 or 0) ) -- Tank warning 3 + ExportScript.Tools.SendDataDAC("307", (lEngineInfo.fuel_internal < 760.0 and 1 or 0) ) -- Tank warning 4 + --ExportScript.Tools.SendDataDAC("308", (lEngineInfo.fuel_internal < 600.0 and 1 or 0) ) -- Bingo Fuel + end + + if ExportScript.Config.IkarusExport and lFunctionTyp == "Ikarus" then + local lTotalFuel_7_5 = 0 + local lTotalFuel_5_0 = 0 + + if lTotalFuel < 7500 then + if lTotalFuel > 5000 then + --[[ + y_min = 0.0 -- minimaler Ausgabewert + y_max = 1.0 -- maximaler Ausgabewert + x_min = 5000 -- minimaler Eingangswert + x_max = 7500 -- maximaler Eingangswert + + x = 6000 -- aktueller Eingangswert + + d_y = 1 -- Delta Ausgabewerte (y_max - y_min) + d_x = 2500 -- Delta Eingangswerte (x_max - x_min) + m = 0.0004 -- Steigung der linearen Funktion (d_y / d_x) + n = -2.0 -- Schnittpunkt der Funktion mit y-Achse (y_max - m * x_max) + + y = 0.4 -- Ergebnis (m * x + n) + ]] + lTotalFuel_7_5 = 0.0004 * lTotalFuel + -2.0 + else + lTotalFuel_7_5 = 0.0 + end + else + lTotalFuel_7_5 = 1.0 + end + if lTotalFuel < 5000 then + --[[ + y_min = 0.04 -- minimaler Ausgabewert + y_max = 1.0 -- maximaler Ausgabewert + x_min = 0 -- minimaler Eingangswert + x_max = 5000 -- maximaler Eingangswert + + x = 3000 -- aktueller Eingangswert + + d_y = 0.96 -- Delta Ausgabewerte (y_max - y_min) + d_x = 5000 -- Delta Eingangswerte (x_max - x_min) + m = 0.000192 -- Steigung der linearen Funktion (d_y / d_x) + n = 0.04 -- Schnittpunkt der Funktion mit y-Achse (y_max - m * x_max) + + y = 0.616 -- Ergebnis (m * x + n) + ]] + lTotalFuel_5_0 = 0.000192 * lTotalFuel + 0.04 + else + lTotalFuel_5_0 = 1.0 + end + + ExportScript.Tools.SendData(301, string.format("%0.4f", lTotalFuel_7_5) ) + ExportScript.Tools.SendData(302, string.format("%0.4f", lTotalFuel_5_0) ) + + ExportScript.Tools.SendData(304, (lEngineInfo.fuel_internal < 3200.0 and 1 or 0) ) -- Tank warning 1 + ExportScript.Tools.SendData(305, (lEngineInfo.fuel_internal < 2800.0 and 1 or 0) ) -- Tank warning 2 + ExportScript.Tools.SendData(306, (lEngineInfo.fuel_internal < 1390.0 and 1 or 0) ) -- Tank warning 3 + ExportScript.Tools.SendData(307, (lEngineInfo.fuel_internal < 760.0 and 1 or 0) ) -- Tank warning 4 + --ExportScript.Tools.SendData(308, (lEngineInfo.fuel_internal < 600.0 and 1 or 0) ) -- Bingo Fuel + end end \ No newline at end of file diff --git a/Scripts/DCS-ExportScript/ExportsModules/Su-25.lua b/Scripts/DCS-ExportScript/ExportsModules/Su-25.lua index ad134fa..615d8cc 100644 --- a/Scripts/DCS-ExportScript/ExportsModules/Su-25.lua +++ b/Scripts/DCS-ExportScript/ExportsModules/Su-25.lua @@ -1,374 +1,247 @@ -- Su-25A Export --- Version 0.9.9 BETA +-- Version 1.0.0 BETA -gES_FoundFCModule = true +ExportScript.FoundFCModule = true -- auxiliary function -dofile(gES_ExportModulePath.."FC_AuxiliaryFuntions.lua") +dofile(ExportScript.Config.ExportModulePath.."FC_AuxiliaryFuntions.lua") ----------------------------------------- -- FLAMING CLIFFS AIRCRAFT / Su-25A -- -- FC aircraft don't support GetDevice -- ----------------------------------------- -function ProcessGlassCockpitFCHighImportanceConfig() - +function ExportScript.ProcessIkarusFCHighImportanceConfig() + local lFunctionTyp = "Ikarus" -- function type for shared function local myData = LoGetSelfData() if (myData) then local lLatitude = myData.LatLongAlt.Lat -- LATITUDE local lLongitude = myData.LatLongAlt.Long -- LONGITUDE + + local lMachNumber = LoGetMachNumber() -- MACH + + local lEngineTempLeft = LoGetEngineInfo().Temperature.left -- ENG1 EGT ºC + local lEngineTempRight = LoGetEngineInfo().Temperature.right -- ENG2 EGT ºC + --[[ local lBasicAtmospherePressure = LoGetBasicAtmospherePressure() -- BAROMETRIC PRESSURE local lAltBar = LoGetAltitudeAboveSeaLevel() -- ALTITUDE SEA LEVEL (Meter) local lAltRad = LoGetAltitudeAboveGroundLevel() -- ALTITUDE GROUND LEVEL (Meter) - --local lTrueAirSpeed = LoGetTrueAirSpeed() -- TRUE AIRSPEED (Meter/Second) + local lTrueAirSpeed = LoGetTrueAirSpeed() -- TRUE AIRSPEED (Meter/Second) local lPitch, lBank, lYaw = LoGetADIPitchBankYaw() -- PITCH, BANK, YAW (Radian) local lHeading = myData.Heading -- HEADING (Radian) local lVVI = LoGetVerticalVelocity() -- VERTICAL SPEED (Meter/Second) local lIAS = LoGetIndicatedAirSpeed() -- INDICATED AIRSPEED (Meter/Second) - local lMachNumber = LoGetMachNumber() -- MACH + local lAoA = LoGetAngleOfAttack() -- ANGLE OF ATTACK AoA (Radian) - + local lGlide = LoGetGlideDeviation() -- VOR1 HORIZONTAL DEFLECTION (-1 +1) local lSide = LoGetSideDeviation() -- VOR1 VERTICAL DEFLECTION (-1 +1) - --local lSlipBallPosition = LoGetSlipBallPosition() -- SLIP BALL (-1 +1) - --local lAccelerationUnits = LoGetAccelerationUnits().y -- G-LOAD - - --local lNavInfoPitch = LoGetNavigationInfo().Requirements.pitch -- AP REQUIRED PITCH (Radian) - --local lNavInfoRoll = LoGetNavigationInfo().Requirements.roll -- AP REQUIRED BANK (Radian) - --local lNavInfoSpeed = LoGetNavigationInfo().Requirements.speed -- AP SPEED (Meter/Second) - --local lNavInfoAltitude = LoGetNavigationInfo().Requirements.altitude -- AP ALTITUDE (Meter) - --local lNavInfoVerticalSpeed = LoGetNavigationInfo().Requirements.vertical_speed -- AP VERTICAL SPEED (Meter/Second) + local lSlipBallPosition = LoGetSlipBallPosition() -- SLIP BALL (-1 +1) + local lAccelerationUnits = LoGetAccelerationUnits().y -- G-LOAD - --local lControlPanel_HSI = LoGetControlPanel_HSI() -- HSI Data + local lNavInfoPitch = LoGetNavigationInfo().Requirements.pitch -- AP REQUIRED PITCH (Radian) + local lNavInfoRoll = LoGetNavigationInfo().Requirements.roll -- AP REQUIRED BANK (Radian) + local lNavInfoSpeed = LoGetNavigationInfo().Requirements.speed -- AP SPEED (Meter/Second) + local lNavInfoAltitude = LoGetNavigationInfo().Requirements.altitude -- AP ALTITUDE (Meter) + local lNavInfoVerticalSpeed = LoGetNavigationInfo().Requirements.vertical_speed -- AP VERTICAL SPEED (Meter/Second) + + local lControlPanel_HSI = LoGetControlPanel_HSI() -- HSI Data local lHSI_RMI = LoGetControlPanel_HSI().RMI_raw -- VOR1 OBS (Radian) local lHSI_ADF = LoGetControlPanel_HSI().ADF_raw -- ADF OBS (Radian) - --local lHSI_Heading = LoGetControlPanel_HSI().Heading_raw -- Heading (Radian) - + local lHSI_Heading = LoGetControlPanel_HSI().Heading_raw -- Heading (Radian) + local lEngineRPMleft = LoGetEngineInfo().RPM.left -- ENG1 RPM % local lEngineRPMright = LoGetEngineInfo().RPM.right -- ENG2 RPM % - local lEngineTempLeft = LoGetEngineInfo().Temperature.left -- ENG1 EGT ºC - local lEngineTempRight = LoGetEngineInfo().Temperature.right -- ENG2 EGT ºC - --local lEngineFuelInternal = LoGetEngineInfo().fuel_internal -- TANK1 (INT) (KG) - --local lEngineFuelExternal = LoGetEngineInfo().fuel_external -- TANK2 (EXT) (KG) - - --local lMechInfo = LoGetMechInfo() -- mechanical components, e.g. Flaps, Wheelbrakes,... - --local lPayloadInfo = LoGetPayloadInfo() -- Paylod, e.g. bombs, guns, rockets, fuel tanks,... - + + local lEngineFuelInternal = LoGetEngineInfo().fuel_internal -- TANK1 (INT) (KG) + local lEngineFuelExternal = LoGetEngineInfo().fuel_external -- TANK2 (EXT) (KG) + + local lMechInfo = LoGetMechInfo() -- mechanical components, e.g. Flaps, Wheelbrakes,... + local lPayloadInfo = LoGetPayloadInfo() -- Paylod, e.g. bombs, guns, rockets, fuel tanks,... + ]] + local lDistanceToWay = 999 local lRoute = LoGetRoute() - + if (myData and lRoute) then -- if neither are nil local myLoc = LoGeoCoordinatesToLoCoordinates(lLongitude, lLatitude) --lDistanceToWay = math.sqrt((myLoc.x - lRoute.goto_point.world_point.x)^2 + (myLoc.y - lRoute.goto_point.world_point.y)^2) lDistanceToWay = math.sqrt((myLoc.x - lRoute.goto_point.world_point.x)^2 + (myLoc.z - lRoute.goto_point.world_point.z)^2) end - if gES_GlassCockpitType == 1 then - -- HELIOS Version 1.3 - -- customizing for HELOS - lPitch = math.deg(lPitch) -- PITCH, (Radian to Grad) - lBank = math.deg(lBank) -- BANK (Radian to Grad) - lYaw = math.deg(lYaw) -- YAW (Radian to Grad) - lHSI_RMI = math.deg(lHSI_RMI) -- VOR1 OBS (Radian to Grad) - lHSI_ADF = math.deg(lHSI_ADF) -- ADF OBS (Radian to Grad) - lAoA = math.deg(lAoA) -- ANGLE OF ATTACK AoA (Radian to Grad) - lHeading = math.deg(lHeading) -- Heading (Radian to Grad) - lHSI_ADF = (360 - lHSI_ADF) + (360 - lHeading) - lHSI_RMI = 360 - lHSI_RMI - lIAS = lIAS * 3.6 -- change from m/s to km/h + -- IAS-TAS Indicator + ExportScript.AF.FC_Russian_AirSpeed_1100hkm() + + -- AOA Indicator and Accelerometer (AOA, GLoad) + ExportScript.AF.FC_Russian_AOA_Su25() + + -- ADI + ExportScript.AF.FC_Russian_ADI_Old() + + -- HSI + ExportScript.AF.FC_Russian_HSI_old() + + -- Vertical Velocity Indicator (VVI, TurnIndicator, SlipBallPosition) + ExportScript.AF.FC_Russian_VVI_Old() + + -- Radar Altimeter (below 100m is warning light on) + ExportScript.AF.FC_Russian_RadarAltimeter_1500m(100) + + -- Barometric Altimeter + ExportScript.AF.FC_Russian_BarometricAltimeter_late() + + -- Tachometer (RPM) + ExportScript.AF.FC_Russian_EngineRPM() + + -- Left Jet Engine Turbine Temperature Indicator (EngineTemp, ExportID) + ExportScript.AF.FC_Russian_EGT_1000gc(lEngineTempLeft, 70) + + -- Right Jet Engine Turbine Temperature Indicator (EngineTemp, ExportID) + ExportScript.AF.FC_Russian_EGT_1000gc(lEngineTempRight, 71) + + -- Clock from Ka-50 + ExportScript.AF.FC_Russian_Clock_late() + + -- HSI Distance + ExportScript.AF.FC_Russian_HSI_Distance_old(lDistanceToWay) + + -- Mach {max, Mach} + local lMachTmp = 0 + if lMachNumber > 0.475 then + --[[ + y_min = 0.0 -- minimaler Ausgabewert + y_max = 1.0 -- maximaler Ausgabewert + x_min = 0.475 -- minimaler Eingangswert + x_max = 1.0 -- maximaler Eingangswert + x = 0.65 -- aktueller Eingangswert + + d_y = 1 -- Delta Ausgabewerte (y_max - y_min) + d_x = 0.525 -- Delta Eingangswerte (x_max - x_min) + m = 1.9047619047619047619047619047619 -- Steigung der linearen Funktion (d_y / d_x) + n = -0.9047619047619047619047619047619 -- Schnittpunkt der Funktion mit y-Achse (y_max - m * x_max) - SendData("1", string.format("%.2f", lPitch) ) - SendData("2", string.format("%.2f", lBank) ) - SendData("3", string.format("%.2f", lYaw) ) - SendData("4", string.format("%.2f", lAltBar) ) - SendData("5", string.format("%.2f", lAltRad) ) - SendData("6", string.format("%.2f", lHSI_ADF) ) - SendData("7", string.format("%.2f", lHSI_RMI) ) - SendData("8", string.format("%.2f", lHeading) ) - SendData("9", string.format("%.2f", lEngineRPMleft) ) - SendData("10", string.format("%.2f", lEngineRPMright) ) - SendData("11", string.format("%.2f", lEngineTempLeft) ) - SendData("12", string.format("%.2f", lEngineTempRight) ) - SendData("13", string.format("%.2f", lVVI) ) - SendData("14", string.format("%.2f", lIAS) ) - SendData("15", string.format("%.2f", lDistanceToWay) ) - SendData("16", string.format("%.2f", lAoA) ) - SendData("17", string.format("%.2f", lGlide) ) - SendData("18", string.format("%.2f", lSide) ) - - elseif gES_GlassCockpitType == 2 then - -- HawgTouch version 1.6 - - local lRadToDCSsignd = math.pi - local lRadToDCSunsignd = math.pi * 2 - local lDefaultNull = 0.0 - local lDefaultOne = 1.0 - - -- IAS-TAS Indicator (IAS, TAS) {"%.4f;%.4f"} - FC_Russian_AirSpeed_1100hkm(1) - - -- AOA Indicator and Accelerometer (AOA, GLoad) - FC_Russian_AOA_Su25(3) - - -- ADI - FC_Russian_ADI_Old(4) - - -- HSI - FC_Russian_HSI_old(5) - - -- Vertical Velocity Indicator (VVI) (VVI, TurnIndicator, SlipBallPosition) - FC_Russian_VVI_Old(6) - - -- Radar Altimeter (AltRad, MinAltitude, WarningFlag, MinAltitudeLamp) {"%.4f;%.4f;%.1f;%.1f"} (below 100m is warning light on) - FC_Russian_RadarAltimeter_1500m(100, 7) - - -- Barometric Altimeter (AltBar, BasicAtmospherePressure) - FC_Russian_BarometricAltimeter_late(8) - - -- Tachometer (RPM) (EngineRPMleft, EngineRPMright) {"%.4f;%.4f"} - FC_Russian_EngineRPM(9) - - -- Left Jet Engine Turbine Temperature Indicator (EngineTemp) {"%.4f"} - FC_Russian_EGT_1000gc(lEngineTempLeft, 10) - - -- Right Jet Engine Turbine Temperature Indicator (EngineTemp) {"%.4f"} - FC_Russian_EGT_1000gc(lEngineTempRight, 11) - - -- Clock from Ka-50 {CurrentHours, CurrentMinutes, CurrentSeconds, 0, FlightTimeHours, FlightTimeMinutes, 0, 0) {"%.4f;%.4f;%.4f;%.1f;%.4f;%.4f;%.4f;%.4f"} - FC_Russian_Clock_late(12) - - -- HSI Distance - FC_Russian_HSI_Distance_old(lDistanceToWay, 21) - - -- Mach {max, Mach} - local lMachTmp = 0 - if lMachNumber > 0.475 then - --[[ - y_min = 0.0 -- minimaler Ausgabewert - y_max = 1.0 -- maximaler Ausgabewert - x_min = 0.475 -- minimaler Eingangswert - x_max = 1.0 -- maximaler Eingangswert - x = 0.65 -- aktueller Eingangswert - - d_y = 1 -- Delta Ausgabewerte (y_max - y_min) - d_x = 0.525 -- Delta Eingangswerte (x_max - x_min) - m = 1.9047619047619047619047619047619 -- Steigung der linearen Funktion (d_y / d_x) - n = -0.9047619047619047619047619047619 -- Schnittpunkt der Funktion mit y-Achse (y_max - m * x_max) - - y = 0,333333333333333333333333333334 -- Ergebnis (m * x + n) - ]] - lMachTmp = 1.9047619047619047619047619047619 * lMachNumber + -0.9047619047619047619047619047619 - else - lMachTmp = 0 - end - - SendData("22", string.format("%0.4f;%0.4f", 0.665, lMachTmp)) + y = 0,333333333333333333333333333334 -- Ergebnis (m * x + n) + ]] + lMachTmp = 1.9047619047619047619047619047619 * lMachNumber + -0.9047619047619047619047619047619 + else + lMachTmp = 0 end + + ExportScript.Tools.SendData(72, string.format("%0.4f", 0.665)) + ExportScript.Tools.SendData(73, string.format("%0.4f", lMachTmp)) else - WriteToLog("Unknown FC Error, no LoGetSelfData.") + ExportScript.Tools.WriteToLog("Unknown FC Error, no LoGetSelfData.") end +end + +function ExportScript.ProcessDACConfigHighImportance() + local lFunctionTyp = "DAC" -- function type for shared function + + -- your script + +end + +function ExportScript.ProcessIkarusFCLowImportanceConfig() + local lFunctionTyp = "Ikarus" -- function type for shared function + + ExportScript.AF.FC_WeaponPanel_SU25(lFunctionTyp) + + ExportScript.AF.FC_SPO15RWR(lFunctionTyp) + + ExportScript.AF.FuelQuantityIndicator(lFunctionTyp) -end + local lEngineInfo = LoGetEngineInfo() + if lEngineInfo ~= nil then + -- Hydraulic Pressure Left + ExportScript.AF.FC_OneNeedleGauge(lEngineInfo.HydraulicPressure.left, 240, 85) -function ProcessHARDWAREConfigHighImportance() -end - -function ProcessGlassCockpitFCLowImportanceConfig() - - if gES_GlassCockpitType == 1 then - -- HELIOS Version 1.3 - - elseif gES_GlassCockpitType == 2 then - -- HawgTouch version 1.6 - - FC_WeaponPanel_SU25(13) - - FC_RadarWarning_SPO15(14) - - -- Fuel Quantity Indicator - local lEngineInfo = LoGetEngineInfo() - if lEngineInfo ~= nil then - --WriteToLog('lEngineInfo: '..dump(lEngineInfo)) - --[[ - [fuel_external] = number: "0" - [Temperature] = { - [left] = number: "626.99444580078" - [right] = number: "626.99444580078" - } - [RPM] = { - [left] = number: "87.453765869141" - [right] = number: "87.453758239746" - } - [FuelConsumption] = { - [left] = number: "0.1500396137767" - [right] = number: "0.1500396137767" - } - [fuel_internal] = number: "3773.2749023438" - [EngineStart] = { - [left] = number: "0" - [right] = number: "0" - } - [HydraulicPressure] = { - [left] = number: "210" - [right] = number: "210" - } - lPayloadInfo.Stations[8].CLSID == E8D4652F-FD48-45B7-BA5B-2AE05BB5A9CF -- ext 800l Fuel Tank - ]] - - local lTotalFuel = lEngineInfo.fuel_internal - local lFuel_leftbar = 1.0 - local lFuel_rightbar = 1.0 - local lExtTank1 = 1.0 -- external tanks - local lExtTank2 = 1.0 -- inner tanks - - if lTotalFuel < 5000 then - if lTotalFuel > 1500 then - --[[ - y_min = 0.0 -- minimaler Ausgabewert - y_max = 1.0 -- maximaler Ausgabewert - x_min = 1500 -- minimaler Eingangswert - x_max = 5000 -- maximaler Eingangswert - x = 3500 -- aktueller Eingangswert - - d_y = 1 -- Delta Ausgabewerte (y_max - y_min) - d_x = 3500 -- Delta Eingangswerte (x_max - x_min) - m = 2.8571428571428571428571428571429e-4 -- Steigung der linearen Funktion (d_y / d_x) - n = -0.42857142857142857142857142857143 -- Schnittpunkt der Funktion mit y-Achse (y_max - m * x_max) - - y = 0,57142857142857142857142857142857 -- Ergebnis (m * x + n) - ]] - lFuel_leftbar = 2.8571428571428571428571428571429e-4 * lTotalFuel + -0.42857142857142857142857142857143 - else - lFuel_leftbar = 0.0 - end - else - lFuel_leftbar = 1.0 - end - if lTotalFuel < 1200 then - lFuel_rightbar = lTotalFuel / 1200 - else - lFuel_rightbar = 1.0 - end - - local lPayloadInfo = LoGetPayloadInfo() - if lPayloadInfo ~= nil then - --WriteToLog('lPayloadInfo: '..dump(lPayloadInfo)) - if lPayloadInfo.Stations[10].CLSID == "{E8D4652F-FD48-45B7-BA5B-2AE05BB5A9CF}" or - lPayloadInfo.Stations[9].CLSID == "{E8D4652F-FD48-45B7-BA5B-2AE05BB5A9CF}" then -- external tanks presend and full (panel 6 and 5) - lExtTank1 = ((lEngineInfo.fuel_external < 1240.0 ) and 1.0 or 0.0) - end - if lPayloadInfo.Stations[5].CLSID == "{E8D4652F-FD48-45B7-BA5B-2AE05BB5A9CF}" or - lPayloadInfo.Stations[6].CLSID == "{E8D4652F-FD48-45B7-BA5B-2AE05BB5A9CF}" then-- inner tanks presend and full (panel 3 and 8) - lExtTank2 = ((lEngineInfo.fuel_external < 1.0 ) and 1.0 or 0.0) - end - end - -- Fuel_leftbar - -- Fuel_rightbar - -- Light1 - -- Light2 - -- Light3 - -- Light4 - -- Light5 - -- BingoLight - SendData("15", string.format("%0.4f;%0.4f;%d;%d;%d;%d;%d", - lFuel_leftbar, - lFuel_rightbar, - lExtTank1, -- external tanks - lExtTank2, -- inner tanks - (lEngineInfo.fuel_internal < 2790.0 and 1 or 0), -- Interne Flügeltanks - (lEngineInfo.fuel_internal < 1840.0 and 1 or 0), -- Interne Rumpftanks - (lEngineInfo.fuel_internal < 600.0 and 1 or 0))) -- Bingo Fuel - - -- Hydraulic Pressure Left - FC_OneNeedleGauge(lEngineInfo.HydraulicPressure.left, 240, 17) - - -- Hydraulic Pressure Right - FC_OneNeedleGauge(lEngineInfo.HydraulicPressure.right, 240, 18) - end - - -- EKRAN Message - FC_EKRAN(16) - - -- Mechanical Configuration Indicator (GearWarningLight, NoseGear, LeftGear, RightGear, Airbreaks, Flaps1, Flaps2) {"%.1f;%d;%d;%d;%d;%d;%d"} - FC_Russian_MDI_SU25(2) - - local lMechInfo = LoGetMechInfo() -- mechanical components, e.g. Flaps, Wheelbrakes,... - if lMechInfo ~= nil then - -- Wheelbrakes Hydraulic Pressure Left - FC_OneNeedleGauge(lMechInfo.wheelbrakes.value, 240, 19) - - -- Wheelbrakes Hydraulic Pressure Right - FC_OneNeedleGauge(lMechInfo.wheelbrakes.value, 240, 20) - end + -- Hydraulic Pressure Right + ExportScript.AF.FC_OneNeedleGauge(lEngineInfo.HydraulicPressure.right, 240, 86) end - - --(x < 0 and 'negative' or 'non-negative') - --[[ - local lPayloadInfo = LoGetPayloadInfo() - WriteToLog('lPayloadInfo: '..dump(lPayloadInfo)) - - local lSnares = LoGetSnares() -- Flare and Chaff - WriteToLog('lSnares: '..dump(lSnares)) - - local lSightingSystemInfo = LoGetSightingSystemInfo() - WriteToLog('lSightingSystemInfo: '..dump(lSightingSystemInfo)) - - local lTWSInfo = LoGetTWSInfo() -- SPO Informationen, z.B. Radarwarner F15C - WriteToLog('lTWSInfo: '..dump(lTWSInfo)) - - local lTargetInformation = LoGetTargetInformation() -- detalierte Radar Infos z.B. F15C - WriteToLog('lTargetInformation: '..dump(lTargetInformation)) - - local lLockedTargetInformation = LoGetLockedTargetInformation() - WriteToLog('lLockedTargetInformation: '..dump(lLockedTargetInformation)) - - local lF15_TWS_Contacs = LoGetF15_TWS_Contacts() -- the same information but only for F-15 in TWS mode - WriteToLog('lF15_TWS_Contacs: '..dump(lF15_TWS_Contacs)) - - local lMechInfo = LoGetMechInfo() -- mechanical components, e.g. Flaps, Wheelbrakes,... - WriteToLog('lMechInfo: '..dump(lMechInfo)) - - local lMCPState = LoGetMCPState() -- Warnlichter - WriteToLog('lMCPState: '..dump(lMCPState)) - - local lControlPanel_HSI = LoGetControlPanel_HSI() - WriteToLog('lControlPanel_HSI: '..dump(lControlPanel_HSI)) - - local lRadioBeaconsStatus = LoGetRadioBeaconsStatus() - WriteToLog('lRadioBeaconsStatus: '..dump(lRadioBeaconsStatus)) - - local lEngineInfo = LoGetEngineInfo() - WriteToLog('lEngineInfo: '..dump(lEngineInfo)) - ]] - -- Weapon Control System - --local lNameByType = LoGetNameByType () -- args 4 (number : level1,level2,level3,level4), result string - -- values from LoGetTargetInformation().type - --WriteToLog('lNameByType: '..dump(lNameByType)) + + -- EKRAN Message + ExportScript.AF.FC_EKRAN() + + -- Mechanical Configuration Indicator (GearWarningLight, NoseGear, LeftGear, RightGear, Airbreaks, Flaps1, Flaps2) + ExportScript.AF.FC_Russian_MDI_SU25(lFunctionTyp) + + local lMechInfo = LoGetMechInfo() -- mechanical components, e.g. Flaps, Wheelbrakes,... + + if lMechInfo ~= nil then + -- Wheelbrakes Hydraulic Pressure Left + ExportScript.AF.FC_OneNeedleGauge(lMechInfo.wheelbrakes.value, 240, 87) + + -- Wheelbrakes Hydraulic Pressure Right + ExportScript.AF.FC_OneNeedleGauge(lMechInfo.wheelbrakes.value, 240, 88) + end + + --(x < 0 and 'negative' or 'non-negative') + --[[ + local lPayloadInfo = LoGetPayloadInfo() + ExportScript.Tools.WriteToLog('lPayloadInfo: '..ExportScript.Tools.dump(lPayloadInfo)) + + local lSnares = LoGetSnares() -- Flare and Chaff + ExportScript.Tools.WriteToLog('lSnares: '..ExportScript.Tools.dump(lSnares)) + + local lSightingSystemInfo = LoGetSightingSystemInfo() + ExportScript.Tools.WriteToLog('lSightingSystemInfo: '..ExportScript.Tools.dump(lSightingSystemInfo)) + + local lTWSInfo = LoGetTWSInfo() -- SPO Informationen, z.B. Radarwarner F15C + ExportScript.Tools.WriteToLog('lTWSInfo: '..ExportScript.Tools.dump(lTWSInfo)) + + local lTargetInformation = LoGetTargetInformation() -- detalierte Radar Infos z.B. F15C + ExportScript.Tools.WriteToLog('lTargetInformation: '..ExportScript.Tools.dump(lTargetInformation)) + + local lLockedTargetInformation = LoGetLockedTargetInformation() + ExportScript.Tools.WriteToLog('lLockedTargetInformation: '..ExportScript.Tools.dump(lLockedTargetInformation)) + + local lF15_TWS_Contacs = LoGetF15_TWS_Contacts() -- the same information but only for F-15 in TWS mode + ExportScript.Tools.WriteToLog('lF15_TWS_Contacs: '..ExportScript.Tools.dump(lF15_TWS_Contacs)) + + local lMechInfo = LoGetMechInfo() -- mechanical components, e.g. Flaps, Wheelbrakes,... + ExportScript.Tools.WriteToLog('lMechInfo: '..ExportScript.Tools.dump(lMechInfo)) + + local lMCPState = LoGetMCPState() -- Warnlichter + ExportScript.Tools.WriteToLog('lMCPState: '..ExportScript.Tools.dump(lMCPState)) + + local lControlPanel_HSI = LoGetControlPanel_HSI() + ExportScript.Tools.WriteToLog('lControlPanel_HSI: '..ExportScript.Tools.dump(lControlPanel_HSI)) + + local lRadioBeaconsStatus = LoGetRadioBeaconsStatus() + ExportScript.Tools.WriteToLog('lRadioBeaconsStatus: '..ExportScript.Tools.dump(lRadioBeaconsStatus)) + + local lEngineInfo = LoGetEngineInfo() + ExportScript.Tools.WriteToLog('lEngineInfo: '..ExportScript.Tools.dump(lEngineInfo)) + ]] + -- Weapon Control System + --local lNameByType = LoGetNameByType () -- args 4 (number : level1,level2,level3,level4), result string + -- values from LoGetTargetInformation().type + --ExportScript.Tools.WriteToLog('lNameByType: '..ExportScript.Tools.dump(lNameByType)) end -function ProcessHARDWAREConfigLowImportance() --- where necessary, specify HardwareID, example WeaponStatusPanel(2) - WeaponStatusPanel() - MechanicalDevicesIndicator() - StatusLamp() - FuelQuantityIndicator() - SightingSystem() - SPO15RWR() +function ExportScript.ProcessDACConfigLowImportance() + local lFunctionTyp = "DAC" -- function type for shared function + ExportScript.AF.FC_WeaponPanel_SU25(lFunctionTyp) + ExportScript.AF.FC_SPO15RWR(lFunctionTyp) + ExportScript.AF.FC_Russian_MDI_SU25(lFunctionTyp) + ExportScript.AF.FuelQuantityIndicator(lFunctionTyp) + + ExportScript.AF.StatusLamp() + ExportScript.AF.SightingSystem() end ----------------------------- -- Custom functions -- ----------------------------- -function SightingSystem(hardware) - local lHardware = hardware or 1 +function ExportScript.AF.SightingSystem() local lSightingSystemInfo = LoGetSightingSystemInfo() if lSightingSystemInfo == nil then return end - --WriteToLog('lSightingSystemInfo: '..dump(lSightingSystemInfo)9 + --ExportScript.Tools.WriteToLog('lSightingSystemInfo: '..ExportScript.Tools.dump(lSightingSystemInfo)9 --[[ [PRF] = { [selection] = string: "ILV" @@ -405,32 +278,30 @@ function SightingSystem(hardware) } } ]] - SendDataHW("600", lSightingSystemInfo.ECM_on == true and 1 or 0, lHardware ) - SendDataHW("601", lSightingSystemInfo.laser_on == true and 1 or 0, lHardware ) - --SendDataHW("602", lSightingSystemInfo.optical_system_on == true and 1 or 0, lHardware ) - SendDataHW("603", lSightingSystemInfo.LaunchAuthorized == true and 1 or 0, lHardware ) - --SendDataHW("604", lSightingSystemInfo.radar_on == true and 1 or 0, lHardware ) + ExportScript.Tools.SendDataDAC("600", lSightingSystemInfo.ECM_on == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("601", lSightingSystemInfo.laser_on == true and 1 or 0 ) + --ExportScript.Tools.SendDataDAC("602", lSightingSystemInfo.optical_system_on == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("603", lSightingSystemInfo.LaunchAuthorized == true and 1 or 0 ) + --ExportScript.Tools.SendDataDAC("604", lSightingSystemInfo.radar_on == true and 1 or 0 ) end -function FlareChaff(hardware) - local lHardware = hardware or 1 +function ExportScript.AF.FlareChaff() local lSnares = LoGetSnares() -- Flare and Chaff if lSnares == nil then return end - --WriteToLog('lSnares: '..dump(lSnares)) - + --ExportScript.Tools.WriteToLog('lSnares: '..ExportScript.Tools.dump(lSnares)) + --[chaff] = number: "128" --[flare] = number: "128" end -function StatusLamp(hardware) - local lHardware = hardware or 1 +function ExportScript.AF.StatusLamp() local lMCPState = LoGetMCPState() -- Warning Lights if lMCPState == nil then return end - --WriteToLog('lMCPState: '..dump(lMCPState)) + --ExportScript.Tools.WriteToLog('lMCPState: '..ExportScript.Tools.dump(lMCPState)) --[[ [RightTailPlaneFailure] = boolean: "false" [EOSFailure] = boolean: "false" @@ -461,333 +332,58 @@ function StatusLamp(hardware) [AutopilotOn] = boolean: "false" [LeftTailPlaneFailure] = boolean: "false" ]] - - SendDataHW("700", lMCPState.LeftTailPlaneFailure == true and 1 or 0, lHardware ) - SendDataHW("701", lMCPState.RightTailPlaneFailure == true and 1 or 0, lHardware ) - SendDataHW("702", lMCPState.MasterWarning == true and 1 or 0, lHardware ) - SendDataHW("703", lMCPState.LeftEngineFailure == true and 1 or 0, lHardware ) - SendDataHW("704", lMCPState.RightEngineFailure == true and 1 or 0, lHardware ) - SendDataHW("705", lMCPState.LeftAileronFailure == true and 1 or 0, lHardware ) - SendDataHW("706", lMCPState.RightAileronFailure == true and 1 or 0, lHardware ) - SendDataHW("707", lMCPState.LeftMainPumpFailure == true and 1 or 0, lHardware ) - SendDataHW("708", lMCPState.RightMainPumpFailure == true and 1 or 0, lHardware ) - SendDataHW("709", lMCPState.LeftWingPumpFailure == true and 1 or 0, lHardware ) - SendDataHW("710", lMCPState.RightWingPumpFailure == true and 1 or 0, lHardware ) - SendDataHW("711", lMCPState.EOSFailure == true and 1 or 0, lHardware ) - SendDataHW("712", lMCPState.ECMFailure == true and 1 or 0, lHardware ) - SendDataHW("713", lMCPState.CannonFailure == true and 1 or 0, lHardware ) - SendDataHW("714", lMCPState.MLWSFailure == true and 1 or 0, lHardware ) - SendDataHW("715", lMCPState.ACSFailure == true and 1 or 0, lHardware ) - SendDataHW("716", lMCPState.RadarFailure == true and 1 or 0, lHardware ) - SendDataHW("717", lMCPState.HelmetFailure == true and 1 or 0, lHardware ) - SendDataHW("718", lMCPState.HUDFailure == true and 1 or 0, lHardware ) - SendDataHW("719", lMCPState.MFDFailure == true and 1 or 0, lHardware ) - SendDataHW("720", lMCPState.RWSFailure == true and 1 or 0, lHardware ) - SendDataHW("721", lMCPState.GearFailure == true and 1 or 0, lHardware ) - SendDataHW("722", lMCPState.HydraulicsFailure == true and 1 or 0, lHardware ) - SendDataHW("723", lMCPState.AutopilotFailure == true and 1 or 0, lHardware ) - SendDataHW("724", lMCPState.FuelTankDamage == true and 1 or 0, lHardware ) - SendDataHW("725", lMCPState.CanopyOpen == true and 1 or 0, lHardware ) - SendDataHW("726", lMCPState.StallSignalization == true and 1 or 0, lHardware ) - SendDataHW("727", lMCPState.AutopilotOn == true and 1 or 0, lHardware ) - + + ExportScript.Tools.SendDataDAC("700", lMCPState.LeftTailPlaneFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("701", lMCPState.RightTailPlaneFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("702", lMCPState.MasterWarning == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("703", lMCPState.LeftEngineFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("704", lMCPState.RightEngineFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("705", lMCPState.LeftAileronFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("706", lMCPState.RightAileronFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("707", lMCPState.LeftMainPumpFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("708", lMCPState.RightMainPumpFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("709", lMCPState.LeftWingPumpFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("710", lMCPState.RightWingPumpFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("711", lMCPState.EOSFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("712", lMCPState.ECMFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("713", lMCPState.CannonFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("714", lMCPState.MLWSFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("715", lMCPState.ACSFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("716", lMCPState.RadarFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("717", lMCPState.HelmetFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("718", lMCPState.HUDFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("719", lMCPState.MFDFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("720", lMCPState.RWSFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("721", lMCPState.GearFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("722", lMCPState.HydraulicsFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("723", lMCPState.AutopilotFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("724", lMCPState.FuelTankDamage == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("725", lMCPState.CanopyOpen == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("726", lMCPState.StallSignalization == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("727", lMCPState.AutopilotOn == true and 1 or 0 ) + local lEngineInfo = LoGetEngineInfo() if lEngineInfo ~= nil then --WriteToLog('lEngineInfo: '..dump(lEngineInfo)) - SendDataHW("728", lEngineInfo.EngineStart.left, lHardware ) -- lamp start left engine 1 (0|1) - SendDataHW("729", lEngineInfo.EngineStart.right, lHardware ) -- lamp start right engine 1 (0|1) + ExportScript.Tools.SendDataDAC("728", lEngineInfo.EngineStart.left ) -- lamp start left engine 1 (0|1) + ExportScript.Tools.SendDataDAC("729", lEngineInfo.EngineStart.right ) -- lamp start right engine 1 (0|1) end - + local lAoA = LoGetAngleOfAttack() if lAoA ~= nil then lAoA = lAoA * 57.3 - SendDataHW("730", (lAoA > 20.0 and 1 or 0), lHardware ) -- lamp start AOA warning (0|1) + ExportScript.Tools.SendDataDAC("730", (lAoA > 20.0 and 1 or 0) ) -- lamp start AOA warning (0|1) end end -function WeaponStatusPanel(hardware) --- The weapon status panel, quantity and readiness of the currently selected weapon and the remaining gun ammunition are indicated. - local lHardware = hardware or 1 - gES_PayloadInfo = LoGetPayloadInfo() - if gES_PayloadInfo == nil then - return - end - --WriteToLog('gES_PayloadInfo: '..dump(gES_PayloadInfo)) - --[[ exsample - [Stations] = { - [1] = { - [CLSID] = string: "{682A481F-0CB5-4693-A382-D00DD4A156D7}" - [container] = boolean: "false" - [count] = number: "1" - [weapon] = { - [level3] = number: "7" - [level1] = number: "4" - [level4] = number: "10" - [level2] = number: "4" - } - } - [2] = { - [CLSID] = string: "{682A481F-0CB5-4693-A382-D00DD4A156D7}" - [container] = boolean: "false" - [count] = number: "1" - [weapon] = { - [level3] = number: "7" - [level1] = number: "4" - [level4] = number: "10" - [level2] = number: "4" - } - } - [3] = { - [wstype] = { - [level3] = number: "32" - [level1] = number: "4" - [level4] = number: "6" - [level2] = number: "7" - } - [count] = number: "20" - [CLSID] = string: "{F72F47E5-C83A-4B85-96ED-D3E46671EE9A}" - [adapter] = { - [level3] = number: "0" - [level1] = number: "0" - [level4] = number: "0" - [level2] = number: "0" - } - [container] = boolean: "true" - [weapon] = { - [level3] = number: "33" - [level1] = number: "4" - [level4] = number: "32" - [level2] = number: "7" - } - } - [4] = { - [wstype] = { - [level3] = number: "32" - [level1] = number: "4" - [level4] = number: "6" - [level2] = number: "7" - } - [count] = number: "20" - [CLSID] = string: "{F72F47E5-C83A-4B85-96ED-D3E46671EE9A}" - [adapter] = { - [level3] = number: "0" - [level1] = number: "0" - [level4] = number: "0" - [level2] = number: "0" - } - [container] = boolean: "true" - [weapon] = { - [level3] = number: "33" - [level1] = number: "4" - [level4] = number: "32" - [level2] = number: "7" - } - } - [5] = { - [wstype] = { - [level3] = number: "32" - [level1] = number: "4" - [level4] = number: "99" - [level2] = number: "4" - } - [count] = number: "1" - [CLSID] = string: "{79D73885-0801-45a9-917F-C90FE1CE3DFC}" - [adapter] = { - [level3] = number: "0" - [level1] = number: "0" - [level4] = number: "0" - [level2] = number: "0" - } - [container] = boolean: "true" - [weapon] = { - [level3] = number: "8" - [level1] = number: "4" - [level4] = number: "45" - [level2] = number: "4" - } - } - [6] = { - [wstype] = { - [level3] = number: "32" - [level1] = number: "4" - [level4] = number: "99" - [level2] = number: "4" - } - [count] = number: "1" - [CLSID] = string: "{79D73885-0801-45a9-917F-C90FE1CE3DFC}" - [adapter] = { - [level3] = number: "0" - [level1] = number: "0" - [level4] = number: "0" - [level2] = number: "0" - } - [container] = boolean: "true" - [weapon] = { - [level3] = number: "8" - [level1] = number: "4" - [level4] = number: "45" - [level2] = number: "4" - } - } - [7] = { - [wstype] = { - [level3] = number: "32" - [level1] = number: "4" - [level4] = number: "47" - [level2] = number: "4" - } - [count] = number: "8" - [CLSID] = string: "{F789E86A-EE2E-4E6B-B81E-D5E5F903B6ED}" - [adapter] = { - [level3] = number: "0" - [level1] = number: "0" - [level4] = number: "0" - [level2] = number: "0" - } - [container] = boolean: "true" - [weapon] = { - [level3] = number: "8" - [level1] = number: "4" - [level4] = number: "58" - [level2] = number: "4" - } - } - [8] = { - [wstype] = { - [level3] = number: "32" - [level1] = number: "4" - [level4] = number: "47" - [level2] = number: "4" - } - [count] = number: "8" - [CLSID] = string: "{F789E86A-EE2E-4E6B-B81E-D5E5F903B6ED}" - [adapter] = { - [level3] = number: "0" - [level1] = number: "0" - [level4] = number: "0" - [level2] = number: "0" - } - [container] = boolean: "true" - [weapon] = { - [level3] = number: "8" - [level1] = number: "4" - [level4] = number: "58" - [level2] = number: "4" - } - } - [9] = { - [CLSID] = string: "{D5435F26-F120-4FA3-9867-34ACE562EF1B}" - [container] = boolean: "false" - [count] = number: "1" - [weapon] = { - [level3] = number: "38" - [level1] = number: "4" - [level4] = number: "20" - [level2] = number: "5" - } - } - [10] = { - [CLSID] = string: "{D5435F26-F120-4FA3-9867-34ACE562EF1B}" - [container] = boolean: "false" - [count] = number: "1" - [weapon] = { - [level3] = number: "38" - [level1] = number: "4" - [level4] = number: "20" - [level2] = number: "5" - } - } - [11] = { - [CLSID] = string: "" - [container] = boolean: "false" - [count] = number: "0" - [weapon] = { - [level3] = number: "0" - [level1] = number: "0" - [level4] = number: "0" - [level2] = number: "0" - } - } - } - [CurrentStation] = number: "0" - [Cannon] = { - [shells] = number: "250" - } - ]] - --[[ - Weapon Panel - | - --------------------------------------------------- - | | | | | | | | | | | - 1 2 3 4 5 C 6 7 8 9 10 - ]] - -- Payload Info - -- weapon stations (panel) 1 (left) - 10 (right), no lamp for center station - SendDataHW("100", gES_PayloadInfo.Cannon.shells, lHardware ) -- count cannon shells - SendDataHW("101", (gES_PayloadInfo.Stations[1].count > 0 and 1 or 0), lHardware ) -- weapon presend > 0 (panel 1) - SendDataHW("110", (gES_PayloadInfo.Stations[2].count > 0 and 1 or 0), lHardware ) -- weapon presend > 0 (panel 10) - SendDataHW("102", (gES_PayloadInfo.Stations[3].count > 0 and 1 or 0), lHardware ) -- weapon presend > 0 (panel 2) - SendDataHW("109", (gES_PayloadInfo.Stations[4].count > 0 and 1 or 0), lHardware ) -- weapon presend > 0 (panel 9) - SendDataHW("103", (gES_PayloadInfo.Stations[5].count > 0 and 1 or 0), lHardware ) -- weapon presend > 0 (panel 3) - SendDataHW("108", (gES_PayloadInfo.Stations[6].count > 0 and 1 or 0), lHardware ) -- weapon presend > 0 (panel 8) - SendDataHW("104", (gES_PayloadInfo.Stations[7].count > 0 and 1 or 0), lHardware ) -- weapon presend > 0 (panel 4) - SendDataHW("107", (gES_PayloadInfo.Stations[8].count > 0 and 1 or 0), lHardware ) -- weapon presend > 0 (panel 7) - SendDataHW("105", (gES_PayloadInfo.Stations[9].count > 0 and 1 or 0), lHardware ) -- weapon presend > 0 (panel 5) - SendDataHW("106", (gES_PayloadInfo.Stations[10].count > 0 and 1 or 0), lHardware ) -- weapon presend > 0 (panel 6) - --SendDataHW("110", (gES_PayloadInfo.Stations[11].count > 0 and 1 or 0) ) -- weapon presend > 0 center station, not visible - --SendDataHW("CurrentStation", gES_PayloadInfo.CurrentStation, lHardware ) - -- air-to-air missils panel 1 and 11, air combat modus, CurrentStation = 1, panel 1 and 11 on - -- CurrentStation 5, panel 3 - -- CurrentStation 3, panel 2 - -- CurrentStation 7, panel 4 - -- CurrentStation 4, panel 9 - -- CurrentStation 9, panel 5 - -- CurrentStation 10, panel 6 - -- CurrentStation 8, panel 7 - -- CurrentStation 6, panel 8 - -- wenn die Waffenstationen gleichmässig belegt sind, hat bei Auswahl CurrentStation immer den Wert der linken Station - -- bei ungleichmäßiger Belegung, hat CurrentStation immer den Wert der jeweiligen Station - -- Waffenbezeichnung als UUID, gES_PayloadInfo.Stations[X].CLSID - - -- defination - if gES_CurrentStationTmp == nil then - gES_CurrentStationTmp = -1 - end - - if gES_PayloadInfo.CurrentStation > 0 and - gES_CurrentStationTmp ~= gES_PayloadInfo.CurrentStation then - gES_CurrentStationTmp = gES_PayloadInfo.CurrentStation - - gES_TmpStationToPanel = {} - gES_TmpStationToPanel[1] = {Panel = 1, StationID = 101, CurrentID = 201, HardwareID = lHardware } -- left - gES_TmpStationToPanel[2] = {Panel = 10, StationID = 110, CurrentID = 210, HardwareID = lHardware } -- right - gES_TmpStationToPanel[3] = {Panel = 2, StationID = 102, CurrentID = 202, HardwareID = lHardware } - gES_TmpStationToPanel[4] = {Panel = 9, StationID = 109, CurrentID = 209, HardwareID = lHardware } - gES_TmpStationToPanel[5] = {Panel = 3, StationID = 103, CurrentID = 203, HardwareID = lHardware } - gES_TmpStationToPanel[6] = {Panel = 8, StationID = 108, CurrentID = 208, HardwareID = lHardware } - gES_TmpStationToPanel[7] = {Panel = 4, StationID = 104, CurrentID = 204, HardwareID = lHardware } - gES_TmpStationToPanel[8] = {Panel = 7, StationID = 107, CurrentID = 207, HardwareID = lHardware } - gES_TmpStationToPanel[9] = {Panel = 5, StationID = 105, CurrentID = 205, HardwareID = lHardware } - gES_TmpStationToPanel[10] = {Panel = 6, StationID = 106, CurrentID = 206, HardwareID = lHardware } - - WeaponStatusPanel_Reset(201, 210, lHardware) - - if gES_TmpStationToPanel[gES_PayloadInfo.CurrentStation] ~= nil then - SendDataHW(gES_TmpStationToPanel[gES_PayloadInfo.CurrentStation].CurrentID, 1, lHardware ) -- eigentliche Auswahl - - table.foreach(gES_PayloadInfo.Stations, WeaponStatusPanel_selectCurrentPayloadStation) -- zugehörige Stationen - end - end -end - -function FuelQuantityIndicator(hardware) +function ExportScript.AF.FuelQuantityIndicator(FunctionTyp) + local lFunctionTyp = FunctionTyp or "Ikarus" -- Fuel quantity shows the fuel remaining in all tanks - local lHardware = hardware or 1 local lEngineInfo = LoGetEngineInfo() if lEngineInfo == nil then return end - --WriteToLog('lEngineInfo: '..dump(lEngineInfo)) + --ExportScript.Tools.WriteToLog('lEngineInfo: '..ExportScript.Tools.dump(lEngineInfo)) --[[ [fuel_external] = number: "0" [Temperature] = { @@ -814,135 +410,79 @@ function FuelQuantityIndicator(hardware) lPayloadInfo.Stations[8].CLSID == E8D4652F-FD48-45B7-BA5B-2AE05BB5A9CF -- ext 800l Fuel Tank ]] - SendDataHW("300", string.format("%d", math.round((lEngineInfo.fuel_internal / 10), 0, "ceil") * 10), lHardware ) -- total fuel in kg - --SendDataHW("301", string.format("%d", lEngineInfo.fuel_internal)) -- total fuel in kg - --SendDataHW("302", string.format("%d", lEngineInfo.fuel_external)) -- external fuel in kg - + local lTotalFuel = lEngineInfo.fuel_internal + local lFuel_leftbar = 1.0 + local lFuel_rightbar = 1.0 + local lExtTank1 = 1.0 -- external tanks + local lExtTank2 = 1.0 -- inner tanks + + if lTotalFuel < 5000 then + if lTotalFuel > 1500 then + --[[ + y_min = 0.0 -- minimaler Ausgabewert + y_max = 1.0 -- maximaler Ausgabewert + x_min = 1500 -- minimaler Eingangswert + x_max = 5000 -- maximaler Eingangswert + x = 3500 -- aktueller Eingangswert + + d_y = 1 -- Delta Ausgabewerte (y_max - y_min) + d_x = 3500 -- Delta Eingangswerte (x_max - x_min) + m = 2.8571428571428571428571428571429e-4 -- Steigung der linearen Funktion (d_y / d_x) + n = -0.42857142857142857142857142857143 -- Schnittpunkt der Funktion mit y-Achse (y_max - m * x_max) + + y = 0,57142857142857142857142857142857 -- Ergebnis (m * x + n) + ]] + lFuel_leftbar = 2.8571428571428571428571428571429e-4 * lTotalFuel + -0.42857142857142857142857142857143 + else + lFuel_leftbar = 0.0 + end + else + lFuel_leftbar = 1.0 + end + if lTotalFuel < 1200 then + lFuel_rightbar = lTotalFuel / 1200 + else + lFuel_rightbar = 1.0 + end + local lPayloadInfo = LoGetPayloadInfo() if lPayloadInfo ~= nil then --WriteToLog('lPayloadInfo: '..dump(lPayloadInfo)) if lPayloadInfo.Stations[10].CLSID == "{E8D4652F-FD48-45B7-BA5B-2AE05BB5A9CF}" or lPayloadInfo.Stations[9].CLSID == "{E8D4652F-FD48-45B7-BA5B-2AE05BB5A9CF}" then -- external tanks presend and full (panel 6 and 5) - SendDataHW("303", ((lEngineInfo.fuel_external < 1240.0 ) and 1 or 0), lHardware ) - else - SendDataHW("303", 1, lHardware ) + lExtTank1 = ((lEngineInfo.fuel_external < 1240.0 ) and 1.0 or 0.0) end if lPayloadInfo.Stations[5].CLSID == "{E8D4652F-FD48-45B7-BA5B-2AE05BB5A9CF}" or - lPayloadInfo.Stations[6].CLSID == "{E8D4652F-FD48-45B7-BA5B-2AE05BB5A9CF}" then-- inner tank presend and full (panel 3 and 8) - SendDataHW("304", ((lEngineInfo.fuel_external < 1.0 ) and 1 or 0), lHardware ) - else - SendDataHW("304", 1, lHardware ) + lPayloadInfo.Stations[6].CLSID == "{E8D4652F-FD48-45B7-BA5B-2AE05BB5A9CF}" then-- inner tanks presend and full (panel 3 and 8) + lExtTank2 = ((lEngineInfo.fuel_external < 1.0 ) and 1.0 or 0.0) end - else - SendDataHW("303", 1, lHardware ) - SendDataHW("304", 1, lHardware ) end - SendDataHW("305", (lEngineInfo.fuel_internal < 2790.0 and 1 or 0), lHardware ) -- Interne Flügeltanks - SendDataHW("306", (lEngineInfo.fuel_internal < 1840.0 and 1 or 0), lHardware ) -- Interne Rumpftanks - --SendDataHW("307", (lEngineInfo.fuel_internal < 1.0 and 1 or 0), lHardware ) -- Zentraler Rumpftanks - SendDataHW("308", (lEngineInfo.fuel_internal < 600.0 and 1 or 0), lHardware ) -- Bingo Fuel - -end + -- Fuel_leftbar + -- Fuel_rightbar + -- Light1 + -- Light2 + -- Light3 + -- Light4 + -- Light5 + -- BingoLight -function MechanicalDevicesIndicator(hardware) --- The mechanical devices indicator shows the position of the landing gear, flaps, leading edge flaps and airbrake - local lHardware = hardware or 1 - local lMechInfo = LoGetMechInfo() -- mechanical components, e.g. Flaps, Wheelbrakes,... - if lMechInfo == nil then - return + if ExportScript.Config.IkarusExport and lFunctionTyp == "Ikarus" then + ExportScript.Tools.SendData(300, string.format("%0.4f", lFuel_leftbar)) + ExportScript.Tools.SendData(301, string.format("%0.4f", lFuel_rightbar)) + ExportScript.Tools.SendData(302, lExtTank1) -- external tanks + ExportScript.Tools.SendData(303, lExtTank2) -- inner tanks + ExportScript.Tools.SendData(304, (lEngineInfo.fuel_internal < 2790.0 and 1 or 0)) -- inner wing tank + ExportScript.Tools.SendData(305, (lEngineInfo.fuel_internal < 1840.0 and 1 or 0)) -- inner hull tank + ExportScript.Tools.SendData(306, (lEngineInfo.fuel_internal < 600.0 and 1 or 0)) -- Bingo Fuel end - --[[ - [hook] = { - [status] = number: "0" - [value] = number: "0" - } - [parachute] = { - [status] = number: "0" - [value] = number: "0" - } - [controlsurfaces] = { - [eleron] = { - [left] = number: "0" - [right] = number: "-0.21084336936474" - } - [elevator] = { - [left] = number: "-0" - [right] = number: "-0" - } - [rudder] = { - [left] = number: "0" - [right] = number: "0" - } - } - [airintake] = { - [status] = number: "0" - [value] = number: "0" - } - [canopy] = { - [status] = number: "0" - [value] = number: "0" - } - [refuelingboom] = { - [status] = number: "0" - [value] = number: "0" - } - [wing] = { - [status] = number: "0" - [value] = number: "0" - } - [noseflap] = { - [status] = number: "0" - [value] = number: "0" - } - [gear] = { - [value] = number: "0" - [nose] = { - [rod] = number: "0" - } - [main] = { - [left] = { - [rod] = number: "0" - } - [right] = { - [rod] = number: "0" - } - } - [status] = number: "0" - } - [speedbrakes] = { - [status] = number: "0" - [value] = number: "0" - } - [wheelbrakes] = { - [status] = number: "0" - [value] = number: "0" - } - [flaps] = { - [status] = number: "0" - [value] = number: "0" - }]] - --SendDataHW("500", lMechInfo.gear.status ) - --SendDataHW("501", lMechInfo.gear.value ) - --SendDataHW("502", lMechInfo.gear.nose.rod ) -- zeigt an wie weit das Fahrwerk einsackt wenn das Flugzeug auf dem Boden ist - --SendDataHW("503", lMechInfo.gear.main.left.rod ) -- zeigt an wie weit das Fahrwerk einsackt wenn das Flugzeug auf dem Boden ist - --SendDataHW("504", lMechInfo.gear.main.right.rod ) -- zeigt an wie weit das Fahrwerk einsackt wenn das Flugzeug auf dem Boden ist - --SendDataHW("500", ((lMechInfo.gear.status == 1 and lMechInfo.gear.value < 1) and 1 or 0 ) ) -- gear warning light, go up - --SendDataHW("500", ((lMechInfo.gear.status == 0 and lMechInfo.gear.value > 0) and 1 or 0 ) ) -- gear warning light, go down - SendDataHW("500", (((lMechInfo.gear.status == 1 and lMechInfo.gear.value < 1) or (lMechInfo.gear.status == 0 and lMechInfo.gear.value > 0)) and 1 or 0 ), lHardware ) -- gear warning light - SendDataHW("501", (lMechInfo.gear.value > 0.85 and 1 or 0), lHardware ) -- nose gear - SendDataHW("502", (lMechInfo.gear.value > 0.95 and 1 or 0), lHardware ) -- left gear - SendDataHW("503", (lMechInfo.gear.value == 1 and 1 or 0), lHardware ) -- right gear - - --SendDataHW("510", lMechInfo.speedbrakes.status ) -- speedbreakes on 1 (0|1) - SendDataHW("510", (lMechInfo.speedbrakes.value > 0.1 and 1 or 0), lHardware ) -- speedbreakes on > 0.1 (0 - 1) - --SendDataHW("520", lMechInfo.wheelbrakes.status, lHardware ) -- not in use - --SendDataHW("521", lMechInfo.wheelbrakes.value, lHardware ) -- not in use - - local lTrueAirSpeed = LoGetTrueAirSpeed() - --SendDataHW("530", lMechInfo.flaps.status ) -- flap switch off 0, 1. position 1, 2. position 2 (0|1|2) - --SendDataHW("531", lMechInfo.flaps.value ) -- flap 1. position > 0.25, 2. position > 0.93 (0 - 1) - SendDataHW("531", (lMechInfo.flaps.value > 0.25 and 1 or 0), lHardware ) -- flap 1. position - SendDataHW("532", (lMechInfo.flaps.value > 0.93 and 1 or 0), lHardware ) -- flap 2. position - SendDataHW("533", ((lMechInfo.flaps.value > 0.93 and lTrueAirSpeed > 340) and 1 or 0), lHardware ) -- Speed Warning for Flaps, same light as gear warning light, but blinking light -end + if ExportScript.Config.DACExport and lFunctionTyp == "DAC" then + ExportScript.Tools.SendDataDAC(300, string.format("%d", ExportScript.Tools.round((lEngineInfo.fuel_internal / 10), 0, "ceil") * 10)) -- total fuel in kg + ExportScript.Tools.SendDataDAC(303, lExtTank1) -- external tanks + ExportScript.Tools.SendDataDAC(304, lExtTank2) -- inner tanks + ExportScript.Tools.SendDataDAC(305, (lEngineInfo.fuel_internal < 2790.0 and 1 or 0)) -- inner wing tank + ExportScript.Tools.SendDataDAC(306, (lEngineInfo.fuel_internal < 1840.0 and 1 or 0)) -- inner hull tank + ExportScript.Tools.SendDataDAC(307, (lEngineInfo.fuel_internal < 1.0 and 1 or 0)) -- central hull tank + ExportScript.Tools.SendDataDAC(308, (lEngineInfo.fuel_internal < 600.0 and 1 or 0)) -- Bingo Fuel + end +end \ No newline at end of file diff --git a/Scripts/DCS-ExportScript/ExportsModules/Su-25T.lua b/Scripts/DCS-ExportScript/ExportsModules/Su-25T.lua index fdc8f24..e1d9bc5 100644 --- a/Scripts/DCS-ExportScript/ExportsModules/Su-25T.lua +++ b/Scripts/DCS-ExportScript/ExportsModules/Su-25T.lua @@ -12,12 +12,15 @@ dofile(ExportScript.Config.ExportModulePath.."FC_AuxiliaryFuntions.lua") ----------------------------------------- function ExportScript.ProcessIkarusFCHighImportanceConfig() - local lFunctionTyp = "Ikarus" -- function type for shared function - local myData = LoGetSelfData() + local lFunctionTyp = "Ikarus" -- function type for shared function + local myData = LoGetSelfData() if (myData) then local lLatitude = myData.LatLongAlt.Lat -- LATITUDE local lLongitude = myData.LatLongAlt.Long -- LONGITUDE + + local lEngineTempLeft = LoGetEngineInfo().Temperature.left -- ENG1 EGT ºC + local lEngineTempRight = LoGetEngineInfo().Temperature.right -- ENG2 EGT ºC --[[ local lBasicAtmospherePressure = LoGetBasicAtmospherePressure() -- BAROMETRIC PRESSURE local lAltBar = LoGetAltitudeAboveSeaLevel() -- ALTITUDE SEA LEVEL (Meter) @@ -28,14 +31,14 @@ function ExportScript.ProcessIkarusFCHighImportanceConfig() local lHeading = myData.Heading -- HEADING (Radian) local lVVI = LoGetVerticalVelocity() -- VERTICAL SPEED (Meter/Second) local lIAS = LoGetIndicatedAirSpeed() -- INDICATED AIRSPEED (Meter/Second) - local lMachNumber = LoGetMachNumber -- MACH + local lMachNumber = LoGetMachNumber() -- MACH local lAoA = LoGetAngleOfAttack() -- ANGLE OF ATTACK AoA (Radian) - + local lGlide = LoGetGlideDeviation() -- VOR1 HORIZONTAL DEFLECTION (-1 +1) local lSide = LoGetSideDeviation() -- VOR1 VERTICAL DEFLECTION (-1 +1) local lSlipBallPosition = LoGetSlipBallPosition() -- SLIP BALL (-1 +1) local lAccelerationUnits = LoGetAccelerationUnits().y -- G-LOAD - + local lNavInfoPitch = LoGetNavigationInfo().Requirements.pitch -- AP REQUIRED PITCH (Radian) local lNavInfoRoll = LoGetNavigationInfo().Requirements.roll -- AP REQUIRED BANK (Radian) local lNavInfoSpeed = LoGetNavigationInfo().Requirements.speed -- AP SPEED (Meter/Second) @@ -46,33 +49,30 @@ function ExportScript.ProcessIkarusFCHighImportanceConfig() local lHSI_RMI = LoGetControlPanel_HSI().RMI_raw -- VOR1 OBS (Radian) local lHSI_ADF = LoGetControlPanel_HSI().ADF_raw -- ADF OBS (Radian) local lHSI_Heading = LoGetControlPanel_HSI().Heading_raw -- Heading (Radian) - + local lEngineRPMleft = LoGetEngineInfo().RPM.left -- ENG1 RPM % local lEngineRPMright = LoGetEngineInfo().RPM.right -- ENG2 RPM % - ]] - local lEngineTempLeft = LoGetEngineInfo().Temperature.left -- ENG1 EGT - local lEngineTempRight = LoGetEngineInfo().Temperature.right -- ENG2 EGT - --[[ + local lEngineFuelInternal = LoGetEngineInfo().fuel_internal -- TANK1 (INT) (KG) local lEngineFuelExternal = LoGetEngineInfo().fuel_external -- TANK2 (EXT) (KG) - + local lMechInfo = LoGetMechInfo() -- mechanical components, e.g. Flaps, Wheelbrakes,... local lPayloadInfo = LoGetPayloadInfo() -- Paylod, e.g. bombs, guns, rockets, fuel tanks,... ]] - + local lDistanceToWay = 999 local lRoute = LoGetRoute() - + if (myData and lRoute) then -- if neither are nil local myLoc = LoGeoCoordinatesToLoCoordinates(lLongitude, lLatitude) --lDistanceToWay = math.sqrt((myLoc.x - lRoute.goto_point.world_point.x)^2 + (myLoc.y - lRoute.goto_point.world_point.y)^2) lDistanceToWay = math.sqrt((myLoc.x - lRoute.goto_point.world_point.x)^2 + (myLoc.z - lRoute.goto_point.world_point.z)^2) end - -- IAS-TAS Indicator (IAS, TAS) {"%.4f;%.4f"} + -- IAS-TAS Indicator ExportScript.AF.FC_Russian_AirSpeed_1100hkm() - -- AOA Indicator and Accelerometer (AOA, GLoad) + -- AOA Indicator and Accelerometer ExportScript.AF.FC_Russian_AOA_Su25() -- ADI @@ -81,133 +81,57 @@ function ExportScript.ProcessIkarusFCHighImportanceConfig() -- HSI ExportScript.AF.FC_Russian_HSI(lDistanceToWay) - -- Vertical Velocity Indicator (VVI) (VVI, TurnIndicator, SlipBallPosition) - ExportScript.AF.FC_Russian_VVI_Old(6) + -- Vertical Velocity Indicator (VVI, TurnIndicator, SlipBallPosition) + ExportScript.AF.FC_Russian_VVI_Old() - -- Radar Altimeter (AltRad, MinAltitude, WarningFlag, MinAltitudeLamp) {"%.4f;%.4f;%.1f;%.1f"} (below 100m is warning light on) + -- Radar Altimeter (below 100m is warning light on) ExportScript.AF.FC_Russian_RadarAltimeter_1500m(100) - -- Barometric Altimeter (AltBar, BasicAtmospherePressure) + -- Barometric Altimeter ExportScript.AF.FC_Russian_BarometricAltimeter_late() - -- Tachometer (RPM) (EngineRPMleft, EngineRPMright) {"%.4f;%.4f"} + -- Tachometer (RPM) ExportScript.AF.FC_Russian_EngineRPM() - -- Left Jet Engine Turbine Temperature Indicator (EngineTemp) {"%.4f"} + -- Left Jet Engine Turbine Temperature Indicator (EngineTemp, ExportID) ExportScript.AF.FC_Russian_EGT_1000gc(lEngineTempLeft, 70) - -- Right Jet Engine Turbine Temperature Indicator (EngineTemp) {"%.4f"} + -- Right Jet Engine Turbine Temperature Indicator (EngineTemp, ExportID) ExportScript.AF.FC_Russian_EGT_1000gc(lEngineTempRight, 71) - -- Clock from Ka-50 {CurrentHours, CurrentMinutes, CurrentSeconds, 0, FlightTimeHours, FlightTimeMinutes, 0, 0) {"%.4f;%.4f;%.4f;%.1f;%.4f;%.4f;%.4f;%.4f"} - ExportScript.AF.FC_Russian_Clock_late() - - ExportScript.AF.EventNumberOLD = ExportScript.AF.EventNumber + -- Clock from Ka-50 + ExportScript.AF.FC_Russian_Clock_late() else - --WriteToLog("Unknown FC Error, no LoGetSelfData.") + ExportScript.Tools.WriteToLog("Unknown FC Error, no LoGetSelfData.") end end function ExportScript.ProcessDACConfigHighImportance() local lFunctionTyp = "DAC" -- function type for shared function + + -- your script + end function ExportScript.ProcessIkarusFCLowImportanceConfig() local lFunctionTyp = "Ikarus" -- function type for shared function -- Weapon Panel - ExportScript.AF.WeaponPanel_SU25(lFunctionTyp) - + ExportScript.AF.FC_WeaponPanel_SU25(lFunctionTyp) + -- SPO15 Radar Warning Reciver - ExportScript.AF.SPO15RWR(lFunctionTyp) + ExportScript.AF.FC_SPO15RWR(lFunctionTyp) -- EKRAN Message ExportScript.AF.FC_EKRAN() - -- Mechanical Configuration Indicator (GearWarningLight, NoseGear, LeftGear, RightGear, Airbreaks, Flaps1, Flaps2) + -- Mechanical Configuration Indicator ExportScript.AF.FC_Russian_MDI_SU25(lFunctionTyp) -- Fuel Quantity Indicator + ExportScript.AF.FC_FuelQuantityIndicator(lFunctionTyp) + local lEngineInfo = LoGetEngineInfo() if lEngineInfo ~= nil then - -- ExportScript.Tools.WriteToLog('lEngineInfo: '..ExportScript.Tools.dump(lEngineInfo)) - --[[ - [fuel_external] = number: "0" - [Temperature] = { - [left] = number: "626.99444580078" - [right] = number: "626.99444580078" - } - [RPM] = { - [left] = number: "87.453765869141" - [right] = number: "87.453758239746" - } - [FuelConsumption] = { - [left] = number: "0.1500396137767" - [right] = number: "0.1500396137767" - } - [fuel_internal] = number: "3773.2749023438" - [EngineStart] = { - [left] = number: "0" - [right] = number: "0" - } - [HydraulicPressure] = { - [left] = number: "210" - [right] = number: "210" - } - lPayloadInfo.Stations[8].CLSID == E8D4652F-FD48-45B7-BA5B-2AE05BB5A9CF -- ext 800l Fuel Tank - ]] - - local lTotalFuel = lEngineInfo.fuel_internal - --local lTotalFuel = string.format("%3d", ExportScript.Tools.round((lEngineInfo.fuel_internal / 10), 0, "ceil") * 10) - --local lTotalFuel = string.format("%4d", lEngineInfo.fuel_internal) -- total fuel in kg - --local lTotalFuel = string.format("%4d", lEngineInfo.fuel_external) -- external fuel in kg - local lFuelCounter = {[0] = 0.0, [1] = 0.11, [2] = 0.22, [3] = 0.33, [4] = 0.44, [5] = 0.55, [6] = 0.66, [7] = 0.77, [8] = 0.88, [9] = 0.99} - lTotalFuel = string.format("%03d", ExportScript.Tools.round((lEngineInfo.fuel_internal / 10), 0, "ceil")) -- auf drei stellen bringen - - local lExtTank1 = 1.0 -- external tanks - local lExtTank2 = 1.0 -- inner tanks - - local lPayloadInfo = LoGetPayloadInfo() - if lPayloadInfo ~= nil then - --ExportScript.Tools.WriteToLog('lPayloadInfo: '..ExportScript.Tools.dump(lPayloadInfo)) - if lPayloadInfo.Stations[10].CLSID == "{E8D4652F-FD48-45B7-BA5B-2AE05BB5A9CF}" or - lPayloadInfo.Stations[9].CLSID == "{E8D4652F-FD48-45B7-BA5B-2AE05BB5A9CF}" then -- external tanks presend and full (panel 6 and 5) - lExtTank1 = ((lEngineInfo.fuel_external < 1240.0 ) and 1.0 or 0.0) - end - if lPayloadInfo.Stations[5].CLSID == "{E8D4652F-FD48-45B7-BA5B-2AE05BB5A9CF}" or - lPayloadInfo.Stations[6].CLSID == "{E8D4652F-FD48-45B7-BA5B-2AE05BB5A9CF}" then-- inner tanks presend and full (panel 3 and 8) - lExtTank2 = ((lEngineInfo.fuel_external < 1.0 ) and 1.0 or 0.0) - end - end - -- TotalFuel_100 - -- TotalFuel_10 - -- TotalFuel_1 - -- Light1 - -- Light2 - -- Light3 - -- Light4 - -- Light5 - -- BingoLight - --[[SendData("15", string.format("%0.2f;%0.2f;%0.2f;%d;%d;%d;%d;%d;%d", - lFuelCounter[tonumber(string.sub(lTotalFuel, 1, 1))], - lFuelCounter[tonumber(string.sub(lTotalFuel, 2, 2))], - lFuelCounter[tonumber(string.sub(lTotalFuel, 3, 3))], - lExtTank1, -- external tanks - lExtTank2, -- inner tanks - (lEngineInfo.fuel_internal < 2800.0 and 1 or 0), -- Interne Flügeltanks - (lEngineInfo.fuel_internal < 1840.0 and 1 or 0), -- Interne Rumpftanks - (lEngineInfo.fuel_internal < 1.0 and 1 or 0), -- Zentraler Rumpftanks - (lEngineInfo.fuel_internal < 600.0 and 1 or 0))) -- Bingo Fuel]] - - ExportScript.Tools.SendData(300, string.format("%0.2f", lFuelCounter[tonumber(string.sub(lTotalFuel, 1, 1))])) - ExportScript.Tools.SendData(301, string.format("%0.2f", lFuelCounter[tonumber(string.sub(lTotalFuel, 2, 2))])) - ExportScript.Tools.SendData(302, string.format("%0.2f", lFuelCounter[tonumber(string.sub(lTotalFuel, 3, 3))])) - ExportScript.Tools.SendData(303, lExtTank1) -- external tanks - ExportScript.Tools.SendData(304, lExtTank2) -- inner tanks - ExportScript.Tools.SendData(305, (lEngineInfo.fuel_internal < 2800.0 and 1 or 0)) -- inner wing tank - ExportScript.Tools.SendData(306, (lEngineInfo.fuel_internal < 1840.0 and 1 or 0)) -- inner hull tank - ExportScript.Tools.SendData(307, (lEngineInfo.fuel_internal < 1.0 and 1 or 0)) -- central hull tank - ExportScript.Tools.SendData(308, (lEngineInfo.fuel_internal < 600.0 and 1 or 0)) -- Bingo Fuel - -- Hydraulic Pressure Left ExportScript.AF.FC_OneNeedleGauge(lEngineInfo.HydraulicPressure.left, 240, 85) @@ -222,45 +146,43 @@ function ExportScript.ProcessIkarusFCLowImportanceConfig() -- Wheelbrakes Hydraulic Pressure Right ExportScript.AF.FC_OneNeedleGauge(lMechInfo.wheelbrakes.value, 240, 88) - end - - ExportScript.AF.EventNumberOLD = ExportScript.AF.EventNumber - + end + -- (x < 0 and 'negative' or 'non-negative') --[[ local lPayloadInfo = LoGetPayloadInfo() ExportScript.Tools.WriteToLog('lPayloadInfo: '..ExportScript.Tools.dump(lPayloadInfo)) - + local lSnares = LoGetSnares() -- Flare and Chaff ExportScript.Tools.WriteToLog('lSnares: '..ExportScript.Tools.dump(lSnares)) - + local lSightingSystemInfo = LoGetSightingSystemInfo() ExportScript.Tools.WriteToLog('lSightingSystemInfo: '..ExportScript.Tools.dump(lSightingSystemInfo)) - + local lTWSInfo = LoGetTWSInfo() -- SPO Informationen, z.B. Radarwarner F15C ExportScript.Tools.WriteToLog('lTWSInfo: '..ExportScript.Tools.dump(lTWSInfo)) - + local lTargetInformation = LoGetTargetInformation() -- detalierte Radar Infos z.B. F15C ExportScript.Tools.WriteToLog('lTargetInformation: '..ExportScript.Tools.dump(lTargetInformation)) - + local lLockedTargetInformation = LoGetLockedTargetInformation() ExportScript.Tools.WriteToLog('lLockedTargetInformation: '..ExportScript.Tools.dump(lLockedTargetInformation)) - + local lF15_TWS_Contacs = LoGetF15_TWS_Contacts() -- the same information but only for F-15 in TWS mode ExportScript.Tools.WriteToLog('lF15_TWS_Contacs: '..ExportScript.Tools.dump(lF15_TWS_Contacs)) - + local lMechInfo = LoGetMechInfo() -- mechanical components, e.g. Flaps, Wheelbrakes,... ExportScript.Tools.WriteToLog('lMechInfo: '..ExportScript.Tools.dump(lMechInfo)) - + local lMCPState = LoGetMCPState() -- Warnlichter ExportScript.Tools.WriteToLog('lMCPState: '..ExportScript.Tools.dump(lMCPState)) - + local lControlPanel_HSI = LoGetControlPanel_HSI() ExportScript.Tools.WriteToLog('lControlPanel_HSI: '..ExportScript.Tools.dump(lControlPanel_HSI)) - + local lRadioBeaconsStatus = LoGetRadioBeaconsStatus() ExportScript.Tools.WriteToLog('lRadioBeaconsStatus: '..ExportScript.Tools.dump(lRadioBeaconsStatus)) - + local lEngineInfo = LoGetEngineInfo() ExportScript.Tools.WriteToLog('lEngineInfo: '..ExportScript.Tools.dump(lEngineInfo)) ]] @@ -272,25 +194,29 @@ end function ExportScript.ProcessDACConfigLowImportance() local lFunctionTyp = "DAC" -- function type for shared function --- WeaponStatusPanel() --- MechanicalDevicesIndicator() --- StatusLamp() --- FuelQuantityIndicator() --- SightingSystem() --- SPO15RWR() + -- Weapon Panel + ExportScript.AF.FC_WeaponPanel_SU25(lFunctionTyp) + -- SPO15 Radar Warning Reciver + ExportScript.AF.FC_SPO15RWR(lFunctionTyp) + -- Mechanical Configuration Indicator + ExportScript.AF.FC_Russian_MDI_SU25(lFunctionTyp) + -- Fuel + ExportScript.AF.FC_FuelQuantityIndicator(lFunctionTyp) + + ExportScript.AF.FC_StatusLamp() + ExportScript.AF.FC_SightingSystem() end ----------------------------- -- Custom functions -- ----------------------------- -function SightingSystem(hardware) - local lHardware = hardware or 1 +function ExportScript.AF.FC_SightingSystem() local lSightingSystemInfo = LoGetSightingSystemInfo() if lSightingSystemInfo == nil then return end - --WriteToLog('lSightingSystemInfo: '..dump(lSightingSystemInfo)9 + --ExportScript.Tools.WriteToLog('lSightingSystemInfo: '..ExportScript.Tools.dump(lSightingSystemInfo)9 --[[ [PRF] = { [selection] = string: "ILV" @@ -327,32 +253,30 @@ function SightingSystem(hardware) } } ]] - SendDataHW("600", lSightingSystemInfo.ECM_on == true and 1 or 0, lHardware ) - SendDataHW("601", lSightingSystemInfo.laser_on == true and 1 or 0, lHardware ) - SendDataHW("602", lSightingSystemInfo.optical_system_on == true and 1 or 0, lHardware ) - SendDataHW("603", lSightingSystemInfo.LaunchAuthorized == true and 1 or 0, lHardware ) - --SendDataHW("604", lSightingSystemInfo.radar_on == true and 1 or 0, lHardware ) + ExportScript.Tools.SendDataDAC("600", lSightingSystemInfo.ECM_on == true and 1 or 0 ) + --ExportScript.Tools.SendDataDAC("601", lSightingSystemInfo.laser_on == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("602", lSightingSystemInfo.optical_system_on == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("603", lSightingSystemInfo.LaunchAuthorized == true and 1 or 0 ) + --ExportScript.Tools.SendDataDAC("604", lSightingSystemInfo.radar_on == true and 1 or 0 ) end -function FlareChaff(hardware) - local lHardware = hardware or 1 +function ExportScript.AF.FC_FlareChaff() local lSnares = LoGetSnares() -- Flare and Chaff if lSnares == nil then return end - --WriteToLog('lSnares: '..dump(lSnares)) - + --ExportScript.Tools.WriteToLog('lSnares: '..ExportScript.Tools.dump(lSnares)) + --[chaff] = number: "128" --[flare] = number: "128" end -function StatusLamp(hardware) - local lHardware = hardware or 1 +function ExportScript.AF.FC_StatusLamp() local lMCPState = LoGetMCPState() -- Warning Lights if lMCPState == nil then return end - --WriteToLog('lMCPState: '..dump(lMCPState)) + --ExportScript.Tools.WriteToLog('lMCPState: '..ExportScript.Tools.dump(lMCPState)) --[[ [RightTailPlaneFailure] = boolean: "false" [EOSFailure] = boolean: "false" @@ -383,332 +307,58 @@ function StatusLamp(hardware) [AutopilotOn] = boolean: "false" [LeftTailPlaneFailure] = boolean: "false" ]] - - SendDataHW("700", lMCPState.LeftTailPlaneFailure == true and 1 or 0, lHardware ) - SendDataHW("701", lMCPState.RightTailPlaneFailure == true and 1 or 0, lHardware ) - SendDataHW("702", lMCPState.MasterWarning == true and 1 or 0, lHardware ) - SendDataHW("703", lMCPState.LeftEngineFailure == true and 1 or 0, lHardware ) - SendDataHW("704", lMCPState.RightEngineFailure == true and 1 or 0, lHardware ) - SendDataHW("705", lMCPState.LeftAileronFailure == true and 1 or 0, lHardware ) - SendDataHW("706", lMCPState.RightAileronFailure == true and 1 or 0, lHardware ) - SendDataHW("707", lMCPState.LeftMainPumpFailure == true and 1 or 0, lHardware ) - SendDataHW("708", lMCPState.RightMainPumpFailure == true and 1 or 0, lHardware ) - SendDataHW("709", lMCPState.LeftWingPumpFailure == true and 1 or 0, lHardware ) - SendDataHW("710", lMCPState.RightWingPumpFailure == true and 1 or 0, lHardware ) - SendDataHW("711", lMCPState.EOSFailure == true and 1 or 0, lHardware ) - SendDataHW("712", lMCPState.ECMFailure == true and 1 or 0, lHardware ) - SendDataHW("713", lMCPState.CannonFailure == true and 1 or 0, lHardware ) - SendDataHW("714", lMCPState.MLWSFailure == true and 1 or 0, lHardware ) - SendDataHW("715", lMCPState.ACSFailure == true and 1 or 0, lHardware ) - SendDataHW("716", lMCPState.RadarFailure == true and 1 or 0, lHardware ) - SendDataHW("717", lMCPState.HelmetFailure == true and 1 or 0, lHardware ) - SendDataHW("718", lMCPState.HUDFailure == true and 1 or 0, lHardware ) - SendDataHW("719", lMCPState.MFDFailure == true and 1 or 0, lHardware ) - SendDataHW("720", lMCPState.RWSFailure == true and 1 or 0, lHardware ) - SendDataHW("721", lMCPState.GearFailure == true and 1 or 0, lHardware ) - SendDataHW("722", lMCPState.HydraulicsFailure == true and 1 or 0, lHardware ) - SendDataHW("723", lMCPState.AutopilotFailure == true and 1 or 0, lHardware ) - SendDataHW("724", lMCPState.FuelTankDamage == true and 1 or 0, lHardware ) - SendDataHW("725", lMCPState.CanopyOpen == true and 1 or 0, lHardware ) - SendDataHW("726", lMCPState.StallSignalization == true and 1 or 0, lHardware ) - SendDataHW("727", lMCPState.AutopilotOn == true and 1 or 0, lHardware ) - + + ExportScript.Tools.SendDataDAC("700", lMCPState.LeftTailPlaneFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("701", lMCPState.RightTailPlaneFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("702", lMCPState.MasterWarning == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("703", lMCPState.LeftEngineFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("704", lMCPState.RightEngineFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("705", lMCPState.LeftAileronFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("706", lMCPState.RightAileronFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("707", lMCPState.LeftMainPumpFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("708", lMCPState.RightMainPumpFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("709", lMCPState.LeftWingPumpFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("710", lMCPState.RightWingPumpFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("711", lMCPState.EOSFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("712", lMCPState.ECMFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("713", lMCPState.CannonFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("714", lMCPState.MLWSFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("715", lMCPState.ACSFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("716", lMCPState.RadarFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("717", lMCPState.HelmetFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("718", lMCPState.HUDFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("719", lMCPState.MFDFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("720", lMCPState.RWSFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("721", lMCPState.GearFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("722", lMCPState.HydraulicsFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("723", lMCPState.AutopilotFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("724", lMCPState.FuelTankDamage == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("725", lMCPState.CanopyOpen == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("726", lMCPState.StallSignalization == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("727", lMCPState.AutopilotOn == true and 1 or 0 ) + local lEngineInfo = LoGetEngineInfo() if lEngineInfo ~= nil then - --WriteToLog('lEngineInfo: '..dump(lEngineInfo)) - SendDataHW("728", lEngineInfo.EngineStart.left, lHardware ) -- lamp start left engine 1 (0|1) - SendDataHW("729", lEngineInfo.EngineStart.right, lHardware ) -- lamp start right engine 1 (0|1) + --ExportScript.Tools.WriteToLog('lEngineInfo: '..ExportScript.Tools.dump(lEngineInfo)) + ExportScript.Tools.SendDataDAC("728", lEngineInfo.EngineStart.left ) -- lamp start left engine 1 (0|1) + ExportScript.Tools.SendDataDAC("729", lEngineInfo.EngineStart.right ) -- lamp start right engine 1 (0|1) end - + local lAoA = LoGetAngleOfAttack() if lAoA ~= nil then lAoA = lAoA * 57.3 - SendDataHW("730", (lAoA > 20.0 and 1 or 0), lHardware ) -- lamp start AOA warning (0|1) + ExportScript.Tools.SendDataDAC("730", (lAoA > 20.0 and 1 or 0) ) -- lamp start AOA warning (0|1) end end -function WeaponStatusPanel(hardware) --- The weapon status panel, quantity and readiness of the currently selected weapon and the remaining gun ammunition are indicated. - local lHardware = hardware or 1 - gES_PayloadInfo = LoGetPayloadInfo() - if gES_PayloadInfo == nil then - return - end - --WriteToLog('gES_PayloadInfo: '..dump(gES_PayloadInfo)) - --[[ exsample - [Stations] = { - [1] = { - [CLSID] = string: "{682A481F-0CB5-4693-A382-D00DD4A156D7}" - [container] = boolean: "false" - [count] = number: "1" - [weapon] = { - [level3] = number: "7" - [level1] = number: "4" - [level4] = number: "10" - [level2] = number: "4" - } - } - [2] = { - [CLSID] = string: "{682A481F-0CB5-4693-A382-D00DD4A156D7}" - [container] = boolean: "false" - [count] = number: "1" - [weapon] = { - [level3] = number: "7" - [level1] = number: "4" - [level4] = number: "10" - [level2] = number: "4" - } - } - [3] = { - [wstype] = { - [level3] = number: "32" - [level1] = number: "4" - [level4] = number: "6" - [level2] = number: "7" - } - [count] = number: "20" - [CLSID] = string: "{F72F47E5-C83A-4B85-96ED-D3E46671EE9A}" - [adapter] = { - [level3] = number: "0" - [level1] = number: "0" - [level4] = number: "0" - [level2] = number: "0" - } - [container] = boolean: "true" - [weapon] = { - [level3] = number: "33" - [level1] = number: "4" - [level4] = number: "32" - [level2] = number: "7" - } - } - [4] = { - [wstype] = { - [level3] = number: "32" - [level1] = number: "4" - [level4] = number: "6" - [level2] = number: "7" - } - [count] = number: "20" - [CLSID] = string: "{F72F47E5-C83A-4B85-96ED-D3E46671EE9A}" - [adapter] = { - [level3] = number: "0" - [level1] = number: "0" - [level4] = number: "0" - [level2] = number: "0" - } - [container] = boolean: "true" - [weapon] = { - [level3] = number: "33" - [level1] = number: "4" - [level4] = number: "32" - [level2] = number: "7" - } - } - [5] = { - [wstype] = { - [level3] = number: "32" - [level1] = number: "4" - [level4] = number: "99" - [level2] = number: "4" - } - [count] = number: "1" - [CLSID] = string: "{79D73885-0801-45a9-917F-C90FE1CE3DFC}" - [adapter] = { - [level3] = number: "0" - [level1] = number: "0" - [level4] = number: "0" - [level2] = number: "0" - } - [container] = boolean: "true" - [weapon] = { - [level3] = number: "8" - [level1] = number: "4" - [level4] = number: "45" - [level2] = number: "4" - } - } - [6] = { - [wstype] = { - [level3] = number: "32" - [level1] = number: "4" - [level4] = number: "99" - [level2] = number: "4" - } - [count] = number: "1" - [CLSID] = string: "{79D73885-0801-45a9-917F-C90FE1CE3DFC}" - [adapter] = { - [level3] = number: "0" - [level1] = number: "0" - [level4] = number: "0" - [level2] = number: "0" - } - [container] = boolean: "true" - [weapon] = { - [level3] = number: "8" - [level1] = number: "4" - [level4] = number: "45" - [level2] = number: "4" - } - } - [7] = { - [wstype] = { - [level3] = number: "32" - [level1] = number: "4" - [level4] = number: "47" - [level2] = number: "4" - } - [count] = number: "8" - [CLSID] = string: "{F789E86A-EE2E-4E6B-B81E-D5E5F903B6ED}" - [adapter] = { - [level3] = number: "0" - [level1] = number: "0" - [level4] = number: "0" - [level2] = number: "0" - } - [container] = boolean: "true" - [weapon] = { - [level3] = number: "8" - [level1] = number: "4" - [level4] = number: "58" - [level2] = number: "4" - } - } - [8] = { - [wstype] = { - [level3] = number: "32" - [level1] = number: "4" - [level4] = number: "47" - [level2] = number: "4" - } - [count] = number: "8" - [CLSID] = string: "{F789E86A-EE2E-4E6B-B81E-D5E5F903B6ED}" - [adapter] = { - [level3] = number: "0" - [level1] = number: "0" - [level4] = number: "0" - [level2] = number: "0" - } - [container] = boolean: "true" - [weapon] = { - [level3] = number: "8" - [level1] = number: "4" - [level4] = number: "58" - [level2] = number: "4" - } - } - [9] = { - [CLSID] = string: "{D5435F26-F120-4FA3-9867-34ACE562EF1B}" - [container] = boolean: "false" - [count] = number: "1" - [weapon] = { - [level3] = number: "38" - [level1] = number: "4" - [level4] = number: "20" - [level2] = number: "5" - } - } - [10] = { - [CLSID] = string: "{D5435F26-F120-4FA3-9867-34ACE562EF1B}" - [container] = boolean: "false" - [count] = number: "1" - [weapon] = { - [level3] = number: "38" - [level1] = number: "4" - [level4] = number: "20" - [level2] = number: "5" - } - } - [11] = { - [CLSID] = string: "" - [container] = boolean: "false" - [count] = number: "0" - [weapon] = { - [level3] = number: "0" - [level1] = number: "0" - [level4] = number: "0" - [level2] = number: "0" - } - } - } - [CurrentStation] = number: "0" - [Cannon] = { - [shells] = number: "250" - } - ]] - --[[ - Weapon Panel - | - --------------------------------------------------- - | | | | | | | | | | | - 1 2 3 4 5 C 6 7 8 9 10 - ]] - -- Payload Info - -- weapon stations (panel) 1 (left) - 10 (right), no lamp for center station - SendDataHW("100", gES_PayloadInfo.Cannon.shells, lHardware ) -- count cannon shells - SendDataHW("101", (gES_PayloadInfo.Stations[1].count > 0 and 1 or 0), lHardware ) -- weapon presend > 0 (panel 1) - SendDataHW("110", (gES_PayloadInfo.Stations[2].count > 0 and 1 or 0), lHardware ) -- weapon presend > 0 (panel 10) - SendDataHW("102", (gES_PayloadInfo.Stations[3].count > 0 and 1 or 0), lHardware ) -- weapon presend > 0 (panel 2) - SendDataHW("109", (gES_PayloadInfo.Stations[4].count > 0 and 1 or 0), lHardware ) -- weapon presend > 0 (panel 9) - SendDataHW("103", (gES_PayloadInfo.Stations[5].count > 0 and 1 or 0), lHardware ) -- weapon presend > 0 (panel 3) - SendDataHW("108", (gES_PayloadInfo.Stations[6].count > 0 and 1 or 0), lHardware ) -- weapon presend > 0 (panel 8) - SendDataHW("104", (gES_PayloadInfo.Stations[7].count > 0 and 1 or 0), lHardware ) -- weapon presend > 0 (panel 4) - SendDataHW("107", (gES_PayloadInfo.Stations[8].count > 0 and 1 or 0), lHardware ) -- weapon presend > 0 (panel 7) - SendDataHW("105", (gES_PayloadInfo.Stations[9].count > 0 and 1 or 0), lHardware ) -- weapon presend > 0 (panel 5) - SendDataHW("106", (gES_PayloadInfo.Stations[10].count > 0 and 1 or 0), lHardware ) -- weapon presend > 0 (panel 6) - --SendDataHW("110", (gES_PayloadInfo.Stations[11].count > 0 and 1 or 0) ) -- weapon presend > 0 center station, not visible - --SendDataHW("CurrentStation", gES_PayloadInfo.CurrentStation, lHardware ) - -- air-to-air missils panel 1 and 11, air combat modus, CurrentStation = 1, panel 1 and 11 on - -- CurrentStation 5, panel 3 - -- CurrentStation 3, panel 2 - -- CurrentStation 7, panel 4 - -- CurrentStation 4, panel 9 - -- CurrentStation 9, panel 5 - -- CurrentStation 10, panel 6 - -- CurrentStation 8, panel 7 - -- CurrentStation 6, panel 8 - -- wenn die Waffenstationen gleichmässig belegt sind, hat bei Auswahl CurrentStation immer den Wert der linken Station - -- bei ungleichmässiger Belegung, hat CurrentStation immer den Wert der jeweiligen Station - -- Waffenbezeichnung als UUID, gES_PayloadInfo.Stations[X].CLSID - - -- defination - if gES_CurrentStationTmp == nil then - gES_CurrentStationTmp = -1 - end - - if gES_PayloadInfo.CurrentStation > 0 and - gES_CurrentStationTmp ~= gES_PayloadInfo.CurrentStation then - gES_CurrentStationTmp = gES_PayloadInfo.CurrentStation - - gES_TmpStationToPanel = {} - gES_TmpStationToPanel[1] = {Panel = 1, StationID = 101, CurrentID = 201, HardwareID = lHardware } -- left - gES_TmpStationToPanel[2] = {Panel = 10, StationID = 110, CurrentID = 210, HardwareID = lHardware } -- right - gES_TmpStationToPanel[3] = {Panel = 2, StationID = 102, CurrentID = 202, HardwareID = lHardware } - gES_TmpStationToPanel[4] = {Panel = 9, StationID = 109, CurrentID = 209, HardwareID = lHardware } - gES_TmpStationToPanel[5] = {Panel = 3, StationID = 103, CurrentID = 203, HardwareID = lHardware } - gES_TmpStationToPanel[6] = {Panel = 8, StationID = 108, CurrentID = 208, HardwareID = lHardware } - gES_TmpStationToPanel[7] = {Panel = 4, StationID = 104, CurrentID = 204, HardwareID = lHardware } - gES_TmpStationToPanel[8] = {Panel = 7, StationID = 107, CurrentID = 207, HardwareID = lHardware } - gES_TmpStationToPanel[9] = {Panel = 5, StationID = 105, CurrentID = 205, HardwareID = lHardware } - gES_TmpStationToPanel[10] = {Panel = 6, StationID = 106, CurrentID = 206, HardwareID = lHardware } - - WeaponStatusPanel_Reset(201, 210, lHardware) - - if gES_TmpStationToPanel[gES_PayloadInfo.CurrentStation] ~= nil then - SendDataHW(gES_TmpStationToPanel[gES_PayloadInfo.CurrentStation].CurrentID, 1, lHardware ) -- eigentliche Auswahl - - table.foreach(gES_PayloadInfo.Stations, WeaponStatusPanel_selectCurrentPayloadStation) -- zugehörige Stationen - end - end -end - -function FuelQuantityIndicator() +function ExportScript.AF.FC_FuelQuantityIndicator(FunctionTyp) + local lFunctionTyp = FunctionTyp or "Ikarus" -- Fuel quantity shows the fuel remaining in all tanks local lEngineInfo = LoGetEngineInfo() if lEngineInfo == nil then return end - --WriteToLog('lEngineInfo: '..dump(lEngineInfo)) + --ExportScript.Tools.WriteToLog('lEngineInfo: '..ExportScript.Tools.dump(lEngineInfo)) --[[ [fuel_external] = number: "0" [Temperature] = { @@ -735,135 +385,59 @@ function FuelQuantityIndicator() lPayloadInfo.Stations[8].CLSID == E8D4652F-FD48-45B7-BA5B-2AE05BB5A9CF -- ext 800l Fuel Tank ]] - ExportScript.Tools.SendDataDAC("300", string.format("%d", math.round((lEngineInfo.fuel_internal / 10), 0, "ceil") * 10)) -- total fuel in kg - --ExportScript.Tools.SendDataDAC("301", string.format("%d", lEngineInfo.fuel_internal)) -- total fuel in kg - --ExportScript.Tools.SendDataDAC("302", string.format("%d", lEngineInfo.fuel_external)) -- external fuel in kg - + local lTotalFuel = lEngineInfo.fuel_internal + --local lTotalFuel = string.format("%3d", ExportScript.Tools.round((lEngineInfo.fuel_internal / 10), 0, "ceil") * 10) + --local lTotalFuel = string.format("%4d", lEngineInfo.fuel_internal) -- total fuel in kg + --local lTotalFuel = string.format("%4d", lEngineInfo.fuel_external) -- external fuel in kg + local lFuelCounter = {[0] = 0.0, [1] = 0.11, [2] = 0.22, [3] = 0.33, [4] = 0.44, [5] = 0.55, [6] = 0.66, [7] = 0.77, [8] = 0.88, [9] = 0.99} + lTotalFuel = string.format("%03d", ExportScript.Tools.round((lEngineInfo.fuel_internal / 10), 0, "ceil")) -- auf drei stellen bringen + + local lExtTank1 = 1.0 -- external tanks + local lExtTank2 = 1.0 -- inner tanks + local lPayloadInfo = LoGetPayloadInfo() if lPayloadInfo ~= nil then - --WriteToLog('lPayloadInfo: '..dump(lPayloadInfo)) + --ExportScript.Tools.WriteToLog('lPayloadInfo: '..ExportScript.Tools.dump(lPayloadInfo)) if lPayloadInfo.Stations[10].CLSID == "{E8D4652F-FD48-45B7-BA5B-2AE05BB5A9CF}" or lPayloadInfo.Stations[9].CLSID == "{E8D4652F-FD48-45B7-BA5B-2AE05BB5A9CF}" then -- external tanks presend and full (panel 6 and 5) - ExportScript.Tools.SendDataDAC("303", ((lEngineInfo.fuel_external < 1240.0 ) and 1 or 0)) - else - ExportScript.Tools.SendDataDAC("303", 1) + lExtTank1 = ((lEngineInfo.fuel_external < 1240.0 ) and 1.0 or 0.0) end if lPayloadInfo.Stations[5].CLSID == "{E8D4652F-FD48-45B7-BA5B-2AE05BB5A9CF}" or - lPayloadInfo.Stations[6].CLSID == "{E8D4652F-FD48-45B7-BA5B-2AE05BB5A9CF}" then-- inner tank presend and full (panel 3 and 8) - ExportScript.Tools.SendDataDAC("304", ((lEngineInfo.fuel_external < 1.0 ) and 1 or 0)) - else - ExportScript.Tools.SendDataDAC("304", 1) + lPayloadInfo.Stations[6].CLSID == "{E8D4652F-FD48-45B7-BA5B-2AE05BB5A9CF}" then-- inner tanks presend and full (panel 3 and 8) + lExtTank2 = ((lEngineInfo.fuel_external < 1.0 ) and 1.0 or 0.0) end - else - ExportScript.Tools.SendDataDAC("303", 1) - ExportScript.Tools.SendDataDAC("304", 1) end - ExportScript.Tools.SendDataDAC("305", (lEngineInfo.fuel_internal < 2800.0 and 1 or 0)) -- inner wing tank - ExportScript.Tools.SendDataDAC("306", (lEngineInfo.fuel_internal < 1840.0 and 1 or 0)) -- inner hull tank - ExportScript.Tools.SendDataDAC("307", (lEngineInfo.fuel_internal < 1.0 and 1 or 0)) -- central hull tank - ExportScript.Tools.SendDataDAC("308", (lEngineInfo.fuel_internal < 600.0 and 1 or 0)) -- Bingo Fuel - -end + -- TotalFuel_100 + -- TotalFuel_10 + -- TotalFuel_1 + -- Light1 + -- Light2 + -- Light3 + -- Light4 + -- Light5 + -- BingoLight -function MechanicalDevicesIndicator(hardware) --- The mechanical devices indicator shows the position of the landing gear, flaps, leading edge flaps and airbrake - local lHardware = hardware or 1 - local lMechInfo = LoGetMechInfo() -- mechanical components, e.g. Flaps, Wheelbrakes,... - if lMechInfo == nil then - return + if ExportScript.Config.IkarusExport and lFunctionTyp == "Ikarus" then + ExportScript.Tools.SendData(300, string.format("%0.2f", lFuelCounter[tonumber(string.sub(lTotalFuel, 1, 1))])) + ExportScript.Tools.SendData(301, string.format("%0.2f", lFuelCounter[tonumber(string.sub(lTotalFuel, 2, 2))])) + ExportScript.Tools.SendData(302, string.format("%0.2f", lFuelCounter[tonumber(string.sub(lTotalFuel, 3, 3))])) + ExportScript.Tools.SendData(303, lExtTank1) -- external tanks + ExportScript.Tools.SendData(304, lExtTank2) -- inner tanks + ExportScript.Tools.SendData(305, (lEngineInfo.fuel_internal < 2800.0 and 1 or 0)) -- inner wing tank + ExportScript.Tools.SendData(306, (lEngineInfo.fuel_internal < 1840.0 and 1 or 0)) -- inner hull tank + ExportScript.Tools.SendData(307, (lEngineInfo.fuel_internal < 1.0 and 1 or 0)) -- central hull tank + ExportScript.Tools.SendData(308, (lEngineInfo.fuel_internal < 600.0 and 1 or 0)) -- Bingo Fuel end - --[[ - [hook] = { - [status] = number: "0" - [value] = number: "0" - } - [parachute] = { - [status] = number: "0" - [value] = number: "0" - } - [controlsurfaces] = { - [eleron] = { - [left] = number: "0" - [right] = number: "-0.21084336936474" - } - [elevator] = { - [left] = number: "-0" - [right] = number: "-0" - } - [rudder] = { - [left] = number: "0" - [right] = number: "0" - } - } - [airintake] = { - [status] = number: "0" - [value] = number: "0" - } - [canopy] = { - [status] = number: "0" - [value] = number: "0" - } - [refuelingboom] = { - [status] = number: "0" - [value] = number: "0" - } - [wing] = { - [status] = number: "0" - [value] = number: "0" - } - [noseflap] = { - [status] = number: "0" - [value] = number: "0" - } - [gear] = { - [value] = number: "0" - [nose] = { - [rod] = number: "0" - } - [main] = { - [left] = { - [rod] = number: "0" - } - [right] = { - [rod] = number: "0" - } - } - [status] = number: "0" - } - [speedbrakes] = { - [status] = number: "0" - [value] = number: "0" - } - [wheelbrakes] = { - [status] = number: "0" - [value] = number: "0" - } - [flaps] = { - [status] = number: "0" - [value] = number: "0" - }]] - --SendDataHW("500", lMechInfo.gear.status ) - --SendDataHW("501", lMechInfo.gear.value ) - --SendDataHW("502", lMechInfo.gear.nose.rod ) -- zeigt an wie weit das Fahrwerk einsackt wenn das Flugzeug auf dem Boden ist - --SendDataHW("503", lMechInfo.gear.main.left.rod ) -- zeigt an wie weit das Fahrwerk einsackt wenn das Flugzeug auf dem Boden ist - --SendDataHW("504", lMechInfo.gear.main.right.rod ) -- zeigt an wie weit das Fahrwerk einsackt wenn das Flugzeug auf dem Boden ist - --SendDataHW("500", ((lMechInfo.gear.status == 1 and lMechInfo.gear.value < 1) and 1 or 0 ) ) -- gear warning light, go up - --SendDataHW("500", ((lMechInfo.gear.status == 0 and lMechInfo.gear.value > 0) and 1 or 0 ) ) -- gear warning light, go down - SendDataHW("500", (((lMechInfo.gear.status == 1 and lMechInfo.gear.value < 1) or (lMechInfo.gear.status == 0 and lMechInfo.gear.value > 0)) and 1 or 0 ), lHardware ) -- gear warning light - SendDataHW("501", (lMechInfo.gear.value > 0.85 and 1 or 0), lHardware ) -- nose gear - SendDataHW("502", (lMechInfo.gear.value > 0.95 and 1 or 0), lHardware ) -- left gear - SendDataHW("503", (lMechInfo.gear.value == 1 and 1 or 0), lHardware ) -- right gear - - --SendDataHW("510", lMechInfo.speedbrakes.status ) -- speedbreakes on 1 (0|1) - SendDataHW("510", (lMechInfo.speedbrakes.value > 0.1 and 1 or 0), lHardware ) -- speedbreakes on > 0.1 (0 - 1) - --SendDataHW("520", lMechInfo.wheelbrakes.status, lHardware ) -- not in use - --SendDataHW("521", lMechInfo.wheelbrakes.value, lHardware ) -- not in use - - local lTrueAirSpeed = LoGetTrueAirSpeed() - --SendDataHW("530", lMechInfo.flaps.status ) -- flap switch off 0, 1. position 1, 2. position 2 (0|1|2) - --SendDataHW("531", lMechInfo.flaps.value ) -- flap 1. position > 0.25, 2. position > 0.93 (0 - 1) - SendDataHW("531", (lMechInfo.flaps.value > 0.25 and 1 or 0), lHardware ) -- flap 1. position - SendDataHW("532", (lMechInfo.flaps.value > 0.93 and 1 or 0), lHardware ) -- flap 2. position - SendDataHW("533", ((lMechInfo.flaps.value > 0.93 and lTrueAirSpeed > 340) and 1 or 0), lHardware ) -- Speed Warning for Flaps, same light as gear warning light, but blinking light -end + if ExportScript.Config.DACExport and lFunctionTyp == "DAC" then + ExportScript.Tools.SendDataDAC("300", string.format("%d", ExportScript.Tools.round((lEngineInfo.fuel_internal / 10), 0, "ceil") * 10)) -- total fuel in kg + --ExportScript.Tools.SendDataDAC("301", string.format("%d", lEngineInfo.fuel_internal)) -- total fuel in kg + --ExportScript.Tools.SendDataDAC("302", string.format("%d", lEngineInfo.fuel_external)) -- external fuel in kg + ExportScript.Tools.SendDataDAC(303, lExtTank1) -- external tanks + ExportScript.Tools.SendDataDAC(304, lExtTank2) -- inner tanks + ExportScript.Tools.SendDataDAC(305, (lEngineInfo.fuel_internal < 2800.0 and 1 or 0)) -- inner wing tank + ExportScript.Tools.SendDataDAC(306, (lEngineInfo.fuel_internal < 1840.0 and 1 or 0)) -- inner hull tank + ExportScript.Tools.SendDataDAC(307, (lEngineInfo.fuel_internal < 1.0 and 1 or 0)) -- central hull tank + ExportScript.Tools.SendDataDAC(308, (lEngineInfo.fuel_internal < 600.0 and 1 or 0)) -- Bingo Fuel + end +end \ No newline at end of file diff --git a/Scripts/DCS-ExportScript/ExportsModules/Su-27.lua b/Scripts/DCS-ExportScript/ExportsModules/Su-27.lua index 42439ec..7d5a163 100644 --- a/Scripts/DCS-ExportScript/ExportsModules/Su-27.lua +++ b/Scripts/DCS-ExportScript/ExportsModules/Su-27.lua @@ -1,364 +1,222 @@ -- Su-27 Export --- Version 0.9.9 BETA - -gES_FoundFCModule = true - --- auxiliary function -dofile(gES_ExportModulePath.."FC_AuxiliaryFuntions.lua") +-- Version 1.0.0 BETA + +ExportScript.FoundFCModule = true + +-- auxiliary function +dofile(ExportScript.Config.ExportModulePath.."FC_AuxiliaryFuntions.lua") ----------------------------------------- -- FLAMING CLIFFS AIRCRAFT / Su-27 -- -- FC aircraft don't support GetDevice -- ----------------------------------------- -function ProcessGlassCockpitFCHighImportanceConfig() - +function ExportScript.ProcessIkarusFCHighImportanceConfig() + local lFunctionTyp = "Ikarus" -- function type for shared function local myData = LoGetSelfData() if (myData) then - local lLatitude = myData.LatLongAlt.Lat -- LATITUDE - local lLongitude = myData.LatLongAlt.Long -- LONGITUDE + local lLatitude = myData.LatLongAlt.Lat -- LATITUDE + local lLongitude = myData.LatLongAlt.Long -- LONGITUDE + + local lEngineTempLeft = LoGetEngineInfo().Temperature.left -- ENG1 EGT ºC + local lEngineTempRight = LoGetEngineInfo().Temperature.right -- ENG2 EGT ºC + --[[ local lBasicAtmospherePressure = LoGetBasicAtmospherePressure() -- BAROMETRIC PRESSURE local lAltBar = LoGetAltitudeAboveSeaLevel() -- ALTITUDE SEA LEVEL (Meter) local lAltRad = LoGetAltitudeAboveGroundLevel() -- ALTITUDE GROUND LEVEL (Meter) - --local lTrueAirSpeed = LoGetTrueAirSpeed() -- TRUE AIRSPEED (Meter/Second) + local lTrueAirSpeed = LoGetTrueAirSpeed() -- TRUE AIRSPEED (Meter/Second) local lPitch, lBank, lYaw = LoGetADIPitchBankYaw() -- PITCH, BANK, YAW (Radian) local lHeading = myData.Heading -- HEADING (Radian) local lVVI = LoGetVerticalVelocity() -- VERTICAL SPEED (Meter/Second) local lIAS = LoGetIndicatedAirSpeed() -- INDICATED AIRSPEED (Meter/Second) - --local lMachNumber = LoGetMachNumber() -- MACH + local lMachNumber = LoGetMachNumber() -- MACH local lAoA = LoGetAngleOfAttack() -- ANGLE OF ATTACK AoA (Radian) - + local lGlide = LoGetGlideDeviation() -- VOR1 HORIZONTAL DEFLECTION (-1 +1) local lSide = LoGetSideDeviation() -- VOR1 VERTICAL DEFLECTION (-1 +1) - --local lSlipBallPosition = LoGetSlipBallPosition() -- SLIP BALL (-1 +1) - --local lAccelerationUnits = LoGetAccelerationUnits().y -- G-LOAD - - --local lNavInfoPitch = LoGetNavigationInfo().Requirements.pitch -- AP REQUIRED PITCH (Radian) - --local lNavInfoRoll = LoGetNavigationInfo().Requirements.roll -- AP REQUIRED BANK (Radian) - --local lNavInfoSpeed = LoGetNavigationInfo().Requirements.speed -- AP SPEED (Meter/Second) - --local lNavInfoAltitude = LoGetNavigationInfo().Requirements.altitude -- AP ALTITUDE (Meter) - --local lNavInfoVerticalSpeed = LoGetNavigationInfo().Requirements.vertical_speed -- AP VERTICAL SPEED (Meter/Second) + local lSlipBallPosition = LoGetSlipBallPosition() -- SLIP BALL (-1 +1) + local lAccelerationUnits = LoGetAccelerationUnits().y -- G-LOAD - --local lControlPanel_HSI = LoGetControlPanel_HSI() -- HSI Data + local lNavInfoPitch = LoGetNavigationInfo().Requirements.pitch -- AP REQUIRED PITCH (Radian) + local lNavInfoRoll = LoGetNavigationInfo().Requirements.roll -- AP REQUIRED BANK (Radian) + local lNavInfoSpeed = LoGetNavigationInfo().Requirements.speed -- AP SPEED (Meter/Second) + local lNavInfoAltitude = LoGetNavigationInfo().Requirements.altitude -- AP ALTITUDE (Meter) + local lNavInfoVerticalSpeed = LoGetNavigationInfo().Requirements.vertical_speed -- AP VERTICAL SPEED (Meter/Second) + + local lControlPanel_HSI = LoGetControlPanel_HSI() -- HSI Data local lHSI_RMI = LoGetControlPanel_HSI().RMI_raw -- VOR1 OBS (Radian) local lHSI_ADF = LoGetControlPanel_HSI().ADF_raw -- ADF OBS (Radian) - --local lHSI_Heading = LoGetControlPanel_HSI().Heading_raw -- Heading (Radian) - + local lHSI_Heading = LoGetControlPanel_HSI().Heading_raw -- Heading (Radian) + local lEngineRPMleft = LoGetEngineInfo().RPM.left -- ENG1 RPM % local lEngineRPMright = LoGetEngineInfo().RPM.right -- ENG2 RPM % - local lEngineTempLeft = LoGetEngineInfo().Temperature.left -- ENG1 EGT ºC - local lEngineTempRight = LoGetEngineInfo().Temperature.right -- ENG2 EGT ºC - --local lEngineFuelInternal = LoGetEngineInfo().fuel_internal -- TANK1 (INT) (KG) - --local lEngineFuelExternal = LoGetEngineInfo().fuel_external -- TANK2 (EXT) (KG) - - --local lMechInfo = LoGetMechInfo() -- mechanical components, e.g. Flaps, Wheelbrakes,... - --local lPayloadInfo = LoGetPayloadInfo() -- Paylod, e.g. bombs, guns, rockets, fuel tanks,... - + local lEngineFuelInternal = LoGetEngineInfo().fuel_internal -- TANK1 (INT) (KG) + local lEngineFuelExternal = LoGetEngineInfo().fuel_external -- TANK2 (EXT) (KG) + + local lMechInfo = LoGetMechInfo() -- mechanical components, e.g. Flaps, Wheelbrakes,... + local lPayloadInfo = LoGetPayloadInfo() -- Paylod, e.g. bombs, guns, rockets, fuel tanks,... + ]] + local lDistanceToWay = 999 local lRoute = LoGetRoute() - + if (myData and lRoute) then -- if neither are nil local myLoc = LoGeoCoordinatesToLoCoordinates(lLongitude, lLatitude) --lDistanceToWay = math.sqrt((myLoc.x - lRoute.goto_point.world_point.x)^2 + (myLoc.y - lRoute.goto_point.world_point.y)^2) lDistanceToWay = math.sqrt((myLoc.x - lRoute.goto_point.world_point.x)^2 + (myLoc.z - lRoute.goto_point.world_point.z)^2) end - if gES_GlassCockpitType == 1 then - -- HELIOS Version 1.3 - -- customizing for HELOS - lPitch = math.deg(lPitch) -- PITCH, (Radian to Grad) - lBank = math.deg(lBank) -- BANK (Radian to Grad) - lYaw = math.deg(lYaw) -- YAW (Radian to Grad) - lHSI_RMI = math.deg(lHSI_RMI) -- VOR1 OBS (Radian to Grad) - lHSI_ADF = math.deg(lHSI_ADF) -- ADF OBS (Radian to Grad) - lAoA = math.deg(lAoA) -- ANGLE OF ATTACK AoA (Radian to Grad) - lHeading = math.deg(lHeading) -- Heading (Radian to Grad) - lHSI_ADF = (360 - lHSI_ADF) + (360 - lHeading) - lHSI_RMI = 360 - lHSI_RMI - lIAS = lIAS * 3.6 -- change from m/s to km/h - - SendData("1", string.format("%.2f", lPitch) ) - SendData("2", string.format("%.2f", lBank) ) - SendData("3", string.format("%.2f", lYaw) ) - SendData("4", string.format("%.2f", lAltBar) ) - SendData("5", string.format("%.2f", lAltRad) ) - SendData("6", string.format("%.2f", lHSI_ADF) ) - SendData("7", string.format("%.2f", lHSI_RMI) ) - SendData("8", string.format("%.2f", lHeading) ) - SendData("9", string.format("%.2f", lEngineRPMleft) ) - SendData("10", string.format("%.2f", lEngineRPMright) ) - SendData("11", string.format("%.2f", lEngineTempLeft) ) - SendData("12", string.format("%.2f", lEngineTempRight) ) - SendData("13", string.format("%.2f", lVVI) ) - SendData("14", string.format("%.2f", lIAS) ) - SendData("15", string.format("%.2f", lDistanceToWay) ) - SendData("16", string.format("%.2f", lAoA) ) - SendData("17", string.format("%.2f", lGlide) ) - SendData("18", string.format("%.2f", lSide) ) - - elseif gES_GlassCockpitType == 2 then - -- HawgTouch version 1.6 + -- IAS-MACH Indicator + ExportScript.AF.FC_Russian_AirSpeed_1600hkm() - local lRadToDCSsignd = math.pi - local lRadToDCSunsignd = math.pi * 2 - local lDefaultNull = 0.0 - local lDefaultOne = 1.0 - - -- IAS-MACH Indicator (IAS, MACH) {"%.4f;%.4f"} - FC_Russian_AirSpeed_1600hkm(1) - - -- AOA Indicator and Accelerometer (AOA, GLoad) - FC_Russian_AOA_Su2733(3) - - -- ADI - FC_Russian_ADI_Old(4) + -- AOA Indicator and Accelerometer (AOA, GLoad) + ExportScript.AF.FC_Russian_AOA_Su2733() - -- HSI - FC_Russian_HSI(lDistanceToWay, 5) + -- ADI + ExportScript.AF.FC_Russian_ADI_Old() - -- Vertical Velocity Indicator (VVI) (VVI, TurnIndicator, SlipBallPosition) - FC_Russian_VVI_Old(6) - - -- Radar Altimeter (AltRad, MinAltitude, WarningFlag, MinAltitudeLamp) {"%.4f;%.4f;%.1f;%.1f"} (below 100m is warning light on) - FC_Russian_RadarAltimeter_1500m(100, 7) - - -- Barometric Altimeter (AltBar, BasicAtmospherePressure) - FC_Russian_BarometricAltimeter_20000(8) + -- HSI + ExportScript.AF.FC_Russian_HSI(lDistanceToWay) - -- Tachometer (RPM) (EngineRPMleft, EngineRPMright) {"%.4f;%.4f"} - FC_Russian_EngineRPM(9) + -- Vertical Velocity Indicator (VVI) + ExportScript.AF.FC_Russian_VVI_Old() - -- Left Jet Engine Turbine Temperature Indicator (EngineTemp) {"%.4f"} - FC_TwoNeedlesGauge(lEngineTempLeft, 1200, 100, 10) + -- Radar Altimeter (below 100m is warning light on) + ExportScript.AF.FC_Russian_RadarAltimeter_1500m(100) - -- Right Jet Engine Turbine Temperature Indicator (EngineTemp) {"%.4f"} - FC_TwoNeedlesGauge(lEngineTempRight, 1200, 100, 11) + -- Barometric Altimeter + ExportScript.AF.FC_Russian_BarometricAltimeter_20000() - -- Clock from Ka-50 {CurrentHours, CurrentMinutes, CurrentSeconds, 0, FlightTimeHours, FlightTimeMinutes, 0, 0) {"%.4f;%.4f;%.4f;%.1f;%.4f;%.4f;%.4f;%.4f"} - FC_Russian_Clock_late(12) - end + -- Tachometer (RPM) + ExportScript.AF.FC_Russian_EngineRPM() + + -- Left Jet Engine Turbine Temperature Indicator (EngineTemp, main scala, second scala, ExportID) + ExportScript.AF.FC_TwoNeedlesGauge(lEngineTempLeft, 1200, 100, 70, 71) + + -- Right Jet Engine Turbine Temperature Indicator (EngineTemp, main scala, second scala, ExportID) + ExportScript.AF.FC_TwoNeedlesGauge(lEngineTempRight, 1200, 100, 72, 73) + + -- Clock from Ka-50 + ExportScript.AF.FC_Russian_Clock_late() else - WriteToLog("Unknown FC Error, no LoGetSelfData.") + ExportScript.Tools.WriteToLog("Unknown FC Error, no LoGetSelfData.") end - end -function ProcessHARDWAREConfigHighImportance(mainPanelDevice) +function ExportScript.ProcessDACConfigHighImportance() + local lFunctionTyp = "DAC" -- function type for shared function + + -- your script + end -function ProcessGlassCockpitFCLowImportanceConfig() +function ExportScript.ProcessIkarusFCLowImportanceConfig() + local lFunctionTyp = "Ikarus" -- function type for shared function + + ExportScript.AF.FC_WeaponPanel_SU27(lFunctionTyp) + + -- SPO15 Radar Warning Reciver + ExportScript.AF.FC_SPO15RWR(lFunctionTyp) + + -- EKRAN Message + ExportScript.AF.FC_EKRAN() - if gES_GlassCockpitType == 1 then - -- HELIOS Version 1.3 - - elseif gES_GlassCockpitType == 2 then - -- HawgTouch version 1.6 + -- Fuel Quantity Indicator + ExportScript.AF.FuelQuantityIndicator(lFunctionTyp) - FC_WeaponPanel_SU2733(13) + local lEngineInfo = LoGetEngineInfo() + if lEngineInfo ~= nil then + -- Hydraulic Pressure Left + ExportScript.AF.FC_OneNeedleGauge(lEngineInfo.HydraulicPressure.left, 240, 85) - FC_RadarWarning_SPO15(14) - - -- Fuel Quantity Indicator - local lEngineInfo = LoGetEngineInfo() - if lEngineInfo ~= nil then - --WriteToLog('lEngineInfo: '..dump(lEngineInfo)) - --[[ - [fuel_external] = number: "0" - [Temperature] = { - [left] = number: "626.99444580078" - [right] = number: "626.99444580078" - } - [RPM] = { - [left] = number: "87.453765869141" - [right] = number: "87.453758239746" - } - [FuelConsumption] = { - [left] = number: "0.1500396137767" - [right] = number: "0.1500396137767" - } - [fuel_internal] = number: "3773.2749023438" - [EngineStart] = { - [left] = number: "0" - [right] = number: "0" - } - [HydraulicPressure] = { - [left] = number: "210" - [right] = number: "210" - } - lPayloadInfo.Stations[8].CLSID == E8D4652F-FD48-45B7-BA5B-2AE05BB5A9CF -- ext 800l Fuel Tank - ]] - - local lTotalFuel = lEngineInfo.fuel_internal - --local lTotalFuel = string.format("%3d", math.round((lEngineInfo.fuel_internal / 10), 0, "ceil") * 10) - --local lTotalFuel = string.format("%4d", lEngineInfo.fuel_internal) -- total fuel in kg - --local lTotalFuel = string.format("%4d", lEngineInfo.fuel_external) -- external fuel in kg - local lTotalFuel_9_3 = 0 - local lTotalFuel_5_0 = 0 - - if lTotalFuel < 9000 then - if lTotalFuel > 3000 then - --[[ - y_min = 0.0 -- minimaler Ausgabewert - y_max = 1.0 -- maximaler Ausgabewert - x_min = 3000 -- minimaler Eingangswert - x_max = 9000 -- maximaler Eingangswert - x = 8000 -- aktueller Eingangswert - - d_y = 1 -- Delta Ausgabewerte (y_max - y_min) - d_x = 6000 -- Delta Eingangswerte (x_max - x_min) - m = 1.66666666666666666666666666667e-4 -- Steigung der linearen Funktion (d_y / d_x) - n = -0,5 -- Schnittpunkt der Funktion mit y-Achse (y_max - m * x_max) - - y = 0.83333 -- Ergebnis (m * x + n) - ]] - lTotalFuel_9_3 = 1.6666666666666666666666666666667e-4 * lTotalFuel + -0.5 - else - lTotalFuel_9_3 = 0.0 - end - else - lTotalFuel_9_3 = 1.0 - end - if lTotalFuel < 5000 then - lTotalFuel_5_0 = lTotalFuel / 5000 - else - lTotalFuel_5_0 = 1.0 - end - - -- TotalFuel_5_0 - -- TotalFuel_9_3 - -- Light1 - -- Light2 - -- Light3 - -- Light4 - -- BingoLight - SendData("15", string.format("%0.4f;%0.4f;%d;%d;%d;%d;%d", - lTotalFuel_5_0, - lTotalFuel_9_3, - (lEngineInfo.fuel_internal < 5000.0 and 1 or 0), -- Tank warning 1 - (lEngineInfo.fuel_internal < 4000.0 and 1 or 0), -- Tank warning 2 - (lEngineInfo.fuel_internal < 1500.0 and 1 or 0), -- Tank warning 3 - (lEngineInfo.fuel_internal < 1000.0 and 1 or 0), -- Tank warning 4 - (lEngineInfo.fuel_internal < 600.0 and 1 or 0))) -- Bingo Fuel - - -- Hydraulic Pressure Left - FC_OneNeedleGauge(lEngineInfo.HydraulicPressure.left, 240, 17) - - -- Hydraulic Pressure Right - FC_OneNeedleGauge(lEngineInfo.HydraulicPressure.right, 240, 18) - end - - -- EKRAN Message - FC_EKRAN(16) - - -- Mechanical Configuration Indicator (GearWarningLight, NoseGear, LeftGear, RightGear, Airbreaks, Flaps1, Flaps2) {"%.1f;%d;%d;%d;%d;%d;%d"} - local lMechInfo = LoGetMechInfo() -- mechanical components, e.g. Flaps, Wheelbrakes,... - if lMechInfo ~= nil then - local lWarningLight = 0.0 - local lTrueAirSpeed = LoGetTrueAirSpeed() - if lTrueAirSpeed ~= nil then - lWarningLight = ((lMechInfo.flaps.value > 0.93 and lTrueAirSpeed > 340) and 1.0 or 0.0) -- Speed Warning for Flaps, same light as gear warning light, but blinking light - lWarningLight = (((lMechInfo.gear.status == 1 and lMechInfo.gear.value < 1) or (lMechInfo.gear.status == 0 and lMechInfo.gear.value > 0)) and 1.0 or lWarningLight ) -- gear warning light - end - -- WarningLight {0.0 = Off, 0.1 = blinking light, 0.2 = on} - -- WarningLight {0.0 = Off, no blinking light, 1.0 = on} - - -- left gear {0, 1} - -- right gear {0, 1} - -- nose gear {0, 1} - -- WarningLight - -- Flap - -- Intake FOD shields - -- Speedbreakes on {0, 1} - SendData("2", string.format("%.1f;%d;%d;%d;%d;%d;%d", - (lMechInfo.gear.value > 0.95 and 1 or 0), -- left gear - (lMechInfo.gear.value == 1 and 1 or 0), -- right gear - (lMechInfo.gear.value > 0.85 and 1 or 0), -- nose gear - lWarningLight, - (lMechInfo.flaps.value > 0.93 and 1 or 0), -- flap - (lMechInfo.gear.value > 0.5 and 1 or 0), -- Intake FOD shields - (lMechInfo.speedbrakes.value > 0.1 and 1 or 0))) -- speedbreakes on > 0.1 (0 - 1) - - -- Wheelbrakes Hydraulic Pressure Left - FC_OneNeedleGauge(lMechInfo.wheelbrakes.value, 240, 19) - - -- Wheelbrakes Hydraulic Pressure Right - FC_OneNeedleGauge(lMechInfo.wheelbrakes.value, 240, 20) - - --WriteToLog('lMechInfo.noseflap.value: '..dump(lMechInfo.noseflap.value)) -- Vorfluegel, Balkenanzeige neben dem Radarhoehenmesser (0=oben bis 30=unten) - end - - -- Airintake - FC_Russian_AirIntake(21) + -- Hydraulic Pressure Right + ExportScript.AF.FC_OneNeedleGauge(lEngineInfo.HydraulicPressure.right, 240, 86) end - - --(x < 0 and 'negative' or 'non-negative') - --[[ - local lPayloadInfo = LoGetPayloadInfo() - WriteToLog('lPayloadInfo: '..dump(lPayloadInfo)) - - local lSnares = LoGetSnares() -- Flare and Chaff - WriteToLog('lSnares: '..dump(lSnares)) - - local lSightingSystemInfo = LoGetSightingSystemInfo() - WriteToLog('lSightingSystemInfo: '..dump(lSightingSystemInfo)) - - local lTWSInfo = LoGetTWSInfo() -- SPO Informationen, z.B. Radarwarner F15C - WriteToLog('lTWSInfo: '..dump(lTWSInfo)) - - local lTargetInformation = LoGetTargetInformation() -- detalierte Radar Infos z.B. F15C - WriteToLog('lTargetInformation: '..dump(lTargetInformation)) - - local lLockedTargetInformation = LoGetLockedTargetInformation() - WriteToLog('lLockedTargetInformation: '..dump(lLockedTargetInformation)) - - local lF15_TWS_Contacs = LoGetF15_TWS_Contacts() -- the same information but only for F-15 in TWS mode - WriteToLog('lF15_TWS_Contacs: '..dump(lF15_TWS_Contacs)) - - local lMechInfo = LoGetMechInfo() -- mechanical components, e.g. Flaps, Wheelbrakes,... - WriteToLog('lMechInfo: '..dump(lMechInfo)) - - local lMCPState = LoGetMCPState() -- Warnlichter - WriteToLog('lMCPState: '..dump(lMCPState)) - - local lControlPanel_HSI = LoGetControlPanel_HSI() - WriteToLog('lControlPanel_HSI: '..dump(lControlPanel_HSI)) - - local lRadioBeaconsStatus = LoGetRadioBeaconsStatus() - WriteToLog('lRadioBeaconsStatus: '..dump(lRadioBeaconsStatus)) - - local lEngineInfo = LoGetEngineInfo() - WriteToLog('lEngineInfo: '..dump(lEngineInfo)) - ]] - -- Weapon Control System - --local lNameByType = LoGetNameByType () -- args 4 (number : level1,level2,level3,level4), result string - -- values from LoGetTargetInformation().type - --WriteToLog('lNameByType: '..dump(lNameByType)) + + -- Mechanical Configuration Indicator + ExportScript.AF.MechanicalDevicesIndicator(lFunctionTyp) + + local lMechInfo = LoGetMechInfo() -- mechanical components, e.g. Flaps, Wheelbrakes,... + if lMechInfo ~= nil then + -- Wheelbrakes Hydraulic Pressure Left + ExportScript.AF.FC_OneNeedleGauge(lMechInfo.wheelbrakes.value, 240, 87) + + -- Wheelbrakes Hydraulic Pressure Right + ExportScript.AF.FC_OneNeedleGauge(lMechInfo.wheelbrakes.value, 240, 88) + + --ExportScript.Tools.WriteToLog('lMechInfo.noseflap.value: '..ExportScript.Tools.dump(lMechInfo.noseflap.value)) -- Vorfluegel, Balkenanzeige neben dem Radarhoehenmesser (0=oben bis 30=unten) + end + + -- Airintake + ExportScript.AF.FC_Russian_AirIntake() + + --[[ + local lPayloadInfo = LoGetPayloadInfo() + ExportScript.Tools.WriteToLog('lPayloadInfo: '..ExportScript.Tools.dump(lPayloadInfo)) + + local lSnares = LoGetSnares() -- Flare and Chaff + ExportScript.Tools.WriteToLog('lSnares: '..ExportScript.Tools.dump(lSnares)) + + local lSightingSystemInfo = LoGetSightingSystemInfo() + ExportScript.Tools.WriteToLog('lSightingSystemInfo: '..ExportScript.Tools.dump(lSightingSystemInfo)) + + local lTWSInfo = LoGetTWSInfo() -- SPO Informationen, z.B. Radarwarner F15C + ExportScript.Tools.WriteToLog('lTWSInfo: '..ExportScript.Tools.dump(lTWSInfo)) + + local lTargetInformation = LoGetTargetInformation() -- detalierte Radar Infos z.B. F15C + ExportScript.Tools.WriteToLog('lTargetInformation: '..ExportScript.Tools.dump(lTargetInformation)) + + local lLockedTargetInformation = LoGetLockedTargetInformation() + ExportScript.Tools.WriteToLog('lLockedTargetInformation: '..ExportScript.Tools.dump(lLockedTargetInformation)) + + local lF15_TWS_Contacs = LoGetF15_TWS_Contacts() -- the same information but only for F-15 in TWS mode + ExportScript.Tools.WriteToLog('lF15_TWS_Contacs: '..ExportScript.Tools.dump(lF15_TWS_Contacs)) + + local lMechInfo = LoGetMechInfo() -- mechanical components, e.g. Flaps, Wheelbrakes,... + ExportScript.Tools.WriteToLog('lMechInfo: '..ExportScript.Tools.dump(lMechInfo)) + + local lMCPState = LoGetMCPState() -- Warnlichter + ExportScript.Tools.WriteToLog('lMCPState: '..ExportScript.Tools.dump(lMCPState)) + + local lControlPanel_HSI = LoGetControlPanel_HSI() + ExportScript.Tools.WriteToLog('lControlPanel_HSI: '..ExportScript.Tools.dump(lControlPanel_HSI)) + + local lRadioBeaconsStatus = LoGetRadioBeaconsStatus() + ExportScript.Tools.WriteToLog('lRadioBeaconsStatus: '..ExportScript.Tools.dump(lRadioBeaconsStatus)) + + local lEngineInfo = LoGetEngineInfo() + ExportScript.Tools.WriteToLog('lEngineInfo: '..ExportScript.Tools.dump(lEngineInfo)) + ]] + -- Weapon Control System + --local lNameByType = LoGetNameByType () -- args 4 (number : level1,level2,level3,level4), result string + -- values from LoGetTargetInformation().type + --ExportScript.Tools.WriteToLog('lNameByType: '..ExportScript.Tools.dump(lNameByType)) end -function ProcessHARDWAREConfigLowImportance(mainPanelDevice) --- where necessary, specify HardwareID, example WeaponStatusPanel(2) - WeaponStatusPanel() - MechanicalDevicesIndicator() - StatusLamp() - FuelQuantityIndicator() - SightingSystem() - SPO15RWR() - PPDSPPanel() +function ExportScript.ProcessDACConfigLowImportance() + local lFunctionTyp = "DAC" -- function type for shared function + + ExportScript.AF.FC_WeaponPanel_SU27(lFunctionTyp) + ExportScript.AF.FC_SPO15RWR(lFunctionTyp) + ExportScript.AF.MechanicalDevicesIndicator(lFunctionTyp) + ExportScript.AF.FuelQuantityIndicator(lFunctionTyp) + ExportScript.AF.StatusLamp() + ExportScript.AF.SightingSystem() + ExportScript.AF.PPDSPPanel() end ----------------------------- -- Custom functions -- ----------------------------- -function SightingSystem(hardware) - local lHardware = hardware or 1 +function ExportScript.AF.SightingSystem() local lSightingSystemInfo = LoGetSightingSystemInfo() if lSightingSystemInfo == nil then return end - --WriteToLog('lSightingSystemInfo: '..dump(lSightingSystemInfo)9 + --ExportScript.Tools.WriteToLog('lSightingSystemInfo: '..ExportScript.Tools.dump(lSightingSystemInfo)9 --[[ [PRF] = { [selection] = string: "ILV" @@ -395,54 +253,51 @@ function SightingSystem(hardware) } } ]] - SendDataHW("600", lSightingSystemInfo.ECM_on == true and 1 or 0, lHardware ) - SendDataHW("601", lSightingSystemInfo.laser_on == true and 1 or 0, lHardware ) - --SendDataHW("602", lSightingSystemInfo.optical_system_on == true and 1 or 0, lHardware ) - SendDataHW("603", lSightingSystemInfo.LaunchAuthorized == true and 1 or 0, lHardware ) - SendDataHW("604", lSightingSystemInfo.radar_on == true and 1 or 0, lHardware ) + ExportScript.Tools.SendDataDAC("600", lSightingSystemInfo.ECM_on == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("601", lSightingSystemInfo.laser_on == true and 1 or 0 ) + --ExportScript.Tools.SendDataDAC("602", lSightingSystemInfo.optical_system_on == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("603", lSightingSystemInfo.LaunchAuthorized == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("604", lSightingSystemInfo.radar_on == true and 1 or 0 ) end -function PPDSPPanel(hardware) - local lHardware = hardware or 1 +function ExportScript.AF.PPDSPPanel() local lSnares = LoGetSnares() -- Flare and Chaff if lSnares == nil then return end - --WriteToLog('lSnares: '..dump(lSnares)) - + --ExportScript.Tools.WriteToLog('lSnares: '..ExportScript.Tools.dump(lSnares)) + --[chaff] = number: "96" --[flare] = number: "96" - - local lChaffLED = math.round(lSnares.chaff / 12, 0, "ceil") + 1 - local lFlareLED = math.round(lSnares.flare / 12, 0, "ceil") + 1 - - SendDataHW("800", (lChaffLED <= 1 and 0 or 1), lHardware ) - SendDataHW("801", (lChaffLED <= 2 and 0 or 1), lHardware ) - SendDataHW("802", (lChaffLED <= 3 and 0 or 1), lHardware ) - SendDataHW("803", (lChaffLED <= 4 and 0 or 1), lHardware ) - SendDataHW("804", (lChaffLED <= 5 and 0 or 1), lHardware ) - SendDataHW("805", (lChaffLED <= 6 and 0 or 1), lHardware ) - SendDataHW("806", (lChaffLED <= 7 and 0 or 1), lHardware ) - SendDataHW("807", (lChaffLED <= 8 and 0 or 1), lHardware ) - - SendDataHW("810", (lFlareLED <= 1 and 0 or 1), lHardware ) - SendDataHW("811", (lFlareLED <= 2 and 0 or 1), lHardware ) - SendDataHW("812", (lFlareLED <= 3 and 0 or 1), lHardware ) - SendDataHW("813", (lFlareLED <= 4 and 0 or 1), lHardware ) - SendDataHW("814", (lFlareLED <= 5 and 0 or 1), lHardware ) - SendDataHW("815", (lFlareLED <= 6 and 0 or 1), lHardware ) - SendDataHW("816", (lFlareLED <= 7 and 0 or 1), lHardware ) - SendDataHW("817", (lFlareLED <= 8 and 0 or 1), lHardware ) - SendDataHW("817", (lFlareLED <= 8 and 0 or 1), lHardware ) + + local lChaffLED = ExportScript.Tools.round(lSnares.chaff / 12, 0, "ceil") + 1 + local lFlareLED = ExportScript.Tools.round(lSnares.flare / 12, 0, "ceil") + 1 + + ExportScript.Tools.SendDataDAC("800", (lChaffLED <= 1 and 0 or 1) ) + ExportScript.Tools.SendDataDAC("801", (lChaffLED <= 2 and 0 or 1) ) + ExportScript.Tools.SendDataDAC("802", (lChaffLED <= 3 and 0 or 1) ) + ExportScript.Tools.SendDataDAC("803", (lChaffLED <= 4 and 0 or 1) ) + ExportScript.Tools.SendDataDAC("804", (lChaffLED <= 5 and 0 or 1) ) + ExportScript.Tools.SendDataDAC("805", (lChaffLED <= 6 and 0 or 1) ) + ExportScript.Tools.SendDataDAC("806", (lChaffLED <= 7 and 0 or 1) ) + ExportScript.Tools.SendDataDAC("807", (lChaffLED <= 8 and 0 or 1) ) + + ExportScript.Tools.SendDataDAC("810", (lFlareLED <= 1 and 0 or 1) ) + ExportScript.Tools.SendDataDAC("811", (lFlareLED <= 2 and 0 or 1) ) + ExportScript.Tools.SendDataDAC("812", (lFlareLED <= 3 and 0 or 1) ) + ExportScript.Tools.SendDataDAC("813", (lFlareLED <= 4 and 0 or 1) ) + ExportScript.Tools.SendDataDAC("814", (lFlareLED <= 5 and 0 or 1) ) + ExportScript.Tools.SendDataDAC("815", (lFlareLED <= 6 and 0 or 1) ) + ExportScript.Tools.SendDataDAC("816", (lFlareLED <= 7 and 0 or 1) ) + ExportScript.Tools.SendDataDAC("817", (lFlareLED <= 8 and 0 or 1) ) end -function StatusLamp(hardware) - local lHardware = hardware or 1 +function ExportScript.AF.StatusLamp() local lMCPState = LoGetMCPState() -- Warning Lights if lMCPState == nil then return end - --WriteToLog('lMCPState: '..dump(lMCPState)) + --ExportScript.Tools.WriteToLog('lMCPState: '..ExportScript.Tools.dump(lMCPState)) --[[ [RightTailPlaneFailure] = boolean: "false" [EOSFailure] = boolean: "false" @@ -473,271 +328,62 @@ function StatusLamp(hardware) [AutopilotOn] = boolean: "false" [LeftTailPlaneFailure] = boolean: "false" ]] - - SendDataHW("700", lMCPState.LeftTailPlaneFailure == true and 1 or 0, lHardware ) - SendDataHW("701", lMCPState.RightTailPlaneFailure == true and 1 or 0, lHardware ) - SendDataHW("702", lMCPState.MasterWarning == true and 1 or 0, lHardware ) - SendDataHW("703", lMCPState.LeftEngineFailure == true and 1 or 0, lHardware ) - SendDataHW("704", lMCPState.RightEngineFailure == true and 1 or 0, lHardware ) - SendDataHW("705", lMCPState.LeftAileronFailure == true and 1 or 0, lHardware ) - SendDataHW("706", lMCPState.RightAileronFailure == true and 1 or 0, lHardware ) - SendDataHW("707", lMCPState.LeftMainPumpFailure == true and 1 or 0, lHardware ) - SendDataHW("708", lMCPState.RightMainPumpFailure == true and 1 or 0, lHardware ) - SendDataHW("709", lMCPState.LeftWingPumpFailure == true and 1 or 0, lHardware ) - SendDataHW("710", lMCPState.RightWingPumpFailure == true and 1 or 0, lHardware ) - SendDataHW("711", lMCPState.EOSFailure == true and 1 or 0, lHardware ) - SendDataHW("712", lMCPState.ECMFailure == true and 1 or 0, lHardware ) - SendDataHW("713", lMCPState.CannonFailure == true and 1 or 0, lHardware ) - SendDataHW("714", lMCPState.MLWSFailure == true and 1 or 0, lHardware ) - SendDataHW("715", lMCPState.ACSFailure == true and 1 or 0, lHardware ) - SendDataHW("716", lMCPState.RadarFailure == true and 1 or 0, lHardware ) - SendDataHW("717", lMCPState.HelmetFailure == true and 1 or 0, lHardware ) - SendDataHW("718", lMCPState.HUDFailure == true and 1 or 0, lHardware ) - SendDataHW("719", lMCPState.MFDFailure == true and 1 or 0, lHardware ) - SendDataHW("720", lMCPState.RWSFailure == true and 1 or 0, lHardware ) - SendDataHW("721", lMCPState.GearFailure == true and 1 or 0, lHardware ) - SendDataHW("722", lMCPState.HydraulicsFailure == true and 1 or 0, lHardware ) - SendDataHW("723", lMCPState.AutopilotFailure == true and 1 or 0, lHardware ) - SendDataHW("724", lMCPState.FuelTankDamage == true and 1 or 0, lHardware ) - SendDataHW("725", lMCPState.CanopyOpen == true and 1 or 0, lHardware ) - SendDataHW("726", lMCPState.StallSignalization == true and 1 or 0, lHardware ) - SendDataHW("727", lMCPState.AutopilotOn == true and 1 or 0, lHardware ) - + + ExportScript.Tools.SendDataDAC("700", lMCPState.LeftTailPlaneFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("701", lMCPState.RightTailPlaneFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("702", lMCPState.MasterWarning == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("703", lMCPState.LeftEngineFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("704", lMCPState.RightEngineFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("705", lMCPState.LeftAileronFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("706", lMCPState.RightAileronFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("707", lMCPState.LeftMainPumpFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("708", lMCPState.RightMainPumpFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("709", lMCPState.LeftWingPumpFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("710", lMCPState.RightWingPumpFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("711", lMCPState.EOSFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("712", lMCPState.ECMFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("713", lMCPState.CannonFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("714", lMCPState.MLWSFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("715", lMCPState.ACSFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("716", lMCPState.RadarFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("717", lMCPState.HelmetFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("718", lMCPState.HUDFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("719", lMCPState.MFDFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("720", lMCPState.RWSFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("721", lMCPState.GearFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("722", lMCPState.HydraulicsFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("723", lMCPState.AutopilotFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("724", lMCPState.FuelTankDamage == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("725", lMCPState.CanopyOpen == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("726", lMCPState.StallSignalization == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("727", lMCPState.AutopilotOn == true and 1 or 0 ) + local lEngineInfo = LoGetEngineInfo() if lEngineInfo ~= nil then - --WriteToLog('lEngineInfo: '..dump(lEngineInfo)) + --ExportScript.Tools.WriteToLog('lEngineInfo: '..ExportScript.Tools.dump(lEngineInfo)) - SendDataHW("728", lEngineInfo.EngineStart.left, lHardware ) -- lamp start left engine 1 (0|1) - SendDataHW("729", lEngineInfo.EngineStart.right, lHardware ) -- lamp start right engine 1 (0|1) + ExportScript.Tools.SendDataDAC("728", lEngineInfo.EngineStart.left ) -- lamp start left engine 1 (0|1) + ExportScript.Tools.SendDataDAC("729", lEngineInfo.EngineStart.right ) -- lamp start right engine 1 (0|1) - SendDataHW("730", (lEngineInfo.RPM.left > 99.95 and 1 or 0), lHardware ) -- lamp after burner left engine - SendDataHW("731", (lEngineInfo.RPM.right > 99.95 and 1 or 0), lHardware ) -- lam after burner right engine + ExportScript.Tools.SendDataDAC("730", (lEngineInfo.RPM.left > 99.95 and 1 or 0) ) -- lamp after burner left engine + ExportScript.Tools.SendDataDAC("731", (lEngineInfo.RPM.right > 99.95 and 1 or 0) ) -- lam after burner right engine end local lAccelerationUnits = LoGetAccelerationUnits() if lAccelerationUnits ~= nil then - --WriteToLog('lAccelerationUnits: '..dump(lAccelerationUnits)) - SendDataHW("732", (lAccelerationUnits.y > 8.0 and 1 or 0), lHardware ) -- lamp Over-G warning + --ExportScript.Tools.WriteToLog('lAccelerationUnits: '..ExportScript.Tools.dump(lAccelerationUnits)) + ExportScript.Tools.SendDataDAC("732", (lAccelerationUnits.y > 8.0 and 1 or 0) ) -- lamp Over-G warning end end -function WeaponStatusPanel(hardware) --- The weapon status panel, quantity and readiness of the currently selected weapon and the remaining gun ammunition are indicated. - local lHardware = hardware or 1 - gES_PayloadInfo = LoGetPayloadInfo() - if gES_PayloadInfo == nil then - return - end - --WriteToLog('gES_PayloadInfo: '..dump(gES_PayloadInfo)) - --[[ exsample - [Stations] = { - [1] = { - [CLSID] = string: "{FBC29BFE-3D24-4C64-B81D-941239D12249}" - [container] = boolean: "false" - [count] = number: "1" - [weapon] = { - [level3] = number: "7" - [level1] = number: "4" - [level4] = number: "18" - [level2] = number: "4" - } - } - [2] = { - [CLSID] = string: "{FBC29BFE-3D24-4C64-B81D-941239D12249}" - [container] = boolean: "false" - [count] = number: "1" - [weapon] = { - [level3] = number: "7" - [level1] = number: "4" - [level4] = number: "18" - [level2] = number: "4" - } - } - [3] = { - [CLSID] = string: "{FBC29BFE-3D24-4C64-B81D-941239D12249}" - [container] = boolean: "false" - [count] = number: "1" - [weapon] = { - [level3] = number: "7" - [level1] = number: "4" - [level4] = number: "18" - [level2] = number: "4" - } - } - [4] = { - [CLSID] = string: "{FBC29BFE-3D24-4C64-B81D-941239D12249}" - [container] = boolean: "false" - [count] = number: "1" - [weapon] = { - [level3] = number: "7" - [level1] = number: "4" - [level4] = number: "18" - [level2] = number: "4" - } - } - [5] = { - [wstype] = { - [level3] = number: "32" - [level1] = number: "4" - [level4] = number: "6" - [level2] = number: "7" - } - [count] = number: "20" - [CLSID] = string: "{F72F47E5-C83A-4B85-96ED-D3E46671EE9A}" - [adapter] = { - [level3] = number: "0" - [level1] = number: "0" - [level4] = number: "0" - [level2] = number: "0" - } - [container] = boolean: "true" - [weapon] = { - [level3] = number: "33" - [level1] = number: "4" - [level4] = number: "32" - [level2] = number: "7" - } - } - [6] = { - [wstype] = { - [level3] = number: "32" - [level1] = number: "4" - [level4] = number: "6" - [level2] = number: "7" - } - [count] = number: "20" - [CLSID] = string: "{F72F47E5-C83A-4B85-96ED-D3E46671EE9A}" - [adapter] = { - [level3] = number: "0" - [level1] = number: "0" - [level4] = number: "0" - [level2] = number: "0" - } - [container] = boolean: "true" - [weapon] = { - [level3] = number: "33" - [level1] = number: "4" - [level4] = number: "32" - [level2] = number: "7" - } - } - [7] = { - [CLSID] = string: "{4203753F-8198-4E85-9924-6F8FF679F9FF}" - [container] = boolean: "false" - [count] = number: "1" - [weapon] = { - [level3] = number: "38" - [level1] = number: "4" - [level4] = number: "18" - [level2] = number: "5" - } - } - [8] = { - [CLSID] = string: "{4203753F-8198-4E85-9924-6F8FF679F9FF}" - [container] = boolean: "false" - [count] = number: "1" - [weapon] = { - [level3] = number: "38" - [level1] = number: "4" - [level4] = number: "18" - [level2] = number: "5" - } - } - [9] = { - [CLSID] = string: "{7AEC222D-C523-425e-B714-719C0D1EB14D}" - [container] = boolean: "false" - [count] = number: "1" - [weapon] = { - [level3] = number: "38" - [level1] = number: "4" - [level4] = number: "91" - [level2] = number: "5" - } - } - [10] = { - [CLSID] = string: "{7AEC222D-C523-425e-B714-719C0D1EB14D}" - [container] = boolean: "false" - [count] = number: "1" - [weapon] = { - [level3] = number: "38" - [level1] = number: "4" - [level4] = number: "91" - [level2] = number: "5" - } - } - } - [CurrentStation] = number: "0" - [Cannon] = { - [shells] = number: "250" - } - ]] - --[[ - Weapon Panel - | - ------------------------------------------- - | | | | | | | | | | - 1 2 3 4 5 6 7 8 9 10 -- Panel ID - 2 4 5 7 10 9 8 6 3 1 -- gES_PayloadInfo.Station.ID - ]] - -- Payload Info - -- weapon stations (panel) 1 (left) - 10 (right), no lamp for center station - SendDataHW("100", gES_PayloadInfo.Cannon.shells, lHardware ) -- count cannon shells - SendDataHW("110", (gES_PayloadInfo.Stations[1].count > 0 and 1 or 0), lHardware ) -- weapon presend > 0 (panel 1) - SendDataHW("101", (gES_PayloadInfo.Stations[2].count > 0 and 1 or 0), lHardware ) -- weapon presend > 0 (panel 10) - SendDataHW("109", (gES_PayloadInfo.Stations[3].count > 0 and 1 or 0), lHardware ) -- weapon presend > 0 (panel 2) - SendDataHW("102", (gES_PayloadInfo.Stations[4].count > 0 and 1 or 0), lHardware ) -- weapon presend > 0 (panel 9) - SendDataHW("103", (gES_PayloadInfo.Stations[5].count > 0 and 1 or 0), lHardware ) -- weapon presend > 0 (panel 3) - SendDataHW("108", (gES_PayloadInfo.Stations[6].count > 0 and 1 or 0), lHardware ) -- weapon presend > 0 (panel 8) - SendDataHW("104", (gES_PayloadInfo.Stations[7].count > 0 and 1 or 0), lHardware ) -- weapon presend > 0 (panel 4) - SendDataHW("107", (gES_PayloadInfo.Stations[8].count > 0 and 1 or 0), lHardware ) -- weapon presend > 0 (panel 7) - SendDataHW("106", (gES_PayloadInfo.Stations[9].count > 0 and 1 or 0), lHardware ) -- weapon presend > 0 (panel 5) - SendDataHW("105", (gES_PayloadInfo.Stations[10].count > 0 and 1 or 0), lHardware ) -- weapon presend > 0 (panel 6) - --SendDataHW("CurrentStation", gES_PayloadInfo.CurrentStation, lHardware ) - -- air-to-air missils panel 1 and 11, air combat modus, CurrentStation = 1, panel 1 and 11 on - - -- wenn die Waffenstationen gleichmässig belegt sind, hat bei Auswahl CurrentStation immer den Wert der linken Station - -- bei ungleichmäßiger Belegung, hat CurrentStation immer den Wert der jeweiligen Station - -- Waffenbezeichnung als UUID, gES_PayloadInfo.Stations[X].CLSID - - -- defination - if gES_CurrentStationTmp == nil then - gES_CurrentStationTmp = -1 - end - - if gES_PayloadInfo.CurrentStation > 0 and - gES_CurrentStationTmp ~= gES_PayloadInfo.CurrentStation then - gES_CurrentStationTmp = gES_PayloadInfo.CurrentStation - - gES_TmpStationToPanel = {} - gES_TmpStationToPanel[1] = {Panel = 10, StationID = 110, CurrentID = 210, HardwareID = lHardware } - gES_TmpStationToPanel[2] = {Panel = 1, StationID = 101, CurrentID = 201, HardwareID = lHardware } - gES_TmpStationToPanel[3] = {Panel = 9, StationID = 109, CurrentID = 209, HardwareID = lHardware } - gES_TmpStationToPanel[4] = {Panel = 2, StationID = 102, CurrentID = 202, HardwareID = lHardware } - gES_TmpStationToPanel[5] = {Panel = 3, StationID = 103, CurrentID = 203, HardwareID = lHardware } - gES_TmpStationToPanel[6] = {Panel = 8, StationID = 108, CurrentID = 208, HardwareID = lHardware } - gES_TmpStationToPanel[7] = {Panel = 4, StationID = 104, CurrentID = 204, HardwareID = lHardware } - gES_TmpStationToPanel[8] = {Panel = 7, StationID = 107, CurrentID = 207, HardwareID = lHardware } - gES_TmpStationToPanel[9] = {Panel = 6, StationID = 106, CurrentID = 206, HardwareID = lHardware } - gES_TmpStationToPanel[10] = {Panel = 5, StationID = 105, CurrentID = 205, HardwareID = lHardware } - - WeaponStatusPanel_Reset(201, 210, lHardware) - - if gES_TmpStationToPanel[gES_PayloadInfo.CurrentStation] ~= nil then - SendDataHW(gES_TmpStationToPanel[gES_PayloadInfo.CurrentStation].CurrentID, 1, lHardware ) -- eigentliche Auswahl - - table.foreach(gES_PayloadInfo.Stations, WeaponStatusPanel_selectCurrentPayloadStation) -- zugehörige Stationen - end - end -end - -function FuelQuantityIndicator(hardware) +function ExportScript.AF.FuelQuantityIndicator(FunctionTyp) + local lFunctionTyp = FunctionTyp or "Ikarus" -- Fuel quantity shows the fuel remaining in all tanks - local lHardware = hardware or 1 local lEngineInfo = LoGetEngineInfo() if lEngineInfo == nil then return end - --WriteToLog('lEngineInfo: '..dump(lEngineInfo)) + --ExportScript.Tools.WriteToLog('lEngineInfo: '..ExportScript.Tools.dump(lEngineInfo)) --[[ [fuel_external] = number: "0" [Temperature] = { @@ -763,22 +409,73 @@ function FuelQuantityIndicator(hardware) } lPayloadInfo.Stations[8].CLSID == E8D4652F-FD48-45B7-BA5B-2AE05BB5A9CF -- ext 800l Fuel Tank ]] + + if ExportScript.Config.DACExport and lFunctionTyp == "DAC" then + ExportScript.Tools.SendDataDAC("300", string.format("%d", ExportScript.Tools.round((lEngineInfo.fuel_internal / 10), 0, "ceil") * 10) ) -- total fuel in kg + --ExportScript.Tools.SendDataDAC("301", string.format("%d", lEngineInfo.fuel_internal)) -- total fuel in kg + --ExportScript.Tools.SendDataDAC("302", string.format("%d", lEngineInfo.fuel_external)) -- external fuel in kg - SendDataHW("300", string.format("%d", math.round((lEngineInfo.fuel_internal / 10), 0, "ceil") * 10), lHardware ) -- total fuel in kg - --SendDataHW("301", string.format("%d", lEngineInfo.fuel_internal)) -- total fuel in kg - --SendDataHW("302", string.format("%d", lEngineInfo.fuel_external)) -- external fuel in kg + ExportScript.Tools.SendDataDAC("304", (lEngineInfo.fuel_internal < 5000.0 and 1 or 0) ) -- Tank warning 1 + ExportScript.Tools.SendDataDAC("305", (lEngineInfo.fuel_internal < 4000.0 and 1 or 0) ) -- Tank warning 2 + ExportScript.Tools.SendDataDAC("306", (lEngineInfo.fuel_internal < 1500.0 and 1 or 0) ) -- Tank warning 3 + ExportScript.Tools.SendDataDAC("307", (lEngineInfo.fuel_internal < 1000.0 and 1 or 0) ) -- Tank warning 4 + ExportScript.Tools.SendDataDAC("308", (lEngineInfo.fuel_internal < 600.0 and 1 or 0) ) -- Bingo Fuel + end + + if ExportScript.Config.IkarusExport and lFunctionTyp == "Ikarus" then + local lTotalFuel_9_3 = 0 + local lTotalFuel_5_0 = 0 + local lTotalFuel = lEngineInfo.fuel_internal - SendDataHW("304", (lEngineInfo.fuel_internal < 5000.0 and 1 or 0), lHardware ) -- Tank warning 1 - SendDataHW("305", (lEngineInfo.fuel_internal < 4000.0 and 1 or 0), lHardware ) -- Tank warning 2 - SendDataHW("306", (lEngineInfo.fuel_internal < 1500.0 and 1 or 0), lHardware ) -- Tank warning 3 - SendDataHW("307", (lEngineInfo.fuel_internal < 1000.0 and 1 or 0), lHardware ) -- Tank warning 4 - SendDataHW("308", (lEngineInfo.fuel_internal < 600.0 and 1 or 0), lHardware ) -- Bingo Fuel - + if lTotalFuel < 9000 then + if lTotalFuel > 3000 then + --[[ + y_min = 0.0 -- minimaler Ausgabewert + y_max = 1.0 -- maximaler Ausgabewert + x_min = 3000 -- minimaler Eingangswert + x_max = 9000 -- maximaler Eingangswert + x = 8000 -- aktueller Eingangswert + + d_y = 1 -- Delta Ausgabewerte (y_max - y_min) + d_x = 6000 -- Delta Eingangswerte (x_max - x_min) + m = 1.66666666666666666666666666667e-4 -- Steigung der linearen Funktion (d_y / d_x) + n = -0,5 -- Schnittpunkt der Funktion mit y-Achse (y_max - m * x_max) + + y = 0.83333 -- Ergebnis (m * x + n) + ]] + lTotalFuel_9_3 = 1.6666666666666666666666666666667e-4 * lTotalFuel + -0.5 + else + lTotalFuel_9_3 = 0.0 + end + else + lTotalFuel_9_3 = 1.0 + end + if lTotalFuel < 5000 then + lTotalFuel_5_0 = lTotalFuel / 5000 + else + lTotalFuel_5_0 = 1.0 + end + + -- TotalFuel_5_0 + -- TotalFuel_9_3 + -- Light1 + -- Light2 + -- Light3 + -- Light4 + -- BingoLight + ExportScript.Tools.SendData(300, lTotalFuel_5_0) + ExportScript.Tools.SendData(301, lTotalFuel_9_3) + ExportScript.Tools.SendData(302, (lEngineInfo.fuel_internal < 5000.0 and 1 or 0)) -- Tank warning 1 + ExportScript.Tools.SendData(303, (lEngineInfo.fuel_internal < 4000.0 and 1 or 0)) -- Tank warning 2 + ExportScript.Tools.SendData(304, (lEngineInfo.fuel_internal < 1500.0 and 1 or 0)) -- Tank warning 3 + ExportScript.Tools.SendData(305, (lEngineInfo.fuel_internal < 1000.0 and 1 or 0)) -- Tank warning 4 + ExportScript.Tools.SendData(306, (lEngineInfo.fuel_internal < 600.0 and 1 or 0)) -- Bingo Fuel + end end -function MechanicalDevicesIndicator(hardware) +function ExportScript.AF.MechanicalDevicesIndicator(FunctionTyp) + local lFunctionTyp = FunctionTyp or "Ikarus" -- The mechanical devices indicator shows the position of the landing gear, flaps, leading edge flaps and airbrake - local lHardware = hardware or 1 local lMechInfo = LoGetMechInfo() -- mechanical components, e.g. Flaps, Wheelbrakes,... if lMechInfo == nil then return @@ -853,32 +550,184 @@ function MechanicalDevicesIndicator(hardware) [status] = number: "0" [value] = number: "0" }]] - --SendDataHW("500", lMechInfo.gear.status ) - --SendDataHW("501", lMechInfo.gear.value ) - --SendDataHW("502", lMechInfo.gear.nose.rod ) -- zeigt an wie weit das Fahrwerk einsackt wenn das Flugzeug auf dem Boden ist - --SendDataHW("503", lMechInfo.gear.main.left.rod ) -- zeigt an wie weit das Fahrwerk einsackt wenn das Flugzeug auf dem Boden ist - --SendDataHW("504", lMechInfo.gear.main.right.rod ) -- zeigt an wie weit das Fahrwerk einsackt wenn das Flugzeug auf dem Boden ist - --SendDataHW("500", ((lMechInfo.gear.status == 1 and lMechInfo.gear.value < 1) and 1 or 0 ) ) -- gear warning light, go up - --SendDataHW("500", ((lMechInfo.gear.status == 0 and lMechInfo.gear.value > 0) and 1 or 0 ) ) -- gear warning light, go down - SendDataHW("500", (((lMechInfo.gear.status == 1 and lMechInfo.gear.value < 1) or (lMechInfo.gear.status == 0 and lMechInfo.gear.value > 0)) and 1 or 0 ), lHardware ) -- gear warning light - SendDataHW("501", (lMechInfo.gear.value > 0.85 and 1 or 0), lHardware ) -- nose gear - SendDataHW("502", (lMechInfo.gear.value > 0.95 and 1 or 0), lHardware ) -- left gear - SendDataHW("503", (lMechInfo.gear.value > 0.97 and 1 or 0), lHardware ) -- right gear - - --SendDataHW("510", lMechInfo.speedbrakes.status ) -- speedbreakes on 1 (0|1) - SendDataHW("510", (lMechInfo.speedbrakes.value > 0.1 and 1 or 0), lHardware ) -- speedbreakes on > 0.1 (0 - 1) + local lTrueAirSpeed = LoGetTrueAirSpeed() + + if ExportScript.Config.DACExport and lFunctionTyp == "DAC" then + ExportScript.Tools.SendDataDAC("500", (((lMechInfo.gear.status == 1 and lMechInfo.gear.value < 1) or (lMechInfo.gear.status == 0 and lMechInfo.gear.value > 0)) and 1 or 0 ) ) -- gear warning light + ExportScript.Tools.SendDataDAC("501", (lMechInfo.gear.value > 0.85 and 1 or 0) ) -- nose gear + ExportScript.Tools.SendDataDAC("502", (lMechInfo.gear.value > 0.95 and 1 or 0) ) -- left gear + ExportScript.Tools.SendDataDAC("503", (lMechInfo.gear.value > 0.97 and 1 or 0) ) -- right gear - --SendDataHW("520", lMechInfo.wheelbrakes.status, lHardware ) -- not in use - --SendDataHW("521", lMechInfo.wheelbrakes.value, lHardware ) -- not in use + ExportScript.Tools.SendDataDAC("510", (lMechInfo.speedbrakes.value > 0.1 and 1 or 0) ) -- speedbreakes on > 0.1 (0 - 1) - local lGetTrueAirSpeed = LoGetTrueAirSpeed() - --SendDataHW("530", lMechInfo.flaps.status ) -- flap switch off 0, 1. position 1, 2. position 2 (0|1|2) - --SendDataHW("531", lMechInfo.flaps.value ) -- flap 1. position > 0.25, 2. position > 0.93 (0 - 1) - SendDataHW("531", (lMechInfo.flaps.value > 0.25 and 1 or 0), lHardware ) -- flap 1. position - SendDataHW("532", (lMechInfo.flaps.value > 0.93 and 1 or 0), lHardware ) -- flap 2. position - SendDataHW("533", ((lMechInfo.flaps.value > 0.93 and lGetTrueAirSpeed > 340) and 1 or 0), lHardware ) -- Speed Warning for Flaps, same light as gear warning light, but blinking light - SendDataHW("534", (lMechInfo.gear.value > 0.5 and 1 or 0), lHardware ) -- Intake FOD shields + ExportScript.Tools.SendDataDAC("531", (lMechInfo.flaps.value > 0.25 and 1 or 0) ) -- Intake FOD shields + ExportScript.Tools.SendDataDAC("532", (lMechInfo.flaps.value > 0.93 and 1 or 0) ) -- flap + ExportScript.Tools.SendDataDAC("533", ((lMechInfo.flaps.value > 0.93 and lTrueAirSpeed > 340) and 1 or 0) ) -- Speed Warning for Flaps, same light as gear warning light, but blinking light + ExportScript.Tools.SendDataDAC("534", (lMechInfo.gear.value > 0.5 and 1 or 0) ) -- Intake FOD shields + + ExportScript.Tools.SendDataDAC("541", (lMechInfo.parachute.value < 0.5 and 1 or 0) ) + end + + if ExportScript.Config.IkarusExport and lFunctionTyp == "Ikarus" then + local lWarningLight = 0.0 - --SendDataHW("540", lMechInfo.parachute.status ) - SendDataHW("541", (lMechInfo.parachute.value < 0.5 and 1 or 0), lHardware ) + if lTrueAirSpeed ~= nil then + lWarningLight = ((lMechInfo.flaps.value > 0.93 and lTrueAirSpeed > 340) and 1.0 or 0.0) -- Speed Warning for Flaps, same light as gear warning light, but blinking light + lWarningLight = (((lMechInfo.gear.status == 1 and lMechInfo.gear.value < 1) or (lMechInfo.gear.status == 0 and lMechInfo.gear.value > 0)) and 1.0 or lWarningLight ) -- gear warning light + end + + ExportScript.Tools.SendData(500, string.format("%.1f", lWarningLight)) + ExportScript.Tools.SendData(501, (lMechInfo.gear.value > 0.85 and 1 or 0)) -- nose gear + ExportScript.Tools.SendData(502, (lMechInfo.gear.value > 0.95 and 1 or 0)) -- left gear + ExportScript.Tools.SendData(503, (lMechInfo.gear.value == 1 and 1 or 0)) -- right gear + ExportScript.Tools.SendData(510, (lMechInfo.speedbrakes.value > 0.1 and 1 or 0)) -- speedbreakes on > 0.1 (0 - 1) + ExportScript.Tools.SendData(531, (lMechInfo.gear.value > 0.5 and 1 or 0)) -- Intake FOD shields + ExportScript.Tools.SendData(532, (lMechInfo.flaps.value > 0.93 and 1 or 0)) -- flap + end +end + +function ExportScript.AF.FC_WeaponPanel_SU27(FunctionTyp) + local lFunctionTyp = FunctionTyp or "Ikarus" + + if ExportScript.AF.TmpWeaponPanelPresend == nil then + ExportScript.AF.TmpWeaponPanelPresend = {[101] = 0, [102] = 0, [103] = 0, [104] = 0, [105] = 0, [106] = 0, [107] = 0, [108] = 0, [109] = 0, [110] = 0} + end + + if ExportScript.AF.TmpWeaponPanelActive == nil then + ExportScript.AF.TmpWeaponPanelActive = {[201] = 0, [202] = 0, [203] = 0, [204] = 0, [205] = 0, [206] = 0, [207] = 0, [208] = 0, [209] = 0, [210] = 0} + end + + if ExportScript.AF.TmpWeaponPanel == nil then + ExportScript.AF.TmpWeaponPanel = {[231] = 0, [232] = 0, [233] = 0, [234] = 0, [235] = 0} + end + + if ExportScript.AF.EventNumberFC_WeaponPanel == nil then + ExportScript.AF.EventNumberFC_WeaponPanel = 0 + end + + if(ExportScript.AF.EventNumberFC_WeaponPanel < ExportScript.AF.EventNumber) then + ExportScript.AF.EventNumberFC_WeaponPanel = ExportScript.AF.EventNumber + + -- defination + ExportScript.AF.PayloadInfo = LoGetPayloadInfo() + if ExportScript.AF.PayloadInfo ~= nil then + if ExportScript.AF.CurrentStationTmp == nil then + ExportScript.AF.CurrentStationTmp = -1 + end + + if ExportScript.AF.PayloadInfo.CurrentStation > 0 and + ExportScript.AF.CurrentStationTmp ~= ExportScript.AF.PayloadInfo.CurrentStation then + ExportScript.AF.CurrentStationTmp = ExportScript.AF.PayloadInfo.CurrentStation + + ExportScript.AF.TmpStationToPanel = {} + ExportScript.AF.TmpStationToPanel[1] = {Panel = 1, StationID = 101, CurrentID = 201 } -- left + ExportScript.AF.TmpStationToPanel[2] = {Panel = 10, StationID = 110, CurrentID = 210 } -- right + ExportScript.AF.TmpStationToPanel[3] = {Panel = 2, StationID = 102, CurrentID = 202 } + ExportScript.AF.TmpStationToPanel[4] = {Panel = 9, StationID = 109, CurrentID = 209 } + ExportScript.AF.TmpStationToPanel[5] = {Panel = 3, StationID = 103, CurrentID = 203 } + ExportScript.AF.TmpStationToPanel[6] = {Panel = 8, StationID = 108, CurrentID = 208 } + ExportScript.AF.TmpStationToPanel[7] = {Panel = 4, StationID = 104, CurrentID = 204 } + ExportScript.AF.TmpStationToPanel[8] = {Panel = 7, StationID = 107, CurrentID = 207 } + ExportScript.AF.TmpStationToPanel[9] = {Panel = 5, StationID = 105, CurrentID = 205 } + ExportScript.AF.TmpStationToPanel[10] = {Panel = 6, StationID = 106, CurrentID = 206 } + + -- ExportScript.AF.TmpWeaponPanelActive reset + for i = 201, 210, 1 do + ExportScript.AF.TmpWeaponPanelActive[i] = 0 + end + + if ExportScript.AF.TmpStationToPanel[ExportScript.AF.PayloadInfo.CurrentStation] ~= nil then + ExportScript.AF.TmpWeaponPanelActive[ExportScript.AF.TmpStationToPanel[ExportScript.AF.PayloadInfo.CurrentStation].CurrentID] = 1 -- currrent value + + table.foreach(ExportScript.AF.PayloadInfo.Stations, ExportScript.AF.WeaponStatusPanel_selectCurrentPayloadStation) -- corresponding station + end + end + + local lWeaponType = 0.0 -- transversely striped + if ExportScript.AF.PayloadInfo.CurrentStation > 0 then + if ExportScript.AF.PayloadInfo.Stations[ExportScript.AF.PayloadInfo.CurrentStation].weapon.level1 == 4 then + if ExportScript.AF.PayloadInfo.Stations[ExportScript.AF.PayloadInfo.CurrentStation].weapon.level2 == 4 then -- Weapon type Missle + lWeaponType = 0.1 -- MSL + elseif ExportScript.AF.PayloadInfo.Stations[ExportScript.AF.PayloadInfo.CurrentStation].weapon.level2 == 7 then -- Weapon type NURS with Container + if ExportScript.AF.PayloadInfo.Stations[ExportScript.AF.PayloadInfo.CurrentStation].weapon.level3 == 33 then -- Weapon type Rocket + lWeaponType = 0.2 -- RCT + end + elseif ExportScript.AF.PayloadInfo.Stations[ExportScript.AF.PayloadInfo.CurrentStation].weapon.level2 == 5 then -- Weapon type Bomb + lWeaponType = 0.3 -- BB + end + end + end + + --[[ + Weapon Panel + | + --------------------------------------------------- + | | | | | | | | | | | + 1 2 3 4 5 C 6 7 8 9 10 -- display + 1 3 5 7 9 10 8 6 4 2 -- Paylod ID + ]] + -- Payload Info + -- weapon stations (panel) 1 (left) - 10 (right), no lamp for center station + + -- WeaponPresend1 {0, 1} + -- WeaponPresend2 {0, 1} + -- WeaponPresend3 {0, 1} + -- WeaponPresend4 {0, 1} + -- WeaponPresend5 {0, 1} + -- WeaponPresend6 {0, 1} + -- WeaponPresend7 {0, 1} + -- WeaponPresend8 {0, 1} + -- WeaponPresend9 {0, 1} + -- WeaponPresend10 {0, 1} + -- WeaponActive1 {0, 1} + -- WeaponActive2 {0, 1} + -- WeaponActive3 {0, 1} + -- WeaponActive4 {0, 1} + -- WeaponActive5 {0, 1} + -- WeaponActive6 {0, 1} + -- WeaponActive7 {0, 1} + -- WeaponActive8 {0, 1} + -- WeaponActive9 {0, 1} + -- WeaponActive10 {0, 1} + + ExportScript.AF.TmpWeaponPanelPresend[101] = (ExportScript.AF.PayloadInfo.Stations[1].count > 0 and 1 or 0) -- weapon presend panel 1 + ExportScript.AF.TmpWeaponPanelPresend[102] = (ExportScript.AF.PayloadInfo.Stations[3].count > 0 and 1 or 0) -- weapon presend panel 2 + ExportScript.AF.TmpWeaponPanelPresend[103] = (ExportScript.AF.PayloadInfo.Stations[5].count > 0 and 1 or 0) -- weapon presend panel 3 + ExportScript.AF.TmpWeaponPanelPresend[104] = (ExportScript.AF.PayloadInfo.Stations[7].count > 0 and 1 or 0) -- weapon presend panel 4 + ExportScript.AF.TmpWeaponPanelPresend[105] = (ExportScript.AF.PayloadInfo.Stations[9].count > 0 and 1 or 0) -- weapon presend panel 5 + ExportScript.AF.TmpWeaponPanelPresend[106] = (ExportScript.AF.PayloadInfo.Stations[10].count > 0 and 1 or 0) -- weapon presend panel 6 + ExportScript.AF.TmpWeaponPanelPresend[107] = (ExportScript.AF.PayloadInfo.Stations[8].count > 0 and 1 or 0) -- weapon presend panel 7 + ExportScript.AF.TmpWeaponPanelPresend[108] = (ExportScript.AF.PayloadInfo.Stations[6].count > 0 and 1 or 0) -- weapon presend panel 8 + ExportScript.AF.TmpWeaponPanelPresend[109] = (ExportScript.AF.PayloadInfo.Stations[4].count > 0 and 1 or 0) -- weapon presend panel 9 + ExportScript.AF.TmpWeaponPanelPresend[110] = (ExportScript.AF.PayloadInfo.Stations[2].count > 0 and 1 or 0) -- weapon presend panel 10 + --ExportScript.AF.TmpWeaponPanelActive[201] -- weapon active panel 1 + --ExportScript.AF.TmpWeaponPanelActive[202] -- weapon active panel 2 + --ExportScript.AF.TmpWeaponPanelActive[203] -- weapon active panel 3 + --ExportScript.AF.TmpWeaponPanelActive[204] -- weapon active panel 4 + --ExportScript.AF.TmpWeaponPanelActive[205] -- weapon active panel 5 + --ExportScript.AF.TmpWeaponPanelActive[206] -- weapon active panel 6 + --ExportScript.AF.TmpWeaponPanelActive[207] -- weapon active panel 7 + --ExportScript.AF.TmpWeaponPanelActive[208] -- weapon active panel 8 + --ExportScript.AF.TmpWeaponPanelActive[209] -- weapon active panel 9 + --ExportScript.AF.TmpWeaponPanelActive[210] -- weapon active panel 10 + end + end + + if ExportScript.Config.IkarusExport and lFunctionTyp == "Ikarus" then + for key, value in pairs(ExportScript.AF.TmpWeaponPanelPresend) do + ExportScript.Tools.SendData(key, value) + end + for key, value in pairs(ExportScript.AF.TmpWeaponPanelActive) do + ExportScript.Tools.SendData(key, value) + end + end + + if ExportScript.Config.DACExport and lFunctionTyp == "DAC" then + for key, value in pairs(ExportScript.AF.TmpWeaponPanelPresend) do + ExportScript.Tools.SendDataDAC(key, value) + end + for key, value in pairs(ExportScript.AF.TmpWeaponPanelActive) do + ExportScript.Tools.SendDataDAC(key, value) + end + end end \ No newline at end of file diff --git a/Scripts/DCS-ExportScript/ExportsModules/Su-33.lua b/Scripts/DCS-ExportScript/ExportsModules/Su-33.lua index bc4fa8d..b1c470b 100644 --- a/Scripts/DCS-ExportScript/ExportsModules/Su-33.lua +++ b/Scripts/DCS-ExportScript/ExportsModules/Su-33.lua @@ -1,348 +1,224 @@ -- Su-33 Export --- Version 0.9.9 BETA - -gES_FoundFCModule = true - --- auxiliary function -dofile(gES_ExportModulePath.."FC_AuxiliaryFuntions.lua") +-- Version 1.0.0 BETA + +ExportScript.FoundFCModule = true + +-- auxiliary function +dofile(ExportScript.Config.ExportModulePath.."FC_AuxiliaryFuntions.lua") ----------------------------------------- -- FLAMING CLIFFS AIRCRAFT / Su-33 -- -- FC aircraft don't support GetDevice -- ----------------------------------------- -function ProcessGlassCockpitFCHighImportanceConfig() - +function ExportScript.ProcessIkarusFCHighImportanceConfig() + local lFunctionTyp = "Ikarus" -- function type for shared function local myData = LoGetSelfData() if (myData) then - local lLatitude = myData.LatLongAlt.Lat -- LATITUDE - local lLongitude = myData.LatLongAlt.Long -- LONGITUDE + local lLatitude = myData.LatLongAlt.Lat -- LATITUDE + local lLongitude = myData.LatLongAlt.Long -- LONGITUDE + + local lEngineTempLeft = LoGetEngineInfo().Temperature.left -- ENG1 EGT ºC + local lEngineTempRight = LoGetEngineInfo().Temperature.right -- ENG2 EGT ºC + --[[ local lBasicAtmospherePressure = LoGetBasicAtmospherePressure() -- BAROMETRIC PRESSURE local lAltBar = LoGetAltitudeAboveSeaLevel() -- ALTITUDE SEA LEVEL (Meter) local lAltRad = LoGetAltitudeAboveGroundLevel() -- ALTITUDE GROUND LEVEL (Meter) - --local lTrueAirSpeed = LoGetTrueAirSpeed() -- TRUE AIRSPEED (Meter/Second) + local lTrueAirSpeed = LoGetTrueAirSpeed() -- TRUE AIRSPEED (Meter/Second) local lPitch, lBank, lYaw = LoGetADIPitchBankYaw() -- PITCH, BANK, YAW (Radian) local lHeading = myData.Heading -- HEADING (Radian) local lVVI = LoGetVerticalVelocity() -- VERTICAL SPEED (Meter/Second) local lIAS = LoGetIndicatedAirSpeed() -- INDICATED AIRSPEED (Meter/Second) - --local lMachNumber = LoGetMachNumber() -- MACH + local lMachNumber = LoGetMachNumber() -- MACH local lAoA = LoGetAngleOfAttack() -- ANGLE OF ATTACK AoA (Radian) - + local lGlide = LoGetGlideDeviation() -- VOR1 HORIZONTAL DEFLECTION (-1 +1) local lSide = LoGetSideDeviation() -- VOR1 VERTICAL DEFLECTION (-1 +1) - --local lSlipBallPosition = LoGetSlipBallPosition() -- SLIP BALL (-1 +1) - --local lAccelerationUnits = LoGetAccelerationUnits().y -- G-LOAD - - --local lNavInfoPitch = LoGetNavigationInfo().Requirements.pitch -- AP REQUIRED PITCH (Radian) - --local lNavInfoRoll = LoGetNavigationInfo().Requirements.roll -- AP REQUIRED BANK (Radian) - --local lNavInfoSpeed = LoGetNavigationInfo().Requirements.speed -- AP SPEED (Meter/Second) - --local lNavInfoAltitude = LoGetNavigationInfo().Requirements.altitude -- AP ALTITUDE (Meter) - --local lNavInfoVerticalSpeed = LoGetNavigationInfo().Requirements.vertical_speed -- AP VERTICAL SPEED (Meter/Second) + local lSlipBallPosition = LoGetSlipBallPosition() -- SLIP BALL (-1 +1) + local lAccelerationUnits = LoGetAccelerationUnits().y -- G-LOAD - --local lControlPanel_HSI = LoGetControlPanel_HSI() -- HSI Data + local lNavInfoPitch = LoGetNavigationInfo().Requirements.pitch -- AP REQUIRED PITCH (Radian) + local lNavInfoRoll = LoGetNavigationInfo().Requirements.roll -- AP REQUIRED BANK (Radian) + local lNavInfoSpeed = LoGetNavigationInfo().Requirements.speed -- AP SPEED (Meter/Second) + local lNavInfoAltitude = LoGetNavigationInfo().Requirements.altitude -- AP ALTITUDE (Meter) + local lNavInfoVerticalSpeed = LoGetNavigationInfo().Requirements.vertical_speed -- AP VERTICAL SPEED (Meter/Second) + + local lControlPanel_HSI = LoGetControlPanel_HSI() -- HSI Data local lHSI_RMI = LoGetControlPanel_HSI().RMI_raw -- VOR1 OBS (Radian) local lHSI_ADF = LoGetControlPanel_HSI().ADF_raw -- ADF OBS (Radian) - --local lHSI_Heading = LoGetControlPanel_HSI().Heading_raw -- Heading (Radian) - + local lHSI_Heading = LoGetControlPanel_HSI().Heading_raw -- Heading (Radian) + local lEngineRPMleft = LoGetEngineInfo().RPM.left -- ENG1 RPM % local lEngineRPMright = LoGetEngineInfo().RPM.right -- ENG2 RPM % - local lEngineTempLeft = LoGetEngineInfo().Temperature.left -- ENG1 EGT ºC - local lEngineTempRight = LoGetEngineInfo().Temperature.right -- ENG2 EGT ºC - --local lEngineFuelInternal = LoGetEngineInfo().fuel_internal -- TANK1 (INT) (KG) - --local lEngineFuelExternal = LoGetEngineInfo().fuel_external -- TANK2 (EXT) (KG) - - --local lMechInfo = LoGetMechInfo() -- mechanical components, e.g. Flaps, Wheelbrakes,... - --local lPayloadInfo = LoGetPayloadInfo() -- Paylod, e.g. bombs, guns, rockets, fuel tanks,... + + local lEngineFuelInternal = LoGetEngineInfo().fuel_internal -- TANK1 (INT) (KG) + local lEngineFuelExternal = LoGetEngineInfo().fuel_external -- TANK2 (EXT) (KG) + + local lMechInfo = LoGetMechInfo() -- mechanical components, e.g. Flaps, Wheelbrakes,... + local lPayloadInfo = LoGetPayloadInfo() -- Paylod, e.g. bombs, guns, rockets, fuel tanks,... + ]] local lDistanceToWay = 999 local lRoute = LoGetRoute() - + if (myData and lRoute) then -- if neither are nil local myLoc = LoGeoCoordinatesToLoCoordinates(lLongitude, lLatitude) --lDistanceToWay = math.sqrt((myLoc.x - lRoute.goto_point.world_point.x)^2 + (myLoc.y - lRoute.goto_point.world_point.y)^2) lDistanceToWay = math.sqrt((myLoc.x - lRoute.goto_point.world_point.x)^2 + (myLoc.z - lRoute.goto_point.world_point.z)^2) end - if gES_GlassCockpitType == 1 then - -- HELIOS Version 1.3 - -- customizing for HELOS - lPitch = math.deg(lPitch) -- PITCH, (Radian to Grad) - lBank = math.deg(lBank) -- BANK (Radian to Grad) - lYaw = math.deg(lYaw) -- YAW (Radian to Grad) - lHSI_RMI = math.deg(lHSI_RMI) -- VOR1 OBS (Radian to Grad) - lHSI_ADF = math.deg(lHSI_ADF) -- ADF OBS (Radian to Grad) - lAoA = math.deg(lAoA) -- ANGLE OF ATTACK AoA (Radian to Grad) - lHeading = math.deg(lHeading) -- Heading (Radian to Grad) - lHSI_ADF = (360 - lHSI_ADF) + (360 - lHeading) - lHSI_RMI = 360 - lHSI_RMI - lIAS = lIAS * 3.6 -- change from m/s to km/h - - SendData("1", string.format("%.2f", lPitch) ) - SendData("2", string.format("%.2f", lBank) ) - SendData("3", string.format("%.2f", lYaw) ) - SendData("4", string.format("%.2f", lAltBar) ) - SendData("5", string.format("%.2f", lAltRad) ) - SendData("6", string.format("%.2f", lHSI_ADF) ) - SendData("7", string.format("%.2f", lHSI_RMI) ) - SendData("8", string.format("%.2f", lHeading) ) - SendData("9", string.format("%.2f", lEngineRPMleft) ) - SendData("10", string.format("%.2f", lEngineRPMright) ) - SendData("11", string.format("%.2f", lEngineTempLeft) ) - SendData("12", string.format("%.2f", lEngineTempRight) ) - SendData("13", string.format("%.2f", lVVI) ) - SendData("14", string.format("%.2f", lIAS) ) - SendData("15", string.format("%.2f", lDistanceToWay) ) - SendData("16", string.format("%.2f", lAoA) ) - SendData("17", string.format("%.2f", lGlide) ) - SendData("18", string.format("%.2f", lSide) ) - - elseif gES_GlassCockpitType == 2 then - -- HawgTouch version 1.6 + -- IAS-MACH Indicator + ExportScript.AF.FC_Russian_AirSpeed_1600hkm() - -- IAS-MACH Indicator (IAS, MACH) {"%.4f;%.4f"} - FC_Russian_AirSpeed_1600hkm(1) + -- AOA Indicator and Accelerometer + ExportScript.AF.FC_Russian_AOA_Su2733() - -- AOA Indicator and Accelerometer (AOA, GLoad) - FC_Russian_AOA_Su2733(3) + -- ADI + ExportScript.AF.FC_Russian_ADI_New() - -- ADI - FC_Russian_ADI_New(4) + -- HSI + ExportScript.AF.FC_Russian_HSI(lDistanceToWay) - -- HSI - FC_Russian_HSI(lDistanceToWay, 5) + -- Vertical Velocity Indicator (VVI) + ExportScript.AF.FC_Russian_VVI_New() - -- Vertical Velocity Indicator (VVI) (VVI, TurnIndicator, SlipBallPosition) - FC_Russian_VVI_New(6) + -- Radar Altimeter (below 100m is warning light on) + ExportScript.AF.FC_Russian_RadarAltimeter_1500m(100) - -- Radar Altimeter (AltRad, MinAltitude, WarningFlag, MinAltitudeLamp) {"%.4f;%.4f;%.1f;%.1f"} (below 100m is warning light on) - FC_Russian_RadarAltimeter_1500m(100, 7) + -- Barometric Altimeter + ExportScript.AF.FC_Russian_BarometricAltimeter_late() - -- Barometric Altimeter (AltBar, BasicAtmospherePressure) - FC_Russian_BarometricAltimeter_late(8) + -- Tachometer (RPM) + ExportScript.AF.FC_Russian_EngineRPM() - -- Tachometer (RPM) (EngineRPMleft, EngineRPMright) {"%.4f;%.4f"} - FC_Russian_EngineRPM(9) + -- Left Jet Engine Turbine Temperature Indicator (EngineTemp, main scala, second scala, ExportID) + ExportScript.AF.FC_TwoNeedlesGauge(lEngineTempLeft, 1200, 100, 70, 71) - -- Left Jet Engine Turbine Temperature Indicator (EngineTemp) {"%.4f"} - FC_TwoNeedlesGauge(lEngineTempLeft, 1200, 100, 10) + -- Right Jet Engine Turbine Temperature Indicator (EngineTemp, main scala, second scala, ExportID) + ExportScript.AF.FC_TwoNeedlesGauge(lEngineTempRight, 1200, 100, 72, 73) - -- Right Jet Engine Turbine Temperature Indicator (EngineTemp) {"%.4f"} - FC_TwoNeedlesGauge(lEngineTempRight, 1200, 100, 11) - - -- Clock from Ka-50 {CurrentHours, CurrentMinutes, CurrentSeconds, 0, FlightTimeHours, FlightTimeMinutes, 0, 0) {"%.4f;%.4f;%.4f;%.1f;%.4f;%.4f;%.4f;%.4f"} - FC_Russian_Clock_late(12) - end + -- Clock from Ka-50 + ExportScript.AF.FC_Russian_Clock_late() else - WriteToLog("Unknown FC Error, no LoGetSelfData.") + ExportScript.Tools.WriteToLog("Unknown FC Error, no LoGetSelfData.") end - end -function ProcessHARDWAREConfigHighImportance(mainPanelDevice) +function ExportScript.ProcessDACConfigHighImportance() + local lFunctionTyp = "DAC" -- function type for shared function + + -- your script + end -function ProcessGlassCockpitFCLowImportanceConfig() +function ExportScript.ProcessIkarusFCLowImportanceConfig() + local lFunctionTyp = "Ikarus" -- function type for shared function + + ExportScript.AF.FC_WeaponPanel_SU33(lFunctionTyp) + + -- SPO15 Radar Warning Reciver + ExportScript.AF.FC_SPO15RWR(lFunctionTyp) + + -- EKRAN Message + ExportScript.AF.FC_EKRAN() - if gES_GlassCockpitType == 1 then - -- HELIOS Version 1.3 - - elseif gES_GlassCockpitType == 2 then - -- HawgTouch version 1.6 + -- Fuel Quantity Indicator + ExportScript.AF.FuelQuantityIndicator(lFunctionTyp) - FC_WeaponPanel_SU2733(13) + ExportScript.AF.MechanicalDevicesIndicator(lFunctionTyp) - FC_RadarWarning_SPO15(14) + local lEngineInfo = LoGetEngineInfo() + local lTotalFuel = 0 + if lEngineInfo ~= nil then + -- Hydraulic Pressure Left + ExportScript.AF.FC_OneNeedleGauge(lEngineInfo.HydraulicPressure.left, 300, 85) + end - -- Fuel Quantity Indicator - local lEngineInfo = LoGetEngineInfo() - local lTotalFuel = 0 - if lEngineInfo ~= nil then - --WriteToLog('lEngineInfo: '..dump(lEngineInfo)) - --[[ - [fuel_external] = number: "0" - [Temperature] = { - [left] = number: "626.99444580078" - [right] = number: "626.99444580078" - } - [RPM] = { - [left] = number: "87.453765869141" - [right] = number: "87.453758239746" - } - [FuelConsumption] = { - [left] = number: "0.1500396137767" - [right] = number: "0.1500396137767" - } - [fuel_internal] = number: "3773.2749023438" - [EngineStart] = { - [left] = number: "0" - [right] = number: "0" - } - [HydraulicPressure] = { - [left] = number: "210" - [right] = number: "210" - } - lPayloadInfo.Stations[8].CLSID == E8D4652F-FD48-45B7-BA5B-2AE05BB5A9CF -- ext 800l Fuel Tank - ]] + local lMechInfo = LoGetMechInfo() -- mechanical components, e.g. Flaps, Wheelbrakes,... + if lMechInfo ~= nil then + -- Wheelbrakes Hydraulic Pressure Left + ExportScript.AF.FC_OneNeedleGauge(lMechInfo.wheelbrakes.value, 300, 87) - lTotalFuel = lEngineInfo.fuel_internal - --lTotalFuel = string.format("%3d", math.round((lEngineInfo.fuel_internal / 10), 0, "ceil") * 10) - --lTotalFuel = string.format("%4d", lEngineInfo.fuel_internal) -- total fuel in kg - --lTotalFuel = string.format("%4d", lEngineInfo.fuel_external) -- external fuel in kg - local lTotalFuel_12_0 = 1.0 + -- Wheelbrakes Hydraulic Pressure Right + ExportScript.AF.FC_OneNeedleGauge(lMechInfo.wheelbrakes.value, 300, 88) - if lTotalFuel < 12000 then - --[[ - y_min = 0.0 -- minimaler Ausgabewert - y_max = 1.0 -- maximaler Ausgabewert - x_min = 0 -- minimaler Eingangswert - x_max = 12000 -- maximaler Eingangswert - x = 8000 -- aktueller Eingangswert - - d_y = 1 -- Delta Ausgabewerte (y_max - y_min) - d_x = 12000 -- Delta Eingangswerte (x_max - x_min) - m = 8.3333333333333333333333333333333e-5 -- Steigung der linearen Funktion (d_y / d_x) - n = 4.e-33 -- Schnittpunkt der Funktion mit y-Achse (y_max - m * x_max) - - y = 0.66666666666666666666666666666667 -- Ergebnis (m * x + n) - ]] - lTotalFuel_12_0 = 8.3333333333333333333333333333333e-5 * lTotalFuel + 4.e-33 - end - - -- TotalFuel_12_0 - -- Light1 - -- Light2 - -- Light3 - -- Light4 - -- BingoLight - SendData("15", string.format("%0.4f;%d;%d;%d;%d;%d", - lTotalFuel_12_0, - (lEngineInfo.fuel_internal < 5000.0 and 1 or 0), -- Tank warning 1 - (lEngineInfo.fuel_internal < 1000.0 and 1 or 0), -- Tank warning 2 4000 - (lEngineInfo.fuel_internal < 4000.0 and 1 or 0), -- Tank warning 3 1500 - (lEngineInfo.fuel_internal < 1500.0 and 1 or 0), -- Tank warning 4 1000 - (lEngineInfo.fuel_internal < 600.0 and 1 or 0))) -- Bingo Fuel - - -- Hydraulic Pressure Left - FC_OneNeedleGauge(lEngineInfo.HydraulicPressure.left, 300, 17) - end - - -- EKRAN Message - FC_EKRAN(16) - - -- Mechanical Configuration Indicator (GearWarningLight, NoseGear, LeftGear, RightGear, Airbreaks, Flaps1, Flaps2) {"%.1f;%d;%d;%d;%d;%d;%d"} - local lMechInfo = LoGetMechInfo() -- mechanical components, e.g. Flaps, Wheelbrakes,... - if lMechInfo ~= nil then - local lWarningLight = 0.0 - local lTrueAirSpeed = LoGetTrueAirSpeed() - if lTrueAirSpeed ~= nil then - lWarningLight = ((lMechInfo.flaps.value > 0.93 and lTrueAirSpeed > 340) and 1.0 or 0.0) -- Speed Warning for Flaps, same light as gear warning light, but blinking light - lWarningLight = (((lMechInfo.gear.status == 1 and lMechInfo.gear.value < 1) or (lMechInfo.gear.status == 0 and lMechInfo.gear.value > 0)) and 1.0 or lWarningLight ) -- gear warning light - end - -- WarningLight {0.0 = Off, 0.1 = blinking light, 0.2 = on} - -- WarningLight {0.0 = Off, no blinking light, 1.0 = on} - - -- left gear {0, 1} - -- right gear {0, 1} - -- nose gear {0, 1} - -- Hook Light - -- WarningLight - -- Flap - -- Intake FOD shields - -- Speedbreakes on {0, 1} - SendData("2", string.format("%.1f;%d;%d;%d;%d;%d;%d;%d", - (lMechInfo.gear.value > 0.95 and 1 or 0), -- left gear - (lMechInfo.gear.value == 1 and 1 or 0), -- right gear - (lMechInfo.gear.value > 0.85 and 1 or 0), -- nose gear - (lMechInfo.hook.value > 0.85 and 1 or 0), -- hook light - lWarningLight, - (lMechInfo.flaps.value > 0.93 and 1 or 0), -- flap - (lMechInfo.gear.value > 0.5 and 1 or 0), -- Intake FOD shields - (lMechInfo.speedbrakes.value > 0.1 and 1 or 0))) -- speedbreakes on > 0.1 (0 - 1) - - -- Wheelbrakes Hydraulic Pressure Left - FC_OneNeedleGauge(lMechInfo.wheelbrakes.value, 300, 18) - - -- Wheelbrakes Hydraulic Pressure Right - FC_OneNeedleGauge(lMechInfo.wheelbrakes.value, 300, 19) - - --WriteToLog('lMechInfo.noseflap.value: '..dump(lMechInfo.noseflap.value)) -- Vorfluegel, Balkenanzeige neben dem Radarhoehenmesser (0=oben bis 30=unten) - end - - -- Airintake - FC_Russian_AirIntake(20) - - -- Fuel Quantity Standby Indicator - FC_OneNeedleGauge(lTotalFuel, 10000, 21) + --ExportScript.Tools.WriteToLog('lMechInfo.noseflap.value: '..ExportScript.Tools.dump(lMechInfo.noseflap.value)) -- Vorfluegel, Balkenanzeige neben dem Radarhoehenmesser (0=oben bis 30=unten) end - - --(x < 0 and 'negative' or 'non-negative') - --[[ - local lPayloadInfo = LoGetPayloadInfo() - WriteToLog('lPayloadInfo: '..dump(lPayloadInfo)) - - local lSnares = LoGetSnares() -- Flare and Chaff - WriteToLog('lSnares: '..dump(lSnares)) - - local lSightingSystemInfo = LoGetSightingSystemInfo() - WriteToLog('lSightingSystemInfo: '..dump(lSightingSystemInfo)) - - local lTWSInfo = LoGetTWSInfo() -- SPO Informationen, z.B. Radarwarner F15C - WriteToLog('lTWSInfo: '..dump(lTWSInfo)) - - local lTargetInformation = LoGetTargetInformation() -- detalierte Radar Infos z.B. F15C - WriteToLog('lTargetInformation: '..dump(lTargetInformation)) - - local lLockedTargetInformation = LoGetLockedTargetInformation() - WriteToLog('lLockedTargetInformation: '..dump(lLockedTargetInformation)) - - local lF15_TWS_Contacs = LoGetF15_TWS_Contacts() -- the same information but only for F-15 in TWS mode - WriteToLog('lF15_TWS_Contacs: '..dump(lF15_TWS_Contacs)) - - local lMechInfo = LoGetMechInfo() -- mechanical components, e.g. Flaps, Wheelbrakes,... - WriteToLog('lMechInfo: '..dump(lMechInfo)) - - local lMCPState = LoGetMCPState() -- Warnlichter - WriteToLog('lMCPState: '..dump(lMCPState)) - - local lControlPanel_HSI = LoGetControlPanel_HSI() - WriteToLog('lControlPanel_HSI: '..dump(lControlPanel_HSI)) - - local lRadioBeaconsStatus = LoGetRadioBeaconsStatus() - WriteToLog('lRadioBeaconsStatus: '..dump(lRadioBeaconsStatus)) - - local lEngineInfo = LoGetEngineInfo() - WriteToLog('lEngineInfo: '..dump(lEngineInfo)) - ]] - -- Weapon Control System - --local lNameByType = LoGetNameByType () -- args 4 (number : level1,level2,level3,level4), result string - -- values from LoGetTargetInformation().type - --WriteToLog('lNameByType: '..dump(lNameByType)) + + -- Airintake + ExportScript.AF.FC_Russian_AirIntake(20) + + -- Fuel Quantity Standby Indicator + ExportScript.AF.FC_OneNeedleGauge(lTotalFuel, 10000, 21) --?? + + -- (x < 0 and 'negative' or 'non-negative') + --[[ + local lPayloadInfo = LoGetPayloadInfo() + ExportScript.Tools.WriteToLog('lPayloadInfo: '..ExportScript.Tools.dump(lPayloadInfo)) + + local lSnares = LoGetSnares() -- Flare and Chaff + ExportScript.Tools.WriteToLog('lSnares: '..ExportScript.Tools.dump(lSnares)) + + local lSightingSystemInfo = LoGetSightingSystemInfo() + ExportScript.Tools.WriteToLog('lSightingSystemInfo: '..ExportScript.Tools.dump(lSightingSystemInfo)) + + local lTWSInfo = LoGetTWSInfo() -- SPO Informationen, z.B. Radarwarner F15C + ExportScript.Tools.WriteToLog('lTWSInfo: '..ExportScript.Tools.dump(lTWSInfo)) + + local lTargetInformation = LoGetTargetInformation() -- detalierte Radar Infos z.B. F15C + ExportScript.Tools.WriteToLog('lTargetInformation: '..ExportScript.Tools.dump(lTargetInformation)) + + local lLockedTargetInformation = LoGetLockedTargetInformation() + ExportScript.Tools.WriteToLog('lLockedTargetInformation: '..ExportScript.Tools.dump(lLockedTargetInformation)) + + local lF15_TWS_Contacs = LoGetF15_TWS_Contacts() -- the same information but only for F-15 in TWS mode + ExportScript.Tools.WriteToLog('lF15_TWS_Contacs: '..ExportScript.Tools.dump(lF15_TWS_Contacs)) + + local lMechInfo = LoGetMechInfo() -- mechanical components, e.g. Flaps, Wheelbrakes,... + ExportScript.Tools.WriteToLog('lMechInfo: '..ExportScript.Tools.dump(lMechInfo)) + + local lMCPState = LoGetMCPState() -- Warnlichter + ExportScript.Tools.WriteToLog('lMCPState: '..ExportScript.Tools.dump(lMCPState)) + + local lControlPanel_HSI = LoGetControlPanel_HSI() + ExportScript.Tools.WriteToLog('lControlPanel_HSI: '..ExportScript.Tools.dump(lControlPanel_HSI)) + + local lRadioBeaconsStatus = LoGetRadioBeaconsStatus() + ExportScript.Tools.WriteToLog('lRadioBeaconsStatus: '..ExportScript.Tools.dump(lRadioBeaconsStatus)) + + local lEngineInfo = LoGetEngineInfo() + ExportScript.Tools.WriteToLog('lEngineInfo: '..ExportScript.Tools.dump(lEngineInfo)) + ]] + -- Weapon Control System + -- local lNameByType = LoGetNameByType () -- args 4 (number : level1,level2,level3,level4), result string + -- values from LoGetTargetInformation().type + -- ExportScript.Tools.WriteToLog('lNameByType: '..ExportScript.Tools.dump(lNameByType)) end -function ProcessHARDWAREConfigLowImportance(mainPanelDevice) --- where necessary, specify HardwareID, example WeaponStatusPanel(2) - WeaponStatusPanel() - MechanicalDevicesIndicator() - StatusLamp() - FuelQuantityIndicator() - SightingSystem() - SPO15RWR() - PPDSPPanel() +function ExportScript.ProcessDACConfigLowImportance() + local lFunctionTyp = "DAC" -- function type for shared function + + ExportScript.AF.FC_WeaponPanel_SU33(lFunctionTyp) + ExportScript.AF.FC_SPO15RWR(lFunctionTyp) + ExportScript.AF.MechanicalDevicesIndicator(lFunctionTyp) + ExportScript.AF.FuelQuantityIndicator(lFunctionTyp) + ExportScript.AF.StatusLamp() + ExportScript.AF.SightingSystem() + ExportScript.AF.PPDSPPanel() end ----------------------------- -- Custom functions -- ----------------------------- -function SightingSystem(hardware) - local lHardware = hardware or 1 +function ExportScript.AF.SightingSystem() local lSightingSystemInfo = LoGetSightingSystemInfo() if lSightingSystemInfo == nil then return end - --WriteToLog('lSightingSystemInfo: '..dump(lSightingSystemInfo)9 + --ExportScript.Tools.WriteToLog('lSightingSystemInfo: '..ExportScript.Tools.dump(lSightingSystemInfo)9 --[[ [PRF] = { [selection] = string: "ILV" @@ -379,54 +255,51 @@ function SightingSystem(hardware) } } ]] - SendDataHW("600", lSightingSystemInfo.ECM_on == true and 1 or 0, lHardware ) - SendDataHW("601", lSightingSystemInfo.laser_on == true and 1 or 0, lHardware ) - --SendDataHW("602", lSightingSystemInfo.optical_system_on == true and 1 or 0, lHardware ) - SendDataHW("603", lSightingSystemInfo.LaunchAuthorized == true and 1 or 0, lHardware ) - SendDataHW("604", lSightingSystemInfo.radar_on == true and 1 or 0, lHardware ) + ExportScript.Tools.SendDataDAC("600", lSightingSystemInfo.ECM_on == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("601", lSightingSystemInfo.laser_on == true and 1 or 0 ) + --ExportScript.Tools.SendDataDAC("602", lSightingSystemInfo.optical_system_on == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("603", lSightingSystemInfo.LaunchAuthorized == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("604", lSightingSystemInfo.radar_on == true and 1 or 0 ) end -function PPDSPPanel(hardware) - local lHardware = hardware or 1 +function ExportScript.AF.PPDSPPanel() local lSnares = LoGetSnares() -- Flare and Chaff if lSnares == nil then return end - --WriteToLog('lSnares: '..dump(lSnares)) - + --ExportScript.Tools.WriteToLog('lSnares: '..ExportScript.Tools.dump(lSnares)) + --[chaff] = number: "48" --[flare] = number: "48" - - local lChaffLED = math.round(lSnares.chaff / 6, 0, "ceil") + 1 - local lFlareLED = math.round(lSnares.flare / 6, 0, "ceil") + 1 - - SendDataHW("800", (lChaffLED <= 1 and 0 or 1), lHardware ) - SendDataHW("801", (lChaffLED <= 2 and 0 or 1), lHardware ) - SendDataHW("802", (lChaffLED <= 3 and 0 or 1), lHardware ) - SendDataHW("803", (lChaffLED <= 4 and 0 or 1), lHardware ) - SendDataHW("804", (lChaffLED <= 5 and 0 or 1), lHardware ) - SendDataHW("805", (lChaffLED <= 6 and 0 or 1), lHardware ) - SendDataHW("806", (lChaffLED <= 7 and 0 or 1), lHardware ) - SendDataHW("807", (lChaffLED <= 8 and 0 or 1), lHardware ) - - SendDataHW("810", (lFlareLED <= 1 and 0 or 1), lHardware ) - SendDataHW("811", (lFlareLED <= 2 and 0 or 1), lHardware ) - SendDataHW("812", (lFlareLED <= 3 and 0 or 1), lHardware ) - SendDataHW("813", (lFlareLED <= 4 and 0 or 1), lHardware ) - SendDataHW("814", (lFlareLED <= 5 and 0 or 1), lHardware ) - SendDataHW("815", (lFlareLED <= 6 and 0 or 1), lHardware ) - SendDataHW("816", (lFlareLED <= 7 and 0 or 1), lHardware ) - SendDataHW("817", (lFlareLED <= 8 and 0 or 1), lHardware ) - SendDataHW("817", (lFlareLED <= 8 and 0 or 1), lHardware ) + + local lChaffLED = ExportScript.Tools.round(lSnares.chaff / 6, 0, "ceil") + 1 + local lFlareLED = ExportScript.Tools.round(lSnares.flare / 6, 0, "ceil") + 1 + + ExportScript.Tools.SendDataDAC("800", (lChaffLED <= 1 and 0 or 1) ) + ExportScript.Tools.SendDataDAC("801", (lChaffLED <= 2 and 0 or 1) ) + ExportScript.Tools.SendDataDAC("802", (lChaffLED <= 3 and 0 or 1) ) + ExportScript.Tools.SendDataDAC("803", (lChaffLED <= 4 and 0 or 1) ) + ExportScript.Tools.SendDataDAC("804", (lChaffLED <= 5 and 0 or 1) ) + ExportScript.Tools.SendDataDAC("805", (lChaffLED <= 6 and 0 or 1) ) + ExportScript.Tools.SendDataDAC("806", (lChaffLED <= 7 and 0 or 1) ) + ExportScript.Tools.SendDataDAC("807", (lChaffLED <= 8 and 0 or 1) ) + + ExportScript.Tools.SendDataDAC("810", (lFlareLED <= 1 and 0 or 1) ) + ExportScript.Tools.SendDataDAC("811", (lFlareLED <= 2 and 0 or 1) ) + ExportScript.Tools.SendDataDAC("812", (lFlareLED <= 3 and 0 or 1) ) + ExportScript.Tools.SendDataDAC("813", (lFlareLED <= 4 and 0 or 1) ) + ExportScript.Tools.SendDataDAC("814", (lFlareLED <= 5 and 0 or 1) ) + ExportScript.Tools.SendDataDAC("815", (lFlareLED <= 6 and 0 or 1) ) + ExportScript.Tools.SendDataDAC("816", (lFlareLED <= 7 and 0 or 1) ) + ExportScript.Tools.SendDataDAC("817", (lFlareLED <= 8 and 0 or 1) ) end -function StatusLamp(hardware) - local lHardware = hardware or 1 +function ExportScript.AF.StatusLamp() local lMCPState = LoGetMCPState() -- Warning Lights if lMCPState == nil then return end - --WriteToLog('lMCPState: '..dump(lMCPState)) + --ExportScript.Tools.WriteToLog('lMCPState: '..ExportScript.Tools.dump(lMCPState)) --[[ [RightTailPlaneFailure] = boolean: "false" [EOSFailure] = boolean: "false" @@ -457,276 +330,62 @@ function StatusLamp(hardware) [AutopilotOn] = boolean: "false" [LeftTailPlaneFailure] = boolean: "false" ]] - - SendDataHW("700", lMCPState.LeftTailPlaneFailure == true and 1 or 0, lHardware ) - SendDataHW("701", lMCPState.RightTailPlaneFailure == true and 1 or 0, lHardware ) - SendDataHW("702", lMCPState.MasterWarning == true and 1 or 0, lHardware ) - SendDataHW("703", lMCPState.LeftEngineFailure == true and 1 or 0, lHardware ) - SendDataHW("704", lMCPState.RightEngineFailure == true and 1 or 0, lHardware ) - SendDataHW("705", lMCPState.LeftAileronFailure == true and 1 or 0, lHardware ) - SendDataHW("706", lMCPState.RightAileronFailure == true and 1 or 0, lHardware ) - SendDataHW("707", lMCPState.LeftMainPumpFailure == true and 1 or 0, lHardware ) - SendDataHW("708", lMCPState.RightMainPumpFailure == true and 1 or 0, lHardware ) - SendDataHW("709", lMCPState.LeftWingPumpFailure == true and 1 or 0, lHardware ) - SendDataHW("710", lMCPState.RightWingPumpFailure == true and 1 or 0, lHardware ) - SendDataHW("711", lMCPState.EOSFailure == true and 1 or 0, lHardware ) - SendDataHW("712", lMCPState.ECMFailure == true and 1 or 0, lHardware ) - SendDataHW("713", lMCPState.CannonFailure == true and 1 or 0, lHardware ) - SendDataHW("714", lMCPState.MLWSFailure == true and 1 or 0, lHardware ) - SendDataHW("715", lMCPState.ACSFailure == true and 1 or 0, lHardware ) - SendDataHW("716", lMCPState.RadarFailure == true and 1 or 0, lHardware ) - SendDataHW("717", lMCPState.HelmetFailure == true and 1 or 0, lHardware ) - SendDataHW("718", lMCPState.HUDFailure == true and 1 or 0, lHardware ) - SendDataHW("719", lMCPState.MFDFailure == true and 1 or 0, lHardware ) - SendDataHW("720", lMCPState.RWSFailure == true and 1 or 0, lHardware ) - SendDataHW("721", lMCPState.GearFailure == true and 1 or 0, lHardware ) - SendDataHW("722", lMCPState.HydraulicsFailure == true and 1 or 0, lHardware ) - SendDataHW("723", lMCPState.AutopilotFailure == true and 1 or 0, lHardware ) - SendDataHW("724", lMCPState.FuelTankDamage == true and 1 or 0, lHardware ) - SendDataHW("725", lMCPState.CanopyOpen == true and 1 or 0, lHardware ) - SendDataHW("726", lMCPState.StallSignalization == true and 1 or 0, lHardware ) - SendDataHW("727", lMCPState.AutopilotOn == true and 1 or 0, lHardware ) - + + ExportScript.Tools.SendDataDAC("700", lMCPState.LeftTailPlaneFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("701", lMCPState.RightTailPlaneFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("702", lMCPState.MasterWarning == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("703", lMCPState.LeftEngineFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("704", lMCPState.RightEngineFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("705", lMCPState.LeftAileronFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("706", lMCPState.RightAileronFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("707", lMCPState.LeftMainPumpFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("708", lMCPState.RightMainPumpFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("709", lMCPState.LeftWingPumpFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("710", lMCPState.RightWingPumpFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("711", lMCPState.EOSFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("712", lMCPState.ECMFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("713", lMCPState.CannonFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("714", lMCPState.MLWSFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("715", lMCPState.ACSFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("716", lMCPState.RadarFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("717", lMCPState.HelmetFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("718", lMCPState.HUDFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("719", lMCPState.MFDFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("720", lMCPState.RWSFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("721", lMCPState.GearFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("722", lMCPState.HydraulicsFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("723", lMCPState.AutopilotFailure == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("724", lMCPState.FuelTankDamage == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("725", lMCPState.CanopyOpen == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("726", lMCPState.StallSignalization == true and 1 or 0 ) + ExportScript.Tools.SendDataDAC("727", lMCPState.AutopilotOn == true and 1 or 0 ) + local lEngineInfo = LoGetEngineInfo() if lEngineInfo ~= nil then - --WriteToLog('lEngineInfo: '..dump(lEngineInfo)) + --ExportScript.Tools.WriteToLog('lEngineInfo: '..ExportScript.Tools.dump(lEngineInfo)) - SendDataHW("728", lEngineInfo.EngineStart.left, lHardware ) -- lamp start left engine 1 (0|1) - SendDataHW("729", lEngineInfo.EngineStart.right, lHardware ) -- lamp start right engine 1 (0|1) + ExportScript.Tools.SendDataDAC("728", lEngineInfo.EngineStart.left ) -- lamp start left engine 1 (0|1) + ExportScript.Tools.SendDataDAC("729", lEngineInfo.EngineStart.right ) -- lamp start right engine 1 (0|1) - SendDataHW("730", (lEngineInfo.RPM.left > 100.0 and 1 or 0), lHardware ) -- lamp after burner left engine - SendDataHW("731", (lEngineInfo.RPM.right > 100.0 and 1 or 0), lHardware ) -- lam after burner right engine + ExportScript.Tools.SendDataDAC("730", (lEngineInfo.RPM.left > 100.0 and 1 or 0) ) -- lamp after burner left engine + ExportScript.Tools.SendDataDAC("731", (lEngineInfo.RPM.right > 100.0 and 1 or 0) ) -- lam after burner right engine end local lAccelerationUnits = LoGetAccelerationUnits() if lAccelerationUnits ~= nil then - --WriteToLog('lAccelerationUnits: '..dump(lAccelerationUnits)) - SendDataHW("732", (lAccelerationUnits.y > 8.0 and 1 or 0), lHardware ) -- lamp Over-G warning + --ExportScript.Tools.WriteToLog('lAccelerationUnits: '..ExportScript.Tools.dump(lAccelerationUnits)) + ExportScript.Tools.SendDataDAC("732", (lAccelerationUnits.y > 8.0 and 1 or 0) ) -- lamp Over-G warning end end -function WeaponStatusPanel(hardware) --- The weapon status panel, quantity and readiness of the currently selected weapon and the remaining gun ammunition are indicated. - local lHardware = hardware or 1 - gES_PayloadInfo = LoGetPayloadInfo() - if gES_PayloadInfo == nil then - return - end - --WriteToLog('gES_PayloadInfo: '..dump(gES_PayloadInfo)) - --[[ exsample - [Stations] = { - [1] = { - [CLSID] = string: "{FBC29BFE-3D24-4C64-B81D-941239D12249}" - [container] = boolean: "false" - [count] = number: "1" - [weapon] = { - [level3] = number: "7" - [level1] = number: "4" - [level4] = number: "18" - [level2] = number: "4" - } - } - [2] = { - [CLSID] = string: "{FBC29BFE-3D24-4C64-B81D-941239D12249}" - [container] = boolean: "false" - [count] = number: "1" - [weapon] = { - [level3] = number: "7" - [level1] = number: "4" - [level4] = number: "18" - [level2] = number: "4" - } - } - [3] = { - [CLSID] = string: "" - [container] = boolean: "false" - [count] = number: "0" - [weapon] = { - [level3] = number: "0" - [level1] = number: "0" - [level4] = number: "0" - [level2] = number: "0" - } - } - [4] = { - [CLSID] = string: "" - [container] = boolean: "false" - [count] = number: "0" - [weapon] = { - [level3] = number: "0" - [level1] = number: "0" - [level4] = number: "0" - [level2] = number: "0" - } - } - [5] = { - [CLSID] = string: "" - [container] = boolean: "false" - [count] = number: "0" - [weapon] = { - [level3] = number: "0" - [level1] = number: "0" - [level4] = number: "0" - [level2] = number: "0" - } - } - [6] = { - [CLSID] = string: "" - [container] = boolean: "false" - [count] = number: "0" - [weapon] = { - [level3] = number: "0" - [level1] = number: "0" - [level4] = number: "0" - [level2] = number: "0" - } - } - [7] = { - [CLSID] = string: "" - [container] = boolean: "false" - [count] = number: "0" - [weapon] = { - [level3] = number: "0" - [level1] = number: "0" - [level4] = number: "0" - [level2] = number: "0" - } - } - [8] = { - [CLSID] = string: "" - [container] = boolean: "false" - [count] = number: "0" - [weapon] = { - [level3] = number: "0" - [level1] = number: "0" - [level4] = number: "0" - [level2] = number: "0" - } - } - [9] = { - [CLSID] = string: "{37DCC01E-9E02-432F-B61D-10C166CA2798}" - [container] = boolean: "false" - [count] = number: "1" - [weapon] = { - [level3] = number: "9" - [level1] = number: "4" - [level4] = number: "7" - [level2] = number: "5" - } - } - [10] = { - [CLSID] = string: "{37DCC01E-9E02-432F-B61D-10C166CA2798}" - [container] = boolean: "false" - [count] = number: "1" - [weapon] = { - [level3] = number: "9" - [level1] = number: "4" - [level4] = number: "7" - [level2] = number: "5" - } - } - [11] = { - [CLSID] = string: "{9B25D316-0434-4954-868F-D51DB1A38DF0}" - [container] = boolean: "false" - [count] = number: "1" - [weapon] = { - [level3] = number: "7" - [level1] = number: "4" - [level4] = number: "13" - [level2] = number: "4" - } - } - [12] = { - [CLSID] = string: "{3C612111-C7AD-476E-8A8E-2485812F4E5C}" - [container] = boolean: "false" - [count] = number: "1" - [weapon] = { - [level3] = number: "9" - [level1] = number: "4" - [level4] = number: "6" - [level2] = number: "5" - } - } - } - [CurrentStation] = number: "0" - [Cannon] = { - [shells] = number: "150" - } - ]] - --[[ - Weapon Panel (Numper = Station number) - | - ------------------------------------------------------- - | | | | | | | | | | | | - L 1 2 3 4 5 6 7 8 9 10 R -- Panel ID - 1 4 5 7 9 12 11 10 8 6 3 2 -- gES_PayloadInfo.Station.ID - ]] - -- Payload Info - -- weapon stations L and R not on Panel - -- weapon station 1 (left) to 10 (right), 5 and 6 center station - SendDataHW("100", gES_PayloadInfo.Cannon.shells, lHardware ) -- count cannon shells - --SendDataHW("101", (gES_PayloadInfo.Stations[1].count > 0 and 1 or 0), lHardware ) -- L - --SendDataHW("111", (gES_PayloadInfo.Stations[2].count > 0 and 1 or 0), lHardware ) -- R - SendDataHW("110", (gES_PayloadInfo.Stations[3].count > 0 and 1 or 0), lHardware ) -- weapon presend > 0 (panel 1) - SendDataHW("101", (gES_PayloadInfo.Stations[4].count > 0 and 1 or 0), lHardware ) -- weapon presend > 0 (panel 10) - SendDataHW("102", (gES_PayloadInfo.Stations[5].count > 0 and 1 or 0), lHardware ) -- weapon presend > 0 (panel 2) - SendDataHW("109", (gES_PayloadInfo.Stations[6].count > 0 and 1 or 0), lHardware ) -- weapon presend > 0 (panel 9) - SendDataHW("103", (gES_PayloadInfo.Stations[7].count > 0 and 1 or 0), lHardware ) -- weapon presend > 0 (panel 3) - SendDataHW("108", (gES_PayloadInfo.Stations[8].count > 0 and 1 or 0), lHardware ) -- weapon presend > 0 (panel 8) - SendDataHW("104", (gES_PayloadInfo.Stations[9].count > 0 and 1 or 0), lHardware ) -- weapon presend > 0 (panel 4) - SendDataHW("107", (gES_PayloadInfo.Stations[10].count > 0 and 1 or 0), lHardware ) -- weapon presend > 0 (panel 7) - SendDataHW("106", (gES_PayloadInfo.Stations[11].count > 0 and 1 or 0), lHardware ) -- weapon presend > 0 (panel 5) - SendDataHW("105", (gES_PayloadInfo.Stations[12].count > 0 and 1 or 0), lHardware ) -- weapon presend > 0 (panel 6) - --SendDataHW("CurrentStation", gES_PayloadInfo.CurrentStation, lHardware ) - -- air-to-air missils panel 1 and 2, air combat modus, CurrentStation = 1, panel 1 and 2 on - -- wenn die Waffenstationen gleichmässig belegt sind, hat bei Auswahl CurrentStation immer den Wert der linken Station - -- bei ungleichmäßiger Belegung, hat CurrentStation immer den Wert der jeweiligen Station - -- Waffenbezeichnung als UUID, gES_PayloadInfo.Stations[X].CLSID - - -- defination - if gES_CurrentStationTmp == nil then - gES_CurrentStationTmp = -1 - end - - if gES_PayloadInfo.CurrentStation > 0 and - gES_CurrentStationTmp ~= gES_PayloadInfo.CurrentStation then - gES_CurrentStationTmp = gES_PayloadInfo.CurrentStation - - gES_TmpStationToPanel = {} - --gES_TmpStationToPanel[1] = {Panel = 'L', StationID = 'L', CurrentID = 'L', HardwareID = lHardware } -- L - --gES_TmpStationToPanel[2] = {Panel = 'R', StationID = 'R', CurrentID = 'R', HardwareID = lHardware } -- R - gES_TmpStationToPanel[3] = {Panel = 10, StationID = 110, CurrentID = 210, HardwareID = lHardware } - gES_TmpStationToPanel[4] = {Panel = 1, StationID = 101, CurrentID = 201, HardwareID = lHardware } - gES_TmpStationToPanel[5] = {Panel = 2, StationID = 102, CurrentID = 202, HardwareID = lHardware } - gES_TmpStationToPanel[6] = {Panel = 9, StationID = 109, CurrentID = 209, HardwareID = lHardware } - gES_TmpStationToPanel[7] = {Panel = 3, StationID = 103, CurrentID = 203, HardwareID = lHardware } - gES_TmpStationToPanel[8] = {Panel = 8, StationID = 108, CurrentID = 208, HardwareID = lHardware } - gES_TmpStationToPanel[9] = {Panel = 4, StationID = 104, CurrentID = 204, HardwareID = lHardware } - gES_TmpStationToPanel[10] = {Panel = 7, StationID = 107, CurrentID = 207, HardwareID = lHardware } - gES_TmpStationToPanel[11] = {Panel = 6, StationID = 106, CurrentID = 206, HardwareID = lHardware } - gES_TmpStationToPanel[12] = {Panel = 5, StationID = 105, CurrentID = 205, HardwareID = lHardware } - - WeaponStatusPanel_Reset(201, 210, lHardware) - - if gES_TmpStationToPanel[gES_PayloadInfo.CurrentStation] ~= nil then - SendDataHW(gES_TmpStationToPanel[gES_PayloadInfo.CurrentStation].CurrentID, 1, lHardware ) -- eigentliche Auswahl - - table.foreach(gES_PayloadInfo.Stations, WeaponStatusPanel_selectCurrentPayloadStation) -- zugehörige Stationen - end - elseif gES_PayloadInfo.CurrentStation == 0 and gES_CurrentStationTmp > 0 then - WeaponStatusPanel_Reset(201, 210, lHardware) - gES_CurrentStationTmp = -1 - end -end - -function FuelQuantityIndicator(hardware) --- Fuel quantity shows the fuel remaining in all tanks - local lHardware = hardware or 1 +function ExportScript.AF.FuelQuantityIndicator(FunctionTyp) +-- Fuel quantity shows the fuel remaining in all tanks + local lFunctionTyp = FunctionTyp or "Ikarus" local lEngineInfo = LoGetEngineInfo() if lEngineInfo == nil then return end - --WriteToLog('lEngineInfo: '..dump(lEngineInfo)) + --ExportScript.Tools.WriteToLog('lEngineInfo: '..ExportScript.Tools.dump(lEngineInfo)) --[[ [fuel_external] = number: "0" [Temperature] = { @@ -752,27 +411,62 @@ function FuelQuantityIndicator(hardware) } lPayloadInfo.Stations[8].CLSID == E8D4652F-FD48-45B7-BA5B-2AE05BB5A9CF -- ext 800l Fuel Tank ]] + + if ExportScript.Config.IkarusExport and lFunctionTyp == "Ikarus" then + lTotalFuel = lEngineInfo.fuel_internal + --lTotalFuel = string.format("%3d", ExportScript.Tools.round((lEngineInfo.fuel_internal / 10), 0, "ceil") * 10) + --lTotalFuel = string.format("%4d", lEngineInfo.fuel_internal) -- total fuel in kg + --lTotalFuel = string.format("%4d", lEngineInfo.fuel_external) -- external fuel in kg + local lTotalFuel_12_0 = 1.0 - SendDataHW("300", string.format("%d", math.round((lEngineInfo.fuel_internal / 10), 0, "ceil") * 10), lHardware ) -- total fuel in kg - --SendDataHW("301", string.format("%d", lEngineInfo.fuel_internal), lHardware ) -- total fuel in kg - --SendDataHW("302", string.format("%d", lEngineInfo.fuel_external), lHardware ) -- external fuel in kg - - SendDataHW("304", (lEngineInfo.fuel_internal < 5000.0 and 1 or 0), lHardware ) -- Tank warning 1 - SendDataHW("305", (lEngineInfo.fuel_internal < 1000.0 and 1 or 0), lHardware ) -- Tank warning 2 4000 - SendDataHW("306", (lEngineInfo.fuel_internal < 4000.0 and 1 or 0), lHardware ) -- Tank warning 3 1500 - SendDataHW("307", (lEngineInfo.fuel_internal < 1500.0 and 1 or 0), lHardware ) -- Tank warning 4 1000 - SendDataHW("308", (lEngineInfo.fuel_internal < 600.0 and 1 or 0), lHardware ) -- Bingo Fuel - + if lTotalFuel < 12000 then + --[[ + y_min = 0.0 -- minimaler Ausgabewert + y_max = 1.0 -- maximaler Ausgabewert + x_min = 0 -- minimaler Eingangswert + x_max = 12000 -- maximaler Eingangswert + x = 8000 -- aktueller Eingangswert + + d_y = 1 -- Delta Ausgabewerte (y_max - y_min) + d_x = 12000 -- Delta Eingangswerte (x_max - x_min) + m = 8.3333333333333333333333333333333e-5 -- Steigung der linearen Funktion (d_y / d_x) + n = 4.e-33 -- Schnittpunkt der Funktion mit y-Achse (y_max - m * x_max) + + y = 0.66666666666666666666666666666667 -- Ergebnis (m * x + n) + ]] + lTotalFuel_12_0 = 8.3333333333333333333333333333333e-5 * lTotalFuel + 4.e-33 + end + + ExportScript.Tools.SendData("301", string.format("%.4f", lTotalFuel_12_0) ) + ExportScript.Tools.SendData("304", (lEngineInfo.fuel_internal < 5000.0 and 1 or 0) ) -- Tank warning 1 + ExportScript.Tools.SendData("305", (lEngineInfo.fuel_internal < 1000.0 and 1 or 0) ) -- Tank warning 2 4000 + ExportScript.Tools.SendData("306", (lEngineInfo.fuel_internal < 4000.0 and 1 or 0) ) -- Tank warning 3 1500 + ExportScript.Tools.SendData("307", (lEngineInfo.fuel_internal < 1500.0 and 1 or 0) ) -- Tank warning 4 1000 + ExportScript.Tools.SendData("308", (lEngineInfo.fuel_internal < 600.0 and 1 or 0) ) -- Bingo Fuel + + ExportScript.AF.FC_OneNeedleGauge(lEngineInfo.fuel_internal, 10000, 302) -- Standby Fuel Indicator + end + + if ExportScript.Config.DACExport and lFunctionTyp == "DAC" then + ExportScript.Tools.SendDataDAC("300", string.format("%d", ExportScript.Tools.round((lEngineInfo.fuel_internal / 10), 0, "ceil") * 10) ) -- total fuel in kg + --ExportScript.Tools.SendDataDAC("301", string.format("%d", lEngineInfo.fuel_internal) ) -- total fuel in kg + --ExportScript.Tools.SendDataDAC("302", string.format("%d", lEngineInfo.fuel_external) ) -- external fuel in kg + + ExportScript.Tools.SendDataDAC("304", (lEngineInfo.fuel_internal < 5000.0 and 1 or 0) ) -- Tank warning 1 + ExportScript.Tools.SendDataDAC("305", (lEngineInfo.fuel_internal < 1000.0 and 1 or 0) ) -- Tank warning 2 4000 + ExportScript.Tools.SendDataDAC("306", (lEngineInfo.fuel_internal < 4000.0 and 1 or 0) ) -- Tank warning 3 1500 + ExportScript.Tools.SendDataDAC("307", (lEngineInfo.fuel_internal < 1500.0 and 1 or 0) ) -- Tank warning 4 1000 + ExportScript.Tools.SendDataDAC("308", (lEngineInfo.fuel_internal < 600.0 and 1 or 0) ) -- Bingo Fuel + end end - -function MechanicalDevicesIndicator(hardware) + +function ExportScript.AF.MechanicalDevicesIndicator(FunctionTyp) + local lFunctionTyp = FunctionTyp or "Ikarus" -- The mechanical devices indicator shows the position of the landing gear, flaps, leading edge flaps and airbrake - local lHardware = hardware or 1 local lMechInfo = LoGetMechInfo() -- mechanical components, e.g. Flaps, Wheelbrakes,... if lMechInfo == nil then return end - --WriteToLog('lMechInfo: '..dump(lMechInfo)) --[[ [hook] = { [status] = number: "0" @@ -843,38 +537,191 @@ function MechanicalDevicesIndicator(hardware) [status] = number: "0" [value] = number: "0" }]] - --SendDataHW("500", lMechInfo.gear.status ) - --SendDataHW("501", lMechInfo.gear.value ) - --SendDataHW("502", lMechInfo.gear.nose.rod ) -- zeigt an wie weit das Fahrwerk einsackt wenn das Flugzeug auf dem Boden ist - --SendDataHW("503", lMechInfo.gear.main.left.rod ) -- zeigt an wie weit das Fahrwerk einsackt wenn das Flugzeug auf dem Boden ist - --SendDataHW("504", lMechInfo.gear.main.right.rod ) -- zeigt an wie weit das Fahrwerk einsackt wenn das Flugzeug auf dem Boden ist - --SendDataHW("500", ((lMechInfo.gear.status == 1 and lMechInfo.gear.value < 1) and 1 or 0 ) ) -- gear warning light, go up - --SendDataHW("500", ((lMechInfo.gear.status == 0 and lMechInfo.gear.value > 0) and 1 or 0 ) ) -- gear warning light, go down - SendDataHW("500", (((lMechInfo.gear.status == 1 and lMechInfo.gear.value < 1) or (lMechInfo.gear.status == 0 and lMechInfo.gear.value > 0)) and 1 or 0 ), lHardware ) -- gear warning light - SendDataHW("501", (lMechInfo.gear.value > 0.85 and 1 or 0), lHardware ) -- nose gear - SendDataHW("502", (lMechInfo.gear.value > 0.95 and 1 or 0), lHardware ) -- left gear - SendDataHW("503", (lMechInfo.gear.value == 1 and 1 or 0), lHardware ) -- right gear - - --SendDataHW("510", lMechInfo.speedbrakes.status ) -- speedbreakes on 1 (0|1) - SendDataHW("510", (lMechInfo.speedbrakes.value > 0.1 and 1 or 0), lHardware ) -- speedbreakes on > 0.1 (0 - 1) + local lTrueAirSpeed = LoGetTrueAirSpeed() + + if ExportScript.Config.DACExport and lFunctionTyp == "DAC" then + ExportScript.Tools.SendDataDAC("500", (((lMechInfo.gear.status == 1 and lMechInfo.gear.value < 1) or (lMechInfo.gear.status == 0 and lMechInfo.gear.value > 0)) and 1 or 0 ) ) -- gear warning light + ExportScript.Tools.SendDataDAC("501", (lMechInfo.gear.value > 0.85 and 1 or 0) ) -- nose gear + ExportScript.Tools.SendDataDAC("502", (lMechInfo.gear.value > 0.95 and 1 or 0) ) -- left gear + ExportScript.Tools.SendDataDAC("503", (lMechInfo.gear.value > 0.97 and 1 or 0) ) -- right gear - --SendDataHW("520", lMechInfo.wheelbrakes.status, lHardware ) -- not in use - --SendDataHW("521", lMechInfo.wheelbrakes.value, lHardware ) -- not in use + ExportScript.Tools.SendDataDAC("510", (lMechInfo.speedbrakes.value > 0.1 and 1 or 0) ) -- speedbreakes on > 0.1 (0 - 1) - local lGetTrueAirSpeed = LoGetTrueAirSpeed() - if lGetTrueAirSpeed == nil then - lGetTrueAirSpeed = 0 + ExportScript.Tools.SendDataDAC("531", (lMechInfo.flaps.value > 0.25 and 1 or 0) ) -- flap 1. position + ExportScript.Tools.SendDataDAC("532", (lMechInfo.flaps.value > 0.93 and 1 or 0) ) -- flap 2. position + ExportScript.Tools.SendDataDAC("533", ((lMechInfo.flaps.value > 0.93 and lTrueAirSpeed > 340) and 1 or 0) ) -- Speed Warning for Flaps, same light as gear warning light, but blinking light + ExportScript.Tools.SendDataDAC("534", (lMechInfo.gear.value > 0.5 and 1 or 0) ) -- Intake FOD shields + + ExportScript.Tools.SendDataDAC("541", (lMechInfo.hook.value > 0.8 and 1 or 0) ) -- Hook + ExportScript.Tools.SendDataDAC("551", (lMechInfo.noseflap.value > 20.0 and 1 or 0) ) + end + + if ExportScript.Config.IkarusExport and lFunctionTyp == "Ikarus" then + local lWarningLight = 0.0 + + if lTrueAirSpeed ~= nil then + lWarningLight = ((lMechInfo.flaps.value > 0.93 and lTrueAirSpeed > 340) and 1.0 or 0.0) -- Speed Warning for Flaps, same light as gear warning light, but blinking light + lWarningLight = (((lMechInfo.gear.status == 1 and lMechInfo.gear.value < 1) or (lMechInfo.gear.status == 0 and lMechInfo.gear.value > 0)) and 1.0 or lWarningLight ) -- gear warning light + end + + ExportScript.Tools.SendData(500, string.format("%.1f", lWarningLight)) + ExportScript.Tools.SendData(501, (lMechInfo.gear.value > 0.85 and 1 or 0)) -- nose gear + ExportScript.Tools.SendData(502, (lMechInfo.gear.value > 0.95 and 1 or 0)) -- left gear + ExportScript.Tools.SendData(503, (lMechInfo.gear.value == 1 and 1 or 0)) -- right gear + ExportScript.Tools.SendData(510, (lMechInfo.speedbrakes.value > 0.1 and 1 or 0)) -- speedbreakes on > 0.1 (0 - 1) + ExportScript.Tools.SendData(531, (lMechInfo.gear.value > 0.5 and 1 or 0)) -- Intake FOD shields + ExportScript.Tools.SendData(532, (lMechInfo.flaps.value > 0.93 and 1 or 0)) -- flap + ExportScript.Tools.SendData(541, (lMechInfo.hook.value > 0.8 and 1 or 0)) -- Hook + end +end + +function ExportScript.AF.FC_WeaponPanel_SU33(FunctionTyp) + local lFunctionTyp = FunctionTyp or "Ikarus" + + if ExportScript.AF.TmpWeaponPanelPresend == nil then + ExportScript.AF.TmpWeaponPanelPresend = {[101] = 0, [102] = 0, [103] = 0, [104] = 0, [105] = 0, [106] = 0, [107] = 0, [108] = 0, [109] = 0, [110] = 0} + end + + if ExportScript.AF.TmpWeaponPanelActive == nil then + ExportScript.AF.TmpWeaponPanelActive = {[201] = 0, [202] = 0, [203] = 0, [204] = 0, [205] = 0, [206] = 0, [207] = 0, [208] = 0, [209] = 0, [210] = 0} + end + + if ExportScript.AF.TmpWeaponPanel == nil then + ExportScript.AF.TmpWeaponPanel = {[231] = 0, [232] = 0, [233] = 0, [234] = 0, [235] = 0} + end + + if ExportScript.AF.EventNumberFC_WeaponPanel == nil then + ExportScript.AF.EventNumberFC_WeaponPanel = 0 + end + + if(ExportScript.AF.EventNumberFC_WeaponPanel < ExportScript.AF.EventNumber) then + ExportScript.AF.EventNumberFC_WeaponPanel = ExportScript.AF.EventNumber + + -- defination + ExportScript.AF.PayloadInfo = LoGetPayloadInfo() + if ExportScript.AF.PayloadInfo ~= nil then + if ExportScript.AF.CurrentStationTmp == nil then + ExportScript.AF.CurrentStationTmp = -1 + end + + if ExportScript.AF.PayloadInfo.CurrentStation > 0 and + ExportScript.AF.CurrentStationTmp ~= ExportScript.AF.PayloadInfo.CurrentStation then + ExportScript.AF.CurrentStationTmp = ExportScript.AF.PayloadInfo.CurrentStation + + ExportScript.AF.TmpStationToPanel = {} + --ExportScript.AF.TmpStationToPanel[1] = {Panel = 1, StationID = 101, CurrentID = 201 } -- L + --ExportScript.AF.TmpStationToPanel[2] = {Panel = 10, StationID = 110, CurrentID = 210 } -- L + ExportScript.AF.TmpStationToPanel[3] = {Panel = 10, StationID = 110, CurrentID = 210 } + ExportScript.AF.TmpStationToPanel[4] = {Panel = 1, StationID = 101, CurrentID = 201 } + ExportScript.AF.TmpStationToPanel[5] = {Panel = 2, StationID = 102, CurrentID = 202 } + ExportScript.AF.TmpStationToPanel[6] = {Panel = 9, StationID = 109, CurrentID = 209 } + ExportScript.AF.TmpStationToPanel[7] = {Panel = 3, StationID = 103, CurrentID = 203 } + ExportScript.AF.TmpStationToPanel[8] = {Panel = 8, StationID = 108, CurrentID = 208 } + ExportScript.AF.TmpStationToPanel[9] = {Panel = 4, StationID = 104, CurrentID = 204 } + ExportScript.AF.TmpStationToPanel[10] = {Panel = 7, StationID = 107, CurrentID = 207 } + ExportScript.AF.TmpStationToPanel[11] = {Panel = 6, StationID = 106, CurrentID = 206 } + ExportScript.AF.TmpStationToPanel[12] = {Panel = 5, StationID = 105, CurrentID = 205 } + + -- ExportScript.AF.TmpWeaponPanelActive reset + for i = 201, 210, 1 do + ExportScript.AF.TmpWeaponPanelActive[i] = 0 + end + + if ExportScript.AF.TmpStationToPanel[ExportScript.AF.PayloadInfo.CurrentStation] ~= nil then + ExportScript.AF.TmpWeaponPanelActive[ExportScript.AF.TmpStationToPanel[ExportScript.AF.PayloadInfo.CurrentStation].CurrentID] = 1 -- currrent value + + table.foreach(ExportScript.AF.PayloadInfo.Stations, ExportScript.AF.WeaponStatusPanel_selectCurrentPayloadStation) -- corresponding station + end + end + + local lWeaponType = 0.0 -- transversely striped + if ExportScript.AF.PayloadInfo.CurrentStation > 0 then + if ExportScript.AF.PayloadInfo.Stations[ExportScript.AF.PayloadInfo.CurrentStation].weapon.level1 == 4 then + if ExportScript.AF.PayloadInfo.Stations[ExportScript.AF.PayloadInfo.CurrentStation].weapon.level2 == 4 then -- Weapon type Missle + lWeaponType = 0.1 -- MSL + elseif ExportScript.AF.PayloadInfo.Stations[ExportScript.AF.PayloadInfo.CurrentStation].weapon.level2 == 7 then -- Weapon type NURS with Container + if ExportScript.AF.PayloadInfo.Stations[ExportScript.AF.PayloadInfo.CurrentStation].weapon.level3 == 33 then -- Weapon type Rocket + lWeaponType = 0.2 -- RCT + end + elseif ExportScript.AF.PayloadInfo.Stations[ExportScript.AF.PayloadInfo.CurrentStation].weapon.level2 == 5 then -- Weapon type Bomb + lWeaponType = 0.3 -- BB + end + end + end + + --[[ + Weapon Panel (Numper = Station number) + | + ------------------------------------------------------- + | | | | | | | | | | | | + L 1 2 3 4 5 6 7 8 9 10 R -- Panel ID + 1 4 5 7 9 12 11 10 8 6 3 2 -- gES_PayloadInfo.Station.ID + ]] + -- Payload Info + -- weapon stations L and R not on Panel + -- weapon station 1 (left) to 10 (right), 5 and 6 center station + + -- WeaponPresend1 {0, 1} + -- WeaponPresend2 {0, 1} + -- WeaponPresend3 {0, 1} + -- WeaponPresend4 {0, 1} + -- WeaponPresend5 {0, 1} + -- WeaponPresend6 {0, 1} + -- WeaponPresend7 {0, 1} + -- WeaponPresend8 {0, 1} + -- WeaponPresend9 {0, 1} + -- WeaponPresend10 {0, 1} + -- WeaponActive1 {0, 1} + -- WeaponActive2 {0, 1} + -- WeaponActive3 {0, 1} + -- WeaponActive4 {0, 1} + -- WeaponActive5 {0, 1} + -- WeaponActive6 {0, 1} + -- WeaponActive7 {0, 1} + -- WeaponActive8 {0, 1} + -- WeaponActive9 {0, 1} + -- WeaponActive10 {0, 1} + + --ExportScript.AF.TmpWeaponPanelPresend[] = (ExportScript.AF.PayloadInfo.Stations[1].count > 0 and 1 or 0) -- L + --ExportScript.AF.TmpWeaponPanelPresend[] = (ExportScript.AF.PayloadInfo.Stations[2].count > 0 and 1 or 0) -- R + ExportScript.AF.TmpWeaponPanelPresend[110] = (ExportScript.AF.PayloadInfo.Stations[3].count > 0 and 1 or 0) -- weapon presend panel 1 + ExportScript.AF.TmpWeaponPanelPresend[101] = (ExportScript.AF.PayloadInfo.Stations[4].count > 0 and 1 or 0) -- weapon presend panel 10 + ExportScript.AF.TmpWeaponPanelPresend[102] = (ExportScript.AF.PayloadInfo.Stations[5].count > 0 and 1 or 0) -- weapon presend panel 2 + ExportScript.AF.TmpWeaponPanelPresend[109] = (ExportScript.AF.PayloadInfo.Stations[6].count > 0 and 1 or 0) -- weapon presend panel 9 + ExportScript.AF.TmpWeaponPanelPresend[103] = (ExportScript.AF.PayloadInfo.Stations[7].count > 0 and 1 or 0) -- weapon presend panel 3 + ExportScript.AF.TmpWeaponPanelPresend[108] = (ExportScript.AF.PayloadInfo.Stations[8].count > 0 and 1 or 0) -- weapon presend panel 8 + ExportScript.AF.TmpWeaponPanelPresend[104] = (ExportScript.AF.PayloadInfo.Stations[9].count > 0 and 1 or 0) -- weapon presend panel 4 + ExportScript.AF.TmpWeaponPanelPresend[107] = (ExportScript.AF.PayloadInfo.Stations[10].count > 0 and 1 or 0) -- weapon presend panel 7 + ExportScript.AF.TmpWeaponPanelPresend[106] = (ExportScript.AF.PayloadInfo.Stations[11].count > 0 and 1 or 0) -- weapon presend panel 5 + ExportScript.AF.TmpWeaponPanelPresend[105] = (ExportScript.AF.PayloadInfo.Stations[12].count > 0 and 1 or 0) -- weapon presend panel 6 + --ExportScript.AF.TmpWeaponPanelActive[201] -- weapon active panel 1 + --ExportScript.AF.TmpWeaponPanelActive[202] -- weapon active panel 2 + --ExportScript.AF.TmpWeaponPanelActive[203] -- weapon active panel 3 + --ExportScript.AF.TmpWeaponPanelActive[204] -- weapon active panel 4 + --ExportScript.AF.TmpWeaponPanelActive[205] -- weapon active panel 5 + --ExportScript.AF.TmpWeaponPanelActive[206] -- weapon active panel 6 + --ExportScript.AF.TmpWeaponPanelActive[207] -- weapon active panel 7 + --ExportScript.AF.TmpWeaponPanelActive[208] -- weapon active panel 8 + --ExportScript.AF.TmpWeaponPanelActive[209] -- weapon active panel 9 + --ExportScript.AF.TmpWeaponPanelActive[210] -- weapon active panel 10 + end + end + + if ExportScript.Config.IkarusExport and lFunctionTyp == "Ikarus" then + for key, value in pairs(ExportScript.AF.TmpWeaponPanelPresend) do + ExportScript.Tools.SendData(key, value) + end + for key, value in pairs(ExportScript.AF.TmpWeaponPanelActive) do + ExportScript.Tools.SendData(key, value) + end + end + + if ExportScript.Config.DACExport and lFunctionTyp == "DAC" then + for key, value in pairs(ExportScript.AF.TmpWeaponPanelPresend) do + ExportScript.Tools.SendDataDAC(key, value) + end + for key, value in pairs(ExportScript.AF.TmpWeaponPanelActive) do + ExportScript.Tools.SendDataDAC(key, value) + end end - --SendDataHW("530", lMechInfo.flaps.status ) -- flap switch off 0, 1. position 1, 2. position 2 (0|1|2) - --SendDataHW("531", lMechInfo.flaps.value ) -- flap 1. position > 0.25, 2. position > 0.93 (0 - 1) - SendDataHW("531", (lMechInfo.flaps.value > 0.25 and 1 or 0), lHardware ) -- flap 1. position - SendDataHW("532", (lMechInfo.flaps.value > 0.93 and 1 or 0), lHardware ) -- flap 2. position - SendDataHW("533", ((lMechInfo.flaps.value > 0.93 and lGetTrueAirSpeed > 340) and 1 or 0), lHardware ) -- Speed Warning for Flaps, same light as gear warning light, but blinking light - SendDataHW("534", (lMechInfo.gear.value > 0.5 and 1 or 0), lHardware ) -- Intake FOD shields - - --SendDataHW("540", lMechInfo.parachute.status ) - SendDataHW("541", (lMechInfo.hook.value > 0.8 and 1 or 0), lHardware ) - - --SendDataHW("550", lMechInfo.noseflap.status ) - SendDataHW("551", (lMechInfo.noseflap.value > 20.0 and 1 or 0), lHardware ) end \ No newline at end of file