flexsim_get_time
Retrieve the current simulation time in FlexSim to monitor model progression, synchronize operations, and track performance metrics during manufacturing or warehouse digital twin analysis.
Instructions
Get current simulation time.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- mcp_server/flexsim_mcp.py:327-335 (handler)Main implementation of flexsim_get_time tool. Decorated with @mcp.tool() which registers it as an MCP tool. Retrieves current simulation time from FlexSim controller and returns formatted string with both human-readable and raw time values.@mcp.tool() async def flexsim_get_time() -> str: """Get current simulation time.""" try: controller = await get_controller() time = controller.time() return f"Time: {format_time(time)} ({time:.2f}s)" except Exception as e: return format_error(e)
- mcp_server/flexsim_mcp.py:147-154 (helper)Helper function get_controller() used by flexsim_get_time to obtain or create the FlexSim controller instance with thread-safe access.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_get_time to convert simulation seconds into human-readable format (e.g., '1.23s', '5.00m', '2.50h').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_get_time to convert exceptions into user-friendly error messages with categorization 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}"
- app.py:122-131 (registration)Documentation table in app.py listing flexsim_get_time among the exposed simulation control tools with its description.### Simulation Control | Tool | Description | |------|-------------| | `flexsim_open_model` | Open .fsm or .fsx model file | | `flexsim_reset` | Reset simulation to time 0 | | `flexsim_run` | Start continuous simulation | | `flexsim_run_to_time` | Run until target time (fast or real-time) | | `flexsim_stop` | Pause running simulation | | `flexsim_step` | Advance by N events | | `flexsim_get_time` | Query current simulation time |