Added fuel level function
This commit is contained in:
parent
f3257a15b8
commit
b30d1ec59d
@ -5,7 +5,7 @@ object ButtonFunctionForm: TButtonFunctionForm
|
||||
BorderIcons = [biSystemMenu]
|
||||
BorderStyle = bsDialog
|
||||
Caption = 'Configure button'
|
||||
ClientHeight = 484
|
||||
ClientHeight = 561
|
||||
ClientWidth = 692
|
||||
Color = clBtnFace
|
||||
Font.Charset = DEFAULT_CHARSET
|
||||
@ -31,7 +31,7 @@ object ButtonFunctionForm: TButtonFunctionForm
|
||||
object pnlButtons: TPanel
|
||||
AlignWithMargins = True
|
||||
Left = 0
|
||||
Top = 441
|
||||
Top = 518
|
||||
Width = 692
|
||||
Height = 43
|
||||
Margins.Left = 0
|
||||
@ -41,6 +41,7 @@ object ButtonFunctionForm: TButtonFunctionForm
|
||||
Align = alBottom
|
||||
BevelOuter = bvNone
|
||||
TabOrder = 3
|
||||
ExplicitTop = 441
|
||||
DesignSize = (
|
||||
692
|
||||
43)
|
||||
@ -80,7 +81,7 @@ object ButtonFunctionForm: TButtonFunctionForm
|
||||
Left = 8
|
||||
Top = 60
|
||||
Width = 257
|
||||
Height = 373
|
||||
Height = 450
|
||||
Margins.Left = 8
|
||||
Margins.Top = 8
|
||||
Margins.Right = 0
|
||||
@ -103,6 +104,7 @@ object ButtonFunctionForm: TButtonFunctionForm
|
||||
OnGetText = vstFunctionsGetText
|
||||
OnPaintText = vstFunctionsPaintText
|
||||
OnIncrementalSearch = vstFunctionsIncrementalSearch
|
||||
ExplicitHeight = 373
|
||||
Columns = <
|
||||
item
|
||||
Position = 0
|
||||
@ -115,7 +117,7 @@ object ButtonFunctionForm: TButtonFunctionForm
|
||||
Left = 273
|
||||
Top = 60
|
||||
Width = 411
|
||||
Height = 373
|
||||
Height = 450
|
||||
Margins.Left = 8
|
||||
Margins.Top = 8
|
||||
Margins.Right = 8
|
||||
@ -123,6 +125,7 @@ object ButtonFunctionForm: TButtonFunctionForm
|
||||
Align = alClient
|
||||
BevelOuter = bvNone
|
||||
TabOrder = 2
|
||||
ExplicitHeight = 373
|
||||
object pnlName: TPanel
|
||||
Left = 0
|
||||
Top = 0
|
||||
@ -190,10 +193,11 @@ object ButtonFunctionForm: TButtonFunctionForm
|
||||
Left = 0
|
||||
Top = 97
|
||||
Width = 411
|
||||
Height = 276
|
||||
Height = 353
|
||||
Align = alClient
|
||||
BorderStyle = bsNone
|
||||
TabOrder = 1
|
||||
ExplicitHeight = 276
|
||||
end
|
||||
end
|
||||
object pnlHeader: TPanel
|
||||
|
@ -8,7 +8,7 @@
|
||||
<FrameworkType>VCL</FrameworkType>
|
||||
<ProjectVersion>13.4</ProjectVersion>
|
||||
<Base>True</Base>
|
||||
<Config Condition="'$(Config)'==''">Release</Config>
|
||||
<Config Condition="'$(Config)'==''">Debug</Config>
|
||||
<Platform Condition="'$(Platform)'==''">Win32</Platform>
|
||||
<TargetedPlatforms>1</TargetedPlatforms>
|
||||
<AppType>Application</AppType>
|
||||
@ -103,7 +103,7 @@
|
||||
<PropertyGroup Condition="'$(Cfg_2_Win32)'!=''">
|
||||
<VerInfo_IncludeVerInfo>false</VerInfo_IncludeVerInfo>
|
||||
<VerInfo_Keys>CompanyName=;FileDescription=;FileVersion=0.2.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=0.2;Comments=</VerInfo_Keys>
|
||||
<Manifest_File>F:\Components\X2Utils\Resources\VistaManAsInvoker.manifest</Manifest_File>
|
||||
<Manifest_File>$(BDS)\bin\default_app.manifest</Manifest_File>
|
||||
<VerInfo_Locale>1033</VerInfo_Locale>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
@ -200,9 +200,7 @@
|
||||
<VersionInfoKeys Name="ProductVersion">1.0.0.0</VersionInfoKeys>
|
||||
<VersionInfoKeys Name="Comments"/>
|
||||
</VersionInfoKeys>
|
||||
<Excluded_Packages>
|
||||
<Excluded_Packages Name="D:\Program Files\Developer Express.VCL\Library\Delphi16\dclcxPivotGridOLAPD16.bpl">ExpressPivotGrid 2 OLAP by Developer Express Inc.</Excluded_Packages>
|
||||
</Excluded_Packages>
|
||||
<Excluded_Packages/>
|
||||
</Delphi.Personality>
|
||||
<Platforms>
|
||||
<Platform value="Win64">False</Platform>
|
||||
|
Binary file not shown.
@ -199,6 +199,15 @@ type
|
||||
end;
|
||||
|
||||
|
||||
{ Fuel }
|
||||
TFSXFuelFunction = class(TCustomFSXFunction)
|
||||
protected
|
||||
procedure RegisterStates; override;
|
||||
function GetCategoryName: string; override;
|
||||
function GetWorkerClass: TCustomLEDMultiStateFunctionWorkerClass; override;
|
||||
end;
|
||||
|
||||
|
||||
implementation
|
||||
uses
|
||||
FSXLEDFunctionWorker,
|
||||
@ -580,4 +589,32 @@ begin
|
||||
Result := TFSXAvionicsMasterFunctionWorker;
|
||||
end;
|
||||
|
||||
|
||||
{ TFSXFuelFunction }
|
||||
procedure TFSXFuelFunction.RegisterStates;
|
||||
begin
|
||||
RegisterState(TLEDState.Create(FSXStateUIDFuelNotAvailable, FSXStateDisplayNameFuelNotAvailable, lcOff));
|
||||
RegisterState(TLEDState.Create(FSXStateUIDFuelEmpty, FSXStateDisplayNameFuelEmpty, lcFlashingRedFast));
|
||||
RegisterState(TLEDState.Create(FSXStateUIDFuel0to1, FSXStateDisplayNameFuel0to1, lcFlashingRedNormal));
|
||||
RegisterState(TLEDState.Create(FSXStateUIDFuel1to2, FSXStateDisplayNameFuel1to2, lcFlashingRedNormal));
|
||||
RegisterState(TLEDState.Create(FSXStateUIDFuel2to5, FSXStateDisplayNameFuel2to5, lcRed));
|
||||
RegisterState(TLEDState.Create(FSXStateUIDFuel5to10, FSXStateDisplayNameFuel5to10, lcAmber));
|
||||
RegisterState(TLEDState.Create(FSXStateUIDFuel10to20, FSXStateDisplayNameFuel10to20, lcAmber));
|
||||
RegisterState(TLEDState.Create(FSXStateUIDFuel20to50, FSXStateDisplayNameFuel20to50, lcGreen));
|
||||
RegisterState(TLEDState.Create(FSXStateUIDFuel50to75, FSXStateDisplayNameFuel50to75, lcGreen));
|
||||
RegisterState(TLEDState.Create(FSXStateUIDFuel75to100, FSXStateDisplayNameFuel75to100, lcGreen));
|
||||
end;
|
||||
|
||||
|
||||
function TFSXFuelFunction.GetCategoryName: string;
|
||||
begin
|
||||
Result := FSXCategorySystems;
|
||||
end;
|
||||
|
||||
|
||||
function TFSXFuelFunction.GetWorkerClass: TCustomLEDMultiStateFunctionWorkerClass;
|
||||
begin
|
||||
Result := TFSXFuelFunctionWorker;
|
||||
end;
|
||||
|
||||
end.
|
||||
|
@ -164,6 +164,9 @@ begin
|
||||
|
||||
{ Radios }
|
||||
RegisterFunction(TFSXAvionicsMasterFunction.Create( Self, FSXFunctionDisplayNameAvionicsMaster, FSXFunctionUIDAvionicsMaster));
|
||||
|
||||
{ Fuel }
|
||||
RegisterFunction(TFSXFuelFunction.Create( Self, FSXFunctionDisplayNameFuel, FSXFunctionUIDFuel));
|
||||
end;
|
||||
|
||||
|
||||
|
@ -165,6 +165,14 @@ type
|
||||
end;
|
||||
|
||||
|
||||
{ Fuel }
|
||||
TFSXFuelFunctionWorker = class(TCustomFSXFunctionWorker)
|
||||
protected
|
||||
procedure RegisterVariables(ADefinition: IFSXSimConnectDefinition); override;
|
||||
procedure HandleData(AData: Pointer); override;
|
||||
end;
|
||||
|
||||
|
||||
implementation
|
||||
uses
|
||||
System.Math,
|
||||
@ -510,7 +518,7 @@ var
|
||||
spoilersData: PSpoilersData;
|
||||
|
||||
begin
|
||||
SpoilersData := AData;
|
||||
spoilersData := AData;
|
||||
|
||||
if SpoilersData^.SpoilersAvailable <> 0 then
|
||||
begin
|
||||
@ -651,4 +659,47 @@ begin
|
||||
SetCurrentState(FSXStateUIDOff);
|
||||
end;
|
||||
|
||||
|
||||
{ TFSXFuelFunctionWorker }
|
||||
procedure TFSXFuelFunctionWorker.RegisterVariables(ADefinition: IFSXSimConnectDefinition);
|
||||
begin
|
||||
ADefinition.AddVariable('FUEL TOTAL CAPACITY', FSX_UNIT_NUMBER, SIMCONNECT_DATAType_FLOAT64);
|
||||
ADefinition.AddVariable('FUEL TOTAL QUANTITY', FSX_UNIT_NUMBER, SIMCONNECT_DATAType_FLOAT64);
|
||||
end;
|
||||
|
||||
|
||||
procedure TFSXFuelFunctionWorker.HandleData(AData: Pointer);
|
||||
type
|
||||
PFuelData = ^TFuelData;
|
||||
TFuelData = packed record
|
||||
TotalCapacity: Double;
|
||||
TotalQuantity: Double;
|
||||
end;
|
||||
|
||||
var
|
||||
fuelData: PFuelData;
|
||||
percentage: Integer;
|
||||
|
||||
begin
|
||||
fuelData := AData;
|
||||
|
||||
if fuelData^.TotalCapacity > 0 then
|
||||
begin
|
||||
percentage := Ceil(fuelData^.TotalQuantity / fuelData^.TotalCapacity * 100);
|
||||
case percentage of
|
||||
0: SetCurrentState(FSXStateUIDFuelEmpty);
|
||||
1: SetCurrentState(FSXStateUIDFuel0to1);
|
||||
2: SetCurrentState(FSXStateUIDFuel1to2);
|
||||
3..5: SetCurrentState(FSXStateUIDFuel2to5);
|
||||
6..10: SetCurrentState(FSXStateUIDFuel5to10);
|
||||
11..20: SetCurrentState(FSXStateUIDFuel10to20);
|
||||
21..50: SetCurrentState(FSXStateUIDFuel20to50);
|
||||
51..75: SetCurrentState(FSXStateUIDFuel50to75);
|
||||
else
|
||||
SetCurrentState(FSXStateUIDFuel75to100);
|
||||
end;
|
||||
end else
|
||||
SetCurrentState(FSXStateUIDFuelNotAvailable);
|
||||
end;
|
||||
|
||||
end.
|
||||
|
@ -194,6 +194,32 @@ const
|
||||
FSXFunctionDisplayNameAutoPilotNav = 'Autopilot nav';
|
||||
|
||||
|
||||
FSXFunctionUIDFuel = 'fuelLevel';
|
||||
FSXFunctionDisplayNameFuel = 'Fuel Level';
|
||||
|
||||
FSXStateUIDFuelNotAvailable = 'notAvailable';
|
||||
FSXStateUIDFuelEmpty = 'empty';
|
||||
FSXStateUIDFuel0to1 = '0To1';
|
||||
FSXStateUIDFuel1to2 = '1To2';
|
||||
FSXStateUIDFuel2to5 = '2To5';
|
||||
FSXStateUIDFuel5to10 = '5To10';
|
||||
FSXStateUIDFuel10to20 = '10To20';
|
||||
FSXStateUIDFuel20to50 = '20To50';
|
||||
FSXStateUIDFuel50to75 = '50To75';
|
||||
FSXStateUIDFuel75to100 = '75To100';
|
||||
|
||||
FSXStateDisplayNameFuelNotAvailable = 'Not available';
|
||||
FSXStateDisplayNameFuelEmpty = 'Empty';
|
||||
FSXStateDisplayNameFuel0to1 = '< 1%';
|
||||
FSXStateDisplayNameFuel1to2 = '< 2%';
|
||||
FSXStateDisplayNameFuel2to5 = '< 5%';
|
||||
FSXStateDisplayNameFuel5to10 = '< 10%';
|
||||
FSXStateDisplayNameFuel10to20 = '< 20%';
|
||||
FSXStateDisplayNameFuel20to50 = '< 50%';
|
||||
FSXStateDisplayNameFuel50to75 = '< 75%';
|
||||
FSXStateDisplayNameFuel75to100 = '75% - Full';
|
||||
|
||||
|
||||
|
||||
FSXMenuProfiles = 'G940 Profile';
|
||||
FSXMenuProfileFormat = 'G940: %s';
|
||||
|
Loading…
Reference in New Issue
Block a user