From 9e2fa518aabe28ae58c6c126ac12dc14c38c0bec Mon Sep 17 00:00:00 2001 From: Mark van Renswoude Date: Mon, 19 Nov 2012 19:56:37 +0000 Subject: [PATCH] Added support for spoilers (air brake) Now checks if flaps/spoilers are available --- G940LEDControl/Forms/MainFrm.pas | 3 +- G940LEDControl/G940LEDControl.dproj | 24 ++++--- G940LEDControl/G940LEDControl.res | Bin 28180 -> 28524 bytes G940LEDControl/Units/FSXLEDStateProvider.pas | 68 +++++++++++++------ 4 files changed, 64 insertions(+), 31 deletions(-) diff --git a/G940LEDControl/Forms/MainFrm.pas b/G940LEDControl/Forms/MainFrm.pas index f125931..2e29851 100644 --- a/G940LEDControl/Forms/MainFrm.pas +++ b/G940LEDControl/Forms/MainFrm.pas @@ -87,8 +87,7 @@ type procedure btnFSXToggleZoomClick(Sender: TObject); procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean); procedure FunctionComboBoxChange(Sender: TObject); - procedure lblLinkLinkClick(Sender: TObject; const Link: string; - LinkType: TSysLinkType); + procedure lblLinkLinkClick(Sender: TObject; const Link: string; LinkType: TSysLinkType); private FEventMonitor: TOmniEventMonitor; FStateConsumerTask: IOmniTaskControl; diff --git a/G940LEDControl/G940LEDControl.dproj b/G940LEDControl/G940LEDControl.dproj index 90392a4..8b9dff9 100644 --- a/G940LEDControl/G940LEDControl.dproj +++ b/G940LEDControl/G940LEDControl.dproj @@ -49,8 +49,16 @@ true + Lib + 0 + Bin + ..\Shared;$(DCC_UnitSearchPath) + true + 2 + None + G940LEDControl_Icon.ico Vcl;Vcl.Imaging;Vcl.Touch;Vcl.Samples;Vcl.Shell;System;Xml;Data;Datasnap;Web;Soap;Winapi;System.Win;$(DCC_Namespace) - CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments= + CompanyName=X²Software;FileDescription=G940 LED Control;FileVersion=0.2.0.0;InternalName=;LegalCopyright=© 2011 X²Software;LegalTrademarks=;OriginalFilename=G940LEDControl.exe;ProductName=G940 LED Control;ProductVersion=0.2;Comments= 1043 @@ -61,8 +69,6 @@ false false false - true - G940LEDControl_Icon.ico Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde;$(DCC_Namespace) 1033 $(BDS)\bin\default_app.manifest @@ -75,17 +81,17 @@ RELEASE;$(DCC_Define) - true + 1 + 3 + CompanyName=X²Software;FileDescription=G940 LED Control;FileVersion=0.3.1.0;InternalName=;LegalCopyright=© 2011 X²Software;LegalTrademarks=;OriginalFilename=G940LEDControl.exe;ProductName=G940 LED Control;ProductVersion=0.3;Comments= 1033 + $(BDS)\bin\default_app.manifest 7.0 DEBUG;$(DCC_Define) - Bin - Lib Lib Lib - ..\DirectX;..\Shared;$(DCC_UnitSearchPath) ..\DirectX;..\Shared;$(DCC_ResourcePath) ..\DirectX;..\Shared;$(DCC_ObjPath) ..\DirectX;..\Shared;$(DCC_IncludePath) @@ -93,10 +99,8 @@ False - 2 - 0 + false CompanyName=;FileDescription=;FileVersion=0.2.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=0.2;Comments= - true F:\Components\X2Utils\Resources\VistaManAsInvoker.manifest 1033 diff --git a/G940LEDControl/G940LEDControl.res b/G940LEDControl/G940LEDControl.res index ea50f477d91adbf85c1c7c9aed77555e5258c2e3..e8d7e2c259a05d3f1b33df851d077be8cacab5f3 100644 GIT binary patch delta 496 zcmZ{gy-EW?6ot>Mv5+(xyHsmzW!b0*X`@k*5Ct1s@h2{9euyh77W)b=u}EcatFNM! z;uH7)cJZ5Gg9t7-Q4<>ktg|*#^YIFxJjXA3hu%&^0InRoN`Yi zY<9EYeVXjPl0Fk{2wnv>XB*t5H5Ku%tEZ0oI#gHJYGFG%aWn^d)IPtbN_2^Tko$Ku zN8Y9)#dtQrxsLdaU`aT8Fxj<5HENd8-Bg1>-xcc;G$1HOu;Sc&BL>s=S66;Y!lV?<@!t~GINb~9N!89WLyEe n>aOiQr~OzLw4D4JSKjXb-NLb?0-}C$49li8?Pl;)Gq3R%;tEm4 delta 136 zcmaEJk8#Q!#t8~a4vY*83JeSk|NjdBF^~fU1`M1mUZs}-3R zFif1MBw7QMW&|oW0b)xq?aE*>Ig(LX*pNXF$cJGDpbC!3*-VPODB_zZGTqJr0J~@x A6#xJL diff --git a/G940LEDControl/Units/FSXLEDStateProvider.pas b/G940LEDControl/Units/FSXLEDStateProvider.pas index c282b60..871779d 100644 --- a/G940LEDControl/Units/FSXLEDStateProvider.pas +++ b/G940LEDControl/Units/FSXLEDStateProvider.pas @@ -29,6 +29,8 @@ const FUNCTION_FSX_BATTERYMASTER = FUNCTION_PROVIDER_OFFSET + 11; FUNCTION_FSX_AVIONICSMASTER = FUNCTION_PROVIDER_OFFSET + 12; + FUNCTION_FSX_SPOILERS = FUNCTION_PROVIDER_OFFSET + 13; + type TFSXLEDStateProvider = class(TLEDStateProvider) @@ -90,7 +92,7 @@ const DEFINITION_ENGINE = 5; DEFINITION_THROTTLE = 6; DEFINITION_EXITDOOR = 7; - DEFINITION_FLAPS = 8; + DEFINITION_FLAPSSPOILERS = 8; DEFINITION_SWITCHES = 9; EVENT_ZOOM = 10; @@ -107,9 +109,12 @@ const FSX_VARIABLE_GEARDAMAGEBYSPEED = 'GEAR DAMAGE BY SPEED'; FSX_VARIABLE_GEARSPEEDEXCEEDED = 'GEAR SPEED EXCEEDED'; FSX_VARIABLE_CANOPYOPEN = 'CANOPY OPEN'; + FSX_VARIABLE_FLAPSAVAILABLE = 'FLAPS AVAILABLE'; FSX_VARIABLE_FLAPSHANDLEPERCENT = 'FLAPS HANDLE PERCENT'; FSX_VARIABLE_AVIONICSMASTERSWITCH = 'AVIONICS MASTER SWITCH'; FSX_VARIABLE_ELECTRICALMASTERBATTERY = 'ELECTRICAL MASTER BATTERY'; + FSX_VARIABLE_SPOILERSAVAILABLE = 'SPOILER AVAILABLE'; + FSX_VARIABLE_SPOILERSHANDLEPOSITION = 'SPOILERS HANDLE POSITION'; @@ -141,6 +146,8 @@ const FUNCTION_DESC_FSX_BATTERYMASTER = 'Battery master switch'; FUNCTION_DESC_FSX_AVIONICSMASTER = 'Avionics master switch'; + FUNCTION_DESC_FSX_SPOILERS = 'Spoilers (air brake)'; + type TThrottleData = packed record NumberOfEngines: Integer; @@ -168,6 +175,8 @@ begin AConsumer.AddFunction(FUNCTION_FSX_FLAPS, FUNCTION_DESC_FSX_FLAPS); AConsumer.AddFunction(FUNCTION_FSX_BATTERYMASTER, FUNCTION_DESC_FSX_BATTERYMASTER); AConsumer.AddFunction(FUNCTION_FSX_AVIONICSMASTER, FUNCTION_DESC_FSX_AVIONICSMASTER); + + AConsumer.AddFunction(FUNCTION_FSX_SPOILERS, FUNCTION_DESC_FSX_SPOILERS); end; @@ -307,11 +316,15 @@ begin AddDefinition(DEFINITION_EXITDOOR); end; - { Flaps } - if Consumer.FunctionMap.HasFunction(FUNCTION_FSX_FLAPS) then + { Flaps & spoilers } + if Consumer.FunctionMap.HasFunction(FUNCTION_FSX_FLAPS) or + Consumer.FunctionMap.HasFunction(FUNCTION_FSX_SPOILERS) then begin - AddVariable(DEFINITION_FLAPS, FSX_VARIABLE_FLAPSHANDLEPERCENT, FSX_UNIT_PERCENT, SIMCONNECT_DATAType_FLOAT64); - AddDefinition(DEFINITION_FLAPS); + AddVariable(DEFINITION_FLAPSSPOILERS, FSX_VARIABLE_FLAPSAVAILABLE, FSX_UNIT_BOOL, SIMCONNECT_DATAType_INT32); + AddVariable(DEFINITION_FLAPSSPOILERS, FSX_VARIABLE_FLAPSHANDLEPERCENT, FSX_UNIT_PERCENT, SIMCONNECT_DATAType_FLOAT64); + AddVariable(DEFINITION_FLAPSSPOILERS, FSX_VARIABLE_SPOILERSAVAILABLE, FSX_UNIT_BOOL, SIMCONNECT_DATAType_INT32); + AddVariable(DEFINITION_FLAPSSPOILERS, FSX_VARIABLE_SPOILERSHANDLEPOSITION, FSX_UNIT_PERCENT, SIMCONNECT_DATAType_FLOAT64); + AddDefinition(DEFINITION_FLAPSSPOILERS); end; { Master switches } @@ -363,7 +376,7 @@ begin DEFINITION_PARKINGBRAKE: HandleParkingBrakeData(data); DEFINITION_ENGINE: HandleEngineData(data); DEFINITION_EXITDOOR: HandleExitDoorData(data); - DEFINITION_FLAPS: HandleFlapsData(data); + DEFINITION_FLAPSSPOILERS: HandleFlapsData(data); DEFINITION_SWITCHES: HandleSwitchesData(data); { DEFINITION_THROTTLE: @@ -397,7 +410,7 @@ procedure TFSXLEDStateProvider.HandleGearData(AData: Pointer); type PGearData = ^TGearData; TGearData = packed record - IsGearRetractable: Integer; + IsGearRetractable: Cardinal; TotalPctExtended: Double; DamageBySpeed: Integer; SpeedExceeded: Integer; @@ -418,9 +431,9 @@ begin else if gearData^.IsGearRetractable <> 0 then begin case Trunc(gearData ^.TotalPctExtended * 100) of - 0: Consumer.SetStateByFunction(FUNCTION_FSX_GEAR, lsRed); - 100: Consumer.SetStateByFunction(FUNCTION_FSX_GEAR, lsGreen); - else Consumer.SetStateByFunction(FUNCTION_FSX_GEAR, lsAmber); + 0: Consumer.SetStateByFunction(FUNCTION_FSX_GEAR, lsRed); + 95..100: Consumer.SetStateByFunction(FUNCTION_FSX_GEAR, lsGreen); + else Consumer.SetStateByFunction(FUNCTION_FSX_GEAR, lsAmber); end; end else Consumer.SetStateByFunction(FUNCTION_FSX_GEAR, lsOff); @@ -508,9 +521,9 @@ begin exitDoorData := AData; case Trunc(exitDoorData^.PercentOpen) of - 0: Consumer.SetStateByFunction(FUNCTION_FSX_EXITDOOR, lsGreen); - 100: Consumer.SetStateByFunction(FUNCTION_FSX_EXITDOOR, lsRed); - else Consumer.SetStateByFunction(FUNCTION_FSX_EXITDOOR, lsAmber); + 0: Consumer.SetStateByFunction(FUNCTION_FSX_EXITDOOR, lsGreen); + 95..100: Consumer.SetStateByFunction(FUNCTION_FSX_EXITDOOR, lsRed); + else Consumer.SetStateByFunction(FUNCTION_FSX_EXITDOOR, lsAmber); end; end; @@ -519,7 +532,10 @@ procedure TFSXLEDStateProvider.HandleFlapsData(AData: Pointer); type PFlapsData = ^TFlapsData; TFlapsData = packed record - HandlePercent: Double; + FlapsAvailable: Cardinal; + FlapsHandlePercent: Double; + SpoilersAvailable: Cardinal; + SpoilersHandlePercent: Double; end; var @@ -528,11 +544,25 @@ var begin flapsData := AData; - case Trunc(flapsData^.HandlePercent) of - 0: Consumer.SetStateByFunction(FUNCTION_FSX_FLAPS, lsGreen); - 100: Consumer.SetStateByFunction(FUNCTION_FSX_FLAPS, lsRed); - else Consumer.SetStateByFunction(FUNCTION_FSX_FLAPS, lsAmber); - end; + if flapsData^.FlapsAvailable <> 0 then + begin + case Trunc(flapsData^.FlapsHandlePercent) of + 0: Consumer.SetStateByFunction(FUNCTION_FSX_FLAPS, lsGreen); + 95..100: Consumer.SetStateByFunction(FUNCTION_FSX_FLAPS, lsRed); + else Consumer.SetStateByFunction(FUNCTION_FSX_FLAPS, lsAmber); + end; + end else + Consumer.SetStateByFunction(FUNCTION_FSX_FLAPS, lsOff); + + if flapsData^.SpoilersAvailable <> 0 then + begin + case Trunc(flapsData^.SpoilersHandlePercent) of + 0: Consumer.SetStateByFunction(FUNCTION_FSX_SPOILERS, lsGreen); + 95..100: Consumer.SetStateByFunction(FUNCTION_FSX_SPOILERS, lsRed); + else Consumer.SetStateByFunction(FUNCTION_FSX_SPOILERS, lsAmber); + end; + end else + Consumer.SetStateByFunction(FUNCTION_FSX_SPOILERS, lsOff); end;