flexsim_stop
Stop the running FlexSim simulation to pause model execution, halt data collection, and prepare for analysis or parameter adjustments in manufacturing and warehouse digital twin environments.
Instructions
Stop the running simulation.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- mcp_server/flexsim_mcp.py:315-324 (handler)The flexsim_stop tool handler decorated with @mcp.tool() that stops the running FlexSim simulation and returns the stop time. It uses get_controller() to access the FlexSim controller, calls controller.stop(), and formats the result with format_time().@mcp.tool() async def flexsim_stop() -> str: """Stop the running simulation.""" try: controller = await get_controller() controller.stop() time = controller.time() return f"✓ Stopped at {format_time(time)}" except Exception as e: return format_error(e)
- mcp_server/flexsim_mcp.py:147-154 (helper)Helper function get_controller() used by flexsim_stop to get or create the FlexSim controller instance with thread-safe locking.async def get_controller(): """Get or create the FlexSim controller instance.""" global _controller async with _controller_lock: if _controller is None: _controller = await launch_flexsim() return _controller
- mcp_server/flexsim_mcp.py:119-126 (helper)Helper function format_time() used by flexsim_stop to format simulation time as human-readable string (seconds, minutes, or hours).def format_time(seconds: float) -> str: """Format simulation time as human-readable string.""" if seconds < 60: return f"{seconds:.2f}s" elif seconds < 3600: return f"{seconds/60:.2f}m" else: return f"{seconds/3600:.2f}h"
- mcp_server/flexsim_mcp.py:129-140 (helper)Helper function format_error() used by flexsim_stop to format exceptions as user-friendly error messages with special handling for common error types.def format_error(e: Exception) -> str: """Format exception as user-friendly error message.""" msg = str(e) if "not found" in msg.lower(): return f"Not found: {msg}" elif "syntax" in msg.lower(): return f"FlexScript syntax error: {msg}" elif "license" in msg.lower(): return f"License error: {msg}" elif "permission" in msg.lower(): return f"Permission denied: {msg}" return f"Error: {msg}"