pyfcstm.entry.simulate.batch
Batch command processor for non-interactive execution.
This module provides batch processing capabilities for executing multiple commands in sequence without user interaction.
BatchProcessor
- class pyfcstm.entry.simulate.batch.BatchProcessor(runtime, state_machine=None, use_color: bool = True, output_func: Callable[[str], None] | None = None)[source]
Processor for executing batch commands.
This class handles parsing and execution of semicolon-separated command strings for non-interactive batch processing.
- Parameters:
runtime (SimulationRuntime) – The simulation runtime instance
use_color (bool, optional) – Whether to use ANSI colors, defaults to True
- Variables:
command_processor (CommandProcessor) – Command processor instance
- __init__(runtime, state_machine=None, use_color: bool = True, output_func: Callable[[str], None] | None = None)[source]
Initialize the batch processor.
- Parameters:
runtime (SimulationRuntime) – The simulation runtime instance
state_machine (StateMachine, optional) – The state machine model (required for init command)
use_color (bool, optional) – Whether to use ANSI colors, defaults to True
output_func (Callable[[str], None], optional) – Function to output text, defaults to cross-platform output
- execute_commands(command_string: str) None[source]
Execute a batch command string with clear command separators.
Commands are separated by semicolons. Each command’s output is printed immediately to maintain proper ordering with log messages.
- Parameters:
command_string (str) – Semicolon-separated command string
Example:
>>> processor.execute_commands("current; cycle Start; current") # Outputs each command result immediately
create_cross_platform_output_func
- pyfcstm.entry.simulate.batch.create_cross_platform_output_func() Callable[[str], None][source]
Create a cross-platform output function that handles Unicode correctly.
On Windows, writes directly to binary stdout with UTF-8 encoding to avoid cp1252 encoding issues. On other platforms, uses standard print.
- Returns:
Output function that takes a string and prints it
- Return type:
Callable[[str], None]