| 481 | } |
| 482 | |
| 483 | smlRunResult AgentSML::Step(smlRunStepSize stepSize) |
| 484 | { |
| 485 | // This method runs a single agent |
| 486 | uint64_t count = 1 ; |
| 487 | uint64_t startCount = GetRunCounter(stepSize) ; // getReleventCounter(stepSize); |
| 488 | const uint64_t END_COUNT = startCount + count ; |
| 489 | |
| 490 | bool interrupted = (m_runState == sml_RUNSTATE_INTERRUPTED) ? true : false; |
| 491 | |
| 492 | if (! interrupted) |
| 493 | { |
| 494 | assert(!m_agent->system_halted) ; // , "System should not be halted here!"); |
| 495 | // Notify that agent is about to execute. (NOT the start of a run, just a step) |
| 496 | FireRunEvent(smlEVENT_BEFORE_RUNNING) ; |
| 497 | |
| 498 | switch (stepSize) |
| 499 | { |
| 500 | case sml_ELABORATION: |
| 501 | run_for_n_elaboration_cycles(m_agent, count); |
| 502 | break; |
| 503 | case sml_PHASE: |
| 504 | run_for_n_phases(m_agent, count); |
| 505 | break; |
| 506 | case sml_DECISION: |
| 507 | run_for_n_decision_cycles(m_agent, count); |
| 508 | break; |
| 509 | case sml_UNTIL_OUTPUT: |
| 510 | run_for_n_modifications_of_output(m_agent, count); |
| 511 | break; |
| 512 | } |
| 513 | } |
| 514 | |
| 515 | if (m_agent->stop_soar || (m_interruptFlags & sml_STOP_AFTER_SMALLEST_STEP) || (m_interruptFlags & sml_STOP_AFTER_PHASE)) |
| 516 | { |
| 517 | interrupted = true; |
| 518 | } |
| 519 | |
| 520 | // KJC: If a gSKI_STOP_AFTER_DECISION_CYCLE has been requested, need to |
| 521 | // check that agent phase is at the proper stopping point before interrupting. |
| 522 | // If not at the right phase, but interrupt was requested, then the SML scheduler |
| 523 | // method IsAgentFinished will return true and MoveTo_StopBeforePhase will |
| 524 | // step the agent by phases until this test is satisfied. |
| 525 | if (m_interruptFlags & sml_STOP_AFTER_DECISION_CYCLE) |
| 526 | { |
| 527 | // JRV: Bug 782: I changed the second half of the interrupt test to be true if: |
| 528 | // * The agent is in the correct phase for stopping (this was only what was here before) |
| 529 | // * OR stepSize == run-til-output because this current_phase will always be input here if running until output |
| 530 | // and we do want to stop in this case, even though the stop-before phase isn't technically honored. |
| 531 | // I've noted that the stop-before phase isn't honored in this case in the bug report. |
| 532 | bool inCorrectStopBeforePhase = m_agent->current_phase == m_pKernelSML->ConvertSMLToSoarPhase(m_pKernelSML->GetStopBefore()); |
| 533 | bool runningUntilOutput = stepSize == sml_UNTIL_OUTPUT; |
| 534 | if (inCorrectStopBeforePhase || runningUntilOutput) |
| 535 | { |
| 536 | interrupted = true; |
| 537 | } |
| 538 | } |
| 539 | |
| 540 | if (interrupted) |
nothing calls this directly
no test coverage detected