1
0
mirror of synced 2024-11-22 10:03:51 +00:00

Changed: poll FSX instead of handling the event (0.6-style), in the hopes of solving a stability issue

This commit is contained in:
Mark van Renswoude 2013-02-28 22:01:26 +00:00
commit a9b472ea9a
5 changed files with 42 additions and 51 deletions

View File

@ -8,7 +8,7 @@
<FrameworkType>VCL</FrameworkType> <FrameworkType>VCL</FrameworkType>
<ProjectVersion>13.4</ProjectVersion> <ProjectVersion>13.4</ProjectVersion>
<Base>True</Base> <Base>True</Base>
<Config Condition="'$(Config)'==''">Debug</Config> <Config Condition="'$(Config)'==''">Release</Config>
<Platform Condition="'$(Platform)'==''">Win32</Platform> <Platform Condition="'$(Platform)'==''">Win32</Platform>
<TargetedPlatforms>1</TargetedPlatforms> <TargetedPlatforms>1</TargetedPlatforms>
<AppType>Application</AppType> <AppType>Application</AppType>
@ -82,9 +82,10 @@
<DCC_Define>RELEASE;$(DCC_Define)</DCC_Define> <DCC_Define>RELEASE;$(DCC_Define)</DCC_Define>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Cfg_1_Win32)'!=''"> <PropertyGroup Condition="'$(Cfg_1_Win32)'!=''">
<VerInfo_Release>1</VerInfo_Release>
<VerInfo_MajorVer>1</VerInfo_MajorVer> <VerInfo_MajorVer>1</VerInfo_MajorVer>
<VerInfo_MinorVer>0</VerInfo_MinorVer> <VerInfo_MinorVer>0</VerInfo_MinorVer>
<VerInfo_Keys>CompanyName=X²Software;FileDescription=G940 LED Control;FileVersion=1.0.0.0;InternalName=;LegalCopyright=© 2011 X²Software;LegalTrademarks=;OriginalFilename=G940LEDControl.exe;ProductName=G940 LED Control;ProductVersion=1.0;Comments=</VerInfo_Keys> <VerInfo_Keys>CompanyName=X²Software;FileDescription=G940 LED Control;FileVersion=1.0.1.0;InternalName=;LegalCopyright=© 2011 X²Software;LegalTrademarks=;OriginalFilename=G940LEDControl.exe;ProductName=G940 LED Control;ProductVersion=1.0;Comments=</VerInfo_Keys>
<VerInfo_Locale>1033</VerInfo_Locale> <VerInfo_Locale>1033</VerInfo_Locale>
<Manifest_File>$(BDS)\bin\default_app.manifest</Manifest_File> <Manifest_File>$(BDS)\bin\default_app.manifest</Manifest_File>
</PropertyGroup> </PropertyGroup>
@ -146,25 +147,6 @@
<Source Name="MainSource">G940LEDControl.dpr</Source> <Source Name="MainSource">G940LEDControl.dpr</Source>
</Source> </Source>
<Excluded_Packages> <Excluded_Packages>
<Excluded_Packages Name="D:\Program Files\Developer Express.VCL\Library\Delphi16\dcldxCoreD16.bpl">ExpressCoreLibrary by Developer Express Inc.</Excluded_Packages>
<Excluded_Packages Name="D:\Program Files\Developer Express.VCL\Library\Delphi16\dclcxLibraryD16.bpl">Express Cross Platform Library by Developer Express Inc.</Excluded_Packages>
<Excluded_Packages Name="D:\Program Files\Developer Express.VCL\Library\Delphi16\dclcxPageControlD16.bpl">ExpressPageControl by Developer Express Inc.</Excluded_Packages>
<Excluded_Packages Name="D:\Program Files\Developer Express.VCL\Library\Delphi16\dclcxEditorsD16.bpl">ExpressEditors Library by Developer Express Inc.</Excluded_Packages>
<Excluded_Packages Name="D:\Program Files\Developer Express.VCL\Library\Delphi16\dcldxBarD16.bpl">ExpressBars by Developer Express Inc.</Excluded_Packages>
<Excluded_Packages Name="D:\Program Files\Developer Express.VCL\Library\Delphi16\dcldxRibbonD16.bpl">ExpressBars Ribbon controls by Developer Express Inc.</Excluded_Packages>
<Excluded_Packages Name="D:\Program Files\Developer Express.VCL\Library\Delphi16\dclcxSchedulerD16.bpl">ExpressScheduler by Developer Express Inc.</Excluded_Packages>
<Excluded_Packages Name="D:\Program Files\Developer Express.VCL\Library\Delphi16\dcldxSkinsCoreD16.bpl">ExpressSkins Library by Developer Express Inc.</Excluded_Packages>
<Excluded_Packages Name="D:\Program Files\Developer Express.VCL\Library\Delphi16\dcldxPSCoreD16.bpl">ExpressPrinting System by Developer Express Inc.</Excluded_Packages>
<Excluded_Packages Name="D:\Program Files\Developer Express.VCL\Library\Delphi16\dclcxPivotGridD16.bpl">ExpressPivotGrid by Developer Express Inc.</Excluded_Packages>
<Excluded_Packages Name="D:\Program Files\Developer Express.VCL\Library\Delphi16\dcldxorgcD16.bpl">ExpressOrgChart by Developer Express Inc.</Excluded_Packages>
<Excluded_Packages Name="D:\Program Files\Developer Express.VCL\Library\Delphi16\dcldxSkinsDesignHelperD16.bpl">ExpressSkins Library Uses Clause Auto Fill Helper by Developer Express Inc.</Excluded_Packages>
<Excluded_Packages Name="D:\Program Files\Developer Express.VCL\Library\Delphi16\dxSkinscxPCPainterD16.bpl">ExpressSkins Library Painter for PageControl by Developer Express Inc.</Excluded_Packages>
<Excluded_Packages Name="D:\Program Files\Developer Express.VCL\Library\Delphi16\dxSkinscxSchedulerPainterD16.bpl">ExpressSkins Library Painter for Scheduler by Developer Express Inc.</Excluded_Packages>
<Excluded_Packages Name="D:\Program Files\Developer Express.VCL\Library\Delphi16\dxSkinsdxBarPainterD16.bpl">ExpressSkins Library Painter for Bars by Developer Express Inc.</Excluded_Packages>
<Excluded_Packages Name="D:\Program Files\Developer Express.VCL\Library\Delphi16\dxSkinsdxNavBarPainterD16.bpl">ExpressSkins Library Painter for NavBar by Developer Express Inc.</Excluded_Packages>
<Excluded_Packages Name="D:\Program Files\Developer Express.VCL\Library\Delphi16\dxSkinsdxRibbonPainterD16.bpl">ExpressSkins Library Painter for Ribbon by Developer Express Inc.</Excluded_Packages>
<Excluded_Packages Name="D:\Program Files\Developer Express.VCL\Library\Delphi16\dxSkinsdxDLPainterD16.bpl">ExpressSkins Library Painter for Docking Library by Developer Express Inc.</Excluded_Packages>
<Excluded_Packages Name="D:\Program Files\Developer Express.VCL\Library\Delphi16\dcldxPSdxLCLnkD16.bpl">ExpressPrinting System ReportLink for ExpressLayoutControl by Developer Express Inc.</Excluded_Packages>
<Excluded_Packages Name="D:\Program Files\Developer Express.VCL\Library\Delphi16\dclcxEditorFieldLinkD16.bpl">ExpressEditors FieldLink by Developer Express Inc.</Excluded_Packages> <Excluded_Packages Name="D:\Program Files\Developer Express.VCL\Library\Delphi16\dclcxEditorFieldLinkD16.bpl">ExpressEditors FieldLink by Developer Express Inc.</Excluded_Packages>
<Excluded_Packages Name="D:\Program Files\Developer Express.VCL\Library\Delphi16\dcldxBarDBNavD16.bpl">ExpressBars DBNavigator by Developer Express Inc.</Excluded_Packages> <Excluded_Packages Name="D:\Program Files\Developer Express.VCL\Library\Delphi16\dcldxBarDBNavD16.bpl">ExpressBars DBNavigator by Developer Express Inc.</Excluded_Packages>
<Excluded_Packages Name="D:\Program Files\Developer Express.VCL\Library\Delphi16\dcldxBarExtDBItemsD16.bpl">ExpressBars extended DB items by Developer Express Inc.</Excluded_Packages> <Excluded_Packages Name="D:\Program Files\Developer Express.VCL\Library\Delphi16\dcldxBarExtDBItemsD16.bpl">ExpressBars extended DB items by Developer Express Inc.</Excluded_Packages>

Binary file not shown.

View File

@ -51,10 +51,13 @@ const
TM_ADDDEFINITION = 3001; TM_ADDDEFINITION = 3001;
TM_REMOVEDEFINITION = 3002; TM_REMOVEDEFINITION = 3002;
TM_TRYSIMCONNECT = 3003; TM_TRYSIMCONNECT = 3003;
TM_PROCESSMESSAGES = 3004;
TIMER_TRYSIMCONNECT = 201; TIMER_TRYSIMCONNECT = 201;
TIMER_PROCESSMESSAGES = 202;
INTERVAL_TRYSIMCONNECT = 5000; INTERVAL_TRYSIMCONNECT = 5000;
INTERVAL_PROCESSMESSAGES = 50;
type type
@ -87,11 +90,12 @@ type
FDefinitions: TFSXSimConnectDefinitionMap; FDefinitions: TFSXSimConnectDefinitionMap;
FLastDefinitionID: Cardinal; FLastDefinitionID: Cardinal;
FSimConnectHandle: THandle; FSimConnectHandle: THandle;
FSimConnectDataEvent: TEvent; // FSimConnectDataEvent: TEvent;
protected protected
procedure TMAddDefinition(var Msg: TOmniMessage); message TM_ADDDEFINITION; procedure TMAddDefinition(var Msg: TOmniMessage); message TM_ADDDEFINITION;
procedure TMRemoveDefinition(var Msg: TOmniMessage); message TM_REMOVEDEFINITION; procedure TMRemoveDefinition(var Msg: TOmniMessage); message TM_REMOVEDEFINITION;
procedure TMTrySimConnect(var Msg: TOmniMessage); message TM_TRYSIMCONNECT; procedure TMTrySimConnect(var Msg: TOmniMessage); message TM_TRYSIMCONNECT;
procedure TMProcessMessages(var Msg: TOmniMessage); message TM_PROCESSMESSAGES;
procedure HandleSimConnectDataEvent; procedure HandleSimConnectDataEvent;
protected protected
@ -110,7 +114,7 @@ type
property Definitions: TFSXSimConnectDefinitionMap read FDefinitions; property Definitions: TFSXSimConnectDefinitionMap read FDefinitions;
property LastDefinitionID: Cardinal read FLastDefinitionID; property LastDefinitionID: Cardinal read FLastDefinitionID;
property SimConnectHandle: THandle read FSimConnectHandle; property SimConnectHandle: THandle read FSimConnectHandle;
property SimConnectDataEvent: TEvent read FSimConnectDataEvent; // property SimConnectDataEvent: TEvent read FSimConnectDataEvent;
end; end;
@ -302,9 +306,9 @@ begin
exit; exit;
FDefinitions := TFSXSimConnectDefinitionMap.Create; FDefinitions := TFSXSimConnectDefinitionMap.Create;
FSimConnectDataEvent := TEvent.Create(nil, False, False, '');
Task.RegisterWaitObject(SimConnectDataEvent.Handle, HandleSimConnectDataEvent); // FSimConnectDataEvent := TEvent.Create(nil, False, False, '');
// Task.RegisterWaitObject(SimConnectDataEvent.Handle, HandleSimConnectDataEvent);
TrySimConnect; TrySimConnect;
end; end;
@ -312,7 +316,7 @@ end;
procedure TFSXSimConnectClient.Cleanup; procedure TFSXSimConnectClient.Cleanup;
begin begin
FreeAndNil(FSimConnectDataEvent); // FreeAndNil(FSimConnectDataEvent);
FreeAndNil(FDefinitions); FreeAndNil(FDefinitions);
if SimConnectHandle <> 0 then if SimConnectHandle <> 0 then
@ -331,12 +335,14 @@ begin
if InitSimConnect then if InitSimConnect then
begin begin
if SimConnect_Open(FSimConnectHandle, FSXSimConnectAppName, 0, 0, SimConnectDataEvent.Handle, 0) = S_OK then if SimConnect_Open(FSimConnectHandle, FSXSimConnectAppName, 0, 0, 0 (*SimConnectDataEvent.Handle*), 0) = S_OK then
begin begin
TFSXSimConnectStateMonitor.SetCurrentState(scsConnected); TFSXSimConnectStateMonitor.SetCurrentState(scsConnected);
Task.ClearTimer(TIMER_TRYSIMCONNECT); Task.ClearTimer(TIMER_TRYSIMCONNECT);
RegisterDefinitions; RegisterDefinitions;
Task.SetTimer(TIMER_PROCESSMESSAGES, INTERVAL_PROCESSMESSAGES, TM_PROCESSMESSAGES);
end; end;
end; end;
@ -345,6 +351,7 @@ begin
TFSXSimConnectStateMonitor.SetCurrentState(scsFailed); TFSXSimConnectStateMonitor.SetCurrentState(scsFailed);
Task.SetTimer(TIMER_TRYSIMCONNECT, INTERVAL_TRYSIMCONNECT, TM_TRYSIMCONNECT); Task.SetTimer(TIMER_TRYSIMCONNECT, INTERVAL_TRYSIMCONNECT, TM_TRYSIMCONNECT);
Task.ClearTimer(TIMER_PROCESSMESSAGES);
end; end;
end; end;
@ -375,6 +382,7 @@ begin
SIMCONNECT_RECV_ID_QUIT: SIMCONNECT_RECV_ID_QUIT:
begin begin
FSimConnectHandle := 0; FSimConnectHandle := 0;
Task.ClearTimer(TIMER_PROCESSMESSAGES);
Task.SetTimer(TIMER_TRYSIMCONNECT, INTERVAL_TRYSIMCONNECT, TM_TRYSIMCONNECT); Task.SetTimer(TIMER_TRYSIMCONNECT, INTERVAL_TRYSIMCONNECT, TM_TRYSIMCONNECT);
TFSXSimConnectStateMonitor.SetCurrentState(scsDisconnected); TFSXSimConnectStateMonitor.SetCurrentState(scsDisconnected);
@ -552,6 +560,12 @@ begin
end; end;
procedure TFSXSimConnectClient.TMProcessMessages(var Msg: TOmniMessage);
begin
HandleSimConnectDataEvent;
end;
{ TFSXSimConnectDefinitionRef } { TFSXSimConnectDefinitionRef }
constructor TFSXSimConnectDefinitionRef.Create(ADefinition: IFSXSimConnectDefinitionAccess); constructor TFSXSimConnectDefinitionRef.Create(ADefinition: IFSXSimConnectDefinitionAccess);
begin begin

View File

@ -90,17 +90,17 @@ var
observer: IInterface; observer: IInterface;
begin begin
CurrentStateLock.Acquire; if Value <> FCurrentState then
try begin
if Value <> FCurrentState then CurrentStateLock.Acquire;
begin try
FCurrentState := Value; FCurrentState := Value;
finally
for observer in Observers do CurrentStateLock.Release;
(observer as IFSXSimConnectStateObserver).ObserverStateUpdate(CurrentState);
end; end;
finally
CurrentStateLock.Release; for observer in Observers do
(observer as IFSXSimConnectStateObserver).ObserverStateUpdate(CurrentState);
end; end;
end; end;

View File

@ -314,29 +314,24 @@ end;
procedure TCustomLEDMultiStateFunctionWorker.SetCurrentState(AState: ILEDStateWorker; ANotifyObservers: Boolean); procedure TCustomLEDMultiStateFunctionWorker.SetCurrentState(AState: ILEDStateWorker; ANotifyObservers: Boolean);
begin begin
FCurrentStateLock.Acquire; if AState <> FCurrentState then
try begin
if AState <> FCurrentState then FCurrentStateLock.Acquire;
begin try
FCurrentState := AState; FCurrentState := AState;
finally
if ANotifyObservers then FCurrentStateLock.Release;
NotifyObservers;
end; end;
finally
FCurrentStateLock.Release; if ANotifyObservers then
NotifyObservers;
end; end;
end; end;
function TCustomLEDMultiStateFunctionWorker.GetCurrentState: ILEDStateWorker; function TCustomLEDMultiStateFunctionWorker.GetCurrentState: ILEDStateWorker;
begin begin
FCurrentStateLock.Acquire; Result := FCurrentState;
try
Result := FCurrentState;
finally
FCurrentStateLock.Release;
end;
end; end;