Changed: poll FSX instead of handling the event (0.6-style), in the hopes of solving a stability issue
This commit is contained in:
commit
a9b472ea9a
@ -8,7 +8,7 @@
|
||||
<FrameworkType>VCL</FrameworkType>
|
||||
<ProjectVersion>13.4</ProjectVersion>
|
||||
<Base>True</Base>
|
||||
<Config Condition="'$(Config)'==''">Debug</Config>
|
||||
<Config Condition="'$(Config)'==''">Release</Config>
|
||||
<Platform Condition="'$(Platform)'==''">Win32</Platform>
|
||||
<TargetedPlatforms>1</TargetedPlatforms>
|
||||
<AppType>Application</AppType>
|
||||
@ -82,9 +82,10 @@
|
||||
<DCC_Define>RELEASE;$(DCC_Define)</DCC_Define>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Cfg_1_Win32)'!=''">
|
||||
<VerInfo_Release>1</VerInfo_Release>
|
||||
<VerInfo_MajorVer>1</VerInfo_MajorVer>
|
||||
<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>
|
||||
<Manifest_File>$(BDS)\bin\default_app.manifest</Manifest_File>
|
||||
</PropertyGroup>
|
||||
@ -146,25 +147,6 @@
|
||||
<Source Name="MainSource">G940LEDControl.dpr</Source>
|
||||
</Source>
|
||||
<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\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>
|
||||
|
Binary file not shown.
@ -51,10 +51,13 @@ const
|
||||
TM_ADDDEFINITION = 3001;
|
||||
TM_REMOVEDEFINITION = 3002;
|
||||
TM_TRYSIMCONNECT = 3003;
|
||||
TM_PROCESSMESSAGES = 3004;
|
||||
|
||||
TIMER_TRYSIMCONNECT = 201;
|
||||
TIMER_PROCESSMESSAGES = 202;
|
||||
|
||||
INTERVAL_TRYSIMCONNECT = 5000;
|
||||
INTERVAL_PROCESSMESSAGES = 50;
|
||||
|
||||
|
||||
type
|
||||
@ -87,11 +90,12 @@ type
|
||||
FDefinitions: TFSXSimConnectDefinitionMap;
|
||||
FLastDefinitionID: Cardinal;
|
||||
FSimConnectHandle: THandle;
|
||||
FSimConnectDataEvent: TEvent;
|
||||
// FSimConnectDataEvent: TEvent;
|
||||
protected
|
||||
procedure TMAddDefinition(var Msg: TOmniMessage); message TM_ADDDEFINITION;
|
||||
procedure TMRemoveDefinition(var Msg: TOmniMessage); message TM_REMOVEDEFINITION;
|
||||
procedure TMTrySimConnect(var Msg: TOmniMessage); message TM_TRYSIMCONNECT;
|
||||
procedure TMProcessMessages(var Msg: TOmniMessage); message TM_PROCESSMESSAGES;
|
||||
|
||||
procedure HandleSimConnectDataEvent;
|
||||
protected
|
||||
@ -110,7 +114,7 @@ type
|
||||
property Definitions: TFSXSimConnectDefinitionMap read FDefinitions;
|
||||
property LastDefinitionID: Cardinal read FLastDefinitionID;
|
||||
property SimConnectHandle: THandle read FSimConnectHandle;
|
||||
property SimConnectDataEvent: TEvent read FSimConnectDataEvent;
|
||||
// property SimConnectDataEvent: TEvent read FSimConnectDataEvent;
|
||||
end;
|
||||
|
||||
|
||||
@ -302,9 +306,9 @@ begin
|
||||
exit;
|
||||
|
||||
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;
|
||||
end;
|
||||
@ -312,7 +316,7 @@ end;
|
||||
|
||||
procedure TFSXSimConnectClient.Cleanup;
|
||||
begin
|
||||
FreeAndNil(FSimConnectDataEvent);
|
||||
// FreeAndNil(FSimConnectDataEvent);
|
||||
FreeAndNil(FDefinitions);
|
||||
|
||||
if SimConnectHandle <> 0 then
|
||||
@ -331,12 +335,14 @@ begin
|
||||
|
||||
if InitSimConnect then
|
||||
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
|
||||
TFSXSimConnectStateMonitor.SetCurrentState(scsConnected);
|
||||
|
||||
Task.ClearTimer(TIMER_TRYSIMCONNECT);
|
||||
RegisterDefinitions;
|
||||
|
||||
Task.SetTimer(TIMER_PROCESSMESSAGES, INTERVAL_PROCESSMESSAGES, TM_PROCESSMESSAGES);
|
||||
end;
|
||||
end;
|
||||
|
||||
@ -345,6 +351,7 @@ begin
|
||||
TFSXSimConnectStateMonitor.SetCurrentState(scsFailed);
|
||||
|
||||
Task.SetTimer(TIMER_TRYSIMCONNECT, INTERVAL_TRYSIMCONNECT, TM_TRYSIMCONNECT);
|
||||
Task.ClearTimer(TIMER_PROCESSMESSAGES);
|
||||
end;
|
||||
end;
|
||||
|
||||
@ -375,6 +382,7 @@ begin
|
||||
SIMCONNECT_RECV_ID_QUIT:
|
||||
begin
|
||||
FSimConnectHandle := 0;
|
||||
Task.ClearTimer(TIMER_PROCESSMESSAGES);
|
||||
Task.SetTimer(TIMER_TRYSIMCONNECT, INTERVAL_TRYSIMCONNECT, TM_TRYSIMCONNECT);
|
||||
|
||||
TFSXSimConnectStateMonitor.SetCurrentState(scsDisconnected);
|
||||
@ -552,6 +560,12 @@ begin
|
||||
end;
|
||||
|
||||
|
||||
procedure TFSXSimConnectClient.TMProcessMessages(var Msg: TOmniMessage);
|
||||
begin
|
||||
HandleSimConnectDataEvent;
|
||||
end;
|
||||
|
||||
|
||||
{ TFSXSimConnectDefinitionRef }
|
||||
constructor TFSXSimConnectDefinitionRef.Create(ADefinition: IFSXSimConnectDefinitionAccess);
|
||||
begin
|
||||
|
@ -90,18 +90,18 @@ var
|
||||
observer: IInterface;
|
||||
|
||||
begin
|
||||
CurrentStateLock.Acquire;
|
||||
try
|
||||
if Value <> FCurrentState then
|
||||
begin
|
||||
CurrentStateLock.Acquire;
|
||||
try
|
||||
FCurrentState := Value;
|
||||
finally
|
||||
CurrentStateLock.Release;
|
||||
end;
|
||||
|
||||
for observer in Observers do
|
||||
(observer as IFSXSimConnectStateObserver).ObserverStateUpdate(CurrentState);
|
||||
end;
|
||||
finally
|
||||
CurrentStateLock.Release;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
|
@ -314,29 +314,24 @@ end;
|
||||
|
||||
procedure TCustomLEDMultiStateFunctionWorker.SetCurrentState(AState: ILEDStateWorker; ANotifyObservers: Boolean);
|
||||
begin
|
||||
FCurrentStateLock.Acquire;
|
||||
try
|
||||
if AState <> FCurrentState then
|
||||
begin
|
||||
FCurrentStateLock.Acquire;
|
||||
try
|
||||
FCurrentState := AState;
|
||||
finally
|
||||
FCurrentStateLock.Release;
|
||||
end;
|
||||
|
||||
if ANotifyObservers then
|
||||
NotifyObservers;
|
||||
end;
|
||||
finally
|
||||
FCurrentStateLock.Release;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
function TCustomLEDMultiStateFunctionWorker.GetCurrentState: ILEDStateWorker;
|
||||
begin
|
||||
FCurrentStateLock.Acquire;
|
||||
try
|
||||
Result := FCurrentState;
|
||||
finally
|
||||
FCurrentStateLock.Release;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user