Cancel
Showing results for 
Search instead for 
Did you mean: 

PlayWithoutRefresh() command leads Process Simulate to not respond

Legend
Legend

Hello!

 

So, basically I have a customized simulation app and it has an option to perform simulation without refreshing Graphics Viewer (same behavior expected from 'Dynamic Collision Report' simulation where you can deactivated Graphics Viewer refreshing by checking an option flag).

 

To perform that I'm using API's PlayWithoutRefresh() command instead of Play(). The command works but it leads Process Simulate to not respond while simulation is running (I can't minimize/maximize the software, for example). But in 'Dynamic Collision Report' I can run simulation without refreshing Graphics Viewer and software continues to respond normally.

 

Is this behavior from PlayWithoutRefresh() command expected?  Is there any workaround for that? 

 

Thanks in advance!

 

Regards

6 REPLIES

Re: PlayWithoutRefresh() command leads Process Simulate to not respond

Siemens Phenom Siemens Phenom
Siemens Phenom

Hello Fred,

 

Can you share a piece of the code?

 

The code should look something like:

 

void PlaySimulation()

{

RegisterSimulationEvents();

simulationPlayer.PlayWithoutRefresh();

UnregisterSimulationEvents();

simulationPlayer.Rewind();

}

 

Best Regards,

DIanaG

Re: PlayWithoutRefresh() command leads Process Simulate to not respond

Legend
Legend

Hello @DianaG

 

The scope of the code looks pretty much like you mention, the simulation works as expected, my only issue is the software itself getting "frozen" while running the simulation when PlayWithoutRefresh() is executed, while when using Play() I can interact normally with the software.

 

Following functions show the events I'm registering for simulation

 public void InitPlayerEvents(TxSimulationPlayer player)
        {
            // 1 - Register simulation events
            player.SimulationEndedForward += player_SimulationEndedForward;
            player.TimeIntervalReached += player_TimeIntervalReached;
            player.OperationEndedForward += player_OperationEndedForward;
            player.OperationStartedForward += player_OperationStartedForward;
            player.SimulationStopped += player_SimulationStopped;

            // 2 - Create this "flag" to know  if simulation events were registered
            _embSim.IsSimulationEventsRegistered = true;
        }

        public void DisposePlayerEvents(TxSimulationPlayer player)
        {
            // 1 - unregister simulation events
            player.SimulationEndedForward -= player_SimulationEndedForward;
            player.TimeIntervalReached -= player_TimeIntervalReached;
            player.OperationEndedForward -= player_OperationEndedForward;
            player.OperationStartedForward -= player_OperationStartedForward;
            player.SimulationStopped -= player_SimulationStopped;

            // 2 - Create this "flag" to know simulation events were unregistered
            _embSim.IsSimulationEventsRegistered = false;
        }

  Regards,

Re: PlayWithoutRefresh() command leads Process Simulate to not respond

Siemens Phenom Siemens Phenom
Siemens Phenom

Hello Fred,

 

Do you mean the application is not responding only while PlayWithoutRefresh() is executing, or the application is not responsive even after that?

 

Best Regards,

DianaG

Re: PlayWithoutRefresh() command leads Process Simulate to not respond

Legend
Legend

Hello @DianaG

 

I mean only during the execution. after simulation is completed it gets back to normal. I'd like also to know if there's a workaround similar to Dynamic Collision Report behavior.

 

Regards!

Re: PlayWithoutRefresh() command leads Process Simulate to not respond

Siemens Phenom Siemens Phenom
Siemens Phenom

I suppose you could call Application.DoEvents() from time to time.

Maybe on timeintervall_reached.

That should keep PS responsive.

Re: PlayWithoutRefresh() command leads Process Simulate to not respond

Legend
Legend

@GuidoDamm

 

Thanks! I was actually refreshing application in the wrong simulation event, your post made me check that Smiley Very Happy

 

Best regards,

 

Fred