Simulation
A Simulation in RobotStudio is the time that progresses, and the changes that happen to the station and Virtual Controllers as the time progresses, from the call to Simulator.Play to the call to Simulator.End.
Time handling during simulation
When simulating stations having events or several controllers, or other time managing equipment (For example, a SmartComponent with the property CanBeSimulated set to true), time can be managed in two modes, either as free runtime or as time slices. You can manually choose between these two modes by setting the Simulation – Virtual Time option in RobotStudio.
RobotStudio uses time slice mode by default, but you can switch to free runtime, if required.
Virtual Time set as Free runtime
In the Free runtime mode, simulations created using Smart Component are supported with a virtual controller. As a result, FlexPendant and ScreenMaker applications can be executed on the FlexPendant together with Smart Component simulations.
In this mode, since all controllers use the same computer resources, their synchronization might not be exactly as in the real world where they run independently. The cycle time will be correct, but the timing for setting signals and triggering events might be inaccurate.
Virtual Time set as Time Slice
Time slices can be used to ensure that the timing for signals and other interaction between controllers is accurate. In this mode, RobotStudio synchronizes the controllers by dividing a time segment into small slices and waiting for all controllers to complete a current time slice before any controller can start anew. Thus, the controllers are synchronized, and the cycle time will be calculated correctly. The drawbacks are that the virtual FlexPendant cannot be open, and that the simulation might be somewhat slow and jerky, depending on the complexity of the simulation and the performance of the computer.
Defining objects in a simulation
All simulatable objects participating in a simulation will have the “chance/possibility/will be requested” to act/move/do stuff for each time slice.
The Active
Simulation end
The RobotStudio simulation ends when the last simulatable object has stopped. The definition of 'stopped' can be found in the enum Simulation
When a RAPID program is stopped, the RobotStudio simulation also stops. However, the stopping of the RobotStudio simulation is also dependant on the SmartComponent implemented by Code Behind.
You can therefore set a SmartComponent to be active even when the RAPID program is stopped. You can consider this as a master SmartComponent which orchestrates everything else, so that RobotStudio simulation will continue when the RAPID program is stopped.
Implementing a SmartComponent that can participate in a simulation
Some SmartComponents have a behavior in a simulation and some have not. The Linear mover will move attached objects along a straight line during a specified time, or by a specified speed. It is an example of a component that requires time to elapse to do its job.
A logical gate SmartComponent on the other hand does not consume virtual time and its function to change its output based on its inputs is immediate.
When developing a SmartComponent that needs to consume virtual time, like the linear mover, you have to set the property Can
You also have to override the On