1
0
mirror of synced 2024-11-16 15:33:50 +00:00

Added: converting old registry settings to new XMLs

Added: framework for all converted FSX functions
This commit is contained in:
Mark van Renswoude 2013-02-22 21:52:12 +00:00
parent 25a26c1888
commit 2cef07e337
12 changed files with 1192 additions and 295 deletions

View File

@ -14,7 +14,6 @@ object MainForm: TMainForm
Font.Style = [] Font.Style = []
OldCreateOrder = False OldCreateOrder = False
Position = poScreenCenter Position = poScreenCenter
OnCloseQuery = FormCloseQuery
OnCreate = FormCreate OnCreate = FormCreate
OnDestroy = FormDestroy OnDestroy = FormDestroy
PixelsPerInch = 96 PixelsPerInch = 96
@ -450,6 +449,7 @@ object MainForm: TMainForm
Height = 17 Height = 17
Caption = ' Automatically check for &updates' Caption = ' Automatically check for &updates'
TabOrder = 2 TabOrder = 2
OnClick = cbCheckUpdatesClick
end end
object btnCheckUpdates: TButton object btnCheckUpdates: TButton
Left = 344 Left = 344

View File

@ -20,7 +20,8 @@ uses
X2UtPersistIntf, X2UtPersistIntf,
LEDStateConsumer, LEDStateConsumer,
Profile, Vcl.AppEvnts; Profile,
Settings;
const const
@ -96,12 +97,12 @@ type
bvlProfiles: TBevel; bvlProfiles: TBevel;
procedure FormCreate(Sender: TObject); procedure FormCreate(Sender: TObject);
procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
procedure lblLinkLinkClick(Sender: TObject; const Link: string; LinkType: TSysLinkType); procedure lblLinkLinkClick(Sender: TObject; const Link: string; LinkType: TSysLinkType);
procedure btnCheckUpdatesClick(Sender: TObject); procedure btnCheckUpdatesClick(Sender: TObject);
procedure LEDButtonClick(Sender: TObject); procedure LEDButtonClick(Sender: TObject);
procedure FormDestroy(Sender: TObject); procedure FormDestroy(Sender: TObject);
procedure cmbProfilesClick(Sender: TObject); procedure cmbProfilesClick(Sender: TObject);
procedure cbCheckUpdatesClick(Sender: TObject);
private private
FLEDControls: array[0..LED_COUNT - 1] of TLEDControls; FLEDControls: array[0..LED_COUNT - 1] of TLEDControls;
FEventMonitor: TOmniEventMonitor; FEventMonitor: TOmniEventMonitor;
@ -114,6 +115,9 @@ type
FDeviceNotification: Pointer; FDeviceNotification: Pointer;
FG940Found: Boolean; FG940Found: Boolean;
FSettingsFileName: string;
FSettings: TSettings;
protected protected
procedure RegisterDeviceArrival; procedure RegisterDeviceArrival;
procedure UnregisterDeviceArrival; procedure UnregisterDeviceArrival;
@ -124,6 +128,9 @@ type
procedure LoadProfiles; procedure LoadProfiles;
procedure SaveProfiles; procedure SaveProfiles;
procedure LoadSettings;
procedure SaveSettings;
function CreateDefaultProfile: TProfile; function CreateDefaultProfile: TProfile;
procedure LoadActiveProfile; procedure LoadActiveProfile;
procedure UpdateButton(AProfile: TProfile; AButtonIndex: Integer); procedure UpdateButton(AProfile: TProfile; AButtonIndex: Integer);
@ -144,6 +151,7 @@ type
property ActiveProfile: TProfile read FActiveProfile; property ActiveProfile: TProfile read FActiveProfile;
property EventMonitor: TOmniEventMonitor read FEventMonitor; property EventMonitor: TOmniEventMonitor read FEventMonitor;
property Profiles: TProfileList read FProfiles; property Profiles: TProfileList read FProfiles;
property Settings: TSettings read FSettings;
property StateConsumerTask: IOmniTaskControl read FStateConsumerTask; property StateConsumerTask: IOmniTaskControl read FStateConsumerTask;
end; end;
@ -178,6 +186,7 @@ const
DefaultProfileName = 'Default'; DefaultProfileName = 'Default';
FILENAME_PROFILES = 'G940LEDControl\Profiles.xml'; FILENAME_PROFILES = 'G940LEDControl\Profiles.xml';
FILENAME_SETTINGS = 'G940LEDControl\Settings.xml';
SPECIAL_CATEGORY = -1; SPECIAL_CATEGORY = -1;
@ -213,26 +222,16 @@ begin
FProfiles := TProfileList.Create(True); FProfiles := TProfileList.Create(True);
LoadProfiles; LoadProfiles;
// TODO implement profile changing properly FSettingsFileName := App.UserPath + FILENAME_SETTINGS;
LoadSettings;
// #ToDo1 -oMvR: 22-2-2013: implement profile changing properly
FStateConsumerTask.Comm.Send(TM_LOADPROFILE, ActiveProfile); FStateConsumerTask.Comm.Send(TM_LOADPROFILE, ActiveProfile);
RegisterDeviceArrival; RegisterDeviceArrival;
end; end;
procedure TMainForm.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
begin
// SaveProfiles;
// if Assigned(StateConsumerTask) then
// begin
// SaveDefaultProfile;
//
// LEDStateConsumer.Finalize(StateConsumerTask);
// CanClose := False;
// end;
end;
procedure TMainForm.FormDestroy(Sender: TObject); procedure TMainForm.FormDestroy(Sender: TObject);
begin begin
UnregisterDeviceArrival; UnregisterDeviceArrival;
@ -395,6 +394,55 @@ begin
end; end;
procedure TMainForm.LoadSettings;
var
persistXML: TX2UtPersistXML;
begin
if not FileExists(FSettingsFileName) then
begin
{ Check if version 0.x settings are in the registry }
FSettings := ConfigConversion.ConvertSettings0To1;
if not Assigned(FSettings) then
FSettings := TSettings.Create;
end else
begin
FSettings := TSettings.Create;
persistXML := TX2UtPersistXML.Create;
try
persistXML.FileName := FSettingsFileName;
Settings.Load(persistXML.CreateReader);
finally
FreeAndNil(persistXML);
end;
end;
cbCheckUpdates.Checked := Settings.CheckUpdates;
if not Settings.HasCheckUpdates then
PostMessage(Self.Handle, CM_ASKAUTOUPDATE, 0, 0)
else if Settings.CheckUpdates then
CheckForUpdates(False);
end;
procedure TMainForm.SaveSettings;
var
persistXML: TX2UtPersistXML;
begin
persistXML := TX2UtPersistXML.Create;
try
persistXML.FileName := FSettingsFileName;
Settings.Save(persistXML.CreateWriter);
finally
FreeAndNil(persistXML);
end;
end;
function TMainForm.CreateDefaultProfile: TProfile; function TMainForm.CreateDefaultProfile: TProfile;
begin begin
{ Default button functions are assigned during UpdateButton } { Default button functions are assigned during UpdateButton }
@ -468,8 +516,12 @@ begin
'Do you want to automatically check for updates?', 'Check for updates', MB_YESNO or MB_ICONQUESTION) = ID_YES then 'Do you want to automatically check for updates?', 'Check for updates', MB_YESNO or MB_ICONQUESTION) = ID_YES then
begin begin
cbCheckUpdates.Checked := True; cbCheckUpdates.Checked := True;
Settings.CheckUpdates := True;
CheckForUpdates(False); CheckForUpdates(False);
end; end;
SaveSettings;
end; end;
@ -485,43 +537,6 @@ begin
end; end;
//procedure TMainForm.ReadAutoUpdate(AReader: IX2PersistReader);
//var
// checkUpdates: Boolean;
// askAutoUpdate: Boolean;
//
//begin
// askAutoUpdate := True;
//
// if AReader.BeginSection(SECTION_SETTINGS) then
// try
// if AReader.ReadBoolean('CheckUpdates', checkUpdates) then
// begin
// cbCheckUpdates.Checked := checkUpdates;
// askAutoUpdate := False;
// end;
// finally
// AReader.EndSection;
// end;
//
// if askAutoUpdate then
// PostMessage(Self.Handle, CM_ASKAUTOUPDATE, 0, 0)
// else if cbCheckUpdates.Checked then
// CheckForUpdates(False);
//end;
//procedure TMainForm.WriteAutoUpdate(AWriter: IX2PersistWriter);
//begin
// if AWriter.BeginSection(SECTION_SETTINGS) then
// try
// AWriter.WriteBoolean('CheckUpdates', cbCheckUpdates.Checked);
// finally
// AWriter.EndSection;
// end;
//end;
procedure TMainForm.LEDButtonClick(Sender: TObject); procedure TMainForm.LEDButtonClick(Sender: TObject);
var var
buttonIndex: NativeInt; buttonIndex: NativeInt;
@ -607,7 +622,7 @@ begin
try try
latestVersion := httpClient.Get('http://g940.x2software.net/version'); latestVersion := httpClient.Get('http://g940.x2software.net/version');
if VersionIsNewer(Format('%d.%d.%d', [App.Version.Major, App.Version.Minor, App.Version.Release]), latestVersion) then if VersionIsNewer(Format('%d.%d.%d', [App.Version.Major, App.Version.Minor, App.Version.Release]), latestVersion) then
ATask.Comm.Send(MSG_UPDATE) ATask.Comm.Send(MSG_UPDATE, latestVersion)
else else
begin begin
if ATask.Param.ByName('ReportNoUpdates').AsBoolean then if ATask.Param.ByName('ReportNoUpdates').AsBoolean then
@ -629,6 +644,13 @@ begin
end; end;
procedure TMainForm.cbCheckUpdatesClick(Sender: TObject);
begin
Settings.CheckUpdates := cbCheckUpdates.Checked;
SaveSettings;
end;
procedure TMainForm.CheckForUpdates(AReportNoUpdates: Boolean); procedure TMainForm.CheckForUpdates(AReportNoUpdates: Boolean);
begin begin
btnCheckUpdates.Enabled := False; btnCheckUpdates.Enabled := False;
@ -647,9 +669,10 @@ begin
HandleDeviceStateMessage(task, msg); HandleDeviceStateMessage(task, msg);
MSG_UPDATE: MSG_UPDATE:
if MessageBox(Self.Handle, 'An update is available on the G940 LED Control website.'#13#10'Do you want to go there now?', if MessageBox(Self.Handle, PChar('Version ' + msg.MsgData + ' is available on the G940 LED Control website.'#13#10 +
'Update available', MB_YESNO or MB_ICONINFORMATION) = ID_YES then 'Do you want to open the website now?'), 'Update available',
ShellExecute(Self.Handle, 'open', PChar('http://g940.x2software.net/#download'), nil, nil, SW_SHOWNORMAL); MB_YESNO or MB_ICONINFORMATION) = ID_YES then
ShellExecute(Self.Handle, 'open', PChar('http://g940.x2software.net/category/releases/'), nil, nil, SW_SHOWNORMAL);
MSG_NOUPDATE: MSG_NOUPDATE:
if msg.MsgData.AsBoolean then if msg.MsgData.AsBoolean then

View File

@ -27,7 +27,9 @@ uses
FSXSimConnectClient in 'Units\FSXSimConnectClient.pas', FSXSimConnectClient in 'Units\FSXSimConnectClient.pas',
FSXSimConnectIntf in 'Units\FSXSimConnectIntf.pas', FSXSimConnectIntf in 'Units\FSXSimConnectIntf.pas',
FSXLEDFunction in 'Units\FSXLEDFunction.pas', FSXLEDFunction in 'Units\FSXLEDFunction.pas',
LEDResources in 'Units\LEDResources.pas'; LEDResources in 'Units\LEDResources.pas',
Settings in 'Units\Settings.pas',
FSXLEDFunctionWorker in 'Units\FSXLEDFunctionWorker.pas';
{$R *.res} {$R *.res}

View File

@ -190,6 +190,8 @@
<DCCReference Include="Units\FSXSimConnectIntf.pas"/> <DCCReference Include="Units\FSXSimConnectIntf.pas"/>
<DCCReference Include="Units\FSXLEDFunction.pas"/> <DCCReference Include="Units\FSXLEDFunction.pas"/>
<DCCReference Include="Units\LEDResources.pas"/> <DCCReference Include="Units\LEDResources.pas"/>
<DCCReference Include="Units\Settings.pas"/>
<DCCReference Include="Units\FSXLEDFunctionWorker.pas"/>
<BuildConfiguration Include="Debug"> <BuildConfiguration Include="Debug">
<Key>Cfg_2</Key> <Key>Cfg_2</Key>
<CfgParent>Base</CfgParent> <CfgParent>Base</CfgParent>

View File

@ -2,10 +2,12 @@ unit ConfigConversion;
interface interface
uses uses
Profile; Profile,
Settings;
{ Version 0.x: registry -> 1.x: XML } { Version 0.x: registry -> 1.x: XML }
function ConvertProfile0To1: TProfile; function ConvertProfile0To1: TProfile;
function ConvertSettings0To1: TSettings;
implementation implementation
@ -16,6 +18,7 @@ uses
X2UtPersistIntf, X2UtPersistIntf,
X2UtPersistRegistry, X2UtPersistRegistry,
FSXResources,
LEDColorIntf, LEDColorIntf,
StaticResources; StaticResources;
@ -46,7 +49,7 @@ const
V0_FUNCTIONFSX_SPOILERS = V0_FUNCTIONPROVIDER_OFFSET + 13; V0_FUNCTIONFSX_SPOILERS = V0_FUNCTIONPROVIDER_OFFSET + 13;
V0_FUNCTIONFSX_PRESSURIZATIONDUMPSWITCH = V0_FUNCTIONPROVIDER_OFFSET + 14; V0_FUNCTIONFSX_PRESSURIZATIONDUMPSWITCH = V0_FUNCTIONPROVIDER_OFFSET + 14;
V0_FUNCTIONFSX_CARBHEAT = V0_FUNCTIONPROVIDER_OFFSET + 15; V0_FUNCTIONFSX_ENGINEANTIICE = V0_FUNCTIONPROVIDER_OFFSET + 15;
V0_FUNCTIONFSX_AUTOPILOT = V0_FUNCTIONPROVIDER_OFFSET + 16; V0_FUNCTIONFSX_AUTOPILOT = V0_FUNCTIONPROVIDER_OFFSET + 16;
V0_FUNCTIONFSX_FUELPUMP = V0_FUNCTIONPROVIDER_OFFSET + 17; V0_FUNCTIONFSX_FUELPUMP = V0_FUNCTIONPROVIDER_OFFSET + 17;
@ -62,7 +65,7 @@ const
V0_FUNCTIONFSX_TAXILIGHTS = V0_FUNCTIONPROVIDER_OFFSET + 25; V0_FUNCTIONFSX_TAXILIGHTS = V0_FUNCTIONPROVIDER_OFFSET + 25;
V0_FUNCTIONFSX_RECOGNITIONLIGHTS = V0_FUNCTIONPROVIDER_OFFSET + 26; V0_FUNCTIONFSX_RECOGNITIONLIGHTS = V0_FUNCTIONPROVIDER_OFFSET + 26;
// TODO 27 (de-ice) V0_FUNCTIONFSX_DEICE = V0_FUNCTIONPROVIDER_OFFSET + 27;
@ -76,6 +79,7 @@ procedure ConvertProfileFunction0To1(AOldFunction: Integer; AButton: TProfileBut
begin begin
{ Default states are handled by the specific functions }
case AOldFunction of case AOldFunction of
{ Static } { Static }
V0_FUNCTION_OFF: SetButton(StaticProviderUID, StaticFunctionUID[lcOff]); V0_FUNCTION_OFF: SetButton(StaticProviderUID, StaticFunctionUID[lcOff]);
@ -84,37 +88,41 @@ begin
V0_FUNCTION_GREEN: SetButton(StaticProviderUID, StaticFunctionUID[lcGreen]); V0_FUNCTION_GREEN: SetButton(StaticProviderUID, StaticFunctionUID[lcGreen]);
{ FSX } { FSX }
{ V0_FUNCTIONFSX_GEAR: SetButton(FSXProviderUID, FSXFunctionUIDGear);
V0_FUNCTIONFSX_GEAR: V0_FUNCTIONFSX_LANDINGLIGHTS: SetButton(FSXProviderUID, FSXFunctionUIDLandingLights);
V0_FUNCTIONFSX_LANDINGLIGHTS: V0_FUNCTIONFSX_INSTRUMENTLIGHTS: SetButton(FSXProviderUID, FSXFunctionUIDInstrumentLights);
V0_FUNCTIONFSX_INSTRUMENTLIGHTS: V0_FUNCTIONFSX_PARKINGBRAKE: SetButton(FSXProviderUID, FSXFunctionUIDParkingBrake);
V0_FUNCTIONFSX_PARKINGBRAKE: V0_FUNCTIONFSX_ENGINE: SetButton(FSXProviderUID, FSXFunctionUIDEngine);
V0_FUNCTIONFSX_ENGINE:
V0_FUNCTIONFSX_EXITDOOR: V0_FUNCTIONFSX_EXITDOOR: SetButton(FSXProviderUID, FSXFunctionUIDExitDoor);
V0_FUNCTIONFSX_STROBELIGHTS: V0_FUNCTIONFSX_STROBELIGHTS: SetButton(FSXProviderUID, FSXFunctionUIDStrobeLights);
V0_FUNCTIONFSX_NAVLIGHTS: V0_FUNCTIONFSX_NAVLIGHTS: SetButton(FSXProviderUID, FSXFunctionUIDNavLights);
V0_FUNCTIONFSX_BEACONLIGHTS: V0_FUNCTIONFSX_BEACONLIGHTS: SetButton(FSXProviderUID, FSXFunctionUIDBeaconLights);
V0_FUNCTIONFSX_FLAPS: V0_FUNCTIONFSX_FLAPS: SetButton(FSXProviderUID, FSXFunctionUIDFlaps);
V0_FUNCTIONFSX_BATTERYMASTER: V0_FUNCTIONFSX_BATTERYMASTER: SetButton(FSXProviderUID, FSXFunctionUIDBatteryMaster);
V0_FUNCTIONFSX_AVIONICSMASTER: V0_FUNCTIONFSX_AVIONICSMASTER: SetButton(FSXProviderUID, FSXFunctionUIDAvionicsMaster);
V0_FUNCTIONFSX_SPOILERS: V0_FUNCTIONFSX_SPOILERS: SetButton(FSXProviderUID, FSXFunctionUIDSpoilers);
V0_FUNCTIONFSX_PRESSURIZATIONDUMPSWITCH: V0_FUNCTIONFSX_PRESSURIZATIONDUMPSWITCH: SetButton(FSXProviderUID, FSXFunctionUIDPressDumpSwitch);
V0_FUNCTIONFSX_CARBHEAT: V0_FUNCTIONFSX_ENGINEANTIICE: SetButton(FSXProviderUID, FSXFunctionUIDEngineAntiIce);
V0_FUNCTIONFSX_AUTOPILOT: V0_FUNCTIONFSX_AUTOPILOT:
V0_FUNCTIONFSX_FUELPUMP: begin
V0_FUNCTIONFSX_TAILHOOK: { The only exception regarding states; the new default is Amber / Off }
V0_FUNCTIONFSX_AUTOPILOT_AMBER: SetButton(FSXProviderUID, FSXFunctionUIDAutoPilot);
V0_FUNCTIONFSX_AUTOPILOT_HEADING: AButton.SetStateColor(FSXStateUIDOn, lcGreen);
V0_FUNCTIONFSX_AUTOPILOT_APPROACH: AButton.SetStateColor(FSXStateUIDOff, lcRed);
V0_FUNCTIONFSX_AUTOPILOT_BACKCOURSE: end;
V0_FUNCTIONFSX_AUTOPILOT_ALTITUDE:
V0_FUNCTIONFSX_AUTOPILOT_NAV: V0_FUNCTIONFSX_FUELPUMP: SetButton(FSXProviderUID, FSXFunctionUIDFuelPump);
V0_FUNCTIONFSX_TAXILIGHTS: V0_FUNCTIONFSX_TAILHOOK: SetButton(FSXProviderUID, FSXFunctionUIDTailHook);
V0_FUNCTIONFSX_RECOGNITIONLIGHTS: V0_FUNCTIONFSX_AUTOPILOT_AMBER: SetButton(FSXProviderUID, FSXFunctionUIDAutoPilot);
} V0_FUNCTIONFSX_AUTOPILOT_HEADING: SetButton(FSXProviderUID, FSXFunctionUIDAutoPilotHeading);
else V0_FUNCTIONFSX_AUTOPILOT_APPROACH: SetButton(FSXProviderUID, FSXFunctionUIDAutoPilotApproach);
SetButton(StaticProviderUID, StaticFunctionUID[lcGreen]); V0_FUNCTIONFSX_AUTOPILOT_BACKCOURSE: SetButton(FSXProviderUID, FSXFunctionUIDAutoPilotBackcourse);
V0_FUNCTIONFSX_AUTOPILOT_ALTITUDE: SetButton(FSXProviderUID, FSXFunctionUIDAutoPilotAltitude);
V0_FUNCTIONFSX_AUTOPILOT_NAV: SetButton(FSXProviderUID, FSXFunctionUIDAutoPilotNav);
V0_FUNCTIONFSX_TAXILIGHTS: SetButton(FSXProviderUID, FSXFunctionUIDTaxiLights);
V0_FUNCTIONFSX_RECOGNITIONLIGHTS: SetButton(FSXProviderUID, FSXFunctionUIDRecognitionLights);
V0_FUNCTIONFSX_DEICE: SetButton(FSXProviderUID, FSXFunctionUIDDeIce);
end; end;
end; end;
@ -124,7 +132,6 @@ const
KEY_SETTINGS = '\Software\X2Software\G940LEDControl\'; KEY_SETTINGS = '\Software\X2Software\G940LEDControl\';
SECTION_DEFAULTPROFILE = 'DefaultProfile'; SECTION_DEFAULTPROFILE = 'DefaultProfile';
SECTION_FSX = 'FSX'; SECTION_FSX = 'FSX';
SECTION_SETTINGS = 'Settings';
var var
registryReader: TX2UtPersistRegistry; registryReader: TX2UtPersistRegistry;
@ -162,9 +169,42 @@ begin
finally finally
reader.EndSection; reader.EndSection;
end; end;
finally
FreeAndNil(registryReader);
end;
end;
// TODO auto update settings
//ReadAutoUpdate(reader); function ConvertSettings0To1: TSettings;
const
KEY_SETTINGS = '\Software\X2Software\G940LEDControl\';
SECTION_SETTINGS = 'Settings';
var
registryReader: TX2UtPersistRegistry;
reader: IX2PersistReader;
value: Boolean;
begin
Result := nil;
registryReader := TX2UtPersistRegistry.Create;
try
registryReader.RootKey := HKEY_CURRENT_USER;
registryReader.Key := KEY_SETTINGS;
reader := registryReader.CreateReader;
if reader.BeginSection(SECTION_SETTINGS) then
try
if reader.ReadBoolean('CheckUpdates', value) then
begin
Result := TSettings.Create;
Result.CheckUpdates := value;
end;
finally
reader.EndSection;
end;
finally finally
FreeAndNil(registryReader); FreeAndNil(registryReader);
end; end;

View File

@ -8,14 +8,13 @@ uses
type type
{ Base classes } TCustomFSXOnOffFunction = class(TCustomFSXFunction)
TFSXOnOffFunction = class(TCustomFSXFunction)
protected protected
procedure RegisterStates; override; procedure RegisterStates; override;
end; end;
{ Function implementations } { Misc }
TFSXEngineFunction = class(TCustomFSXFunction) TFSXEngineFunction = class(TCustomFSXFunction)
protected protected
procedure RegisterStates; override; procedure RegisterStates; override;
@ -28,8 +27,74 @@ type
function GetWorkerClass: TCustomLEDFunctionWorkerClass; override; function GetWorkerClass: TCustomLEDFunctionWorkerClass; override;
end; end;
TFSXParkingBrakeFunction = class(TCustomFSXOnOffFunction)
protected
function GetWorkerClass: TCustomLEDFunctionWorkerClass; override;
end;
TFSXLightFunction = class(TFSXOnOffFunction) TFSXExitDoorFunction = class(TCustomFSXFunction)
protected
procedure RegisterStates; override;
function GetWorkerClass: TCustomLEDFunctionWorkerClass; override;
end;
TFSXTailHookFunction = class(TCustomFSXFunction)
protected
procedure RegisterStates; override;
function GetWorkerClass: TCustomLEDFunctionWorkerClass; override;
end;
TFSXFlapsFunction = class(TCustomFSXFunction)
protected
procedure RegisterStates; override;
function GetWorkerClass: TCustomLEDFunctionWorkerClass; override;
end;
TFSXSpoilersFunction = class(TCustomFSXFunction)
protected
procedure RegisterStates; override;
function GetWorkerClass: TCustomLEDFunctionWorkerClass; override;
end;
TFSXBatteryMasterFunction = class(TCustomFSXFunction)
protected
procedure RegisterStates; override;
function GetWorkerClass: TCustomLEDFunctionWorkerClass; override;
end;
TFSXAvionicsMasterFunction = class(TCustomFSXFunction)
protected
procedure RegisterStates; override;
function GetWorkerClass: TCustomLEDFunctionWorkerClass; override;
end;
TFSXPressDumpSwitchFunction = class(TCustomFSXFunction)
protected
procedure RegisterStates; override;
function GetWorkerClass: TCustomLEDFunctionWorkerClass; override;
end;
TFSXEngineAntiIceFunction = class(TCustomFSXFunction)
protected
procedure RegisterStates; override;
function GetWorkerClass: TCustomLEDFunctionWorkerClass; override;
end;
TFSXFuelPumpFunction = class(TCustomFSXFunction)
protected
procedure RegisterStates; override;
function GetWorkerClass: TCustomLEDFunctionWorkerClass; override;
end;
TFSXDeIceFunction = class(TCustomFSXFunction)
protected
procedure RegisterStates; override;
function GetWorkerClass: TCustomLEDFunctionWorkerClass; override;
end;
{ Lights }
TCustomFSXLightFunction = class(TCustomFSXOnOffFunction)
protected protected
function GetCategoryName: string; override; function GetCategoryName: string; override;
@ -39,82 +104,96 @@ type
function GetLightMask: Integer; virtual; abstract; function GetLightMask: Integer; virtual; abstract;
end; end;
TFSXLandingLightsFunction = class(TFSXLightFunction) TFSXLandingLightsFunction = class(TCustomFSXLightFunction)
protected protected
function GetLightMask: Integer; override; function GetLightMask: Integer; override;
end; end;
TFSXInstrumentLightsFunction = class(TFSXLightFunction) TFSXInstrumentLightsFunction = class(TCustomFSXLightFunction)
protected protected
function GetLightMask: Integer; override; function GetLightMask: Integer; override;
end; end;
TFSXBeaconLightsFunction = class(TFSXLightFunction) TFSXBeaconLightsFunction = class(TCustomFSXLightFunction)
protected protected
function GetLightMask: Integer; override; function GetLightMask: Integer; override;
end; end;
TFSXNavLightsFunction = class(TFSXLightFunction) TFSXNavLightsFunction = class(TCustomFSXLightFunction)
protected protected
function GetLightMask: Integer; override; function GetLightMask: Integer; override;
end; end;
TFSXStrobeLightsFunction = class(TFSXLightFunction) TFSXStrobeLightsFunction = class(TCustomFSXLightFunction)
protected protected
function GetLightMask: Integer; override; function GetLightMask: Integer; override;
end; end;
TFSXTaxiLightsFunction = class(TFSXLightFunction) TFSXTaxiLightsFunction = class(TCustomFSXLightFunction)
protected protected
function GetLightMask: Integer; override; function GetLightMask: Integer; override;
end; end;
TFSXRecognitionLightsFunction = class(TFSXLightFunction) TFSXRecognitionLightsFunction = class(TCustomFSXLightFunction)
protected protected
function GetLightMask: Integer; override; function GetLightMask: Integer; override;
end; end;
{ Autopilot }
TCustomFSXAutoPilotFunction = class(TCustomFSXFunction)
protected
function GetCategoryName: string; override;
end;
TFSXAutoPilotFunction = class(TCustomFSXAutoPilotFunction)
protected
procedure RegisterStates; override;
function GetWorkerClass: TCustomLEDFunctionWorkerClass; override;
end;
TFSXAutoPilotHeadingFunction = class(TCustomFSXAutoPilotFunction)
protected
procedure RegisterStates; override;
function GetWorkerClass: TCustomLEDFunctionWorkerClass; override;
end;
TFSXAutoPilotApproachFunction = class(TCustomFSXAutoPilotFunction)
protected
procedure RegisterStates; override;
function GetWorkerClass: TCustomLEDFunctionWorkerClass; override;
end;
TFSXAutoPilotBackcourseFunction = class(TCustomFSXAutoPilotFunction)
protected
procedure RegisterStates; override;
function GetWorkerClass: TCustomLEDFunctionWorkerClass; override;
end;
TFSXAutoPilotAltitudeFunction = class(TCustomFSXAutoPilotFunction)
protected
procedure RegisterStates; override;
function GetWorkerClass: TCustomLEDFunctionWorkerClass; override;
end;
TFSXAutoPilotNavFunction = class(TCustomFSXAutoPilotFunction)
protected
procedure RegisterStates; override;
function GetWorkerClass: TCustomLEDFunctionWorkerClass; override;
end;
implementation implementation
uses uses
System.Math, FSXLEDFunctionWorker,
System.SysUtils,
FSXSimConnectIntf,
FSXResources, FSXResources,
FSXSimConnectIntf,
LEDColorIntf, LEDColorIntf,
LEDState, LEDState;
LEDStateIntf,
SimConnect;
type
{ Worker implementations }
TFSXEngineFunctionWorker = class(TCustomFSXFunctionWorker)
protected
procedure RegisterVariables(ADefinition: IFSXSimConnectDefinition); override;
procedure HandleData(AData: Pointer); override;
end;
TFSXGearFunctionWorker = class(TCustomFSXFunctionWorker)
protected
procedure RegisterVariables(ADefinition: IFSXSimConnectDefinition); override;
procedure HandleData(AData: Pointer); override;
end;
TFSXLightStatesFunctionWorker = class(TCustomFSXFunctionWorker)
private
FStateMask: Integer;
protected
procedure RegisterVariables(ADefinition: IFSXSimConnectDefinition); override;
procedure HandleData(AData: Pointer); override;
public
property StateMask: Integer read FStateMask write FStateMask;
end;
{ TFSXOnOffFunction } { TFSXOnOffFunction }
procedure TFSXOnOffFunction.RegisterStates; procedure TCustomFSXOnOffFunction.RegisterStates;
begin begin
RegisterState(TLEDState.Create(FSXStateUIDOn, FSXStateDisplayNameOn, lcGreen)); RegisterState(TLEDState.Create(FSXStateUIDOn, FSXStateDisplayNameOn, lcGreen));
RegisterState(TLEDState.Create(FSXStateUIDOff, FSXStateDisplayNameOff, lcRed)); RegisterState(TLEDState.Create(FSXStateUIDOff, FSXStateDisplayNameOff, lcRed));
@ -139,84 +218,6 @@ begin
end; end;
{ TFSXEngineFunctionWorker }
procedure TFSXEngineFunctionWorker.RegisterVariables(ADefinition: IFSXSimConnectDefinition);
var
engineIndex: Integer;
begin
ADefinition.AddVariable('NUMBER OF ENGINES', FSX_UNIT_NUMBER, SIMCONNECT_DATAType_INT32);
for engineIndex := 1 to FSX_MAX_ENGINES do
ADefinition.AddVariable(Format('GENERAL ENG COMBUSTION:%d', [engineIndex]), FSX_UNIT_BOOL, SIMCONNECT_DATAType_INT32);
for engineIndex := 1 to FSX_MAX_ENGINES do
ADefinition.AddVariable(Format('ENG FAILED:%d', [engineIndex]), FSX_UNIT_BOOL, SIMCONNECT_DATAType_INT32);
for engineIndex := 1 to FSX_MAX_ENGINES do
ADefinition.AddVariable(Format('ENG ON FIRE:%d', [engineIndex]), FSX_UNIT_BOOL, SIMCONNECT_DATAType_INT32);
end;
procedure TFSXEngineFunctionWorker.HandleData(AData: Pointer);
type
PEngineData = ^TEngineData;
TEngineData = packed record
NumberOfEngines: Integer;
Combustion: array[1..FSX_MAX_ENGINES] of Integer;
Failed: array[1..FSX_MAX_ENGINES] of Integer;
OnFire: array[1..FSX_MAX_ENGINES] of Integer;
end;
var
engineData: PEngineData;
engineCount: Integer;
engineIndex: Integer;
hasFire: Boolean;
hasFailure: Boolean;
runningCount: Integer;
begin
engineData := AData;
if engineData^.NumberOfEngines > 0 then
begin
engineCount := Min(engineData^.NumberOfEngines, FSX_MAX_ENGINES);
hasFire := False;
hasFailure := False;
runningCount := 0;
for engineIndex := 1 to engineCount do
begin
if engineData^.OnFire[engineIndex] <> 0 then
hasFire := True;
if engineData^.Failed[engineIndex] <> 0 then
hasFailure := True;
if engineData^.Combustion[engineIndex] <> 0 then
Inc(runningCount);
end;
if hasFire then
SetCurrentState(FSXStateUIDEngineOnFire)
else if hasFailure then
SetCurrentState(FSXStateUIDEngineFailed)
else if runningCount = 0 then
SetCurrentState(FSXStateUIDEngineAllOff)
else if runningCount = engineCount then
SetCurrentState(FSXStateUIDEngineAllRunning)
else
SetCurrentState(FSXStateUIDEnginePartiallyRunning);
end else
SetCurrentState(FSXStateUIDEngineNoEngines);
end;
{ TFSXGearFunction } { TFSXGearFunction }
procedure TFSXGearFunction.RegisterStates; procedure TFSXGearFunction.RegisterStates;
begin begin
@ -235,64 +236,161 @@ begin
end; end;
{ TFSXGearFunctionWorker } { TFSXParkingBrakeFunction }
procedure TFSXGearFunctionWorker.RegisterVariables(ADefinition: IFSXSimConnectDefinition); function TFSXParkingBrakeFunction.GetWorkerClass: TCustomLEDFunctionWorkerClass;
begin begin
ADefinition.AddVariable('IS GEAR RETRACTABLE', FSX_UNIT_BOOL, SIMCONNECT_DATAType_INT32); Result := TFSXParkingBrakeFunctionWorker;
ADefinition.AddVariable('GEAR TOTAL PCT EXTENDED', FSX_UNIT_PERCENT, SIMCONNECT_DATAType_FLOAT64);
ADefinition.AddVariable('GEAR DAMAGE BY SPEED', FSX_UNIT_BOOL, SIMCONNECT_DATAType_INT32);
ADefinition.AddVariable('GEAR SPEED EXCEEDED', FSX_UNIT_BOOL, SIMCONNECT_DATAType_INT32);
end; end;
procedure TFSXGearFunctionWorker.HandleData(AData: Pointer); { TFSXExitDoorFunction }
type procedure TFSXExitDoorFunction.RegisterStates;
PGearData = ^TGearData; begin
TGearData = packed record RegisterState(TLEDState.Create(FSXStateUIDExitDoorClosed, FSXStateDisplayNameExitDoorClosed, lcGreen));
IsGearRetractable: Cardinal; RegisterState(TLEDState.Create(FSXStateUIDExitDoorBetween, FSXStateDisplayNameExitDoorBetween, lcAmber));
TotalPctExtended: Double; RegisterState(TLEDState.Create(FSXStateUIDExitDoorOpen, FSXStateDisplayNameExitDoorOpen, lcRed));
DamageBySpeed: Integer;
SpeedExceeded: Integer;
end; end;
var
gearData: PGearData;
function TFSXExitDoorFunction.GetWorkerClass: TCustomLEDFunctionWorkerClass;
begin begin
gearData := AData; Result := TFSXExitDoorFunctionWorker;
if gearData^.DamageBySpeed <> 0 then
SetCurrentState(FSXStateUIDGearDamageBySpeed)
else if gearData^.SpeedExceeded <> 0 then
SetCurrentState(FSXStateUIDGearSpeedExceeded)
else if gearData^.IsGearRetractable <> 0 then
begin
case Trunc(gearData ^.TotalPctExtended * 100) of
0: SetCurrentState(FSXStateUIDGearRetracted);
95..100: SetCurrentState(FSXStateUIDGearExtended);
else SetCurrentState(FSXStateUIDGearBetween);
end; end;
end else
SetCurrentState(FSXStateUIDGearNotRetractable);
{ TFSXTailHookFunction }
procedure TFSXTailHookFunction.RegisterStates;
begin
RegisterState(TLEDState.Create(FSXStateUIDTailHookRetracted, FSXStateDisplayNameTailHookRetracted, lcGreen));
RegisterState(TLEDState.Create(FSXStateUIDTailHookBetween, FSXStateDisplayNameTailHookBetween, lcAmber));
RegisterState(TLEDState.Create(FSXStateUIDTailHookExtended, FSXStateDisplayNameTailHookExtended, lcRed));
end;
function TFSXTailHookFunction.GetWorkerClass: TCustomLEDFunctionWorkerClass;
begin
Result := TFSXTailHookFunctionWorker;
end;
{ TFSXFlapsFunction }
procedure TFSXFlapsFunction.RegisterStates;
begin
// #ToDo1 -cEmpty -oMvR: 22-2-2013: TFSXFlapsFunction.RegisterStates
end;
function TFSXFlapsFunction.GetWorkerClass: TCustomLEDFunctionWorkerClass;
begin
Result := TFSXFlapsFunctionWorker;
end;
{ TFSXSpoilersFunction }
procedure TFSXSpoilersFunction.RegisterStates;
begin
// #ToDo1 -cEmpty -oMvR: 22-2-2013: TFSXSpoilersFunction.RegisterStates
end;
function TFSXSpoilersFunction.GetWorkerClass: TCustomLEDFunctionWorkerClass;
begin
Result := TFSXSpoilersFunctionWorker;
end;
{ TFSXBatteryMasterFunction }
procedure TFSXBatteryMasterFunction.RegisterStates;
begin
// #ToDo1 -cEmpty -oMvR: 22-2-2013: TFSXBatteryMasterFunction.RegisterStates
end;
function TFSXBatteryMasterFunction.GetWorkerClass: TCustomLEDFunctionWorkerClass;
begin
Result := TFSXBatteryMasterFunctionWorker;
end;
{ TFSXAvionicsMasterFunction }
procedure TFSXAvionicsMasterFunction.RegisterStates;
begin
// #ToDo1 -cEmpty -oMvR: 22-2-2013: TFSXAvionicsMasterFunction.RegisterStates
end;
function TFSXAvionicsMasterFunction.GetWorkerClass: TCustomLEDFunctionWorkerClass;
begin
Result := TFSXAvionicsMasterFunctionWorker;
end;
{ TFSXPressDumpSwitchFunction }
procedure TFSXPressDumpSwitchFunction.RegisterStates;
begin
// #ToDo1 -cEmpty -oMvR: 22-2-2013: TFSXPressDumpSwitchFunction.RegisterStates
end;
function TFSXPressDumpSwitchFunction.GetWorkerClass: TCustomLEDFunctionWorkerClass;
begin
Result := TFSXPressDumpSwitchFunctionWorker;
end;
{ TFSXEngineAntiIceFunction }
procedure TFSXEngineAntiIceFunction.RegisterStates;
begin
// #ToDo1 -cEmpty -oMvR: 22-2-2013: TFSXEngineAntiIceFunction.RegisterStates
end;
function TFSXEngineAntiIceFunction.GetWorkerClass: TCustomLEDFunctionWorkerClass;
begin
Result := TFSXEngineAntiIceFunctionWorker;
end;
{ TFSXFuelPumpFunction }
procedure TFSXFuelPumpFunction.RegisterStates;
begin
// #ToDo1 -cEmpty -oMvR: 22-2-2013: TFSXFuelPumpFunction.RegisterStates
end;
function TFSXFuelPumpFunction.GetWorkerClass: TCustomLEDFunctionWorkerClass;
begin
Result := TFSXFuelPumpFunctionWorker;
end;
{ TFSXDeIceFunction }
procedure TFSXDeIceFunction.RegisterStates;
begin
// #ToDo1 -cEmpty -oMvR: 22-2-2013: TFSXDeIceFunction.RegisterStates
end;
function TFSXDeIceFunction.GetWorkerClass: TCustomLEDFunctionWorkerClass;
begin
Result := TFSXDeIceFunctionWorker;
end; end;
{ TFSXLightFunction } { TFSXLightFunction }
function TFSXLightFunction.GetCategoryName: string; function TCustomFSXLightFunction.GetCategoryName: string;
begin begin
Result := FSXCategoryLights; Result := FSXCategoryLights;
end; end;
function TFSXLightFunction.GetWorkerClass: TCustomLEDFunctionWorkerClass; function TCustomFSXLightFunction.GetWorkerClass: TCustomLEDFunctionWorkerClass;
begin begin
Result := TFSXLightStatesFunctionWorker; Result := TFSXLightStatesFunctionWorker;
end; end;
function TFSXLightFunction.DoCreateWorker(ASettings: ILEDFunctionWorkerSettings): TCustomLEDFunctionWorker; function TCustomFSXLightFunction.DoCreateWorker(ASettings: ILEDFunctionWorkerSettings): TCustomLEDFunctionWorker;
begin begin
Result := inherited DoCreateWorker(ASettings); Result := inherited DoCreateWorker(ASettings);
(Result as TFSXLightStatesFunctionWorker).StateMask := GetLightMask; (Result as TFSXLightStatesFunctionWorker).StateMask := GetLightMask;
@ -348,19 +446,88 @@ begin
end; end;
{ TFSXLightStatesFunctionWorker } { TCustomFSXAutoPilotFunction }
procedure TFSXLightStatesFunctionWorker.RegisterVariables(ADefinition: IFSXSimConnectDefinition); function TCustomFSXAutoPilotFunction.GetCategoryName: string;
begin begin
ADefinition.AddVariable('LIGHT ON STATES', FSX_UNIT_MASK, SIMCONNECT_DATATYPE_INT32); Result := FSXCategoryAutoPilot;
end; end;
procedure TFSXLightStatesFunctionWorker.HandleData(AData: Pointer); { TFSXAutoPilotFunction }
procedure TFSXAutoPilotFunction.RegisterStates;
begin begin
if (PCardinal(AData)^ and StateMask) <> 0 then // #ToDo1 -cEmpty -oMvR: 22-2-2013: TFSXAutoPilotFunction.RegisterStates
SetCurrentState(FSXStateUIDOn) end;
else
SetCurrentState(FSXStateUIDOff);
function TFSXAutoPilotFunction.GetWorkerClass: TCustomLEDFunctionWorkerClass;
begin
Result := TFSXAutoPilotFunctionWorker;
end;
{ TFSXAutoPilotHeadingFunction }
procedure TFSXAutoPilotHeadingFunction.RegisterStates;
begin
// #ToDo1 -cEmpty -oMvR: 22-2-2013: TFSXAutoPilotHeadingFunction.RegisterState
end;
function TFSXAutoPilotHeadingFunction.GetWorkerClass: TCustomLEDFunctionWorkerClass;
begin
Result := TFSXAutoPilotHeadingFunctionWorker;
end;
{ TFSXAutoPilotApproachFunction }
procedure TFSXAutoPilotApproachFunction.RegisterStates;
begin
// #ToDo1 -cEmpty -oMvR: 22-2-2013: TFSXAutoPilotApproachFunction.RegisterStates
end;
function TFSXAutoPilotApproachFunction.GetWorkerClass: TCustomLEDFunctionWorkerClass;
begin
Result := TFSXAutoPilotApproachFunctionWorker;
end;
{ TFSXAutoPilotBackcourseFunction }
procedure TFSXAutoPilotBackcourseFunction.RegisterStates;
begin
// #ToDo1 -cEmpty -oMvR: 22-2-2013: TFSXAutoPilotBackcourseFunction.RegisterStates
end;
function TFSXAutoPilotBackcourseFunction.GetWorkerClass: TCustomLEDFunctionWorkerClass;
begin
Result := TFSXAutoPilotBackcourseFunctionWorker;
end;
{ TFSXAutoPilotAltitudeFunction }
procedure TFSXAutoPilotAltitudeFunction.RegisterStates;
begin
// #ToDo1 -cEmpty -oMvR: 22-2-2013: TFSXAutoPilotAltitudeFunction.RegisterStates
end;
function TFSXAutoPilotAltitudeFunction.GetWorkerClass: TCustomLEDFunctionWorkerClass;
begin
Result := TFSXAutoPilotAltitudeFunctionWorker;
end;
{ TFSXAutoPilotNavFunction }
procedure TFSXAutoPilotNavFunction.RegisterStates;
begin
// #ToDo1 -cEmpty -oMvR: 22-2-2013: TFSXAutoPilotNavFunction.RegisterStates
end;
function TFSXAutoPilotNavFunction.GetWorkerClass: TCustomLEDFunctionWorkerClass;
begin
Result := TFSXAutoPilotNavFunctionWorker;
end; end;
end. end.

View File

@ -129,29 +129,20 @@ end;
procedure TFSXLEDFunctionProvider.RegisterFunctions; procedure TFSXLEDFunctionProvider.RegisterFunctions;
begin begin
{
AConsumer.AddFunction(FUNCTION_FSX_CARBHEAT, 'Anti-ice');
AConsumer.AddFunction(FUNCTION_FSX_AUTOPILOT, 'Auto pilot (main)');
AConsumer.AddFunction(FUNCTION_FSX_AUTOPILOT_AMBER, 'Auto pilot (main - off / amber)');
AConsumer.AddFunction(FUNCTION_FSX_AUTOPILOT_ALTITUDE, 'Auto pilot - Altitude');
AConsumer.AddFunction(FUNCTION_FSX_AUTOPILOT_APPROACH, 'Auto pilot - Approach');
AConsumer.AddFunction(FUNCTION_FSX_AUTOPILOT_BACKCOURSE, 'Auto pilot - Backcourse');
AConsumer.AddFunction(FUNCTION_FSX_AUTOPILOT_HEADING, 'Auto pilot - Heading');
AConsumer.AddFunction(FUNCTION_FSX_AUTOPILOT_NAV, 'Auto pilot - Nav');
AConsumer.AddFunction(FUNCTION_FSX_AVIONICSMASTER, 'Avionics master switch');
AConsumer.AddFunction(FUNCTION_FSX_BATTERYMASTER, 'Battery master switch');
AConsumer.AddFunction(FUNCTION_FSX_ENGINE, 'Engine');
AConsumer.AddFunction(FUNCTION_FSX_EXITDOOR, 'Exit door');
AConsumer.AddFunction(FUNCTION_FSX_FLAPS, 'Flaps');
AConsumer.AddFunction(FUNCTION_FSX_PARKINGBRAKE, 'Parking brake');
AConsumer.AddFunction(FUNCTION_FSX_PRESSURIZATIONDUMPSWITCH, 'Pressurization dump switch');
AConsumer.AddFunction(FUNCTION_FSX_SPOILERS, 'Spoilers (air brake)');
AConsumer.AddFunction(FUNCTION_FSX_TAILHOOK, 'Tail hook');
}
{ Misc } { Misc }
RegisterFunction(TFSXAvionicsMasterFunction.Create( Self, FSXFunctionDisplayNameAvionicsMaster, FSXFunctionUIDAvionicsMaster));
RegisterFunction(TFSXBatteryMasterFunction.Create( Self, FSXFunctionDisplayNameBatteryMaster, FSXFunctionUIDBatteryMaster));
RegisterFunction(TFSXDeIceFunction.Create( Self, FSXFunctionDisplayNameDeIce, FSXFunctionUIDDeIce));
RegisterFunction(TFSXEngineAntiIceFunction.Create( Self, FSXFunctionDisplayNameEngineAntiIce, FSXFunctionUIDEngineAntiIce));
RegisterFunction(TFSXEngineFunction.Create( Self, FSXFunctionDisplayNameEngine, FSXFunctionUIDEngine)); RegisterFunction(TFSXEngineFunction.Create( Self, FSXFunctionDisplayNameEngine, FSXFunctionUIDEngine));
RegisterFunction(TFSXExitDoorFunction.Create( Self, FSXFunctionDisplayNameExitDoor, FSXFunctionUIDExitDoor));
RegisterFunction(TFSXFlapsFunction.Create( Self, FSXFunctionDisplayNameFlaps, FSXFunctionUIDFlaps));
RegisterFunction(TFSXFuelPumpFunction.Create( Self, FSXFunctionDisplayNameFuelPump, FSXFunctionUIDFuelPump));
RegisterFunction(TFSXGearFunction.Create( Self, FSXFunctionDisplayNameGear, FSXFunctionUIDGear)); RegisterFunction(TFSXGearFunction.Create( Self, FSXFunctionDisplayNameGear, FSXFunctionUIDGear));
RegisterFunction(TFSXParkingBrakeFunction.Create( Self, FSXFunctionDisplayNameParkingBrake, FSXFunctionUIDParkingBrake));
RegisterFunction(TFSXPressDumpSwitchFunction.Create( Self, FSXFunctionDisplayNamePressDumpSwitch, FSXFunctionUIDPressDumpSwitch));
RegisterFunction(TFSXSpoilersFunction.Create( Self, FSXFunctionDisplayNameSpoilers, FSXFunctionUIDSpoilers));
RegisterFunction(TFSXTailHookFunction.Create( Self, FSXFunctionDisplayNameTailHook, FSXFunctionUIDTailHook));
{ Lights } { Lights }
RegisterFunction(TFSXBeaconLightsFunction.Create( Self, FSXFunctionDisplayNameBeaconLights, FSXFunctionUIDBeaconLights)); RegisterFunction(TFSXBeaconLightsFunction.Create( Self, FSXFunctionDisplayNameBeaconLights, FSXFunctionUIDBeaconLights));
@ -161,6 +152,14 @@ begin
RegisterFunction(TFSXRecognitionLightsFunction.Create( Self, FSXFunctionDisplayNameRecognitionLights, FSXFunctionUIDRecognitionLights)); RegisterFunction(TFSXRecognitionLightsFunction.Create( Self, FSXFunctionDisplayNameRecognitionLights, FSXFunctionUIDRecognitionLights));
RegisterFunction(TFSXStrobeLightsFunction.Create( Self, FSXFunctionDisplayNameStrobeLights, FSXFunctionUIDStrobeLights)); RegisterFunction(TFSXStrobeLightsFunction.Create( Self, FSXFunctionDisplayNameStrobeLights, FSXFunctionUIDStrobeLights));
RegisterFunction(TFSXTaxiLightsFunction.Create( Self, FSXFunctionDisplayNameTaxiLights, FSXFunctionUIDTaxiLights)); RegisterFunction(TFSXTaxiLightsFunction.Create( Self, FSXFunctionDisplayNameTaxiLights, FSXFunctionUIDTaxiLights));
{ Autopilot }
RegisterFunction(TFSXAutoPilotFunction.Create( Self, FSXFunctionDisplayNameAutoPilot, FSXFunctionUIDAutoPilot));
RegisterFunction(TFSXAutoPilotAltitudeFunction.Create( Self, FSXFunctionDisplayNameAutoPilotAltitude, FSXFunctionUIDAutoPilotAltitude));
RegisterFunction(TFSXAutoPilotApproachFunction.Create( Self, FSXFunctionDisplayNameAutoPilotApproach, FSXFunctionUIDAutoPilotApproach));
RegisterFunction(TFSXAutoPilotBackcourseFunction.Create(Self, FSXFunctionDisplayNameAutoPilotBackcourse, FSXFunctionUIDAutoPilotBackcourse));
RegisterFunction(TFSXAutoPilotHeadingFunction.Create( Self, FSXFunctionDisplayNameAutoPilotHeading, FSXFunctionUIDAutoPilotHeading));
RegisterFunction(TFSXAutoPilotNavFunction.Create( Self, FSXFunctionDisplayNameAutoPilotNav, FSXFunctionUIDAutoPilotNav));
end; end;

View File

@ -0,0 +1,526 @@
unit FSXLEDFunctionWorker;
interface
uses
FSXLEDFunctionProvider,
FSXSimConnectIntf;
type
{ Misc }
TFSXEngineFunctionWorker = class(TCustomFSXFunctionWorker)
protected
procedure RegisterVariables(ADefinition: IFSXSimConnectDefinition); override;
procedure HandleData(AData: Pointer); override;
end;
TFSXGearFunctionWorker = class(TCustomFSXFunctionWorker)
protected
procedure RegisterVariables(ADefinition: IFSXSimConnectDefinition); override;
procedure HandleData(AData: Pointer); override;
end;
TFSXParkingBrakeFunctionWorker = class(TCustomFSXFunctionWorker)
protected
procedure RegisterVariables(ADefinition: IFSXSimConnectDefinition); override;
procedure HandleData(AData: Pointer); override;
end;
TFSXExitDoorFunctionWorker = class(TCustomFSXFunctionWorker)
protected
procedure RegisterVariables(ADefinition: IFSXSimConnectDefinition); override;
procedure HandleData(AData: Pointer); override;
end;
TFSXTailHookFunctionWorker = class(TCustomFSXFunctionWorker)
protected
procedure RegisterVariables(ADefinition: IFSXSimConnectDefinition); override;
procedure HandleData(AData: Pointer); override;
end;
TFSXFlapsFunctionWorker = class(TCustomFSXFunctionWorker)
protected
procedure RegisterVariables(ADefinition: IFSXSimConnectDefinition); override;
procedure HandleData(AData: Pointer); override;
end;
TFSXSpoilersFunctionWorker = class(TCustomFSXFunctionWorker)
protected
procedure RegisterVariables(ADefinition: IFSXSimConnectDefinition); override;
procedure HandleData(AData: Pointer); override;
end;
TFSXBatteryMasterFunctionWorker = class(TCustomFSXFunctionWorker)
protected
procedure RegisterVariables(ADefinition: IFSXSimConnectDefinition); override;
procedure HandleData(AData: Pointer); override;
end;
TFSXAvionicsMasterFunctionWorker = class(TCustomFSXFunctionWorker)
protected
procedure RegisterVariables(ADefinition: IFSXSimConnectDefinition); override;
procedure HandleData(AData: Pointer); override;
end;
TFSXPressDumpSwitchFunctionWorker = class(TCustomFSXFunctionWorker)
protected
procedure RegisterVariables(ADefinition: IFSXSimConnectDefinition); override;
procedure HandleData(AData: Pointer); override;
end;
TFSXEngineAntiIceFunctionWorker = class(TCustomFSXFunctionWorker)
protected
procedure RegisterVariables(ADefinition: IFSXSimConnectDefinition); override;
procedure HandleData(AData: Pointer); override;
end;
TFSXFuelPumpFunctionWorker = class(TCustomFSXFunctionWorker)
protected
procedure RegisterVariables(ADefinition: IFSXSimConnectDefinition); override;
procedure HandleData(AData: Pointer); override;
end;
TFSXDeIceFunctionWorker = class(TCustomFSXFunctionWorker)
protected
procedure RegisterVariables(ADefinition: IFSXSimConnectDefinition); override;
procedure HandleData(AData: Pointer); override;
end;
TFSXLightStatesFunctionWorker = class(TCustomFSXFunctionWorker)
private
FStateMask: Integer;
protected
procedure RegisterVariables(ADefinition: IFSXSimConnectDefinition); override;
procedure HandleData(AData: Pointer); override;
public
property StateMask: Integer read FStateMask write FStateMask;
end;
TFSXAutoPilotFunctionWorker = class(TCustomFSXFunctionWorker)
protected
procedure RegisterVariables(ADefinition: IFSXSimConnectDefinition); override;
procedure HandleData(AData: Pointer); override;
end;
TFSXAutoPilotHeadingFunctionWorker = class(TCustomFSXFunctionWorker)
protected
procedure RegisterVariables(ADefinition: IFSXSimConnectDefinition); override;
procedure HandleData(AData: Pointer); override;
end;
TFSXAutoPilotApproachFunctionWorker = class(TCustomFSXFunctionWorker)
protected
procedure RegisterVariables(ADefinition: IFSXSimConnectDefinition); override;
procedure HandleData(AData: Pointer); override;
end;
TFSXAutoPilotBackcourseFunctionWorker = class(TCustomFSXFunctionWorker)
protected
procedure RegisterVariables(ADefinition: IFSXSimConnectDefinition); override;
procedure HandleData(AData: Pointer); override;
end;
TFSXAutoPilotAltitudeFunctionWorker = class(TCustomFSXFunctionWorker)
protected
procedure RegisterVariables(ADefinition: IFSXSimConnectDefinition); override;
procedure HandleData(AData: Pointer); override;
end;
TFSXAutoPilotNavFunctionWorker = class(TCustomFSXFunctionWorker)
protected
procedure RegisterVariables(ADefinition: IFSXSimConnectDefinition); override;
procedure HandleData(AData: Pointer); override;
end;
implementation
uses
System.Math,
System.SysUtils,
FSXResources,
LEDStateIntf,
SimConnect;
{ TFSXEngineFunctionWorker }
procedure TFSXEngineFunctionWorker.RegisterVariables(ADefinition: IFSXSimConnectDefinition);
var
engineIndex: Integer;
begin
ADefinition.AddVariable('NUMBER OF ENGINES', FSX_UNIT_NUMBER, SIMCONNECT_DATAType_INT32);
for engineIndex := 1 to FSX_MAX_ENGINES do
ADefinition.AddVariable(Format('GENERAL ENG COMBUSTION:%d', [engineIndex]), FSX_UNIT_BOOL, SIMCONNECT_DATAType_INT32);
for engineIndex := 1 to FSX_MAX_ENGINES do
ADefinition.AddVariable(Format('ENG FAILED:%d', [engineIndex]), FSX_UNIT_BOOL, SIMCONNECT_DATAType_INT32);
for engineIndex := 1 to FSX_MAX_ENGINES do
ADefinition.AddVariable(Format('ENG ON FIRE:%d', [engineIndex]), FSX_UNIT_BOOL, SIMCONNECT_DATAType_INT32);
end;
procedure TFSXEngineFunctionWorker.HandleData(AData: Pointer);
type
PEngineData = ^TEngineData;
TEngineData = packed record
NumberOfEngines: Integer;
Combustion: array[1..FSX_MAX_ENGINES] of Integer;
Failed: array[1..FSX_MAX_ENGINES] of Integer;
OnFire: array[1..FSX_MAX_ENGINES] of Integer;
end;
var
engineData: PEngineData;
engineCount: Integer;
engineIndex: Integer;
hasFire: Boolean;
hasFailure: Boolean;
runningCount: Integer;
begin
engineData := AData;
if engineData^.NumberOfEngines > 0 then
begin
engineCount := Min(engineData^.NumberOfEngines, FSX_MAX_ENGINES);
hasFire := False;
hasFailure := False;
runningCount := 0;
for engineIndex := 1 to engineCount do
begin
if engineData^.OnFire[engineIndex] <> 0 then
hasFire := True;
if engineData^.Failed[engineIndex] <> 0 then
hasFailure := True;
if engineData^.Combustion[engineIndex] <> 0 then
Inc(runningCount);
end;
if hasFire then
SetCurrentState(FSXStateUIDEngineOnFire)
else if hasFailure then
SetCurrentState(FSXStateUIDEngineFailed)
else if runningCount = 0 then
SetCurrentState(FSXStateUIDEngineAllOff)
else if runningCount = engineCount then
SetCurrentState(FSXStateUIDEngineAllRunning)
else
SetCurrentState(FSXStateUIDEnginePartiallyRunning);
end else
SetCurrentState(FSXStateUIDEngineNoEngines);
end;
{ TFSXGearFunctionWorker }
procedure TFSXGearFunctionWorker.RegisterVariables(ADefinition: IFSXSimConnectDefinition);
begin
ADefinition.AddVariable('IS GEAR RETRACTABLE', FSX_UNIT_BOOL, SIMCONNECT_DATAType_INT32);
ADefinition.AddVariable('GEAR TOTAL PCT EXTENDED', FSX_UNIT_PERCENT, SIMCONNECT_DATAType_FLOAT64);
ADefinition.AddVariable('GEAR DAMAGE BY SPEED', FSX_UNIT_BOOL, SIMCONNECT_DATAType_INT32);
ADefinition.AddVariable('GEAR SPEED EXCEEDED', FSX_UNIT_BOOL, SIMCONNECT_DATAType_INT32);
end;
procedure TFSXGearFunctionWorker.HandleData(AData: Pointer);
type
PGearData = ^TGearData;
TGearData = packed record
IsGearRetractable: Cardinal;
TotalPctExtended: Double;
DamageBySpeed: Integer;
SpeedExceeded: Integer;
end;
var
gearData: PGearData;
begin
gearData := AData;
if gearData^.DamageBySpeed <> 0 then
SetCurrentState(FSXStateUIDGearDamageBySpeed)
else if gearData^.SpeedExceeded <> 0 then
SetCurrentState(FSXStateUIDGearSpeedExceeded)
else if gearData^.IsGearRetractable <> 0 then
begin
case Trunc(gearData ^.TotalPctExtended * 100) of
0: SetCurrentState(FSXStateUIDGearRetracted);
95..100: SetCurrentState(FSXStateUIDGearExtended);
else SetCurrentState(FSXStateUIDGearBetween);
end;
end else
SetCurrentState(FSXStateUIDGearNotRetractable);
end;
{ TFSXParkingBrakeFunctionWorker }
procedure TFSXParkingBrakeFunctionWorker.RegisterVariables(ADefinition: IFSXSimConnectDefinition);
begin
ADefinition.AddVariable('BRAKE PARKING INDICATOR', FSX_UNIT_BOOL, SIMCONNECT_DATATYPE_INT32);
end;
procedure TFSXParkingBrakeFunctionWorker.HandleData(AData: Pointer);
begin
if PCardinal(AData)^ <> 0 then
SetCurrentState(FSXStateUIDOn)
else
SetCurrentState(FSXStateUIDOff);
end;
{ TFSXExitDoorFunctionWorker }
procedure TFSXExitDoorFunctionWorker.RegisterVariables(ADefinition: IFSXSimConnectDefinition);
begin
ADefinition.AddVariable('CANOPY OPEN', FSX_UNIT_PERCENT, SIMCONNECT_DATAType_FLOAT64);
end;
procedure TFSXExitDoorFunctionWorker.HandleData(AData: Pointer);
begin
case Trunc(PDouble(AData)^) of
0..5: SetCurrentState(FSXStateUIDExitDoorClosed);
95..100: SetCurrentState(FSXStateUIDExitDoorOpen);
else SetCurrentState(FSXStateUIDExitDoorBetween);
end;
end;
{ TFSXTailHookFunctionWorker }
procedure TFSXTailHookFunctionWorker.RegisterVariables(ADefinition: IFSXSimConnectDefinition);
begin
// #ToDo1 -cEmpty -oMvR: 22-2-2013: TFSXTailHookFunctionWorker.RegisterVariables
end;
procedure TFSXTailHookFunctionWorker.HandleData(AData: Pointer);
begin
// #ToDo1 -cEmpty -oMvR: 22-2-2013: TFSXTailHookFunctionWorker.HandleData
end;
{ TFSXFlapsFunctionWorker }
procedure TFSXFlapsFunctionWorker.RegisterVariables(ADefinition: IFSXSimConnectDefinition);
begin
// #ToDo1 -cEmpty -oMvR: 22-2-2013: TFSXFlapsFunctionWorker.RegisterVariables
end;
procedure TFSXFlapsFunctionWorker.HandleData(AData: Pointer);
begin
// #ToDo1 -cEmpty -oMvR: 22-2-2013: TFSXFlapsFunctionWorker.HandleData
end;
{ TFSXSpoilersFunctionWorker }
procedure TFSXSpoilersFunctionWorker.RegisterVariables(ADefinition: IFSXSimConnectDefinition);
begin
// #ToDo1 -cEmpty -oMvR: 22-2-2013: TFSXSpoilersFunctionWorker.RegisterVariables
end;
procedure TFSXSpoilersFunctionWorker.HandleData(AData: Pointer);
begin
// #ToDo1 -cEmpty -oMvR: 22-2-2013: TFSXSpoilersFunctionWorker.HandleData
end;
{ TFSXBatteryMasterFunctionWorker }
procedure TFSXBatteryMasterFunctionWorker.RegisterVariables(ADefinition: IFSXSimConnectDefinition);
begin
// #ToDo1 -cEmpty -oMvR: 22-2-2013: TFSXBatteryMasterFunctionWorker.RegisterVariables
end;
procedure TFSXBatteryMasterFunctionWorker.HandleData(AData: Pointer);
begin
// #ToDo1 -cEmpty -oMvR: 22-2-2013: TFSXBatteryMasterFunctionWorker.HandleData
end;
{ TFSXAvionicsMasterFunctionWorker }
procedure TFSXAvionicsMasterFunctionWorker.RegisterVariables(ADefinition: IFSXSimConnectDefinition);
begin
// #ToDo1 -cEmpty -oMvR: 22-2-2013: TFSXAvionicsMasterFunctionWorker.RegisterVariables
end;
procedure TFSXAvionicsMasterFunctionWorker.HandleData(AData: Pointer);
begin
// #ToDo1 -cEmpty -oMvR: 22-2-2013: TFSXAvionicsMasterFunctionWorker.HandleData
end;
{ TFSXPressDumpSwitchFunctionWorker }
procedure TFSXPressDumpSwitchFunctionWorker.RegisterVariables(ADefinition: IFSXSimConnectDefinition);
begin
// #ToDo1 -cEmpty -oMvR: 22-2-2013: TFSXPressDumpSwitchFunctionWorker.RegisterVariables
end;
procedure TFSXPressDumpSwitchFunctionWorker.HandleData(AData: Pointer);
begin
// #ToDo1 -cEmpty -oMvR: 22-2-2013: TFSXPressDumpSwitchFunctionWorker.HandleData
end;
{ TFSXEngineAntiIceFunctionWorker }
procedure TFSXEngineAntiIceFunctionWorker.RegisterVariables(ADefinition: IFSXSimConnectDefinition);
begin
// #ToDo1 -cEmpty -oMvR: 22-2-2013: TFSXEngineAntiIceFunctionWorker.RegisterVariables
end;
procedure TFSXEngineAntiIceFunctionWorker.HandleData(AData: Pointer);
begin
// #ToDo1 -cEmpty -oMvR: 22-2-2013: TFSXEngineAntiIceFunctionWorker.HandleData
end;
{ TFSXFuelPumpFunctionWorker }
procedure TFSXFuelPumpFunctionWorker.RegisterVariables(ADefinition: IFSXSimConnectDefinition);
begin
// #ToDo1 -cEmpty -oMvR: 22-2-2013: TFSXFuelPumpFunctionWorker.RegisterVariables
end;
procedure TFSXFuelPumpFunctionWorker.HandleData(AData: Pointer);
begin
// #ToDo1 -cEmpty -oMvR: 22-2-2013: TFSXFuelPumpFunctionWorker.HandleData
end;
{ TFSXDeIceFunctionWorker }
procedure TFSXDeIceFunctionWorker.RegisterVariables(ADefinition: IFSXSimConnectDefinition);
begin
// #ToDo1 -cEmpty -oMvR: 22-2-2013: TFSXDeIceFunctionWorker.RegisterVariables
end;
procedure TFSXDeIceFunctionWorker.HandleData(AData: Pointer);
begin
// #ToDo1 -cEmpty -oMvR: 22-2-2013: TFSXDeIceFunctionWorker.HandleData
end;
{ TFSXLightStatesFunctionWorker }
procedure TFSXLightStatesFunctionWorker.RegisterVariables(ADefinition: IFSXSimConnectDefinition);
begin
ADefinition.AddVariable('LIGHT ON STATES', FSX_UNIT_MASK, SIMCONNECT_DATATYPE_INT32);
end;
procedure TFSXLightStatesFunctionWorker.HandleData(AData: Pointer);
begin
if (PCardinal(AData)^ and StateMask) <> 0 then
SetCurrentState(FSXStateUIDOn)
else
SetCurrentState(FSXStateUIDOff);
end;
{ TFSXAutoPilotFunctionWorker }
procedure TFSXAutoPilotFunctionWorker.RegisterVariables(ADefinition: IFSXSimConnectDefinition);
begin
// #ToDo1 -cEmpty -oMvR: 22-2-2013: TFSXAutoPilotFunctionWorker.RegisterVariables
end;
procedure TFSXAutoPilotFunctionWorker.HandleData(AData: Pointer);
begin
// #ToDo1 -cEmpty -oMvR: 22-2-2013: TFSXAutoPilotFunctionWorker.HandleData
end;
{ TFSXAutoPilotHeadingFunctionWorker }
procedure TFSXAutoPilotHeadingFunctionWorker.RegisterVariables(ADefinition: IFSXSimConnectDefinition);
begin
// #ToDo1 -cEmpty -oMvR: 22-2-2013: TFSXAutoPilotHeadingFunctionWorker.RegisterVariables
end;
procedure TFSXAutoPilotHeadingFunctionWorker.HandleData(AData: Pointer);
begin
// #ToDo1 -cEmpty -oMvR: 22-2-2013: TFSXAutoPilotHeadingFunctionWorker.HandleData
end;
{ TFSXAutoPilotApproachFunctionWorker }
procedure TFSXAutoPilotApproachFunctionWorker.RegisterVariables(ADefinition: IFSXSimConnectDefinition);
begin
// #ToDo1 -cEmpty -oMvR: 22-2-2013: TFSXAutoPilotApproachFunctionWorker.RegisterVariables
end;
procedure TFSXAutoPilotApproachFunctionWorker.HandleData(AData: Pointer);
begin
// #ToDo1 -cEmpty -oMvR: 22-2-2013: TFSXAutoPilotApproachFunctionWorker.HandleData
end;
{ TFSXAutoPilotBackcourseFunctionWorker }
procedure TFSXAutoPilotBackcourseFunctionWorker.RegisterVariables(ADefinition: IFSXSimConnectDefinition);
begin
// #ToDo1 -cEmpty -oMvR: 22-2-2013: TFSXAutoPilotBackcourseFunctionWorker.RegisterVariables
end;
procedure TFSXAutoPilotBackcourseFunctionWorker.HandleData(AData: Pointer);
begin
// #ToDo1 -cEmpty -oMvR: 22-2-2013: TFSXAutoPilotBackcourseFunctionWorker.HandleData
end;
{ TFSXAutoPilotAltitudeFunctionWorker }
procedure TFSXAutoPilotAltitudeFunctionWorker.RegisterVariables(ADefinition: IFSXSimConnectDefinition);
begin
// #ToDo1 -cEmpty -oMvR: 22-2-2013: TFSXAutoPilotAltitudeFunctionWorker.RegisterVariables
end;
procedure TFSXAutoPilotAltitudeFunctionWorker.HandleData(AData: Pointer);
begin
// #ToDo1 -cEmpty -oMvR: 22-2-2013: TFSXAutoPilotAltitudeFunctionWorker.HandleData
end;
{ TFSXAutoPilotNavFunctionWorker }
procedure TFSXAutoPilotNavFunctionWorker.RegisterVariables(ADefinition: IFSXSimConnectDefinition);
begin
// #ToDo1 -cEmpty -oMvR: 22-2-2013: TFSXAutoPilotNavFunctionWorker.RegisterVariables
end;
procedure TFSXAutoPilotNavFunctionWorker.HandleData(AData: Pointer);
begin
// #ToDo1 -cEmpty -oMvR: 22-2-2013: TFSXAutoPilotNavFunctionWorker.HandleData
end;
end.

View File

@ -7,6 +7,7 @@ const
FSXProviderUID = 'fsx'; FSXProviderUID = 'fsx';
FSXCategory = 'Flight Simulator X'; FSXCategory = 'Flight Simulator X';
FSXCategoryLights = FSXCategory + ' - Lights'; FSXCategoryLights = FSXCategory + ' - Lights';
FSXCategoryAutoPilot = FSXCategory + ' - Autopilot';
FSXStateUIDOn = 'on'; FSXStateUIDOn = 'on';
FSXStateUIDOff = 'off'; FSXStateUIDOff = 'off';
@ -72,6 +73,76 @@ const
FSXFunctionUIDRecognitionLights = 'recognitionLights'; FSXFunctionUIDRecognitionLights = 'recognitionLights';
FSXFunctionDisplayNameRecognitionLights = 'Recognition lights'; FSXFunctionDisplayNameRecognitionLights = 'Recognition lights';
FSXFunctionUIDParkingBrake = 'parkingBrake';
FSXFunctionDisplayNameParkingBrake = 'Parking brake';
FSXFunctionUIDExitDoor = 'exitDoor';
FSXFunctionDisplayNameExitDoor = 'Exit door';
FSXStateUIDExitDoorClosed = 'closed';
FSXStateUIDExitDoorBetween = 'between';
FSXStateUIDExitDoorOpen = 'open';
FSXStateDisplayNameExitDoorClosed = 'Closed';
FSXStateDisplayNameExitDoorBetween = 'Opening / closing';
FSXStateDisplayNameExitDoorOpen = 'Open';
FSXFunctionUIDTailHook = 'tailHook';
FSXFunctionDisplayNameTailHook = 'Tail hook';
FSXStateUIDTailHookRetracted = 'retracted';
FSXStateUIDTailHookBetween = 'between';
FSXStateUIDTailHookExtended = 'extended';
FSXStateDisplayNameTailHookRetracted = 'Retracted';
FSXStateDisplayNameTailHookBetween = 'Extending / retracting';
FSXStateDisplayNameTailHookExtended = 'Extended';
FSXFunctionUIDFlaps = 'flaps';
FSXFunctionDisplayNameFlaps = 'Flaps';
FSXFunctionUIDSpoilers = 'spoilers';
FSXFunctionDisplayNameSpoilers = 'Spoilers';
FSXFunctionUIDBatteryMaster = 'batteryMaster';
FSXFunctionDisplayNameBatteryMaster = 'Battery master';
FSXFunctionUIDAvionicsMaster = 'avionicsMaster';
FSXFunctionDisplayNameAvionicsMaster = 'Avionics master';
FSXFunctionUIDPressDumpSwitch = 'pressurizationDumpSwitch';
FSXFunctionDisplayNamePressDumpSwitch = 'Pressurization dump switch';
FSXFunctionUIDEngineAntiIce = 'engineAntiIce';
FSXFunctionDisplayNameEngineAntiIce = 'Engine anti-ice';
FSXFunctionUIDFuelPump = 'fuelPump';
FSXFunctionDisplayNameFuelPump = 'Fuel pump';
FSXFunctionUIDDeIce = 'structuralDeIce';
FSXFunctionDisplayNameDeIce = 'De-ice';
FSXFunctionUIDAutoPilot = 'autoPilotMaster';
FSXFunctionDisplayNameAutoPilot = 'Autopilot master';
FSXFunctionUIDAutoPilotHeading = 'autoPilotHeading';
FSXFunctionDisplayNameAutoPilotHeading = 'Autopilot heading';
FSXFunctionUIDAutoPilotApproach = 'autoPilotApproach';
FSXFunctionDisplayNameAutoPilotApproach = 'Autopilot approach';
FSXFunctionUIDAutoPilotBackcourse = 'autoPilotBackcourse';
FSXFunctionDisplayNameAutoPilotBackcourse = 'Autopilot backcourse';
FSXFunctionUIDAutoPilotAltitude = 'autoPilotAltitude';
FSXFunctionDisplayNameAutoPilotAltitude = 'Autopilot altitude';
FSXFunctionUIDAutoPilotNav = 'autoPilotNav';
FSXFunctionDisplayNameAutoPilotNav = 'Autopilot nav';
implementation implementation

View File

@ -306,7 +306,8 @@ end;
procedure TFSXSimConnectClient.Cleanup; procedure TFSXSimConnectClient.Cleanup;
begin begin
// TODO unregister definitions ? // #ToDo1 -oMvR: 22-2-2013: unregister definitions
if SimConnectHandle <> 0 then if SimConnectHandle <> 0 then
SimConnect_Close(SimConnectHandle); SimConnect_Close(SimConnectHandle);
@ -491,7 +492,7 @@ var
begin begin
removeDefinition := Msg.MsgData; removeDefinition := Msg.MsgData;
// TODO actually remove the definition // #ToDo1 -oMvR: 22-2-2013: actually remove the definition
removeDefinition.Signal; removeDefinition.Signal;
end; end;

View File

@ -192,8 +192,11 @@ begin
for oldWorker in ButtonWorkers do for oldWorker in ButtonWorkers do
begin begin
if Assigned(oldWorker) then if Assigned(oldWorker) then
begin
(oldWorker as ILEDFunctionWorker).Detach(Self);
oldWorkers.Add(oldWorker); oldWorkers.Add(oldWorker);
end; end;
end;
ButtonWorkers.Clear; ButtonWorkers.Clear;

View File

@ -0,0 +1,63 @@
unit Settings;
interface
uses
X2UtPersistIntf;
type
TSettings = class(TObject)
private
FCheckUpdates: Boolean;
FHasCheckUpdates: Boolean;
procedure SetCheckUpdates(const Value: Boolean);
public
procedure Load(AReader: IX2PersistReader);
procedure Save(AWriter: IX2PersistWriter);
property CheckUpdates: Boolean read FCheckUpdates write SetCheckUpdates;
property HasCheckUpdates: Boolean read FHasCheckUpdates;
end;
implementation
const
SectionSettings = 'Settings';
KeyCheckUpdates = 'CheckUpdates';
{ TSettings }
procedure TSettings.Load(AReader: IX2PersistReader);
var
value: Boolean;
begin
if AReader.BeginSection(SectionSettings) then
try
if AReader.ReadBoolean(KeyCheckUpdates, value) then
CheckUpdates := value;
finally
AReader.EndSection;
end;
end;
procedure TSettings.Save(AWriter: IX2PersistWriter);
begin
if AWriter.BeginSection(SectionSettings) then
try
AWriter.WriteBoolean(KeyCheckUpdates, CheckUpdates);
finally
AWriter.EndSection;
end;
end;
procedure TSettings.SetCheckUpdates(const Value: Boolean);
begin
FCheckUpdates := Value;
FHasCheckUpdates := True;
end;
end.