From cda6872b3729117eed82b511273c01e9d5fdd3b0 Mon Sep 17 00:00:00 2001 From: slughead Date: Sun, 3 Dec 2023 19:37:34 +0000 Subject: [PATCH] Added logic for A-10C/A-10C2/F/A-18C left and right engine logic for console illumination. Reset aircraft state when simulation stops. --- Hooks/dcs2arget.lua | 12 ++++++++++-- dcs2target/a-10c_lamps.lua | 21 +++++++++++++++------ dcs2target/fa-18c_hornet_lamps.lua | 13 +++++++++++-- 3 files changed, 36 insertions(+), 10 deletions(-) diff --git a/Hooks/dcs2arget.lua b/Hooks/dcs2arget.lua index 4da4c29..c2a88e1 100644 --- a/Hooks/dcs2arget.lua +++ b/Hooks/dcs2arget.lua @@ -29,8 +29,10 @@ -- -- -- Author: slughead --- Date: 2/12/2023 +-- Date: 03/12/2023 -- +-- Version 1.0.6 - Added logic for A-10C/A-10C2/F/A-18C left and right engine +-- logic for console illumination. -- Version 1.0.5 - Added F/A-18C Hornet console light control. -- Version 1.0.4 - Converted from export.lua to "hooks" file. -- Version 1.0.3 - Added A-10C console light control. @@ -42,7 +44,7 @@ local generic_aircraft_utils local dcs2target = {} - dcs2target.VERSION = "DCS2TARGET v1.0.5" + dcs2target.VERSION = "DCS2TARGET v1.0.6" dcs2target.lastUpdateTime = DCS.getModelTime() @@ -87,6 +89,8 @@ end function dcs2target.onSimulationStop() log.write('dcs2target', log.INFO, 'onSimulationStop') + dcs2target.aircraft_lamp_utils = nil + if target_socket then socket.try(target_socket:send( tm_target_utils.pack_data(tm_target_utils.QUIT) )) target_socket:close() @@ -125,6 +129,10 @@ function dcs2target.onSimulationFrame() elseif (dcs2target.aircraft.Name == "FA-18C_hornet") then dcs2target.aircraft_lamp_utils = require("fa-18c_hornet_lamps") end + + if (dcs2target.aircraft_lamp_utils ~= nil) then + dcs2target.aircraft_lamp_utils.init() + end end local send_update = false diff --git a/dcs2target/a-10c_lamps.lua b/dcs2target/a-10c_lamps.lua index 7d42825..3fdc6e2 100644 --- a/dcs2target/a-10c_lamps.lua +++ b/dcs2target/a-10c_lamps.lua @@ -9,16 +9,18 @@ -- script. -- -- Author: slughead --- Date: 28/11/2023 +-- Date: 03/12/2023 -- ------------------------------------------------------------------------------ local P = {} a_10c_lamps = P - P.APU_RPM_GUAGE = 13 - P.APU_GEN_PWR_SWITCH = 241 - P.CONSOLE_LIGHT_DIAL = 297 + P.APU_RPM_GUAGE = 13 + P.APU_GEN_PWR_SWITCH = 241 + P.LEFT_AC_GENERATOR_POWER = 244 + P.RIGHT_AC_GENERATOR_POWER = 245 + P.CONSOLE_LIGHT_DIAL = 297 P.speedbrakes_value = nil P.console_light_value = nil @@ -39,8 +41,10 @@ local function get_console_light_value( current_value ) -- get engine info local lEngInfo = Export.LoGetEngineInfo() - if ((apu_rpm >= 0.7 and apu_gen_pwr_switch == 1) or (lEngInfo.RPM.left > 50)) then - + if ((apu_rpm > 0.8 and apu_gen_pwr_switch == 1) or + (lEngInfo.RPM.left > 50 and device:get_argument_value(aircraft_lamp_utils.LEFT_AC_GENERATOR_POWER) == 1) or + (lEngInfo.RPM.right > 50 and device:get_argument_value(aircraft_lamp_utils.RIGHT_AC_GENERATOR_POWER) == 1) ) + then value = device:get_argument_value(aircraft_lamp_utils.CONSOLE_LIGHT_DIAL) value = math.floor(value * 5) end @@ -78,6 +82,11 @@ local function get_speedbrake_value( current_value ) return updated, value end +function P.init( self ) + self.speedbrakes_value = nil + self.console_light_value = nil +end + function P.create_lamp_status_payload( self ) local updated = false diff --git a/dcs2target/fa-18c_hornet_lamps.lua b/dcs2target/fa-18c_hornet_lamps.lua index 04114f2..781a431 100644 --- a/dcs2target/fa-18c_hornet_lamps.lua +++ b/dcs2target/fa-18c_hornet_lamps.lua @@ -9,7 +9,7 @@ -- TMHotasLEDSync.tmc script. -- -- Author: slughead --- Date: 2/12/2023 +-- Date: 03/12/2023 -- ------------------------------------------------------------------------------ @@ -17,6 +17,8 @@ local P = {} fa_18c_hornet_lamps = P P.CONSOLE_LIGHT_DIAL = 413 + P.LEFT_GENERATOR_CONTROL_SWITCH = 402 + P.RIGHT_GENERATOR_CONTROL_SWITCH = 403 P.speedbrakes_value = nil P.console_light_value = nil @@ -33,7 +35,9 @@ local function get_console_light_value( current_value ) -- get engine info local lEngInfo = Export.LoGetEngineInfo() - if (lEngInfo.RPM.left > 60) then + if ((lEngInfo.RPM.left > 60 and device:get_argument_value(aircraft_lamp_utils.LEFT_GENERATOR_CONTROL_SWITCH) == 1) or + (lEngInfo.RPM.right > 60 and device:get_argument_value(aircraft_lamp_utils.RIGHT_GENERATOR_CONTROL_SWITCH) == 1)) + then value = device:get_argument_value(aircraft_lamp_utils.CONSOLE_LIGHT_DIAL) value = math.floor(value * 5) end @@ -68,6 +72,11 @@ local function get_speedbrake_value( current_value ) return updated, value end +function P.init( self ) + self.speedbrakes_value = nil + self.console_light_value = nil +end + function P.create_lamp_status_payload( self ) local updated = false