* @brief Interrupt the currently running Soar agent. * * Call this after calling "Run" in order to stop all Soar agents. * The usual way to do this is to register for an event (e.g. AFTER_DECISION_CYCLE) * and in that event handler decide if the user wishes to stop soar. * If so, call to this method inside that handler. * * The request to Stop may not be honored immediately. * Soar will stop at th
| 1504 | * Soar will stop at the next point it is considered safe to do so. |
| 1505 | *************************************************************/ |
| 1506 | char const* Kernel::StopAllAgents() |
| 1507 | { |
| 1508 | std::string cmd = "stop-soar" ; |
| 1509 | |
| 1510 | // The command line currently requires an agent in order |
| 1511 | // to execute a stop-soar command, so we provide one (which one should make no difference). |
| 1512 | if (GetNumberAgents() == 0) |
| 1513 | { |
| 1514 | return "There are no agents to stop" ; |
| 1515 | } |
| 1516 | |
| 1517 | Agent* pFirstAgent = GetAgentByIndex(0) ; |
| 1518 | |
| 1519 | // Execute the command. |
| 1520 | char const* pResult = ExecuteCommandLine(cmd.c_str(), pFirstAgent->GetAgentName()) ; |
| 1521 | return pResult ; |
| 1522 | } |
| 1523 | |
| 1524 | /************************************************************* |
| 1525 | * @brief Returns true if one or more agents are currently running. |