Menu

SingleStepping

Help
Andi Walti
2006-06-27
2013-03-22
  • Andi Walti

    Andi Walti - 2006-06-27

    My experiences and questions regarding the new SingleStep function (which I extended by a "milliseconds" parameter).

    - The Step lenghts are (randomly) off by a few m_nTimeStep. Example: 90 - 170 - 300 - 370 - 490 with SingleStep(100ms). Hopefully not so much of a problem for my application, but might be worth looking into.

    - SingleStepping HexWalker2 right after loading it, prevents the controller from doing anything. The Walker just sits there. The simulation needs to be started and paused manually first. I haven't tested it with my model yet, but this could become a problem. Are we missing some notification that starts the controller-thread?

    - Notification of components after SingleStep finished. I assume this would have to be done in the same way as the OnStopped/OnStarted-events via the Simulation.
    The question is: How could it be done so that a Plugin is notified?

    Thank you in advance,
    Andi

     
    • Patrik Stellmann

      I have no code (and I'm short with time to write some) to test the SingleStep. Maybe you could email me your extension so I can debug it here to find the problem with the strange time steps?

      After taking a deeper look into the sources I remembered, that all controller-threads are only started after their RCProcessor-instance was started which is done in RCGlobalSimComponent::OnStart of the corresponding instance of RCRobot which has registered at the simulation with AddSyncAccessor(). This again is called in RCSimSyncHandler::OnStart().

      Since GlobalSimComponents were notefied twice (RCGlobalSimComponent::OnSimStarted and RCSimSyncAccessor::OnStart) I extended the interface RCSimSyncAccessor by OnFirstStart and OnStop (in addition to OnStart and OnQuit) and also added the notifications to RCSimSyncHandler.

      I also adapted RCSimSyncHandler::OnStart with a time-parameter (negative value means to run until OnStop is called) and removed the (now obsolete) function SingleStep. The SyncAccessors are notified when the simulation starts and when it stops be it explicitly or be the specified run time having elapsed.

      These all extensions allows you to derive your own class from RCSyncSimAccessor, register it at the simulation you want to watch and be notified appropriatly. Of corse you could also derive your plugin itself from RCSyncSimAccessor, but consider the case when more than one simulation is opened to keep it from beeing notified by both simulations since in OnStart() you can not distinguish which simulation has notified you.

      Again I only checked if it compiles and the old simulations still work.
      The modifications are checked into CVS (several files had to be modified).

       

Log in to post a comment.