JaamSim Remote Control --- User Manual
This Python script connects to your JaamSim simulation through Kafka. It lets you control the simulation and modify entities in real-time from outside JaamSim --- no need to touch the JaamSim GUI.
Your Java plugin (KafkaCommandListener) runs inside JaamSim and listens for commands on the Kafka topic jaamsim-commands. This Python script sends commands to that topic.
-
Kafka running on localhost:9092
-
JaamSim running with the Java Kafka plugin loaded
-
Python with kafka-python installed (pip install kafka-python)
python jaamsim_control.py
You'll see this menu:
============================================================
JaamSim Remote Control
============================================================
--- Toggle Buttons ---
1 = Toggle ToggleButton1
2 = Toggle ToggleButton2
--- Simulation Control ---
s = Start/Resume simulation
p = Pause simulation
x = Stop simulation
--- Entity Control ---
e = Edit any entity input
qe = Query any entity input
q = Quit
Flips ToggleButton1 between ON and OFF. If it's currently ON, it goes OFF, and vice versa.
Enter command: 1
-> Sent: {'entity': 'ToggleButton1', 'action': 'TOGGLE'}
Use case: ToggleButton1 might control a branch in your model --- e.g., enabling/disabling a conveyor path.
Same as above but for ToggleButton2.
Enter command: 2
-> Sent: {'entity': 'ToggleButton2', 'action': 'TOGGLE'}
Starts the simulation if it's stopped, or resumes it if it's paused.
Enter command: s
-> Sent: {'action': 'SIM_START'}
Pauses the simulation. The sim time freezes but everything stays in place. Use s to resume.
Enter command: p
-> Sent: {'action': 'SIM_PAUSE'}
Fully stops the simulation and resets it. You'd need to press s to start from the beginning.
Enter command: x
-> Sent: {'action': 'SIM_STOP'}
This is the most powerful command. It lets you change any input on any entity in the running model.
How it works:
-
You type the exact entity name (as it appears in JaamSim)
-
You type the exact input/keyword name
-
You type the new value
Example 1 --- Change a server's processing time:
Enter command: e
Entity name: Server1
Input name: ServiceTime
New value: 5 s
This changes Server1's service time to 5 seconds.
Example 2 --- Change an entity's position:
Enter command: e
Entity name: Server1
Input name: Position
New value: 1.0 2.0 0.0 m
Example 3 --- Change a generator's arrival rate:
Enter command: e
Entity name: EntityGenerator1
Input name: InterArrivalTime
New value: 10 s
Example 4 --- Change a queue's max size:
Enter command: e
Entity name: Queue1
Input name: MaxValidLength
New value: 20
Tips:
-
Entity names and input names are case-sensitive --- they must match exactly what's in JaamSim
-
Values must be in the same format JaamSim expects (including units like s, m, h)
-
To find the exact input names, click on an entity in JaamSim and look at the Input Editor panel
Sends a request to read an entity's current input value.
Enter command: qe
Entity name: Server1
Input name: ServiceTime
-> Sent: {'entity': 'Server1', 'action': 'QUERY', 'input': 'ServiceTime'}
Closes the Kafka connection and exits the script.
Enter command: q
Bye!
-
Open JaamSim with your model and the Kafka plugin loaded
-
Start Kafka (zookeeper + kafka-server-start)
-
Run the Python script
-
Press s to start the simulation
-
Press 1 or 2 to toggle buttons as needed
-
Use e to tweak parameters while the sim runs
-
Press p to pause and inspect, s to resume
-
Press x to stop and reset
-
Press q to exit
| Problem | Solution |
|---|---|
| NoBrokersAvailable | Kafka isn't running --- start Zookeeper and Kafka first |
| Command sent but nothing happens in JaamSim | Make sure the Java plugin is loaded and listening on jaamsim-commands |
| e command doesn't change anything | Double-check entity name and input name --- they're case-sensitive |
| Unknown entity error in JaamSim logs | The entity name you typed doesn't exist in the model |