| 1440 | } |
| 1441 | |
| 1442 | char const* Kernel::RunAllTilOutput(smlRunStepSize interleaveStepSize) |
| 1443 | { |
| 1444 | CommitAll(); |
| 1445 | |
| 1446 | #ifdef SML_DIRECT |
| 1447 | if (GetConnection()->IsDirectConnection()) |
| 1448 | { |
| 1449 | EmbeddedConnection* ec = static_cast<EmbeddedConnection*>(GetConnection()); |
| 1450 | ec->DirectRun(NULL, false, sml_UNTIL_OUTPUT, interleaveStepSize, 1) ; |
| 1451 | return "DirectRun completed" ; |
| 1452 | } |
| 1453 | #endif |
| 1454 | |
| 1455 | std::string interleave ; |
| 1456 | |
| 1457 | switch (interleaveStepSize) |
| 1458 | { |
| 1459 | case sml_ELABORATION: |
| 1460 | interleave = "-i e" ; |
| 1461 | break ; |
| 1462 | case sml_PHASE: |
| 1463 | interleave = "-i p" ; |
| 1464 | break ; |
| 1465 | case sml_DECISION: |
| 1466 | interleave = "-i d" ; |
| 1467 | break ; |
| 1468 | case sml_UNTIL_OUTPUT: |
| 1469 | interleave = "-i o" ; |
| 1470 | break ; |
| 1471 | default: |
| 1472 | return "Unrecognized interleave size parameter passed to RunAllAgents" ; |
| 1473 | } |
| 1474 | |
| 1475 | // Run all agents until each has generated output. Each agent will stop at the point |
| 1476 | // it has generated output, so they may run for different numbers of decisions. |
| 1477 | // For now, maxDecisions is being ignored. We should make this a separate call |
| 1478 | // to set this parameter. |
| 1479 | std::string cmd = "run --output " + interleave ; |
| 1480 | |
| 1481 | // The command line currently requires an agent in order |
| 1482 | // to execute a run command, so we provide one (which one should make no difference). |
| 1483 | if (GetNumberAgents() == 0) |
| 1484 | { |
| 1485 | return "There are no agents to run" ; |
| 1486 | } |
| 1487 | |
| 1488 | Agent* pFirstAgent = GetAgentByIndex(0) ; |
| 1489 | |
| 1490 | // Execute the run command. |
| 1491 | char const* pResult = ExecuteCommandLine(cmd.c_str(), pFirstAgent->GetAgentName()) ; |
| 1492 | return pResult ; |
| 1493 | } |
| 1494 | |
| 1495 | /************************************************************* |
| 1496 | * @brief Interrupt the currently running Soar agent. |